feat: add twocrypto factory

This commit is contained in:
Florian Pellissier
2024-06-19 10:01:21 +02:00
committed by tvinagre
parent fe27fc397f
commit 3aa880a700
7 changed files with 4565 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ abis = {
"MainRegistry": "0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5",
"MetaPoolFactory": "0xB9fC157394Af804a3578134A6585C0dc9cc990d4",
"CryptoPoolFactory": "0xF18056Bbd320E96A48e3Fbf8bC061322531aac99",
"TwocryptoFactory": "0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F",
# pool
"Pool": "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7",
"3Pool": "0x5F890841f657d90E081bAbdB532A05996Af79Fe6",

View File

@@ -0,0 +1,662 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "pool",
"type": "address"
},
{
"indexed": false,
"name": "name",
"type": "string"
},
{
"indexed": false,
"name": "symbol",
"type": "string"
},
{
"indexed": false,
"name": "coins",
"type": "address[2]"
},
{
"indexed": false,
"name": "math",
"type": "address"
},
{
"indexed": false,
"name": "salt",
"type": "bytes32"
},
{
"indexed": false,
"name": "precisions",
"type": "uint256[2]"
},
{
"indexed": false,
"name": "packed_A_gamma",
"type": "uint256"
},
{
"indexed": false,
"name": "packed_fee_params",
"type": "uint256"
},
{
"indexed": false,
"name": "packed_rebalancing_params",
"type": "uint256"
},
{
"indexed": false,
"name": "packed_prices",
"type": "uint256"
},
{
"indexed": false,
"name": "deployer",
"type": "address"
}
],
"name": "TwocryptoPoolDeployed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "pool",
"type": "address"
},
{
"indexed": false,
"name": "gauge",
"type": "address"
}
],
"name": "LiquidityGaugeDeployed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "_old_fee_receiver",
"type": "address"
},
{
"indexed": false,
"name": "_new_fee_receiver",
"type": "address"
}
],
"name": "UpdateFeeReceiver",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "_implemention_id",
"type": "uint256"
},
{
"indexed": false,
"name": "_old_pool_implementation",
"type": "address"
},
{
"indexed": false,
"name": "_new_pool_implementation",
"type": "address"
}
],
"name": "UpdatePoolImplementation",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "_old_gauge_implementation",
"type": "address"
},
{
"indexed": false,
"name": "_new_gauge_implementation",
"type": "address"
}
],
"name": "UpdateGaugeImplementation",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "_old_math_implementation",
"type": "address"
},
{
"indexed": false,
"name": "_new_math_implementation",
"type": "address"
}
],
"name": "UpdateMathImplementation",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "_old_views_implementation",
"type": "address"
},
{
"indexed": false,
"name": "_new_views_implementation",
"type": "address"
}
],
"name": "UpdateViewsImplementation",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "_old_owner",
"type": "address"
},
{
"indexed": false,
"name": "_new_owner",
"type": "address"
}
],
"name": "TransferOwnership",
"type": "event"
},
{
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"name": "_fee_receiver",
"type": "address"
},
{
"name": "_admin",
"type": "address"
}
],
"name": "initialise_ownership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_name",
"type": "string"
},
{
"name": "_symbol",
"type": "string"
},
{
"name": "_coins",
"type": "address[2]"
},
{
"name": "implementation_id",
"type": "uint256"
},
{
"name": "A",
"type": "uint256"
},
{
"name": "gamma",
"type": "uint256"
},
{
"name": "mid_fee",
"type": "uint256"
},
{
"name": "out_fee",
"type": "uint256"
},
{
"name": "fee_gamma",
"type": "uint256"
},
{
"name": "allowed_extra_profit",
"type": "uint256"
},
{
"name": "adjustment_step",
"type": "uint256"
},
{
"name": "ma_exp_time",
"type": "uint256"
},
{
"name": "initial_price",
"type": "uint256"
}
],
"name": "deploy_pool",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"name": "deploy_gauge",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_fee_receiver",
"type": "address"
}
],
"name": "set_fee_receiver",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_pool_implementation",
"type": "address"
},
{
"name": "_implementation_index",
"type": "uint256"
}
],
"name": "set_pool_implementation",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_gauge_implementation",
"type": "address"
}
],
"name": "set_gauge_implementation",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_views_implementation",
"type": "address"
}
],
"name": "set_views_implementation",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_math_implementation",
"type": "address"
}
],
"name": "set_math_implementation",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_addr",
"type": "address"
}
],
"name": "commit_transfer_ownership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "accept_transfer_ownership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
}
],
"name": "find_pool_for_coins",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
},
{
"name": "i",
"type": "uint256"
}
],
"name": "find_pool_for_coins",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "pool_count",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"name": "get_coins",
"outputs": [
{
"name": "",
"type": "address[2]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"name": "get_decimals",
"outputs": [
{
"name": "",
"type": "uint256[2]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"name": "get_balances",
"outputs": [
{
"name": "",
"type": "uint256[2]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "_pool",
"type": "address"
},
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
}
],
"name": "get_coin_indices",
"outputs": [
{
"name": "",
"type": "uint256"
},
{
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"name": "get_gauge",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "coin_a",
"type": "address"
},
{
"name": "coin_b",
"type": "address"
}
],
"name": "get_market_counts",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "admin",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "future_admin",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "fee_receiver",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "arg0",
"type": "uint256"
}
],
"name": "pool_implementations",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gauge_implementation",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "views_implementation",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "math_implementation",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "arg0",
"type": "uint256"
}
],
"name": "pool_list",
"outputs": [
{
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]

View File

@@ -4,6 +4,6 @@ pub mod stableswap_factory;
pub mod crypto_swap_ng_factory;
pub mod meta_registry;
pub mod tricrypto_factory;
pub mod main_registry;
pub mod twocrypto_factory;
pub mod erc20;
pub mod meta_pool_factory;

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,7 @@ pub const META_POOL_FACTORY: [u8; 20] = hex!("B9fC157394Af804a3578134A6585C0dc9c
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");
pub const STABLESWAP_FACTORY: [u8; 20] = hex!("4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d");
// Important addresses

View File

@@ -681,6 +681,54 @@ pub fn address_map(
None
}
}
TWOCRYPTO_FACTORY => {
if let Some(pool_added) =
abi::twocrypto_factory::events::TwocryptoPoolDeployed::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],
static_att: vec![
Attribute {
name: "pool_type".into(),
value: "twocrypto".into(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "name".into(),
value: pool_added.name.into(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "factory_name".into(),
value: "twocrypto_factory".into(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "factory".into(),
value: address_to_bytes_with_0x(&TWOCRYPTO_FACTORY),
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(),
}),
})
} else {
None
}
}
_ => None,
}
}

