diff --git a/uniswap-v2/Makefile b/uniswap-v2/Makefile index a4f6826..9e7821e 100644 --- a/uniswap-v2/Makefile +++ b/uniswap-v2/Makefile @@ -8,9 +8,14 @@ build_all: build: cargo build --target wasm32-unknown-unknown --release +.PHONY: run_mainnet +run_mainnet: + substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml graph_out -s 10008300 + .PHONY: run run: - substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml graph_out -s 10008300 + substreams run -e bsc.substreams.pinax.network:9000 substreams.yaml graph_out -s 6809737 + .PHONY: pack pack: substreams pack ./substreams.yaml diff --git a/uniswap-v2/src/common/constants.rs b/uniswap-v2/src/common/constants.rs index 55308f5..b85058c 100644 --- a/uniswap-v2/src/common/constants.rs +++ b/uniswap-v2/src/common/constants.rs @@ -1,42 +1,77 @@ +// pub const WETH_ADDRESS: &str = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"; +// pub const USDC_ADDRESS: &str = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"; + +// pub const UNISWAP_V2_FACTORY: &str = "0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f"; + +// pub const STABLE_COINS: [&str; 5] = [ +// "0x6b175474e89094c44da98b954eedeac495271d0f", // DAI +// "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC +// "0xdac17f958d2ee523a2206206994597c13d831ec7", // USDT +// "0x0000000000085d4780b73119b644ae5ecd22b376", // TUSD +// "0x956f47f50a910163d8bf957cf5846d573e7f87ca", // FEI +// ]; + +// pub const PAIR_COINS: [&str; 4] = [ +// "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH +// "0x6b175474e89094c44da98b954eedeac495271d0f", // DAI +// "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC +// "0xdac17f958d2ee523a2206206994597c13d831ec7", // USDT +// ]; + +// pub const WHITELIST_TOKENS: [&str; 21] = [ +// "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH +// "0x6b175474e89094c44da98b954eedeac495271d0f", // DAI +// "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC +// "0xdac17f958d2ee523a2206206994597c13d831ec7", // USDT +// "0x0000000000085d4780b73119b644ae5ecd22b376", // TUSD +// "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", // WBTC +// "0x5d3a536e4d6dbd6114cc1ead35777bab948e3643", // cDAI +// "0x39aa39c021dfbae8fac545936693ac917d5e7563", // cUSDC +// "0x86fadb80d8d2cff3c3680819e4da99c10232ba0f", // EBASE +// "0x57ab1ec28d129707052df4df418d58a2d46d5f51", // sUSD +// "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2", // MKR +// "0xc00e94cb662c3520282e6f5717214004a7f26888", // COMP +// "0x514910771af9ca656af840dff83e8264ecf986ca", // LINK +// "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f", // SNX +// "0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e", // YFI +// "0x111111111117dc0aa78b770fa6a738034120c302", // 1INCH +// "0xdf5e0e81dff6faf3a7e52ba697820c5e32d806a8", // yCurv +// "0x956f47f50a910163d8bf957cf5846d573e7f87ca", // FEI +// "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0", // MATIC +// "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", // AAVE +// "0xfe2e637202056d30016725477c5da089ab0a043a", // sETH2 +// ]; + pub const WETH_ADDRESS: &str = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"; pub const USDC_ADDRESS: &str = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"; -pub const UNISWAP_V2_FACTORY: &str = "0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f"; + +pub const UNISWAP_V2_FACTORY: &str = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"; pub const STABLE_COINS: [&str; 5] = [ - "0x6b175474e89094c44da98b954eedeac495271d0f", // DAI - "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC - "0xdac17f958d2ee523a2206206994597c13d831ec7", // USDT - "0x0000000000085d4780b73119b644ae5ecd22b376", // TUSD - "0x956f47f50a910163d8bf957cf5846d573e7f87ca", // FEI + "0x55d398326f99059ff775485246999027b3197955", // BUSD + "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", // USDC + "0xe9e7cea3dedca5984780bafc599bd69add087d56", // USDT + "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3", // DAI + "0x40af3827F39D0EAcBF4A168f8D4ee67c121D11c9", // TUSD ]; pub const PAIR_COINS: [&str; 4] = [ - "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH - "0x6b175474e89094c44da98b954eedeac495271d0f", // DAI - "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC - "0xdac17f958d2ee523a2206206994597c13d831ec7", // USDT + "0x2170ed0880ac9a755fd29b2688956bd959f933f8", // WETH + "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3", // DAI + "0x55d398326f99059ff775485246999027b3197955", // USDC + "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", // USDT ]; -pub const WHITELIST_TOKENS: [&str; 21] = [ - "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH - "0x6b175474e89094c44da98b954eedeac495271d0f", // DAI - "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC - "0xdac17f958d2ee523a2206206994597c13d831ec7", // USDT - "0x0000000000085d4780b73119b644ae5ecd22b376", // TUSD - "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", // WBTC - "0x5d3a536e4d6dbd6114cc1ead35777bab948e3643", // cDAI - "0x39aa39c021dfbae8fac545936693ac917d5e7563", // cUSDC - "0x86fadb80d8d2cff3c3680819e4da99c10232ba0f", // EBASE - "0x57ab1ec28d129707052df4df418d58a2d46d5f51", // sUSD - "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2", // MKR - "0xc00e94cb662c3520282e6f5717214004a7f26888", // COMP - "0x514910771af9ca656af840dff83e8264ecf986ca", // LINK - "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f", // SNX - "0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e", // YFI - "0x111111111117dc0aa78b770fa6a738034120c302", // 1INCH - "0xdf5e0e81dff6faf3a7e52ba697820c5e32d806a8", // yCurv - "0x956f47f50a910163d8bf957cf5846d573e7f87ca", // FEI - "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0", // MATIC - "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", // AAVE - "0xfe2e637202056d30016725477c5da089ab0a043a", // sETH2 +pub const WHITELIST_TOKENS: [&str; 11] = [ + "0x2170ed0880ac9a755fd29b2688956bd959f933f8", // WETH + "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3", // DAI + "0x55d398326f99059ff775485246999027b3197955", // USDC + "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", // USDT + "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", // wBNB + "0x3ee2200efb3400fabb9aacf31297cbdd1d435d47", // ADA + "0xcc42724c6683b7e57334c4e856f4c9965ed682bd", // Matic + "0xf8a0bf9cf54bb92f17374d9e9a321e6a111a51bd", // Chainlink + "0xbf5140a22578168fd562dccf235e5d43a02ce9b1", // UNI + "0xad29abb318791d579433d831ed122afeaf29dcfe", // FTM + "0x26433c8127d9b4e9b71eaa15111df99ea2eeb2f8", // MANA ]; diff --git a/uniswap-v2/src/modules/22_graph_out.rs b/uniswap-v2/src/modules/22_graph_out.rs index d215b86..0703b8c 100644 --- a/uniswap-v2/src/modules/22_graph_out.rs +++ b/uniswap-v2/src/modules/22_graph_out.rs @@ -2,19 +2,19 @@ use substreams_entity_change::pb::entity::{EntityChange, EntityChanges}; #[substreams::handlers::map] pub fn graph_out( - liquidity_pool_map: EntityChanges, - liquidity_pool_snapshots_map: EntityChanges, - liquidity_protocol_map: EntityChanges, - financial_daily_snapshot_map: EntityChanges, + // liquidity_pool_map: EntityChanges, + // liquidity_pool_snapshots_map: EntityChanges, + // liquidity_protocol_map: EntityChanges, + // financial_daily_snapshot_map: EntityChanges, token_map: EntityChanges, events_map: EntityChanges, ) -> Result { let mut entity_changes: Vec = vec![]; - entity_changes.extend(liquidity_pool_map.entity_changes); - entity_changes.extend(liquidity_pool_snapshots_map.entity_changes); - entity_changes.extend(liquidity_protocol_map.entity_changes); - entity_changes.extend(financial_daily_snapshot_map.entity_changes); + // entity_changes.extend(liquidity_pool_map.entity_changes); + // entity_changes.extend(liquidity_pool_snapshots_map.entity_changes); + // entity_changes.extend(liquidity_protocol_map.entity_changes); + // entity_changes.extend(financial_daily_snapshot_map.entity_changes); entity_changes.extend(token_map.entity_changes); entity_changes.extend(events_map.entity_changes); diff --git a/uniswap-v2/src/modules/4_map_pool_events.rs b/uniswap-v2/src/modules/4_map_pool_events.rs index 8951a6d..19b2c06 100644 --- a/uniswap-v2/src/modules/4_map_pool_events.rs +++ b/uniswap-v2/src/modules/4_map_pool_events.rs @@ -42,7 +42,7 @@ fn handle_mint( events.push(Event { hash: tx.hash.to_hex(), - log_index: log.index, + log_index: log.block_index, log_ordinal: log.ordinal, to: tx.to.to_hex(), from: tx.from.to_hex(), @@ -78,7 +78,7 @@ fn handle_burn( events.push(Event { hash: tx.hash.to_hex(), - log_index: log.index, + log_index: log.block_index, log_ordinal: log.ordinal, to: tx.to.to_hex(), from: tx.from.to_hex(), @@ -107,7 +107,7 @@ fn handle_sync(block: ð::Block, store: &StoreGetProto, events: &mut Vec events.push(Event { hash: tx.hash.to_hex(), - log_index: log.index, + log_index: log.block_index, log_ordinal: log.ordinal, to: tx.to.to_hex(), from: tx.from.to_hex(), @@ -133,7 +133,7 @@ fn handle_swap(block: ð::Block, store: &StoreGetProto, events: &mut Vec events.push(Event { hash: tx.hash.to_hex(), - log_index: log.index, + log_index: log.block_index, log_ordinal: log.ordinal, to: tx.to.to_hex(), from: tx.from.to_hex(), diff --git a/uniswap-v2/subgraph.yaml b/uniswap-v2/subgraph.yaml index 50bf984..294948f 100644 --- a/uniswap-v2/subgraph.yaml +++ b/uniswap-v2/subgraph.yaml @@ -7,7 +7,7 @@ schema: dataSources: - kind: substreams name: uniswap_v2 - network: mainnet + network: bsc source: package: moduleName: graph_out diff --git a/uniswap-v2/substreams.yaml b/uniswap-v2/substreams.yaml index 6b76037..ccafcb7 100644 --- a/uniswap-v2/substreams.yaml +++ b/uniswap-v2/substreams.yaml @@ -24,7 +24,7 @@ protobuf: modules: - name: map_pool_created kind: map - initialBlock: 10008300 + initialBlock: 6809737 inputs: - source: sf.ethereum.type.v2.Block output: @@ -47,7 +47,7 @@ modules: - name: map_pool_events kind: map - initialBlock: 10008300 + initialBlock: 6809737 inputs: - source: sf.ethereum.type.v2.Block - store: store_pools @@ -82,134 +82,134 @@ modules: - map: map_pool_events - store: store_native_prices - - name: store_pool_tvl - kind: store - updatePolicy: set - valueType: bigdecimal - inputs: - - store: store_pools - - store: store_input_token_balances - - store: store_input_token_balances - mode: deltas - - store: store_usd_prices - - - name: store_volume - kind: store - updatePolicy: add - valueType: bigdecimal - inputs: - - map: map_pool_events - - store: store_usd_prices - - - name: store_volume_by_token_amount - kind: store - updatePolicy: add - valueType: bigint - inputs: - - map: map_pool_events - - - name: store_cumulative_fields - kind: store - updatePolicy: add - valueType: bigdecimal - inputs: - - store: store_volume - mode: deltas - - - name: map_liquidity_pool_entity - kind: map - initialBlock: 10008300 - inputs: - - store: store_pools - - store: store_output_token_supply - - store: store_input_token_balances - - store: store_input_token_balances - mode: deltas - - store: store_pool_tvl - - store: store_cumulative_fields - output: - type: proto:substreams.entity.v1.EntityChanges - - - name: store_daily_and_hourly_fields - kind: store - updatePolicy: add - valueType: bigdecimal - inputs: - - source: sf.substreams.v1.Clock - - store: store_volume - mode: deltas - - - name: map_liquidity_pool_snapshots_entity - kind: map - initialBlock: 10008300 - inputs: - - source: sf.substreams.v1.Clock - - store: store_pools - - store: store_output_token_supply - - store: store_input_token_balances - - store: store_input_token_balances - mode: deltas - - store: store_pool_tvl - - store: store_cumulative_fields - - store: store_daily_and_hourly_fields - - store: store_volume_by_token_amount - - store: store_usd_prices - output: - type: proto:substreams.entity.v1.EntityChanges - - - name: store_protocol_tvl - kind: store - updatePolicy: add - valueType: bigdecimal - inputs: - - store: store_pool_tvl - mode: deltas - - - name: store_protocol_cumulative_fields - kind: store - updatePolicy: add - valueType: bigdecimal - inputs: - - store: store_cumulative_fields - mode: deltas - - - name: store_protocol_daily_fields - kind: store - updatePolicy: add - valueType: bigdecimal - inputs: - - source: sf.substreams.v1.Clock - - store: store_volume - mode: deltas - - - name: map_protocol_entity - kind: map - initialBlock: 10008300 - inputs: - - store: store_input_token_balances - mode: deltas - - store: store_protocol_tvl - - store: store_protocol_cumulative_fields - output: - type: proto:substreams.entity.v1.EntityChanges - - - name: map_financial_daily_snapshot_entity - kind: map - initialBlock: 10008300 - inputs: - - source: sf.substreams.v1.Clock - - store: store_input_token_balances - - store: store_input_token_balances - mode: deltas - - store: store_protocol_tvl - - store: store_protocol_cumulative_fields - - store: store_protocol_daily_fields - output: - type: proto:substreams.entity.v1.EntityChanges + # - name: store_pool_tvl + # kind: store + # updatePolicy: set + # valueType: bigdecimal + # inputs: + # - store: store_pools + # - store: store_input_token_balances + # - store: store_input_token_balances + # mode: deltas + # - store: store_usd_prices + + # - name: store_volume + # kind: store + # updatePolicy: add + # valueType: bigdecimal + # inputs: + # - map: map_pool_events + # - store: store_usd_prices + + # - name: store_volume_by_token_amount + # kind: store + # updatePolicy: add + # valueType: bigint + # inputs: + # - map: map_pool_events + + # - name: store_cumulative_fields + # kind: store + # updatePolicy: add + # valueType: bigdecimal + # inputs: + # - store: store_volume + # mode: deltas + + # - name: map_liquidity_pool_entity + # kind: map + # initialBlock: 6809737 + # inputs: + # - store: store_pools + # - store: store_output_token_supply + # - store: store_input_token_balances + # - store: store_input_token_balances + # mode: deltas + # - store: store_pool_tvl + # - store: store_cumulative_fields + # output: + # type: proto:substreams.entity.v1.EntityChanges + + # - name: store_daily_and_hourly_fields + # kind: store + # updatePolicy: add + # valueType: bigdecimal + # inputs: + # - source: sf.substreams.v1.Clock + # - store: store_volume + # mode: deltas + + # - name: map_liquidity_pool_snapshots_entity + # kind: map + # initialBlock: 6809737 + # inputs: + # - source: sf.substreams.v1.Clock + # - store: store_pools + # - store: store_output_token_supply + # - store: store_input_token_balances + # - store: store_input_token_balances + # mode: deltas + # - store: store_pool_tvl + # - store: store_cumulative_fields + # - store: store_daily_and_hourly_fields + # - store: store_volume_by_token_amount + # - store: store_usd_prices + # output: + # type: proto:substreams.entity.v1.EntityChanges + + # - name: store_protocol_tvl + # kind: store + # updatePolicy: add + # valueType: bigdecimal + # inputs: + # - store: store_pool_tvl + # mode: deltas + + # - name: store_protocol_cumulative_fields + # kind: store + # updatePolicy: add + # valueType: bigdecimal + # inputs: + # - store: store_cumulative_fields + # mode: deltas + + # - name: store_protocol_daily_fields + # kind: store + # updatePolicy: add + # valueType: bigdecimal + # inputs: + # - source: sf.substreams.v1.Clock + # - store: store_volume + # mode: deltas + + # - name: map_protocol_entity + # kind: map + # initialBlock: 6809737 + # inputs: + # - store: store_input_token_balances + # mode: deltas + # - store: store_protocol_tvl + # - store: store_protocol_cumulative_fields + # output: + # type: proto:substreams.entity.v1.EntityChanges + + # - name: map_financial_daily_snapshot_entity + # kind: map + # initialBlock: 6809737 + # inputs: + # - source: sf.substreams.v1.Clock + # - store: store_input_token_balances + # - store: store_input_token_balances + # mode: deltas + # - store: store_protocol_tvl + # - store: store_protocol_cumulative_fields + # - store: store_protocol_daily_fields + # output: + # type: proto:substreams.entity.v1.EntityChanges - name: map_token_entity kind: map - initialBlock: 10008300 + initialBlock: 6809737 inputs: - map: map_pool_created - store: store_usd_prices @@ -219,7 +219,7 @@ modules: - name: map_events_entity kind: map - initialBlock: 10008300 + initialBlock: 6809737 inputs: - map: map_pool_events - store: store_pools @@ -229,12 +229,12 @@ modules: - name: graph_out kind: map - initialBlock: 10008300 + initialBlock: 6809737 inputs: - - map: map_liquidity_pool_entity - - map: map_liquidity_pool_snapshots_entity - - map: map_protocol_entity - - map: map_financial_daily_snapshot_entity + # - map: map_liquidity_pool_entity + # - map: map_liquidity_pool_snapshots_entity + # - map: map_protocol_entity + # - map: map_financial_daily_snapshot_entity - map: map_token_entity - map: map_events_entity output: