diff --git a/substreams/ethereum-curve/abi/pool_3pool.json b/substreams/ethereum-curve/abi/pool_3pool.json index e18b62c..eb81103 100644 --- a/substreams/ethereum-curve/abi/pool_3pool.json +++ b/substreams/ethereum-curve/abi/pool_3pool.json @@ -1,48 +1,4 @@ [ - { - "name": "Transfer", - "inputs": [ - { - "type": "address", - "name": "sender", - "indexed": true - }, - { - "type": "address", - "name": "receiver", - "indexed": true - }, - { - "type": "uint256", - "name": "value", - "indexed": false - } - ], - "anonymous": false, - "type": "event" - }, - { - "name": "Approval", - "inputs": [ - { - "type": "address", - "name": "owner", - "indexed": true - }, - { - "type": "address", - "name": "spender", - "indexed": true - }, - { - "type": "uint256", - "name": "value", - "indexed": false - } - ], - "anonymous": false, - "type": "event" - }, { "name": "TokenExchange", "inputs": [ @@ -75,38 +31,6 @@ "anonymous": false, "type": "event" }, - { - "name": "TokenExchangeUnderlying", - "inputs": [ - { - "type": "address", - "name": "buyer", - "indexed": true - }, - { - "type": "int128", - "name": "sold_id", - "indexed": false - }, - { - "type": "uint256", - "name": "tokens_sold", - "indexed": false - }, - { - "type": "int128", - "name": "bought_id", - "indexed": false - }, - { - "type": "uint256", - "name": "tokens_bought", - "indexed": false - } - ], - "anonymous": false, - "type": "event" - }, { "name": "AddLiquidity", "inputs": [ @@ -116,12 +40,12 @@ "indexed": true }, { - "type": "uint256[2]", + "type": "uint256[3]", "name": "token_amounts", "indexed": false }, { - "type": "uint256[2]", + "type": "uint256[3]", "name": "fees", "indexed": false }, @@ -148,12 +72,12 @@ "indexed": true }, { - "type": "uint256[2]", + "type": "uint256[3]", "name": "token_amounts", "indexed": false }, { - "type": "uint256[2]", + "type": "uint256[3]", "name": "fees", "indexed": false }, @@ -183,11 +107,6 @@ "type": "uint256", "name": "coin_amount", "indexed": false - }, - { - "type": "uint256", - "name": "token_supply", - "indexed": false } ], "anonymous": false, @@ -202,12 +121,12 @@ "indexed": true }, { - "type": "uint256[2]", + "type": "uint256[3]", "name": "token_amounts", "indexed": false }, { - "type": "uint256[2]", + "type": "uint256[3]", "name": "fees", "indexed": false }, @@ -338,30 +257,19 @@ "type": "event" }, { - "outputs": [], - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "name": "initialize", "outputs": [], "inputs": [ { - "type": "string", - "name": "_name" + "type": "address", + "name": "_owner" }, { - "type": "string", - "name": "_symbol" + "type": "address[3]", + "name": "_coins" }, { "type": "address", - "name": "_coin" - }, - { - "type": "uint256", - "name": "_decimals" + "name": "_pool_token" }, { "type": "uint256", @@ -372,174 +280,12 @@ "name": "_fee" }, { - "type": "address", - "name": "_admin" + "type": "uint256", + "name": "_admin_fee" } ], "stateMutability": "nonpayable", - "type": "function", - "gas": 470049 - }, - { - "name": "decimals", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [], - "stateMutability": "view", - "type": "function", - "gas": 291 - }, - { - "name": "transfer", - "outputs": [ - { - "type": "bool", - "name": "" - } - ], - "inputs": [ - { - "type": "address", - "name": "_to" - }, - { - "type": "uint256", - "name": "_value" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "gas": 75402 - }, - { - "name": "transferFrom", - "outputs": [ - { - "type": "bool", - "name": "" - } - ], - "inputs": [ - { - "type": "address", - "name": "_from" - }, - { - "type": "address", - "name": "_to" - }, - { - "type": "uint256", - "name": "_value" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "gas": 112037 - }, - { - "name": "approve", - "outputs": [ - { - "type": "bool", - "name": "" - } - ], - "inputs": [ - { - "type": "address", - "name": "_spender" - }, - { - "type": "uint256", - "name": "_value" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "gas": 37854 - }, - { - "name": "get_previous_balances", - "outputs": [ - { - "type": "uint256[2]", - "name": "" - } - ], - "inputs": [], - "stateMutability": "view", - "type": "function", - "gas": 2254 - }, - { - "name": "get_balances", - "outputs": [ - { - "type": "uint256[2]", - "name": "" - } - ], - "inputs": [], - "stateMutability": "view", - "type": "function", - "gas": 2284 - }, - { - "name": "get_twap_balances", - "outputs": [ - { - "type": "uint256[2]", - "name": "" - } - ], - "inputs": [ - { - "type": "uint256[2]", - "name": "_first_balances" - }, - { - "type": "uint256[2]", - "name": "_last_balances" - }, - { - "type": "uint256", - "name": "_time_elapsed" - } - ], - "stateMutability": "view", - "type": "function", - "gas": 1522 - }, - { - "name": "get_price_cumulative_last", - "outputs": [ - { - "type": "uint256[2]", - "name": "" - } - ], - "inputs": [], - "stateMutability": "view", - "type": "function", - "gas": 2344 - }, - { - "name": "admin_fee", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [], - "stateMutability": "view", - "type": "function", - "gas": 621 + "type": "constructor" }, { "name": "A", @@ -552,20 +298,7 @@ "inputs": [], "stateMutability": "view", "type": "function", - "gas": 5859 - }, - { - "name": "A_precise", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [], - "stateMutability": "view", - "type": "function", - "gas": 5821 + "gas": 5227 }, { "name": "get_virtual_price", @@ -578,7 +311,7 @@ "inputs": [], "stateMutability": "view", "type": "function", - "gas": 1011891 + "gas": 1133537 }, { "name": "calc_token_amount", @@ -590,87 +323,34 @@ ], "inputs": [ { - "type": "uint256[2]", - "name": "_amounts" + "type": "uint256[3]", + "name": "amounts" }, { "type": "bool", - "name": "_is_deposit" + "name": "deposit" } ], "stateMutability": "view", - "type": "function" - }, - { - "name": "calc_token_amount", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "uint256[2]", - "name": "_amounts" - }, - { - "type": "bool", - "name": "_is_deposit" - }, - { - "type": "bool", - "name": "_previous" - } - ], - "stateMutability": "view", - "type": "function" + "type": "function", + "gas": 4508776 }, { "name": "add_liquidity", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], + "outputs": [], "inputs": [ { - "type": "uint256[2]", - "name": "_amounts" + "type": "uint256[3]", + "name": "amounts" }, { "type": "uint256", - "name": "_min_mint_amount" + "name": "min_mint_amount" } ], "stateMutability": "nonpayable", - "type": "function" - }, - { - "name": "add_liquidity", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "uint256[2]", - "name": "_amounts" - }, - { - "type": "uint256", - "name": "_min_mint_amount" - }, - { - "type": "address", - "name": "_receiver" - } - ], - "stateMutability": "nonpayable", - "type": "function" + "type": "function", + "gas": 6954858 }, { "name": "get_dy", @@ -695,36 +375,8 @@ } ], "stateMutability": "view", - "type": "function" - }, - { - "name": "get_dy", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "int128", - "name": "i" - }, - { - "type": "int128", - "name": "j" - }, - { - "type": "uint256", - "name": "dx" - }, - { - "type": "uint256[2]", - "name": "_balances" - } - ], - "stateMutability": "view", - "type": "function" + "type": "function", + "gas": 2673791 }, { "name": "get_dy_underlying", @@ -749,45 +401,12 @@ } ], "stateMutability": "view", - "type": "function" - }, - { - "name": "get_dy_underlying", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "int128", - "name": "i" - }, - { - "type": "int128", - "name": "j" - }, - { - "type": "uint256", - "name": "dx" - }, - { - "type": "uint256[2]", - "name": "_balances" - } - ], - "stateMutability": "view", - "type": "function" + "type": "function", + "gas": 2673474 }, { "name": "exchange", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], + "outputs": [], "inputs": [ { "type": "int128", @@ -807,194 +426,42 @@ } ], "stateMutability": "nonpayable", - "type": "function" - }, - { - "name": "exchange", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "int128", - "name": "i" - }, - { - "type": "int128", - "name": "j" - }, - { - "type": "uint256", - "name": "dx" - }, - { - "type": "uint256", - "name": "min_dy" - }, - { - "type": "address", - "name": "_receiver" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "name": "exchange_underlying", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "int128", - "name": "i" - }, - { - "type": "int128", - "name": "j" - }, - { - "type": "uint256", - "name": "dx" - }, - { - "type": "uint256", - "name": "min_dy" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "name": "exchange_underlying", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "int128", - "name": "i" - }, - { - "type": "int128", - "name": "j" - }, - { - "type": "uint256", - "name": "dx" - }, - { - "type": "uint256", - "name": "min_dy" - }, - { - "type": "address", - "name": "_receiver" - } - ], - "stateMutability": "nonpayable", - "type": "function" + "type": "function", + "gas": 2818066 }, { "name": "remove_liquidity", - "outputs": [ - { - "type": "uint256[2]", - "name": "" - } - ], + "outputs": [], "inputs": [ { "type": "uint256", - "name": "_burn_amount" + "name": "_amount" }, { - "type": "uint256[2]", - "name": "_min_amounts" + "type": "uint256[3]", + "name": "min_amounts" } ], "stateMutability": "nonpayable", - "type": "function" - }, - { - "name": "remove_liquidity", - "outputs": [ - { - "type": "uint256[2]", - "name": "" - } - ], - "inputs": [ - { - "type": "uint256", - "name": "_burn_amount" - }, - { - "type": "uint256[2]", - "name": "_min_amounts" - }, - { - "type": "address", - "name": "_receiver" - } - ], - "stateMutability": "nonpayable", - "type": "function" + "type": "function", + "gas": 192846 }, { "name": "remove_liquidity_imbalance", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], + "outputs": [], "inputs": [ { - "type": "uint256[2]", - "name": "_amounts" + "type": "uint256[3]", + "name": "amounts" }, { "type": "uint256", - "name": "_max_burn_amount" + "name": "max_burn_amount" } ], "stateMutability": "nonpayable", - "type": "function" - }, - { - "name": "remove_liquidity_imbalance", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "uint256[2]", - "name": "_amounts" - }, - { - "type": "uint256", - "name": "_max_burn_amount" - }, - { - "type": "address", - "name": "_receiver" - } - ], - "stateMutability": "nonpayable", - "type": "function" + "type": "function", + "gas": 6951851 }, { "name": "calc_withdraw_one_coin", @@ -1007,7 +474,7 @@ "inputs": [ { "type": "uint256", - "name": "_burn_amount" + "name": "_token_amount" }, { "type": "int128", @@ -1015,45 +482,16 @@ } ], "stateMutability": "view", - "type": "function" - }, - { - "name": "calc_withdraw_one_coin", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "uint256", - "name": "_burn_amount" - }, - { - "type": "int128", - "name": "i" - }, - { - "type": "bool", - "name": "_previous" - } - ], - "stateMutability": "view", - "type": "function" + "type": "function", + "gas": 1102 }, { "name": "remove_liquidity_one_coin", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], + "outputs": [], "inputs": [ { "type": "uint256", - "name": "_burn_amount" + "name": "_token_amount" }, { "type": "int128", @@ -1061,40 +499,12 @@ }, { "type": "uint256", - "name": "_min_received" + "name": "min_amount" } ], "stateMutability": "nonpayable", - "type": "function" - }, - { - "name": "remove_liquidity_one_coin", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "uint256", - "name": "_burn_amount" - }, - { - "type": "int128", - "name": "i" - }, - { - "type": "uint256", - "name": "_min_received" - }, - { - "type": "address", - "name": "_receiver" - } - ], - "stateMutability": "nonpayable", - "type": "function" + "type": "function", + "gas": 4025523 }, { "name": "ramp_A", @@ -1111,7 +521,7 @@ ], "stateMutability": "nonpayable", "type": "function", - "gas": 152464 + "gas": 151919 }, { "name": "stop_ramp_A", @@ -1119,7 +529,69 @@ "inputs": [], "stateMutability": "nonpayable", "type": "function", - "gas": 149225 + "gas": 148637 + }, + { + "name": "commit_new_fee", + "outputs": [], + "inputs": [ + { + "type": "uint256", + "name": "new_fee" + }, + { + "type": "uint256", + "name": "new_admin_fee" + } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 110461 + }, + { + "name": "apply_new_fee", + "outputs": [], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function", + "gas": 97242 + }, + { + "name": "revert_new_parameters", + "outputs": [], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function", + "gas": 21895 + }, + { + "name": "commit_transfer_ownership", + "outputs": [], + "inputs": [ + { + "type": "address", + "name": "_owner" + } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 74572 + }, + { + "name": "apply_transfer_ownership", + "outputs": [], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function", + "gas": 60710 + }, + { + "name": "revert_transfer_ownership", + "outputs": [], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function", + "gas": 21985 }, { "name": "admin_balances", @@ -1137,7 +609,7 @@ ], "stateMutability": "view", "type": "function", - "gas": 3601 + "gas": 3481 }, { "name": "withdraw_admin_fees", @@ -1145,20 +617,31 @@ "inputs": [], "stateMutability": "nonpayable", "type": "function", - "gas": 11347 + "gas": 21502 }, { - "name": "admin", - "outputs": [ - { - "type": "address", - "name": "" - } - ], + "name": "donate_admin_fees", + "outputs": [], "inputs": [], - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "gas": 2141 + "gas": 111389 + }, + { + "name": "kill_me", + "outputs": [], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37998 + }, + { + "name": "unkill_me", + "outputs": [], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function", + "gas": 22135 }, { "name": "coins", @@ -1176,7 +659,7 @@ ], "stateMutability": "view", "type": "function", - "gas": 2280 + "gas": 2220 }, { "name": "balances", @@ -1194,7 +677,7 @@ ], "stateMutability": "view", "type": "function", - "gas": 2310 + "gas": 2250 }, { "name": "fee", @@ -1207,10 +690,10 @@ "inputs": [], "stateMutability": "view", "type": "function", - "gas": 2231 + "gas": 2171 }, { - "name": "block_timestamp_last", + "name": "admin_fee", "outputs": [ { "type": "uint256", @@ -1220,7 +703,20 @@ "inputs": [], "stateMutability": "view", "type": "function", - "gas": 2261 + "gas": 2201 + }, + { + "name": "owner", + "outputs": [ + { + "type": "address", + "name": "" + } + ], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2231 }, { "name": "initial_A", @@ -1233,7 +729,7 @@ "inputs": [], "stateMutability": "view", "type": "function", - "gas": 2291 + "gas": 2261 }, { "name": "future_A", @@ -1246,7 +742,7 @@ "inputs": [], "stateMutability": "view", "type": "function", - "gas": 2321 + "gas": 2291 }, { "name": "initial_A_time", @@ -1259,7 +755,7 @@ "inputs": [], "stateMutability": "view", "type": "function", - "gas": 2351 + "gas": 2321 }, { "name": "future_A_time", @@ -1272,76 +768,23 @@ "inputs": [], "stateMutability": "view", "type": "function", + "gas": 2351 + }, + { + "name": "admin_actions_deadline", + "outputs": [ + { + "type": "uint256", + "name": "" + } + ], + "inputs": [], + "stateMutability": "view", + "type": "function", "gas": 2381 }, { - "name": "name", - "outputs": [ - { - "type": "string", - "name": "" - } - ], - "inputs": [], - "stateMutability": "view", - "type": "function", - "gas": 8813 - }, - { - "name": "symbol", - "outputs": [ - { - "type": "string", - "name": "" - } - ], - "inputs": [], - "stateMutability": "view", - "type": "function", - "gas": 7866 - }, - { - "name": "balanceOf", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "address", - "name": "arg0" - } - ], - "stateMutability": "view", - "type": "function", - "gas": 2686 - }, - { - "name": "allowance", - "outputs": [ - { - "type": "uint256", - "name": "" - } - ], - "inputs": [ - { - "type": "address", - "name": "arg0" - }, - { - "type": "address", - "name": "arg1" - } - ], - "stateMutability": "view", - "type": "function", - "gas": 2931 - }, - { - "name": "totalSupply", + "name": "transfer_ownership_deadline", "outputs": [ { "type": "uint256", @@ -1351,6 +794,45 @@ "inputs": [], "stateMutability": "view", "type": "function", - "gas": 2531 + "gas": 2411 + }, + { + "name": "future_fee", + "outputs": [ + { + "type": "uint256", + "name": "" + } + ], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2441 + }, + { + "name": "future_admin_fee", + "outputs": [ + { + "type": "uint256", + "name": "" + } + ], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2471 + }, + { + "name": "future_owner", + "outputs": [ + { + "type": "address", + "name": "" + } + ], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2501 } ] \ No newline at end of file diff --git a/substreams/ethereum-curve/params.json b/substreams/ethereum-curve/params.json index fcdd5d5..1a48ec9 100644 --- a/substreams/ethereum-curve/params.json +++ b/substreams/ethereum-curve/params.json @@ -1,13 +1,23 @@ [ { "name": "3pool", - "address": "bEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7", - "tx_hash": "20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6", + "address": "bebc44782c7db0a1a60cb6fe97d0b483032ff1c7", + "tx_hash": "e90adc0e0a1ae9dde6c240b348adef761444e61f4194245a2096f7ca8310ac2f", "tokens": [ "6b175474e89094c44da98b954eedeac495271d0f", "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "dac17f958d2ee523a2206206994597c13d831ec7" ], "attributes": {} + }, + { + "name": "steth", + "address": "dc24316b9ae028f1497c275eb9192a3ea0f67022", + "tx_hash": "d844051b63ce310f0f354e29e8c7f550a02fcd3bc642592a2eae6a2804e17d9c", + "tokens": [ + "EeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + "ae7ab96520DE3A18E5e111B5EaAb095312D7fE84" + ], + "attributes": {} } ] \ No newline at end of file diff --git a/substreams/ethereum-curve/src/modules.rs b/substreams/ethereum-curve/src/modules.rs index e67677c..255b6e0 100644 --- a/substreams/ethereum-curve/src/modules.rs +++ b/substreams/ethereum-curve/src/modules.rs @@ -4,6 +4,7 @@ use anyhow::Result; use itertools::Itertools; use substreams::{ pb::substreams::StoreDeltas, + scalar::BigInt, store::{ StoreAdd, StoreAddBigInt, StoreAddInt64, StoreGet, StoreGetInt64, StoreGetString, StoreNew, StoreSet, StoreSetString, @@ -179,7 +180,7 @@ pub fn map_protocol_changes( .extend_from_slice(&tx_component.components); }); - // Balance changes are gathered by the `StoreDelta` based on `PoolBalanceChanged` creating + // Balance changes are gathered by the `StoreDelta` based on `TokenExchange`, etc. creating // `BalanceDeltas`. We essentially just process the changes that occured to the `store` this // block. Then, these balance changes are merged onto the existing map of tx contract changes, // inserting a new one if it doesn't exist. @@ -188,14 +189,16 @@ pub fn map_protocol_changes( .into_iter() .zip(deltas.balance_deltas) .map(|(store_delta, balance_delta)| { - let pool_id = key::segment_at(&store_delta.key, 1); - let token_id = key::segment_at(&store_delta.key, 3); + let new_value_string = String::from_utf8_lossy(&store_delta.new_value).to_string(); ( balance_delta.tx.unwrap(), BalanceChange { - token: hex::decode(token_id).expect("Token ID not valid hex"), - balance: store_delta.new_value, - component_id: hex::decode(pool_id).expect("Token ID not valid hex"), + token: balance_delta.token, + balance: BigInt::try_from(new_value_string) + .unwrap() + .to_signed_bytes_be(), + component_id: hex::decode(balance_delta.component_id) + .expect("Pool ID not valid hex"), }, ) }) diff --git a/substreams/ethereum-curve/src/pool_changes.rs b/substreams/ethereum-curve/src/pool_changes.rs index 6117106..e665b86 100644 --- a/substreams/ethereum-curve/src/pool_changes.rs +++ b/substreams/ethereum-curve/src/pool_changes.rs @@ -1,4 +1,5 @@ use substreams::{ + hex, scalar::BigInt, store::{StoreGet, StoreGetInt64, StoreGetString}, }; @@ -37,9 +38,10 @@ pub fn emit_deltas( .collect::>(); if let Some(event) = abi::pool::events::TokenExchange::match_and_decode(log) { - token_change_deltas(event, log) + token_change_deltas(tokens, event, log) } else if let Some(event) = abi::pool_3pool::events::TokenExchange::match_and_decode(log) { token_change_deltas( + tokens, abi::pool::events::TokenExchange { sold_id: event.sold_id, bought_id: event.bought_id, @@ -51,6 +53,7 @@ pub fn emit_deltas( ) } else if let Some(event) = abi::pool_steth::events::TokenExchange::match_and_decode(log) { token_change_deltas( + tokens, abi::pool::events::TokenExchange { sold_id: event.sold_id, bought_id: event.bought_id, @@ -62,6 +65,7 @@ pub fn emit_deltas( ) } else if let Some(event) = abi::pool_tricrypto::events::TokenExchange::match_and_decode(log) { token_change_deltas( + tokens, abi::pool::events::TokenExchange { sold_id: event.sold_id, bought_id: event.bought_id, @@ -94,24 +98,27 @@ pub fn emit_deltas( } fn token_change_deltas( + tokens: Vec, event: abi::pool::events::TokenExchange, log: LogView<'_>, ) -> Option> { let tokens_bought_delta: BigInt = event.tokens_bought * -1; + let sold_token_id = &tokens[event.sold_id.to_u64() as usize]; + let bought_token_id = &tokens[event.bought_id.to_u64() as usize]; Some(vec![ BalanceDelta { ord: log.log.ordinal, tx: Some(tx_from_log(&log)), - token: event.sold_id.to_signed_bytes_be(), + token: hex::decode(sold_token_id.clone()).unwrap(), delta: event.tokens_sold.to_signed_bytes_be(), - component_id: log.address().into(), + component_id: hex::encode(log.address()).into(), }, BalanceDelta { ord: log.log.ordinal, tx: Some(tx_from_log(&log)), - token: event.bought_id.to_signed_bytes_be(), + token: hex::decode(bought_token_id.clone()).unwrap(), delta: tokens_bought_delta.to_signed_bytes_be(), - component_id: log.address().into(), + component_id: hex::encode(log.address()).into(), }, ]) } @@ -128,9 +135,9 @@ fn add_liquidity_deltas( .map(move |(token_amount, token_id)| BalanceDelta { ord: log.log.ordinal, tx: Some(tx_from_log(&log)), - token: token_id.as_str().into(), + token: hex::decode(token_id).unwrap(), delta: token_amount.to_signed_bytes_be(), - component_id: log.address().into(), + component_id: hex::encode(log.address()).into(), }) .collect::>(), ) @@ -148,9 +155,9 @@ fn remove_liquidity_deltas( .map(move |(token_amount, token_id)| BalanceDelta { ord: log.log.ordinal, tx: Some(tx_from_log(&log)), - token: token_id.as_str().into(), + token: hex::decode(token_id).unwrap(), delta: token_amount.to_signed_bytes_be(), - component_id: log.address().into(), + component_id: hex::encode(log.address()).into(), }) .collect::>(), ) diff --git a/substreams/ethereum-curve/src/pools.rs b/substreams/ethereum-curve/src/pools.rs index 8839298..9e2ad9b 100644 --- a/substreams/ethereum-curve/src/pools.rs +++ b/substreams/ethereum-curve/src/pools.rs @@ -24,7 +24,7 @@ struct PoolQueryParams { /// Static attributes are defined as a vector of tuples with the name and value of the attribute. /// These contain things like the pool type, specific pool fees, etc. You can see /// `pool_factories.rs` for an example of the modern curve pool attributes and also the ones chosen -/// for 3pool, etc. +/// for 3pool, etc. /// /// This function can error based on some basic parsing errors and deeper down hex decoding errors /// if various addresses are not formatted properly. diff --git a/substreams/ethereum-curve/substreams.yaml b/substreams/ethereum-curve/substreams.yaml index bedbdba..4adba5b 100644 --- a/substreams/ethereum-curve/substreams.yaml +++ b/substreams/ethereum-curve/substreams.yaml @@ -19,7 +19,7 @@ binaries: modules: - name: map_components kind: map - initialBlock: 10809473 + initialBlock: 19355224 inputs: - params: string - source: sf.ethereum.type.v2.Block @@ -28,7 +28,7 @@ modules: - name: store_components kind: store - initialBlock: 10809473 + initialBlock: 19355224 updatePolicy: add valueType: int64 inputs: @@ -36,7 +36,7 @@ modules: - name: store_component_tokens kind: store - initialBlock: 10809473 + initialBlock: 19355224 updatePolicy: set valueType: string inputs: @@ -44,7 +44,7 @@ modules: - name: map_relative_balances kind: map - initialBlock: 10809473 # An arbitrary block that should change based on your requirements + initialBlock: 19355224 # An arbitrary block that should change based on your requirements inputs: - source: sf.ethereum.type.v2.Block - store: store_components @@ -54,7 +54,7 @@ modules: - name: store_balances kind: store - initialBlock: 10809473 + initialBlock: 19355224 updatePolicy: add valueType: bigint inputs: @@ -62,7 +62,7 @@ modules: - name: map_protocol_changes kind: map - initialBlock: 10809473 + initialBlock: 19355224 inputs: - source: sf.ethereum.type.v2.Block - map: map_components