View File

@@ -104,3 +104,38 @@ tests:
- "0x0000000000000000000000000000000000000000"
static_attributes:
creation_tx: "0x2bd59c19f993b83729fb23498f897a58567c6f0b3ee2f00613ba515a7b19fe23"
- name: test_twocrypto_factory_creation
start_block: 19760009
stop_block: 19763634
expected_state:
protocol_components:
- id: "0x011e998d2d794424de95935d55a6ca81822ecb2b"
tokens:
- "0x6c4a8973e6633da2da7187669479c27830c7b1c4"
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
static_attributes:
creation_tx: "0x412b745a9467aed14f22d2a4cc30651939872d19cee65053f14dd3eb9d488003"
- id: "0x19d2b5ce188ca60790755204691e38102749297b"
tokens:
- "0x6c4a8973e6633da2da7187669479c27830c7b1c4"
- "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
static_attributes:
creation_tx: "0x61118d9903f8344e5971d1e7c781f76e855996408dac979d3a4971cefafa6587"
- id: "0xb3341ca63b6cecf1e1a0d1a99bf0587f4c305652"
tokens:
- "0x6c4a8973e6633da2da7187669479c27830c7b1c4"
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
static_attributes:
creation_tx: "0xc69332294313b3a8f260e0d5b6a50f0d83707f715fbd8016c32ca61a39ce7ad5"
- id: "0x99ca0fbaa278cd62e26f0e9b6d167b07d1f0d51b"
tokens:
- "0x6c4a8973e6633da2da7187669479c27830c7b1c4"
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
static_attributes:
creation_tx: "0xf2b0c697161f08384c642297e01b3a35f7ec00dd3871d4237a16ae4bb8a1ca99"
- id: "0xde73e407efc75edbafc5bcd62ebb1e7a9b38ebcd"
tokens:
- "0x0d86883faf4ffd7aeb116390af37746f45b6f378"
- "0x78da5799cf427fee11e9996982f4150ece7a99a7"
static_attributes:
creation_tx: "0xd4ad7efdcc16d797dd3494ba02b377da4127fd5b1bd25089858b66e5a7e456ab"