fix(curve): fix sUSD pool

This commit is contained in:
Florian Pellissier
2024-08-02 17:12:19 +02:00
parent 2f0b084cc6
commit a46e1e4a57
3 changed files with 70 additions and 11 deletions

View File

@@ -15,3 +15,5 @@ pub const STABLESWAP_FACTORY: [u8; 20] = hex!("4F8846Ae9380B90d2E71D5e3D042dff3E
// Important addresses
pub const WETH_ADDRESS: [u8; 20] = hex!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2");
pub const ETH_ADDRESS: [u8; 20] = hex!("EeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE");
pub const OLD_SUSD: [u8; 20] = hex!("57Ab1E02fEE23774580C119740129eAC7081e9D3");
pub const NEW_SUSD: [u8; 20] = hex!("57ab1ec28d129707052df4df418d58a2d46d5f51");

View File

@@ -13,7 +13,7 @@ use substreams::{
use substreams_ethereum::pb::eth;
use crate::{
consts::{CRYPTO_SWAP_NG_FACTORY, TRICRYPTO_FACTORY},
consts::{CRYPTO_SWAP_NG_FACTORY, NEW_SUSD, OLD_SUSD, TRICRYPTO_FACTORY},
pool_changes::emit_eth_deltas,
pool_factories,
pools::emit_specific_pools,
@@ -157,15 +157,30 @@ pub fn map_relative_balances(
.flat_map(|tx| {
emit_eth_deltas(tx, &tokens_store)
.into_iter()
.chain(extract_balance_deltas_from_tx(tx, |token, transactor| {
let pool_key = format!("pool:{}", hex::encode(transactor));
if let Some(tokens) = tokens_store.get_last(pool_key) {
let token_id = hex::encode(token);
tokens.split(':').any(|t| t == token_id)
} else {
false
}
}))
.chain(
extract_balance_deltas_from_tx(tx, |token, transactor| {
let pool_key = format!("pool:{}", hex::encode(transactor));
if let Some(tokens) = tokens_store.get_last(pool_key) {
let token_id;
if token == OLD_SUSD {
token_id = hex::encode(NEW_SUSD);
} else {
token_id = hex::encode(token);
}
tokens.split(':').any(|t| t == token_id)
} else {
false
}
})
.into_iter()
.map(|mut balance| {
if balance.token == OLD_SUSD {
balance.token = NEW_SUSD.into();
}
balance
})
.collect::<Vec<_>>(),
)
})
.collect();