diff --git a/uniswap-v2/Makefile b/uniswap-v2/Makefile index a4f6826..acdeea5 100644 --- a/uniswap-v2/Makefile +++ b/uniswap-v2/Makefile @@ -10,7 +10,7 @@ build: .PHONY: run run: - substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml graph_out -s 10008300 + substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml map_events_entity -s 10008300 .PHONY: pack pack: substreams pack ./substreams.yaml diff --git a/uniswap-v2/schema.graphql b/uniswap-v2/schema.graphql index b7a8fac..4cea44f 100644 --- a/uniswap-v2/schema.graphql +++ b/uniswap-v2/schema.graphql @@ -428,10 +428,10 @@ type LiquidityPool @entity { cumulativeVolumeUSD: BigDecimal! " Amount of input tokens in the pool. The ordering should be the same as the pool's `inputTokens` field. " - inputTokenBalances: [String!]! + inputTokenBalances: [BigInt!]! " Weights of input tokens in the liquidity pool in percentage values. For example, 50/50 for Uniswap pools, 48.2/51.8 for a Curve pool, 10/10/80 for a Balancer pool " - inputTokenWeights: [String!]! + inputTokenWeights: [BigDecimal!]! " Total supply of output token. Note that certain DEXes don't have an output token (e.g. Bancor) " outputTokenSupply: BigInt @@ -515,19 +515,19 @@ type LiquidityPoolDailySnapshot @entity { dailyVolumeUSD: BigDecimal! " All trade volume occurred in a given day for a specific input token, in native amount. The ordering should be the same as the pool's `inputTokens` field. " - dailyVolumeByTokenAmount: [String!]! + dailyVolumeByTokenAmount: [BigInt!]! " All trade volume occurred in a given day for a specific input token, in USD. The ordering should be the same as the pool's `inputTokens` field. " - dailyVolumeByTokenUSD: [String!]! + dailyVolumeByTokenUSD: [BigDecimal!]! " All historical trade volume occurred in this pool, in USD " cumulativeVolumeUSD: BigDecimal! " Amount of input tokens in the pool. The ordering should be the same as the pool's `inputTokens` field. " - inputTokenBalances: [String!]! + inputTokenBalances: [BigInt!]! " Weights of input tokens in the liquidity pool in percentage values. For example, 50/50 for Uniswap pools, 48.2/51.8 for a Curve pool, 10/10/80 for a Balancer pool " - inputTokenWeights: [String!]! + inputTokenWeights: [BigDecimal!]! " Total supply of output token. Note that certain DEXes don't have an output token (e.g. Bancor) " outputTokenSupply: BigInt @@ -544,7 +544,7 @@ type LiquidityPoolDailySnapshot @entity { " Per-block reward token emission as of the current block normalized to a day, in USD value. This should be ideally calculated as the theoretical rate instead of the realized amount. " rewardTokenEmissionsUSD: [BigDecimal!] - _inputTokenPrices: [String!] + _inputTokenPrices: [BigDecimal!] } type LiquidityPoolHourlySnapshot @entity { @@ -590,19 +590,19 @@ type LiquidityPoolHourlySnapshot @entity { hourlyVolumeUSD: BigDecimal! " All trade volume occurred in a given hour for a specific input token, in native amount. The ordering should be the same as the pool's `inputTokens` field. " - hourlyVolumeByTokenAmount: [String!]! + hourlyVolumeByTokenAmount: [BigInt!]! " All trade volume occurred in a given hour for a specific input token, in USD. The ordering should be the same as the pool's `inputTokens` field. " - hourlyVolumeByTokenUSD: [String!]! + hourlyVolumeByTokenUSD: [BigDecimal!]! " All historical trade volume occurred in this pool, in USD " cumulativeVolumeUSD: BigDecimal! " Amount of input tokens in the pool. The ordering should be the same as the pool's `inputTokens` field. " - inputTokenBalances: [String!]! + inputTokenBalances: [BigInt!]! " Weights of input tokens in the liquidity pool in percentage values. For example, 50/50 for Uniswap pools, 48.2/51.8 for a Curve pool, 10/10/80 for a Balancer pool " - inputTokenWeights: [String!]! + inputTokenWeights: [BigDecimal!]! " Total supply of output token. Note that certain DEXes don't have an output token (e.g. Bancor) " outputTokenSupply: BigInt @@ -690,7 +690,7 @@ type Deposit implements Event @entity { outputToken: Token " Amount of input tokens in the token's native unit " - inputTokenAmounts: [String!]! + inputTokenAmounts: [BigInt!]! " Amount of output tokens in the token's native unit " outputTokenAmount: BigInt @@ -734,7 +734,7 @@ type Withdraw implements Event @entity { outputToken: Token " Amount of input tokens in the token's native unit " - inputTokenAmounts: [String!]! + inputTokenAmounts: [BigInt!]! " Amount of output tokens in the token's native unit " outputTokenAmount: BigInt diff --git a/uniswap-v2/src/common/constants.rs b/uniswap-v2/src/common/constants.rs index 55308f5..a3d61b0 100644 --- a/uniswap-v2/src/common/constants.rs +++ b/uniswap-v2/src/common/constants.rs @@ -40,3 +40,26 @@ pub const WHITELIST_TOKENS: [&str; 21] = [ "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", // AAVE "0xfe2e637202056d30016725477c5da089ab0a043a", // sETH2 ]; + +pub const BLACKLISTED_TOKENS: [&str; 12] = [ + "0x9d1555d8cb3c846bb4f7d5b1b1080872c3166676", // Wrapped Mirror SLV Token + "0x76306f029f8f99effe509534037ba7030999e3cf", // Acreage + "0x9d86f93ff837b80032e3fd7b3f8e1aacc25d3d80", // MIR EAEUnion + "0xb611920d44324655335b5e11ebc9c929faddfbaf", // Lawa USD + "0x0698dda3c390ff92722f9eed766d8b1727621df9", // Ethereum2Proof-of-stake + "0x35bd8472ed2da9eed980e49b8b92ccbcf625adbd", // Enreich + "0xf2bae67cc0b4642b9bc71264cc878598cb0722bd", // Nicaragua Canal + "0x2b591e99afe9f32eaa6214f7b7629768c40eeb39", // HEX + "0x9bb6fd000109e24eb38b0deb806382ff9247e478", // hex.bet + "0x57bfb100498f5ce6c54298f0730f1bc9b67addd6", // MAGGIE + "0x72e5390edb7727e3d4e3436451dadaff675dbcc0", // Hanu Yokia + "0x395c8db957d743a62ac3aaaa4574553bcf2380b3", // ulock.eth Wrapped Ether +]; + +pub const BLACKLISTED_POOLS: [&str; 5] = [ + "0x1f447690a6ddf18400533b705516159e1312f892", + "0x340a5a2f73ebaa181ec2826802fdf8ed21fc759a", + "0x6a9e7f087a7d1057dd36a84ae148dac2c07ea67e", + "0x13bb5add7fd43c52d987e2c320f95d4b5e9cfa5f", + "0x1693c24445895bd8f4d5a327eafa0263191ed906", +]; diff --git a/uniswap-v2/src/modules/11_store_cumulative_fields.rs b/uniswap-v2/src/modules/11_store_cumulative_fields.rs index 2f15c17..50aab68 100644 --- a/uniswap-v2/src/modules/11_store_cumulative_fields.rs +++ b/uniswap-v2/src/modules/11_store_cumulative_fields.rs @@ -12,28 +12,31 @@ pub fn store_cumulative_fields( for delta in volume_deltas.deltas { if let Some(pool_address) = StoreKey::Volume.get_pool(&delta.key) { let volume = utils::delta_value(&delta); - output_store.add( - delta.ordinal, - StoreKey::CumulativeVolumeUSD.get_unique_pool_key(&pool_address), - &volume, - ); - let (supply_side_revenue, protocol_side_revenue) = utils::calculate_revenue(volume); - output_store.add( - delta.ordinal, - StoreKey::CumulativeSupplySideRevenueUSD.get_unique_pool_key(&pool_address), - &supply_side_revenue, - ); - output_store.add( - delta.ordinal, - StoreKey::CumulativeProtocolSideRevenueUSD.get_unique_pool_key(&pool_address), - &protocol_side_revenue, - ); - output_store.add( - delta.ordinal, - StoreKey::CumulativeTotalRevenueUSD.get_unique_pool_key(&pool_address), - &(supply_side_revenue + protocol_side_revenue), - ); + if utils::is_valid_amount(&volume) { + output_store.add( + delta.ordinal, + StoreKey::CumulativeVolumeUSD.get_unique_pool_key(&pool_address), + &volume, + ); + + let (supply_side_revenue, protocol_side_revenue) = utils::calculate_revenue(volume); + output_store.add( + delta.ordinal, + StoreKey::CumulativeSupplySideRevenueUSD.get_unique_pool_key(&pool_address), + &supply_side_revenue, + ); + output_store.add( + delta.ordinal, + StoreKey::CumulativeProtocolSideRevenueUSD.get_unique_pool_key(&pool_address), + &protocol_side_revenue, + ); + output_store.add( + delta.ordinal, + StoreKey::CumulativeTotalRevenueUSD.get_unique_pool_key(&pool_address), + &(supply_side_revenue + protocol_side_revenue), + ); + } } } } diff --git a/uniswap-v2/src/modules/12_map_liquidity_pool_entity.rs b/uniswap-v2/src/modules/12_map_liquidity_pool_entity.rs index 92ad555..10521de 100644 --- a/uniswap-v2/src/modules/12_map_liquidity_pool_entity.rs +++ b/uniswap-v2/src/modules/12_map_liquidity_pool_entity.rs @@ -130,18 +130,19 @@ fn create_liquidity_pool( ordinal, StoreKey::Token0Balance.get_unique_pool_key(&pool_address), ) - .unwrap_or(BigInt::zero()) - .to_string(), + .unwrap_or(BigInt::zero()), input_token_balances_store .get_at( ordinal, StoreKey::Token1Balance.get_unique_pool_key(&pool_address), ) - .unwrap_or(BigInt::zero()) - .to_string(), + .unwrap_or(BigInt::zero()), ], ) - .change("inputTokenWeights", vec!["0.5".to_string(); 2]) + .change( + "inputTokenWeights", + vec![BigDecimal::try_from("0.5").unwrap(); 2], + ) .change( "outputTokenSupply", output_token_supply_store diff --git a/uniswap-v2/src/modules/14_map_liquidity_pool_snapshots_entity.rs b/uniswap-v2/src/modules/14_map_liquidity_pool_snapshots_entity.rs index 20ae35a..3a96de1 100644 --- a/uniswap-v2/src/modules/14_map_liquidity_pool_snapshots_entity.rs +++ b/uniswap-v2/src/modules/14_map_liquidity_pool_snapshots_entity.rs @@ -196,8 +196,7 @@ fn create_liquidity_pool_daily_snapshot( vec![&pool_address, &pool.token0_address()], ), ) - .unwrap_or(BigInt::zero()) - .to_string(), + .unwrap_or(BigInt::zero()), volume_by_token_amount_store .get_at( ordinal, @@ -206,8 +205,7 @@ fn create_liquidity_pool_daily_snapshot( vec![&pool_address, &pool.token1_address()], ), ) - .unwrap_or(BigInt::zero()) - .to_string(), + .unwrap_or(BigInt::zero()), ], ) .change( @@ -222,7 +220,7 @@ fn create_liquidity_pool_daily_snapshot( ), ) .unwrap_or(BigDecimal::zero()) - .to_string(), + .with_prec(20), daily_and_hourly_fields_store .get_at( ordinal, @@ -232,7 +230,7 @@ fn create_liquidity_pool_daily_snapshot( ), ) .unwrap_or(BigDecimal::zero()) - .to_string(), + .with_prec(20), ], ) .change( @@ -252,18 +250,19 @@ fn create_liquidity_pool_daily_snapshot( ordinal, StoreKey::Token0Balance.get_unique_pool_key(&pool_address), ) - .unwrap_or(BigInt::zero()) - .to_string(), + .unwrap_or(BigInt::zero()), balances_store .get_at( ordinal, StoreKey::Token1Balance.get_unique_pool_key(&pool_address), ) - .unwrap_or(BigInt::zero()) - .to_string(), + .unwrap_or(BigInt::zero()), ], ) - .change("inputTokenWeights", vec!["0.5".to_string(); 2]) + .change( + "inputTokenWeights", + vec![BigDecimal::try_from("0.5").unwrap(); 2], + ) .change( "outputTokenSupply", pool_supply_store @@ -282,14 +281,14 @@ fn create_liquidity_pool_daily_snapshot( StoreKey::TokenPrice.get_unique_pool_key(&pool.token0_address()), ) .unwrap_or(BigDecimal::zero()) - .to_string(), + .with_prec(20), prices_store .get_at( ordinal, StoreKey::TokenPrice.get_unique_pool_key(&pool.token1_address()), ) .unwrap_or(BigDecimal::zero()) - .to_string(), + .with_prec(20), ], ) .change("blockNumber", block_number) @@ -416,8 +415,7 @@ fn create_liquidity_pool_hourly_snapshot( vec![&pool_address, &pool.token0_address()], ), ) - .unwrap_or(BigInt::zero()) - .to_string(), + .unwrap_or(BigInt::zero()), volume_by_token_amount_store .get_at( ordinal, @@ -426,8 +424,7 @@ fn create_liquidity_pool_hourly_snapshot( vec![&pool_address, &pool.token1_address()], ), ) - .unwrap_or(BigInt::zero()) - .to_string(), + .unwrap_or(BigInt::zero()), ], ) .change( @@ -442,7 +439,7 @@ fn create_liquidity_pool_hourly_snapshot( ), ) .unwrap_or(BigDecimal::zero()) - .to_string(), + .with_prec(20), daily_and_hourly_fields_store .get_at( ordinal, @@ -452,7 +449,7 @@ fn create_liquidity_pool_hourly_snapshot( ), ) .unwrap_or(BigDecimal::zero()) - .to_string(), + .with_prec(20), ], ) .change( @@ -472,18 +469,19 @@ fn create_liquidity_pool_hourly_snapshot( ordinal, StoreKey::Token0Balance.get_unique_pool_key(&pool_address), ) - .unwrap_or(BigInt::zero()) - .to_string(), + .unwrap_or(BigInt::zero()), balances_store .get_at( ordinal, StoreKey::Token1Balance.get_unique_pool_key(&pool_address), ) - .unwrap_or(BigInt::zero()) - .to_string(), + .unwrap_or(BigInt::zero()), ], ) - .change("inputTokenWeights", vec!["0.5".to_string(); 2]) + .change( + "inputTokenWeights", + vec![BigDecimal::try_from("0.5").unwrap(); 2], + ) .change( "outputTokenSupply", pool_supply_store diff --git a/uniswap-v2/src/modules/18_map_protocol_entity.rs b/uniswap-v2/src/modules/18_map_protocol_entity.rs index 49ea9cd..eb6040f 100644 --- a/uniswap-v2/src/modules/18_map_protocol_entity.rs +++ b/uniswap-v2/src/modules/18_map_protocol_entity.rs @@ -66,7 +66,8 @@ fn create_protocol( ordinal, StoreKey::TotalValueLockedUSD.get_unique_protocol_key(), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "cumulativeVolumeUSD", @@ -75,7 +76,8 @@ fn create_protocol( ordinal, StoreKey::CumulativeVolumeUSD.get_unique_protocol_key(), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "cumulativeSupplySideRevenueUSD", @@ -84,7 +86,8 @@ fn create_protocol( ordinal, StoreKey::CumulativeSupplySideRevenueUSD.get_unique_protocol_key(), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "cumulativeProtocolSideRevenueUSD", @@ -93,7 +96,8 @@ fn create_protocol( ordinal, StoreKey::CumulativeProtocolSideRevenueUSD.get_unique_protocol_key(), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "cumulativeTotalRevenueUSD", @@ -102,7 +106,8 @@ fn create_protocol( ordinal, StoreKey::CumulativeTotalRevenueUSD.get_unique_protocol_key(), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change("cumulativeUniqueUsers", 0) .change("totalPoolCount", 0); diff --git a/uniswap-v2/src/modules/19_map_financial_daily_snapshot_entity.rs b/uniswap-v2/src/modules/19_map_financial_daily_snapshot_entity.rs index 3555948..d4445ec 100644 --- a/uniswap-v2/src/modules/19_map_financial_daily_snapshot_entity.rs +++ b/uniswap-v2/src/modules/19_map_financial_daily_snapshot_entity.rs @@ -84,7 +84,8 @@ fn create_financial_daily_snapshot( ordinal, StoreKey::TotalValueLockedUSD.get_unique_protocol_key(), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "dailyVolumeUSD", @@ -93,7 +94,8 @@ fn create_financial_daily_snapshot( ordinal, StoreKey::DailyVolumeUSD.get_unique_daily_protocol_key(day_id), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "cumulativeVolumeUSD", @@ -102,7 +104,8 @@ fn create_financial_daily_snapshot( ordinal, StoreKey::CumulativeVolumeUSD.get_unique_protocol_key(), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "dailySupplySideRevenueUSD", @@ -111,7 +114,8 @@ fn create_financial_daily_snapshot( ordinal, StoreKey::DailySupplySideRevenueUSD.get_unique_daily_protocol_key(day_id), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "cumulativeSupplySideRevenueUSD", @@ -120,7 +124,8 @@ fn create_financial_daily_snapshot( ordinal, StoreKey::CumulativeSupplySideRevenueUSD.get_unique_protocol_key(), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "dailyProtocolSideRevenueUSD", @@ -129,7 +134,8 @@ fn create_financial_daily_snapshot( ordinal, StoreKey::DailyProtocolSideRevenueUSD.get_unique_daily_protocol_key(day_id), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "cumulativeProtocolSideRevenueUSD", @@ -138,7 +144,8 @@ fn create_financial_daily_snapshot( ordinal, StoreKey::CumulativeProtocolSideRevenueUSD.get_unique_protocol_key(), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "dailyTotalRevenueUSD", @@ -147,7 +154,8 @@ fn create_financial_daily_snapshot( ordinal, StoreKey::DailyTotalRevenueUSD.get_unique_daily_protocol_key(day_id), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change( "cumulativeTotalRevenueUSD", @@ -156,7 +164,8 @@ fn create_financial_daily_snapshot( ordinal, StoreKey::CumulativeTotalRevenueUSD.get_unique_protocol_key(), ) - .unwrap_or(BigDecimal::zero()), + .unwrap_or(BigDecimal::zero()) + .with_prec(20), ) .change("blockNumber", block_number) .change("timestamp", timestamp); diff --git a/uniswap-v2/src/modules/1_map_pool_created.rs b/uniswap-v2/src/modules/1_map_pool_created.rs index e4efa49..ec380b4 100644 --- a/uniswap-v2/src/modules/1_map_pool_created.rs +++ b/uniswap-v2/src/modules/1_map_pool_created.rs @@ -25,17 +25,22 @@ fn get_pools(block: ð::Block, pools: &mut Vec) { let token0 = TokenContract::new(Address::from_slice(event.token0.as_slice())).as_struct(); let token1 = TokenContract::new(Address::from_slice(event.token1.as_slice())).as_struct(); - pools.push(Pool { - name: format! {"{}/{}", token0.symbol, token1.symbol}, - symbol: String::new(), - address: pool.address.clone(), - input_tokens: Some(Erc20Tokens { - items: vec![token0, token1], - }), - output_token: Some(pool), - created_timestamp: block.timestamp_seconds() as i64, - created_block_number: block.number as i64, - }) + if !constants::BLACKLISTED_TOKENS.contains(&token0.address.as_str()) + && !constants::BLACKLISTED_POOLS.contains(&pool.address.as_str()) + && !constants::BLACKLISTED_TOKENS.contains(&token1.address.as_str()) + { + pools.push(Pool { + name: format! {"{}/{}", token0.symbol, token1.symbol}, + symbol: String::new(), + address: pool.address.clone(), + input_tokens: Some(Erc20Tokens { + items: vec![token0, token1], + }), + output_token: Some(pool), + created_timestamp: block.timestamp_seconds() as i64, + created_block_number: block.number as i64, + }) + } }; let mut eh = EventHandler::new(&block); diff --git a/uniswap-v2/src/modules/21_map_events_entity.rs b/uniswap-v2/src/modules/21_map_events_entity.rs index e7fac78..1987ca1 100644 --- a/uniswap-v2/src/modules/21_map_events_entity.rs +++ b/uniswap-v2/src/modules/21_map_events_entity.rs @@ -111,9 +111,15 @@ fn create_deposit_transaction( .change("timestamp", BigInt::from(event.timestamp)) .change("inputTokens", pool.input_tokens()) .change("outputToken", pool.output_token_address()) - .change("inputTokenAmounts", input_token_amounts) + .change( + "inputTokenAmounts", + input_token_amounts + .iter() + .map(|x| BigInt::try_from(x).unwrap_or(BigInt::zero())) + .collect::>(), + ) .change("outputTokenAmount", output_token_amount) - .change("amountUSD", amount_usd) + .change("amountUSD", amount_usd.with_prec(20)) .change("pool", pool.address.clone()); deposit_entity_change @@ -154,9 +160,15 @@ fn create_withdraw_transaction( .change("timestamp", BigInt::from(event.timestamp)) .change("inputTokens", pool.input_tokens()) .change("outputToken", pool.output_token_address()) - .change("inputTokenAmounts", input_token_amounts) + .change( + "inputTokenAmounts", + input_token_amounts + .iter() + .map(|x| BigInt::try_from(x).unwrap_or(BigInt::zero())) + .collect::>(), + ) .change("outputTokenAmount", output_token_amount) - .change("amountUSD", amount_usd) + .change("amountUSD", amount_usd.with_prec(20)) .change("pool", pool.address.clone()); withdraw_entity_change @@ -196,10 +208,10 @@ fn create_swap_transaction( .change("timestamp", BigInt::from(event.timestamp)) .change("tokenIn", token_in.address) .change("amountIn", amount_in) - .change("amountInUSD", amount_in_usd) + .change("amountInUSD", amount_in_usd.with_prec(20)) .change("tokenOut", token_out.address) .change("amountOut", amount_out) - .change("amountOutUSD", amount_out_usd) + .change("amountOutUSD", amount_out_usd.with_prec(20)) .change("pool", event.pool.clone()); swap_entity_change 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/src/utils.rs b/uniswap-v2/src/utils.rs index b5f2ba6..b2d8710 100644 --- a/uniswap-v2/src/utils.rs +++ b/uniswap-v2/src/utils.rs @@ -36,6 +36,14 @@ pub fn calculate_revenue(volume: BigDecimal) -> (BigDecimal, BigDecimal) { (supply_side_revenue, protocol_side_revenue) } +pub fn is_valid_amount(amount: &BigDecimal) -> bool { + if amount.ge(&BigDecimal::from(10_i32.pow(9))) { + return false; + } + + return true; +} + pub fn get_token_price(ordinal: u64, store: &StoreGetBigDecimal, address: &String) -> BigDecimal { store .get_at(ordinal, StoreKey::TokenPrice.get_unique_pool_key(address))