refactor(curve): Update testing suite and remove metapools factories (#109)
* chore(lib): update testing suite with new naming * refactor(curve): remove metapool These pools aren't compatible yet due to how they are created (first the lp token and then later the pool). We will need DCI to handle this properly. * chore(lib): use correct package name for tycho-simulation --------- Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
This commit is contained in:
@@ -6,7 +6,7 @@ pub const META_REGISTRY: [u8; 20] = hex!("F98B45FA17DE75FB1aD0e7aFD971b0ca00e379
|
||||
// Factories
|
||||
pub const CRYPTO_POOL_FACTORY: [u8; 20] = hex!("F18056Bbd320E96A48e3Fbf8bC061322531aac99");
|
||||
pub const META_POOL_FACTORY: [u8; 20] = hex!("B9fC157394Af804a3578134A6585C0dc9cc990d4");
|
||||
pub const META_POOL_FACTORY_OLD: [u8; 20] = hex!("0959158b6040D32d04c301A72CBFD6b39E21c9AE");
|
||||
// pub const META_POOL_FACTORY_OLD: [u8; 20] = hex!("0959158b6040D32d04c301A72CBFD6b39E21c9AE");
|
||||
pub const CRYPTO_SWAP_NG_FACTORY: [u8; 20] = hex!("6A8cbed756804B16E05E741eDaBd5cB544AE21bf");
|
||||
pub const TRICRYPTO_FACTORY: [u8; 20] = hex!("0c0e5f2fF0ff18a3be9b835635039256dC4B4963");
|
||||
pub const TWOCRYPTO_FACTORY: [u8; 20] = hex!("98ee851a00abee0d95d08cf4ca2bdce32aeaaf7f");
|
||||
|
||||
@@ -253,185 +253,187 @@ pub fn address_map(
|
||||
}],
|
||||
}],
|
||||
))
|
||||
} else if let Some(pool_added) =
|
||||
abi::meta_pool_factory::events::MetaPoolDeployed::match_and_decode(log)
|
||||
{
|
||||
let add_pool =
|
||||
abi::meta_pool_factory::functions::DeployMetapool1::match_and_decode(call)
|
||||
.map(|add_pool| abi::meta_pool_factory::functions::DeployMetapool2 {
|
||||
base_pool: add_pool.base_pool,
|
||||
name: add_pool.name,
|
||||
symbol: add_pool.symbol,
|
||||
coin: add_pool.coin,
|
||||
a: add_pool.a,
|
||||
fee: add_pool.fee,
|
||||
implementation_idx: BigInt::from(0),
|
||||
})
|
||||
.or_else(|| {
|
||||
abi::meta_pool_factory::functions::DeployMetapool2::match_and_decode(
|
||||
call,
|
||||
)
|
||||
})?;
|
||||
}
|
||||
// else if let Some(pool_added) =
|
||||
// abi::meta_pool_factory::events::MetaPoolDeployed::match_and_decode(log)
|
||||
// {
|
||||
// let add_pool =
|
||||
// abi::meta_pool_factory::functions::DeployMetapool1::match_and_decode(call)
|
||||
// .map(|add_pool| abi::meta_pool_factory::functions::DeployMetapool2 {
|
||||
// base_pool: add_pool.base_pool,
|
||||
// name: add_pool.name,
|
||||
// symbol: add_pool.symbol,
|
||||
// coin: add_pool.coin,
|
||||
// a: add_pool.a,
|
||||
// fee: add_pool.fee,
|
||||
// implementation_idx: BigInt::from(0),
|
||||
// })
|
||||
// .or_else(|| {
|
||||
// abi::meta_pool_factory::functions::DeployMetapool2::match_and_decode(
|
||||
// call,
|
||||
// )
|
||||
// })?;
|
||||
|
||||
let component_id = &call.return_data[12..];
|
||||
// let component_id = &call.return_data[12..];
|
||||
|
||||
// The `add_pool.base_pool` may only refer to the contract of the base pool and not
|
||||
// the token itself. This means we **have** to make an RPC call to the
|
||||
// `meta_registry` in order to get the real LP token address.
|
||||
let get_lp_token =
|
||||
abi::meta_registry::functions::GetLpToken1 { pool: add_pool.base_pool.clone() };
|
||||
let lp_token = get_lp_token.call(META_REGISTRY.to_vec())?;
|
||||
// // The `add_pool.base_pool` may only refer to the contract of the base pool and
|
||||
// not // the token itself. This means we **have** to make an RPC call
|
||||
// to the // `meta_registry` in order to get the real LP token address.
|
||||
// let get_lp_token =
|
||||
// abi::meta_registry::functions::GetLpToken1 { pool: add_pool.base_pool.clone()
|
||||
// }; let lp_token = get_lp_token.call(META_REGISTRY.to_vec())?;
|
||||
|
||||
let pool_implementation = extract_proxy_impl(call, tx, 0).unwrap_or([1u8; 20]);
|
||||
// let pool_implementation = extract_proxy_impl(call, tx, 0).unwrap_or([1u8; 20]);
|
||||
|
||||
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, lp_token],
|
||||
contracts: vec![component_id.into(), add_pool.base_pool.clone()],
|
||||
static_att: vec![
|
||||
Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "metapool".into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "name".into(),
|
||||
value: add_pool.name.into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "factory_name".into(),
|
||||
value: "meta_pool_factory".into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "factory".into(),
|
||||
value: address_to_bytes_with_0x(&META_POOL_FACTORY),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "base_pool".into(),
|
||||
value: address_to_bytes_with_0x(
|
||||
&add_pool.base_pool.try_into().unwrap(),
|
||||
),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: ChangeType::Creation.into(),
|
||||
protocol_type: Some(ProtocolType {
|
||||
name: "curve_pool".into(),
|
||||
financial_type: FinancialType::Swap.into(),
|
||||
attribute_schema: Vec::new(),
|
||||
implementation_type: ImplementationType::Vm.into(),
|
||||
}),
|
||||
},
|
||||
vec![EntityChanges {
|
||||
component_id: address_to_string_with_0x(component_id),
|
||||
attributes: vec![Attribute {
|
||||
name: "stateless_contract_addr_0".into(),
|
||||
value: address_to_bytes_with_0x(&pool_implementation),
|
||||
change: ChangeType::Creation.into(),
|
||||
}],
|
||||
}],
|
||||
))
|
||||
} else {
|
||||
// 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, lp_token],
|
||||
// contracts: vec![component_id.into(), add_pool.base_pool.clone()],
|
||||
// static_att: vec![
|
||||
// Attribute {
|
||||
// name: "pool_type".into(),
|
||||
// value: "metapool".into(),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "name".into(),
|
||||
// value: add_pool.name.into(),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "factory_name".into(),
|
||||
// value: "meta_pool_factory".into(),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "factory".into(),
|
||||
// value: address_to_bytes_with_0x(&META_POOL_FACTORY),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "base_pool".into(),
|
||||
// value: address_to_bytes_with_0x(
|
||||
// &add_pool.base_pool.try_into().unwrap(),
|
||||
// ),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// ],
|
||||
// change: ChangeType::Creation.into(),
|
||||
// protocol_type: Some(ProtocolType {
|
||||
// name: "curve_pool".into(),
|
||||
// financial_type: FinancialType::Swap.into(),
|
||||
// attribute_schema: Vec::new(),
|
||||
// implementation_type: ImplementationType::Vm.into(),
|
||||
// }),
|
||||
// },
|
||||
// vec![EntityChanges {
|
||||
// component_id: address_to_string_with_0x(component_id),
|
||||
// attributes: vec![Attribute {
|
||||
// name: "stateless_contract_addr_0".into(),
|
||||
// value: address_to_bytes_with_0x(&pool_implementation),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// }],
|
||||
// }],
|
||||
// ))
|
||||
// }
|
||||
else {
|
||||
None
|
||||
}
|
||||
}
|
||||
META_POOL_FACTORY_OLD => {
|
||||
if let Some(pool_added) =
|
||||
abi::meta_pool_factory::events::MetaPoolDeployed::match_and_decode(log)
|
||||
{
|
||||
let add_pool =
|
||||
abi::meta_pool_factory::functions::DeployMetapool1::match_and_decode(call)
|
||||
.map(|add_pool| abi::meta_pool_factory::functions::DeployMetapool2 {
|
||||
base_pool: add_pool.base_pool,
|
||||
name: add_pool.name,
|
||||
symbol: add_pool.symbol,
|
||||
coin: add_pool.coin,
|
||||
a: add_pool.a,
|
||||
fee: add_pool.fee,
|
||||
implementation_idx: BigInt::from(0),
|
||||
})
|
||||
.or_else(|| {
|
||||
abi::meta_pool_factory::functions::DeployMetapool2::match_and_decode(
|
||||
call,
|
||||
)
|
||||
})?;
|
||||
// META_POOL_FACTORY_OLD => {
|
||||
// if let Some(pool_added) =
|
||||
// abi::meta_pool_factory::events::MetaPoolDeployed::match_and_decode(log)
|
||||
// {
|
||||
// let add_pool =
|
||||
// abi::meta_pool_factory::functions::DeployMetapool1::match_and_decode(call)
|
||||
// .map(|add_pool| abi::meta_pool_factory::functions::DeployMetapool2 {
|
||||
// base_pool: add_pool.base_pool,
|
||||
// name: add_pool.name,
|
||||
// symbol: add_pool.symbol,
|
||||
// coin: add_pool.coin,
|
||||
// a: add_pool.a,
|
||||
// fee: add_pool.fee,
|
||||
// implementation_idx: BigInt::from(0),
|
||||
// })
|
||||
// .or_else(|| {
|
||||
// abi::meta_pool_factory::functions::DeployMetapool2::match_and_decode(
|
||||
// call,
|
||||
// )
|
||||
// })?;
|
||||
|
||||
let pool_implementation = extract_proxy_impl(call, tx, 0).unwrap_or([1u8; 20]);
|
||||
// let pool_implementation = extract_proxy_impl(call, tx, 0).unwrap_or([1u8; 20]);
|
||||
|
||||
let component_id = &call.return_data[12..];
|
||||
let lp_token = get_token_from_pool(&pool_added.base_pool);
|
||||
// let component_id = &call.return_data[12..];
|
||||
// let lp_token = get_token_from_pool(&pool_added.base_pool);
|
||||
|
||||
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, lp_token],
|
||||
contracts: vec![component_id.into()],
|
||||
static_att: vec![
|
||||
Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "metapool".into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "name".into(),
|
||||
value: add_pool.name.into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "factory_name".into(),
|
||||
value: "meta_pool_factory_old".into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "factory".into(),
|
||||
value: address_to_bytes_with_0x(&META_POOL_FACTORY_OLD),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "base_pool".into(),
|
||||
value: address_to_bytes_with_0x(
|
||||
&add_pool.base_pool.try_into().unwrap(),
|
||||
),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: ChangeType::Creation.into(),
|
||||
protocol_type: Some(ProtocolType {
|
||||
name: "curve_pool".into(),
|
||||
financial_type: FinancialType::Swap.into(),
|
||||
attribute_schema: Vec::new(),
|
||||
implementation_type: ImplementationType::Vm.into(),
|
||||
}),
|
||||
},
|
||||
vec![EntityChanges {
|
||||
component_id: address_to_string_with_0x(component_id),
|
||||
attributes: vec![Attribute {
|
||||
name: "stateless_contract_addr_0".into(),
|
||||
value: address_to_bytes_with_0x(&pool_implementation),
|
||||
change: ChangeType::Creation.into(),
|
||||
}],
|
||||
}],
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
// 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, lp_token],
|
||||
// contracts: vec![component_id.into()],
|
||||
// static_att: vec![
|
||||
// Attribute {
|
||||
// name: "pool_type".into(),
|
||||
// value: "metapool".into(),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "name".into(),
|
||||
// value: add_pool.name.into(),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "factory_name".into(),
|
||||
// value: "meta_pool_factory_old".into(),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "factory".into(),
|
||||
// value: address_to_bytes_with_0x(&META_POOL_FACTORY_OLD),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "base_pool".into(),
|
||||
// value: address_to_bytes_with_0x(
|
||||
// &add_pool.base_pool.try_into().unwrap(),
|
||||
// ),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// ],
|
||||
// change: ChangeType::Creation.into(),
|
||||
// protocol_type: Some(ProtocolType {
|
||||
// name: "curve_pool".into(),
|
||||
// financial_type: FinancialType::Swap.into(),
|
||||
// attribute_schema: Vec::new(),
|
||||
// implementation_type: ImplementationType::Vm.into(),
|
||||
// }),
|
||||
// },
|
||||
// vec![EntityChanges {
|
||||
// component_id: address_to_string_with_0x(component_id),
|
||||
// attributes: vec![Attribute {
|
||||
// name: "stateless_contract_addr_0".into(),
|
||||
// value: address_to_bytes_with_0x(&pool_implementation),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// }],
|
||||
// }],
|
||||
// ))
|
||||
// } else {
|
||||
// None
|
||||
// }
|
||||
// }
|
||||
CRYPTO_SWAP_NG_FACTORY => {
|
||||
if let Some(pool_added) =
|
||||
abi::crypto_swap_ng_factory::events::PlainPoolDeployed::match_and_decode(log)
|
||||
@@ -759,85 +761,87 @@ pub fn address_map(
|
||||
}],
|
||||
}],
|
||||
))
|
||||
} else if let Some(pool_added) =
|
||||
abi::stableswap_factory::events::MetaPoolDeployed::match_and_decode(log)
|
||||
{
|
||||
let add_pool = if let Some(pool) =
|
||||
abi::stableswap_factory::functions::DeployMetapool1::match_and_decode(call)
|
||||
{
|
||||
abi::stableswap_factory::functions::DeployMetapool2 {
|
||||
base_pool: pool.base_pool,
|
||||
name: pool.name,
|
||||
symbol: pool.symbol,
|
||||
coin: pool.coin,
|
||||
a: pool.a,
|
||||
fee: pool.fee,
|
||||
implementation_idx: BigInt::from(0),
|
||||
}
|
||||
} else if let Some(pool) =
|
||||
abi::stableswap_factory::functions::DeployMetapool2::match_and_decode(call)
|
||||
{
|
||||
pool
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
let component_id = &call.return_data[12..];
|
||||
}
|
||||
// else if let Some(pool_added) =
|
||||
// abi::stableswap_factory::events::MetaPoolDeployed::match_and_decode(log)
|
||||
// {
|
||||
// let add_pool = if let Some(pool) =
|
||||
// abi::stableswap_factory::functions::DeployMetapool1::match_and_decode(call)
|
||||
// {
|
||||
// abi::stableswap_factory::functions::DeployMetapool2 {
|
||||
// base_pool: pool.base_pool,
|
||||
// name: pool.name,
|
||||
// symbol: pool.symbol,
|
||||
// coin: pool.coin,
|
||||
// a: pool.a,
|
||||
// fee: pool.fee,
|
||||
// implementation_idx: BigInt::from(0),
|
||||
// }
|
||||
// } else if let Some(pool) =
|
||||
// abi::stableswap_factory::functions::DeployMetapool2::match_and_decode(call)
|
||||
// {
|
||||
// pool
|
||||
// } else {
|
||||
// return None;
|
||||
// };
|
||||
// let component_id = &call.return_data[12..];
|
||||
|
||||
let get_lp_token =
|
||||
abi::meta_registry::functions::GetLpToken1 { pool: add_pool.base_pool.clone() };
|
||||
let lp_token = get_lp_token.call(META_REGISTRY.to_vec())?;
|
||||
// let get_lp_token =
|
||||
// abi::meta_registry::functions::GetLpToken1 { pool: add_pool.base_pool.clone()
|
||||
// }; let lp_token = get_lp_token.call(META_REGISTRY.to_vec())?;
|
||||
|
||||
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, lp_token],
|
||||
contracts: vec![component_id.into()],
|
||||
static_att: vec![
|
||||
Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "metapool".into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "name".into(),
|
||||
value: add_pool.name.into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "factory_name".into(),
|
||||
value: "stable_swap_factory".into(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "factory".into(),
|
||||
value: address_to_bytes_with_0x(&STABLESWAP_FACTORY),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "base_pool".into(),
|
||||
value: address_to_bytes_with_0x(
|
||||
&pool_added.base_pool.try_into().unwrap(),
|
||||
),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: ChangeType::Creation.into(),
|
||||
protocol_type: Some(ProtocolType {
|
||||
name: "curve_pool".into(),
|
||||
financial_type: FinancialType::Swap.into(),
|
||||
attribute_schema: Vec::new(),
|
||||
implementation_type: ImplementationType::Vm.into(),
|
||||
}),
|
||||
},
|
||||
vec![],
|
||||
))
|
||||
} else {
|
||||
// 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, lp_token],
|
||||
// contracts: vec![component_id.into()],
|
||||
// static_att: vec![
|
||||
// Attribute {
|
||||
// name: "pool_type".into(),
|
||||
// value: "metapool".into(),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "name".into(),
|
||||
// value: add_pool.name.into(),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "factory_name".into(),
|
||||
// value: "stable_swap_factory".into(),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "factory".into(),
|
||||
// value: address_to_bytes_with_0x(&STABLESWAP_FACTORY),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// Attribute {
|
||||
// name: "base_pool".into(),
|
||||
// value: address_to_bytes_with_0x(
|
||||
// &pool_added.base_pool.try_into().unwrap(),
|
||||
// ),
|
||||
// change: ChangeType::Creation.into(),
|
||||
// },
|
||||
// ],
|
||||
// change: ChangeType::Creation.into(),
|
||||
// protocol_type: Some(ProtocolType {
|
||||
// name: "curve_pool".into(),
|
||||
// financial_type: FinancialType::Swap.into(),
|
||||
// attribute_schema: Vec::new(),
|
||||
// implementation_type: ImplementationType::Vm.into(),
|
||||
// }),
|
||||
// },
|
||||
// vec![],
|
||||
// ))
|
||||
// }
|
||||
else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user