🎉
This commit is contained in:
6173
substreams/ethereum-curve/src/abi/crypto_swap_ng_factory.rs
Normal file
6173
substreams/ethereum-curve/src/abi/crypto_swap_ng_factory.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,11 @@
|
||||
pub mod crypto_pool_factory;
|
||||
pub mod pool_tricrypto;
|
||||
pub mod pool_crypto_swap_ng;
|
||||
pub mod pool_tricrypto2;
|
||||
pub mod crypto_swap_ng_factory;
|
||||
pub mod pool_steth;
|
||||
pub mod pool;
|
||||
pub mod tricrypto_factory;
|
||||
pub mod main_registry;
|
||||
pub mod pool_3pool;
|
||||
pub mod meta_pool_factory;
|
||||
|
||||
9433
substreams/ethereum-curve/src/abi/pool_crypto_swap_ng.rs
Normal file
9433
substreams/ethereum-curve/src/abi/pool_crypto_swap_ng.rs
Normal file
File diff suppressed because it is too large
Load Diff
7512
substreams/ethereum-curve/src/abi/pool_tricrypto2.rs
Normal file
7512
substreams/ethereum-curve/src/abi/pool_tricrypto2.rs
Normal file
File diff suppressed because it is too large
Load Diff
3785
substreams/ethereum-curve/src/abi/tricrypto_factory.rs
Normal file
3785
substreams/ethereum-curve/src/abi/tricrypto_factory.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -227,7 +227,7 @@ pub fn map_protocol_changes(
|
||||
&block,
|
||||
|addr| {
|
||||
components_store
|
||||
.get_last(format!("pool:0x{0}", hex::encode(addr)))
|
||||
.get_last(format!("pool:{0}", hex::encode(addr)))
|
||||
.is_some()
|
||||
},
|
||||
&mut transaction_contract_changes,
|
||||
|
||||
@@ -75,6 +75,46 @@ pub fn emit_deltas(
|
||||
},
|
||||
log,
|
||||
)
|
||||
} else if let Some(event) = abi::pool_tricrypto2::events::TokenExchange::match_and_decode(log) {
|
||||
token_change_deltas(
|
||||
tokens,
|
||||
abi::pool::events::TokenExchange {
|
||||
sold_id: event.sold_id,
|
||||
bought_id: event.bought_id,
|
||||
tokens_sold: event.tokens_sold,
|
||||
tokens_bought: event.tokens_bought,
|
||||
buyer: event.buyer,
|
||||
},
|
||||
log,
|
||||
)
|
||||
} else if let Some(event) =
|
||||
abi::pool_crypto_swap_ng::events::TokenExchange::match_and_decode(log)
|
||||
{
|
||||
token_change_deltas(
|
||||
tokens,
|
||||
abi::pool::events::TokenExchange {
|
||||
sold_id: event.sold_id,
|
||||
bought_id: event.bought_id,
|
||||
tokens_sold: event.tokens_sold,
|
||||
tokens_bought: event.tokens_bought,
|
||||
buyer: event.buyer,
|
||||
},
|
||||
log,
|
||||
)
|
||||
} else if let Some(event) =
|
||||
abi::pool_crypto_swap_ng::events::TokenExchangeUnderlying::match_and_decode(log)
|
||||
{
|
||||
token_change_deltas(
|
||||
tokens,
|
||||
abi::pool::events::TokenExchange {
|
||||
sold_id: event.sold_id,
|
||||
bought_id: event.bought_id,
|
||||
tokens_sold: event.tokens_sold,
|
||||
tokens_bought: event.tokens_bought,
|
||||
buyer: event.buyer,
|
||||
},
|
||||
log,
|
||||
)
|
||||
} else if let Some(event) = abi::pool::events::AddLiquidity::match_and_decode(log) {
|
||||
add_liquidity_deltas(event.token_amounts.into(), &tokens, log)
|
||||
} else if let Some(event) = abi::pool_3pool::events::AddLiquidity::match_and_decode(log) {
|
||||
@@ -83,6 +123,12 @@ pub fn emit_deltas(
|
||||
add_liquidity_deltas(event.token_amounts.into(), &tokens, log)
|
||||
} else if let Some(event) = abi::pool_tricrypto::events::AddLiquidity::match_and_decode(log) {
|
||||
add_liquidity_deltas(event.token_amounts.into(), &tokens, log)
|
||||
} else if let Some(event) = abi::pool_tricrypto2::events::AddLiquidity::match_and_decode(log) {
|
||||
add_liquidity_deltas(event.token_amounts.into(), &tokens, log)
|
||||
} else if let Some(event) =
|
||||
abi::pool_crypto_swap_ng::events::AddLiquidity::match_and_decode(log)
|
||||
{
|
||||
add_liquidity_deltas(event.token_amounts.into(), &tokens, log)
|
||||
} else if let Some(event) = abi::pool::events::RemoveLiquidity::match_and_decode(log) {
|
||||
remove_liquidity_deltas(event.token_amounts.into(), &tokens, log)
|
||||
} else if let Some(event) = abi::pool_3pool::events::RemoveLiquidity::match_and_decode(log) {
|
||||
@@ -92,6 +138,36 @@ pub fn emit_deltas(
|
||||
} else if let Some(event) = abi::pool_tricrypto::events::RemoveLiquidity::match_and_decode(log)
|
||||
{
|
||||
remove_liquidity_deltas(event.token_amounts.into(), &tokens, log)
|
||||
} else if let Some(event) = abi::pool_tricrypto2::events::RemoveLiquidity::match_and_decode(log)
|
||||
{
|
||||
remove_liquidity_deltas(event.token_amounts.into(), &tokens, log)
|
||||
} else if let Some(event) =
|
||||
abi::pool_crypto_swap_ng::events::RemoveLiquidity::match_and_decode(log)
|
||||
{
|
||||
remove_liquidity_deltas(event.token_amounts.into(), &tokens, log)
|
||||
// } else if let Some(event) =
|
||||
// abi::pool_crypto_swap_ng::events::RemoveLiquidityImbalance::match_and_decode(log)
|
||||
// {
|
||||
// remove_liquidity_deltas(event.token_amounts.into(), &tokens, log)
|
||||
// } else if let Some(event) =
|
||||
// abi::pool_crypto_swap_ng::events::RemoveLiquidityOne::match_and_decode(log)
|
||||
// {
|
||||
// Some(vec![
|
||||
// BalanceDelta {
|
||||
// ord: log.log.ordinal,
|
||||
// tx: Some(tx_from_log(&log)),
|
||||
// token: hex::decode(sold_token_id.clone()).unwrap(),
|
||||
// delta: event.tokens_sold.to_signed_bytes_be(),
|
||||
// component_id: hex::encode(log.address()).into(),
|
||||
// },
|
||||
// BalanceDelta {
|
||||
// ord: log.log.ordinal,
|
||||
// tx: Some(tx_from_log(&log)),
|
||||
// token: hex::decode(sold_token_id.clone()).unwrap(),
|
||||
// delta: event.tokens_sold.to_signed_bytes_be(),
|
||||
// component_id: hex::encode(log.address()).into(),
|
||||
// },
|
||||
// ])
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -152,12 +228,15 @@ fn remove_liquidity_deltas(
|
||||
amounts
|
||||
.iter()
|
||||
.zip(tokens)
|
||||
.map(move |(token_amount, token_id)| BalanceDelta {
|
||||
ord: log.log.ordinal,
|
||||
tx: Some(tx_from_log(&log)),
|
||||
token: hex::decode(token_id).unwrap(),
|
||||
delta: token_amount.to_signed_bytes_be(),
|
||||
component_id: hex::encode(log.address()).into(),
|
||||
.map(move |(token_amount, token_id)| {
|
||||
let token_amount_neg: BigInt = token_amount.clone() * -1;
|
||||
BalanceDelta {
|
||||
ord: log.log.ordinal,
|
||||
tx: Some(tx_from_log(&log)),
|
||||
token: hex::decode(token_id).unwrap(),
|
||||
delta: token_amount_neg.to_signed_bytes_be(),
|
||||
component_id: hex::encode(log.address()).into(),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
|
||||
@@ -16,6 +16,8 @@ const CRYPTO_SWAP_REGISTRY: [u8; 20] = hex!("897888115Ada5773E02aA29F775430BFB5F
|
||||
const MAIN_REGISTRY: [u8; 20] = hex!("90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5");
|
||||
const CRYPTO_POOL_FACTORY: [u8; 20] = hex!("F18056Bbd320E96A48e3Fbf8bC061322531aac99");
|
||||
const META_POOL_FACTORY: [u8; 20] = hex!("B9fC157394Af804a3578134A6585C0dc9cc990d4");
|
||||
const CRYPTO_SWAP_NG_FACTORY: [u8; 20] = hex!("6A8cbed756804B16E05E741eDaBd5cB544AE21bf");
|
||||
const TRICRYPTO_FACTORY: [u8; 20] = hex!("0c0e5f2fF0ff18a3be9b835635039256dC4B4963");
|
||||
|
||||
/// This trait defines some helpers for serializing and deserializing `Vec<BigInt>` which is needed
|
||||
/// to be able to encode some of the `Attribute`s. This should also be handled by any downstream
|
||||
@@ -174,9 +176,9 @@ pub fn address_map(
|
||||
|
||||
// We need to perform an eth_call in order to actually get the pool's tokens
|
||||
let coins_function =
|
||||
abi::crypto_swap_registry::functions::GetCoins { pool: add_pool.pool };
|
||||
abi::main_registry::functions::GetCoins { pool: add_pool.pool };
|
||||
|
||||
let coins = coins_function.call(CRYPTO_SWAP_REGISTRY.to_vec())?;
|
||||
let coins = coins_function.call(MAIN_REGISTRY.to_vec())?;
|
||||
let trimmed_coins: Vec<_> = coins
|
||||
.get(0..add_pool.n_coins.to_i32() as usize)
|
||||
.unwrap_or(&[])
|
||||
@@ -227,7 +229,7 @@ pub fn address_map(
|
||||
let component_id = &call.return_data[12..];
|
||||
|
||||
Some(ProtocolComponent {
|
||||
id: format!("0x{0}", hex::encode(component_id)),
|
||||
id: hex::encode(component_id),
|
||||
tx: Some(Transaction {
|
||||
to: tx.to.clone(),
|
||||
from: tx.from.clone(),
|
||||
@@ -354,7 +356,7 @@ pub fn address_map(
|
||||
let component_id = &call.return_data[12..];
|
||||
|
||||
Some(ProtocolComponent {
|
||||
id: format!("0x{0}", hex::encode(component_id)),
|
||||
id: hex::encode(component_id),
|
||||
tx: Some(Transaction {
|
||||
to: tx.to.clone(),
|
||||
from: tx.from.clone(),
|
||||
@@ -442,6 +444,143 @@ pub fn address_map(
|
||||
None
|
||||
}
|
||||
}
|
||||
CRYPTO_SWAP_NG_FACTORY => {
|
||||
if let Some(pool_added) =
|
||||
abi::crypto_swap_ng_factory::events::PlainPoolDeployed::match_and_decode(log)
|
||||
{
|
||||
let add_pool =
|
||||
abi::crypto_swap_ng_factory::functions::DeployPlainPool::match_and_decode(
|
||||
call,
|
||||
)?;
|
||||
let component_id = &call.return_data[12..];
|
||||
Some(ProtocolComponent {
|
||||
id: hex::encode(component_id),
|
||||
tx: Some(Transaction {
|
||||
to: tx.to.clone(),
|
||||
from: tx.from.clone(),
|
||||
hash: tx.hash.clone(),
|
||||
index: tx.index.into(),
|
||||
}),
|
||||
tokens: pool_added.coins.into(),
|
||||
contracts: vec![component_id.into()],
|
||||
static_att: vec![
|
||||
Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "Pool".into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "name".into(),
|
||||
value: add_pool.name.into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "fee".into(),
|
||||
value: pool_added.fee.to_string().into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "a".into(),
|
||||
value: pool_added.a.to_string().into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: ChangeType::Creation.into(),
|
||||
protocol_type: Some(ProtocolType {
|
||||
name: "crypto_swap_ng".into(),
|
||||
financial_type: FinancialType::Swap.into(),
|
||||
attribute_schema: Vec::new(),
|
||||
implementation_type: ImplementationType::Vm.into(),
|
||||
}),
|
||||
})
|
||||
} else if let Some(pool_added) =
|
||||
abi::crypto_swap_ng_factory::events::MetaPoolDeployed::match_and_decode(log)
|
||||
{
|
||||
let add_pool =
|
||||
abi::crypto_swap_ng_factory::functions::DeployMetapool::match_and_decode(call)?;
|
||||
let component_id = &call.return_data[12..];
|
||||
Some(ProtocolComponent {
|
||||
id: hex::encode(component_id),
|
||||
tx: Some(Transaction {
|
||||
to: tx.to.clone(),
|
||||
from: tx.from.clone(),
|
||||
hash: tx.hash.clone(),
|
||||
index: tx.index.into(),
|
||||
}),
|
||||
tokens: vec![pool_added.coin, pool_added.base_pool],
|
||||
contracts: vec![component_id.into()],
|
||||
static_att: vec![
|
||||
Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "Pool".into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "name".into(),
|
||||
value: add_pool.name.into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "fee".into(),
|
||||
value: pool_added.fee.to_string().into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "a".into(),
|
||||
value: pool_added.a.to_string().into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: ChangeType::Creation.into(),
|
||||
protocol_type: Some(ProtocolType {
|
||||
name: "crypto_swap_ng".into(),
|
||||
financial_type: FinancialType::Swap.into(),
|
||||
attribute_schema: Vec::new(),
|
||||
implementation_type: ImplementationType::Vm.into(),
|
||||
}),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
TRICRYPTO_FACTORY => {
|
||||
if let Some(pool_added) =
|
||||
abi::tricrypto_factory::events::TricryptoPoolDeployed::match_and_decode(log)
|
||||
{
|
||||
Some(ProtocolComponent {
|
||||
id: hex::encode(&pool_added.pool),
|
||||
tx: Some(Transaction {
|
||||
to: tx.to.clone(),
|
||||
from: tx.from.clone(),
|
||||
hash: tx.hash.clone(),
|
||||
index: tx.index.into(),
|
||||
}),
|
||||
tokens: pool_added.coins.into(),
|
||||
contracts: vec![pool_added.pool.into()],
|
||||
static_att: vec![
|
||||
Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "Pool".into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "name".into(),
|
||||
value: pool_added.name.into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: ChangeType::Creation.into(),
|
||||
protocol_type: Some(ProtocolType {
|
||||
name: "tricrypto".into(),
|
||||
financial_type: FinancialType::Swap.into(),
|
||||
attribute_schema: Vec::new(),
|
||||
implementation_type: ImplementationType::Vm.into(),
|
||||
}),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,11 +89,11 @@ fn create_component(
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_params(params: &String) -> Result<HashMap<String, PoolQueryParams>, anyhow::Error> {
|
||||
fn parse_params(params: &str) -> Result<HashMap<String, PoolQueryParams>, anyhow::Error> {
|
||||
let pools: HashMap<String, PoolQueryParams> = params
|
||||
.split(PARAMS_SEPERATOR)
|
||||
.map(|param| {
|
||||
let pool: PoolQueryParams = serde_qs::from_str(¶m)
|
||||
let pool: PoolQueryParams = serde_qs::from_str(param)
|
||||
.with_context(|| format!("Failed to parse pool query params: {0}", param))?;
|
||||
Ok((pool.tx_hash.clone(), pool))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user