curve
This commit is contained in:
1269
substreams/ethereum-curve/Cargo.lock
generated
Normal file
1269
substreams/ethereum-curve/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
29
substreams/ethereum-curve/Cargo.toml
Normal file
29
substreams/ethereum-curve/Cargo.toml
Normal file
@@ -0,0 +1,29 @@
|
||||
[package]
|
||||
name = "substreams-balancer"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
name = "substreams_balancer"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
substreams = "0.5"
|
||||
substreams-ethereum = "0.9.9"
|
||||
prost = "0.11"
|
||||
hex-literal = "0.4.1"
|
||||
ethabi = "18.0.0"
|
||||
hex = "0.4.2"
|
||||
bytes = "1.5.0"
|
||||
anyhow = "1.0.75"
|
||||
prost-types = "0.12.3"
|
||||
num-bigint = "0.4.4"
|
||||
itertools = "0.12.0"
|
||||
|
||||
[build-dependencies]
|
||||
anyhow = "1"
|
||||
substreams-ethereum = "0.9"
|
||||
|
||||
# Required so that ethabi > ethereum-types build correctly under wasm32-unknown-unknown
|
||||
[target.wasm32-unknown-unknown.dependencies]
|
||||
getrandom = { version = "0.2", features = ["custom"] }
|
||||
22
substreams/ethereum-curve/abi/README.md
Normal file
22
substreams/ethereum-curve/abi/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# ABIs
|
||||
|
||||
`get_abis.py` is a simple python script using the etherscan API (free plan) to gather ABIs for all of the contracts we are tracking!
|
||||
|
||||
We then can define all of the abis via `substreams_ethereum::Abigen::new` in our `build.rs`.
|
||||
|
||||
## Recommendation
|
||||
|
||||
It would be apt to convert (maybe through copilot) the python code into the `build.rs` file and then automate the `Abigen` functionality.
|
||||
|
||||
## Usage
|
||||
|
||||
Requires `python 3.8+`,
|
||||
|
||||
```bash
|
||||
cd abi
|
||||
python get_abis.py
|
||||
```
|
||||
|
||||
This will populate the files in the `abi` folder.
|
||||
|
||||
When the `build.rs` file runs (when `rust-analyzer` activates or `cargo build` is manually ran), Abigen will generate new rust src files from the abis in the `src/abi` folder.
|
||||
635
substreams/ethereum-curve/abi/crypto_pool_factory.json
Normal file
635
substreams/ethereum-curve/abi/crypto_pool_factory.json
Normal file
@@ -0,0 +1,635 @@
|
||||
[
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "coins",
|
||||
"type": "address[2]"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "A",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "gamma",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "mid_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "out_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "allowed_extra_profit",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "fee_gamma",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "adjustment_step",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "admin_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "ma_half_time",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "initial_price",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "deployer",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "CryptoPoolDeployed",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "token",
|
||||
"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": "_old_pool_implementation",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_new_pool_implementation",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "UpdatePoolImplementation",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_old_token_implementation",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_new_token_implementation",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "UpdateTokenImplementation",
|
||||
"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_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_new_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "TransferOwnership",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_fee_receiver",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_pool_implementation",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_token_implementation",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_gauge_implementation",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_weth",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_coins",
|
||||
"type": "address[2]"
|
||||
},
|
||||
{
|
||||
"name": "A",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "gamma",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "mid_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "out_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "allowed_extra_profit",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "fee_gamma",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "adjustment_step",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "admin_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "ma_half_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": "set_pool_implementation",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token_implementation",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "set_token_implementation",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_gauge_implementation",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "set_gauge_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",
|
||||
"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": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_eth_index",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"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": "pool_implementation",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "token_implementation",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "gauge_implementation",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "pool_count",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "pool_list",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
751
substreams/ethereum-curve/abi/crypto_swap_registry.json
Normal file
751
substreams/ethereum-curve/abi/crypto_swap_registry.json
Normal file
@@ -0,0 +1,751 @@
|
||||
[
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "PoolAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "basepool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "BasePoolAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "PoolRemoved",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_address_provider",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_base_pool_registry",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_n_coins",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_n_underlying_coins",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_coins",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_underlying_coins",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_decimals",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_underlying_decimals",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_gauges",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address[10]"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "int128[10]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_balances",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_underlying_balances",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_virtual_price_from_lp_token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_A",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_D",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_gamma",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_fees",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[4]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_admin_balances",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_coin_indices",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "is_meta",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_base_pool",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_pool_name",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_lp_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_gauge",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_zap",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_n_coins",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "add_pool",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_lp_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_gauge",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_zap",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_n_coins",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_base_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "add_pool",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_lp_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_gauge",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_zap",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_n_coins",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_base_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_has_positive_rebasing_tokens",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"name": "add_pool",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "remove_pool",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_liquidity_gauges",
|
||||
"type": "address[10]"
|
||||
}
|
||||
],
|
||||
"name": "set_liquidity_gauges",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pools",
|
||||
"type": "address[10]"
|
||||
},
|
||||
{
|
||||
"name": "_liquidity_gauges",
|
||||
"type": "address[10]"
|
||||
}
|
||||
],
|
||||
"name": "batch_set_liquidity_gauges",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "address_provider",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "base_pool_registry",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "pool_list",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "pool_count",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "base_pool_count",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "get_coin",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "coin_count",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_pool_from_lp_token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_lp_token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_zap",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "last_updated",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
48
substreams/ethereum-curve/abi/get_abis.py
Normal file
48
substreams/ethereum-curve/abi/get_abis.py
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/python
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
# Exports contract ABI in JSON
|
||||
|
||||
abis = {
|
||||
# Factories
|
||||
"CryptoSwapRegistry": "0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0",
|
||||
"MainRegistry": "0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5",
|
||||
"MetaPoolFactory": "0xB9fC157394Af804a3578134A6585C0dc9cc990d4",
|
||||
"CryptoPoolFactory": "0xF18056Bbd320E96A48e3Fbf8bC061322531aac99",
|
||||
# pool
|
||||
"Pool": "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7",
|
||||
}
|
||||
|
||||
ABI_ENDPOINT = (
|
||||
"https://api.etherscan.io/api?module=contract&action=getabi&address={address}"
|
||||
)
|
||||
|
||||
if etherscan_key := os.environ.get("ETHERSCAN_API_TOKEN"):
|
||||
print("API KEY Loaded!")
|
||||
ABI_ENDPOINT += f"&apikey={etherscan_key}"
|
||||
|
||||
|
||||
def __main__():
|
||||
for name, addr in abis.items():
|
||||
normalized_name = "_".join(re.findall(r"[A-Z]+[a-z]*", name)).lower()
|
||||
print(f"Getting ABI for {name} at {addr} ({normalized_name})")
|
||||
|
||||
try:
|
||||
with urllib.request.urlopen(ABI_ENDPOINT.format(address=addr)) as response:
|
||||
response_json = json.loads(response.read().decode())
|
||||
abi_json = json.loads(response_json["result"])
|
||||
result = json.dumps(abi_json, indent=4, sort_keys=True)
|
||||
with open(f"{normalized_name}.json", "w") as f:
|
||||
f.write(result)
|
||||
except Exception as err:
|
||||
print(response.content)
|
||||
raise err
|
||||
time.sleep(0.25)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
940
substreams/ethereum-curve/abi/main_registry.json
Normal file
940
substreams/ethereum-curve/abi/main_registry.json
Normal file
@@ -0,0 +1,940 @@
|
||||
[
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "rate_method_id",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "PoolAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "PoolRemoved",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_address_provider",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_gauge_controller",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"gas": 1521,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_n_coins",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[2]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 12102,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_coins",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 12194,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_underlying_coins",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 7874,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_decimals",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 7966,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_underlying_decimals",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 36992,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_rates",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 20157,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_gauges",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address[10]"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "int128[10]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 16583,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_balances",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 162842,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_underlying_balances",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 1927,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_virtual_price_from_lp_token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 1045,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_A",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 6305,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_parameters",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "A",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "future_A",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "admin_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "future_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "future_admin_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "future_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "initial_A",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "initial_A_time",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "future_A_time",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 1450,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_fees",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[2]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 36454,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_admin_balances",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256[8]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 27131,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_coin_indices",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 32004,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "estimate_gas_used",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 1900,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "is_meta",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 8323,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_pool_name",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 1951,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_coin",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_coin_swap_count",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2090,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_coin",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_index",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "get_coin_swap_complement",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2011,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_pool_asset_type",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 61485845,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_n_coins",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_lp_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_rate_info",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"name": "_decimals",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_underlying_decimals",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_has_initial_A",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "_is_v1",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "add_pool",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 31306062,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_n_coins",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_lp_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_rate_info",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"name": "_decimals",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_use_rates",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_has_initial_A",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "_is_v1",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "add_pool_without_underlying",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_n_coins",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_lp_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_decimals",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "add_metapool",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_n_coins",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_lp_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_decimals",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_base_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "add_metapool",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 779731418758,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "remove_pool",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 390460,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_addr",
|
||||
"type": "address[5]"
|
||||
},
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256[2][5]"
|
||||
}
|
||||
],
|
||||
"name": "set_pool_gas_estimates",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 392047,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_addr",
|
||||
"type": "address[10]"
|
||||
},
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256[10]"
|
||||
}
|
||||
],
|
||||
"name": "set_coin_gas_estimates",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 72629,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_estimator",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "set_gas_estimate_contract",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 400675,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_liquidity_gauges",
|
||||
"type": "address[10]"
|
||||
}
|
||||
],
|
||||
"name": "set_liquidity_gauges",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 72667,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pool",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_asset_type",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "set_pool_asset_type",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 1173447,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_pools",
|
||||
"type": "address[32]"
|
||||
},
|
||||
{
|
||||
"name": "_asset_types",
|
||||
"type": "uint256[32]"
|
||||
}
|
||||
],
|
||||
"name": "batch_set_pool_asset_type",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2048,
|
||||
"inputs": [],
|
||||
"name": "address_provider",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2078,
|
||||
"inputs": [],
|
||||
"name": "gauge_controller",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2217,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "pool_list",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2138,
|
||||
"inputs": [],
|
||||
"name": "pool_count",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2168,
|
||||
"inputs": [],
|
||||
"name": "coin_count",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2307,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "get_coin",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2443,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_pool_from_lp_token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2473,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "get_lp_token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2288,
|
||||
"inputs": [],
|
||||
"name": "last_updated",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
1063
substreams/ethereum-curve/abi/meta_pool_factory.json
Normal file
1063
substreams/ethereum-curve/abi/meta_pool_factory.json
Normal file
File diff suppressed because it is too large
Load Diff
838
substreams/ethereum-curve/abi/pool.json
Normal file
838
substreams/ethereum-curve/abi/pool.json
Normal file
@@ -0,0 +1,838 @@
|
||||
[
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "buyer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "sold_id",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "tokens_sold",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "bought_id",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "tokens_bought",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "TokenExchange",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "provider",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "token_amounts",
|
||||
"type": "uint256[3]"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "fees",
|
||||
"type": "uint256[3]"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "invariant",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "token_supply",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "AddLiquidity",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "provider",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "token_amounts",
|
||||
"type": "uint256[3]"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "fees",
|
||||
"type": "uint256[3]"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "token_supply",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RemoveLiquidity",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "provider",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "token_amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "coin_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RemoveLiquidityOne",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "provider",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "token_amounts",
|
||||
"type": "uint256[3]"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "fees",
|
||||
"type": "uint256[3]"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "invariant",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "token_supply",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RemoveLiquidityImbalance",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "deadline",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "admin",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "CommitNewAdmin",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "admin",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "NewAdmin",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "deadline",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "admin_fee",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "CommitNewFee",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "admin_fee",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "NewFee",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "old_A",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "new_A",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "initial_time",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "future_time",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RampA",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "A",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "t",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "StopRampA",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_coins",
|
||||
"type": "address[3]"
|
||||
},
|
||||
{
|
||||
"name": "_pool_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_A",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_admin_fee",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"gas": 5227,
|
||||
"inputs": [],
|
||||
"name": "A",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 1133537,
|
||||
"inputs": [],
|
||||
"name": "get_virtual_price",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 4508776,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "amounts",
|
||||
"type": "uint256[3]"
|
||||
},
|
||||
{
|
||||
"name": "deposit",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"name": "calc_token_amount",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 6954858,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "amounts",
|
||||
"type": "uint256[3]"
|
||||
},
|
||||
{
|
||||
"name": "min_mint_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "add_liquidity",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2673791,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "i",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "j",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "dx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "get_dy",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2673474,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "i",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "j",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "dx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "get_dy_underlying",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2818066,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "i",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "j",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "dx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "min_dy",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "exchange",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 192846,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "min_amounts",
|
||||
"type": "uint256[3]"
|
||||
}
|
||||
],
|
||||
"name": "remove_liquidity",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 6951851,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "amounts",
|
||||
"type": "uint256[3]"
|
||||
},
|
||||
{
|
||||
"name": "max_burn_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "remove_liquidity_imbalance",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 1102,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token_amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "i",
|
||||
"type": "int128"
|
||||
}
|
||||
],
|
||||
"name": "calc_withdraw_one_coin",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 4025523,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token_amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "i",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"name": "min_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "remove_liquidity_one_coin",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 151919,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_future_A",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_future_time",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "ramp_A",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 148637,
|
||||
"inputs": [],
|
||||
"name": "stop_ramp_A",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 110461,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "new_fee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "new_admin_fee",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "commit_new_fee",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 97242,
|
||||
"inputs": [],
|
||||
"name": "apply_new_fee",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 21895,
|
||||
"inputs": [],
|
||||
"name": "revert_new_parameters",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 74572,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "commit_transfer_ownership",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 60710,
|
||||
"inputs": [],
|
||||
"name": "apply_transfer_ownership",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 21985,
|
||||
"inputs": [],
|
||||
"name": "revert_transfer_ownership",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 3481,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "i",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "admin_balances",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 21502,
|
||||
"inputs": [],
|
||||
"name": "withdraw_admin_fees",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 111389,
|
||||
"inputs": [],
|
||||
"name": "donate_admin_fees",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 37998,
|
||||
"inputs": [],
|
||||
"name": "kill_me",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 22135,
|
||||
"inputs": [],
|
||||
"name": "unkill_me",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2220,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "coins",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2250,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "balances",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2171,
|
||||
"inputs": [],
|
||||
"name": "fee",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2201,
|
||||
"inputs": [],
|
||||
"name": "admin_fee",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2231,
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2261,
|
||||
"inputs": [],
|
||||
"name": "initial_A",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2291,
|
||||
"inputs": [],
|
||||
"name": "future_A",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2321,
|
||||
"inputs": [],
|
||||
"name": "initial_A_time",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2351,
|
||||
"inputs": [],
|
||||
"name": "future_A_time",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2381,
|
||||
"inputs": [],
|
||||
"name": "admin_actions_deadline",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2411,
|
||||
"inputs": [],
|
||||
"name": "transfer_ownership_deadline",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2441,
|
||||
"inputs": [],
|
||||
"name": "future_fee",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2471,
|
||||
"inputs": [],
|
||||
"name": "future_admin_fee",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"gas": 2501,
|
||||
"inputs": [],
|
||||
"name": "future_owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
12
substreams/ethereum-curve/buf.gen.yaml
Normal file
12
substreams/ethereum-curve/buf.gen.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
version: v1
|
||||
plugins:
|
||||
- plugin: buf.build/community/neoeinstein-prost:v0.2.2
|
||||
out: src/pb
|
||||
opt:
|
||||
- file_descriptor_set=false
|
||||
|
||||
- plugin: buf.build/community/neoeinstein-prost-crate:v0.3.1
|
||||
out: src/pb
|
||||
opt:
|
||||
- no_features
|
||||
43
substreams/ethereum-curve/build.rs
Normal file
43
substreams/ethereum-curve/build.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use anyhow::Result;
|
||||
use std::{fs, io::Write};
|
||||
use substreams_ethereum::Abigen;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let abi_folder = "abi";
|
||||
let output_folder = "src/abi";
|
||||
|
||||
let files = fs::read_dir(abi_folder)?;
|
||||
let mut mod_rs_content = String::new();
|
||||
|
||||
for file in files {
|
||||
let file = file?;
|
||||
let file_name = file.file_name();
|
||||
let file_name = file_name.to_string_lossy();
|
||||
|
||||
if !file_name.ends_with(".json") {
|
||||
continue;
|
||||
}
|
||||
|
||||
let contract_name = file_name.split('.').next().unwrap();
|
||||
|
||||
let input_path = format!("{}/{}", abi_folder, file_name);
|
||||
let output_path = format!("{}/{}.rs", output_folder, contract_name);
|
||||
|
||||
mod_rs_content.push_str(&format!("pub mod {};\n", contract_name));
|
||||
|
||||
if std::path::Path::new(&output_path).exists() {
|
||||
continue;
|
||||
}
|
||||
|
||||
Abigen::new(contract_name, &input_path)?
|
||||
.generate()?
|
||||
.write_to_file(&output_path)?;
|
||||
}
|
||||
|
||||
let mod_rs_path = format!("{}/mod.rs", output_folder);
|
||||
let mut mod_rs_file = fs::File::create(mod_rs_path)?;
|
||||
|
||||
mod_rs_file.write_all(mod_rs_content.as_bytes())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
19
substreams/ethereum-curve/proto/factory.proto
Normal file
19
substreams/ethereum-curve/proto/factory.proto
Normal file
@@ -0,0 +1,19 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package eth.factory.v1;
|
||||
|
||||
message Pools {
|
||||
repeated Pool pools = 1;
|
||||
}
|
||||
|
||||
message Pool {
|
||||
bytes pool_id = 1;
|
||||
fixed64 log_ordinal = 2;
|
||||
}
|
||||
|
||||
message Transfer {
|
||||
bytes from = 1;
|
||||
bytes to = 2;
|
||||
string token = 3;
|
||||
string amount = 4;
|
||||
}
|
||||
15
substreams/ethereum-curve/proto/pool.proto
Normal file
15
substreams/ethereum-curve/proto/pool.proto
Normal file
@@ -0,0 +1,15 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package eth.pool.v1;
|
||||
|
||||
message Transfers {
|
||||
repeated Transfer transfers = 1;
|
||||
}
|
||||
|
||||
message Transfer {
|
||||
string from = 1;
|
||||
string to = 2;
|
||||
uint64 token_id = 3;
|
||||
string trx_hash = 4;
|
||||
uint64 ordinal = 5;
|
||||
}
|
||||
113
substreams/ethereum-curve/proto/tycho/evm/v1/common.proto
Normal file
113
substreams/ethereum-curve/proto/tycho/evm/v1/common.proto
Normal file
@@ -0,0 +1,113 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package tycho.evm.v1;
|
||||
|
||||
// This file contains the proto definitions for Substreams common to all integrations.
|
||||
|
||||
// A struct describing a block.
|
||||
message Block {
|
||||
// The blocks hash.
|
||||
bytes hash = 1;
|
||||
// The parent blocks hash.
|
||||
bytes parent_hash = 2;
|
||||
// The block number.
|
||||
uint64 number = 3;
|
||||
// The block timestamp.
|
||||
uint64 ts = 4;
|
||||
}
|
||||
|
||||
// A struct describing a transaction.
|
||||
message Transaction {
|
||||
// The transaction hash.
|
||||
bytes hash = 1;
|
||||
// The sender of the transaction.
|
||||
bytes from = 2;
|
||||
// The receiver of the transaction.
|
||||
bytes to = 3;
|
||||
// The transactions index within the block.
|
||||
// TODO: should this be uint32? to match the type from the native substream type?
|
||||
uint64 index = 4;
|
||||
}
|
||||
|
||||
// Enum to specify the type of a change.
|
||||
enum ChangeType {
|
||||
CHANGE_TYPE_UNSPECIFIED = 0;
|
||||
CHANGE_TYPE_UPDATE = 1;
|
||||
CHANGE_TYPE_CREATION = 2;
|
||||
CHANGE_TYPE_DELETION = 3;
|
||||
}
|
||||
|
||||
// A custom struct representing an arbitrary attribute of a protocol component.
|
||||
// This is mainly used by the native integration to track the necessary information about the protocol.
|
||||
message Attribute {
|
||||
// The name of the attribute.
|
||||
string name = 1;
|
||||
// The value of the attribute.
|
||||
bytes value = 2;
|
||||
// The type of change the attribute underwent.
|
||||
ChangeType change = 3;
|
||||
}
|
||||
|
||||
// A struct describing a part of the protocol.
|
||||
// Note: For example this can be a UniswapV2 pair, that tracks the two ERC20 tokens used by the pair,
|
||||
// the component would represent a single contract. In case of VM integration, such component would
|
||||
// not need any attributes, because all the relevant info would be tracked via storage slots and balance changes.
|
||||
// It can also be a wrapping contract, like WETH, that has a constant price, but it allows swapping tokens.
|
||||
// This is why the name ProtocolComponent is used instead of "Pool" or "Pair".
|
||||
message ProtocolComponent {
|
||||
// A unique identifier for the component within the protocol.
|
||||
// Can be e.g. a stringified address or a string describing the trading pair.
|
||||
string id = 1;
|
||||
// Addresses of the ERC20 tokens used by the component.
|
||||
repeated bytes tokens = 2;
|
||||
// Addresses of the contracts used by the component.
|
||||
// Usually it is a single contract, but some protocols use multiple contracts.
|
||||
repeated bytes contracts = 3;
|
||||
// Attributes of the component. Used mainly be the native integration.
|
||||
// The inner ChangeType of the attribute has to match the ChangeType of the ProtocolComponent.
|
||||
repeated Attribute static_att = 4;
|
||||
// Type of change the component underwent.
|
||||
ChangeType change = 5;
|
||||
}
|
||||
|
||||
message TransactionProtocolComponents {
|
||||
Transaction tx = 1;
|
||||
repeated ProtocolComponent components = 2;
|
||||
}
|
||||
|
||||
message GroupedTransactionProtocolComponents {
|
||||
repeated TransactionProtocolComponents tx_components = 1;
|
||||
}
|
||||
|
||||
// A struct for following the changes of Total Value Locked (TVL) of a protocol component.
|
||||
// Note that if a ProtocolComponent contains multiple contracts, the TVL is tracked for the component as a whole.
|
||||
// E.g. for UniswapV2 pair WETH/USDC, this tracks the USDC and WETH balance of the pair contract.
|
||||
message BalanceChange {
|
||||
// The address of the ERC20 token whose balance changed.
|
||||
bytes token = 1;
|
||||
// The new balance of the token.
|
||||
bytes balance = 2;
|
||||
// The id of the component whose TVL is tracked.
|
||||
// If the protocol component includes multiple contracts, the balance change must be aggregated to reflect how much tokens can be traded.
|
||||
bytes component_id = 3;
|
||||
}
|
||||
|
||||
// A struct for following the changes of Total Value Locked (TVL) of a protocol component.
|
||||
// Note that if a ProtocolComponent contains multiple contracts, the TVL is tracked for the component as a whole.
|
||||
// E.g. for UniswapV2 pair WETH/USDC, this tracks the USDC and WETH balance of the pair contract.
|
||||
message BalanceDelta {
|
||||
uint64 ord = 1;
|
||||
// The tx hash of the transaction that caused the balance change.
|
||||
Transaction tx = 2;
|
||||
// The address of the ERC20 token whose balance changed.
|
||||
bytes token = 3;
|
||||
// The delta balance of the token.
|
||||
bytes delta = 4;
|
||||
// The id of the component whose TVL is tracked.
|
||||
// If the protocol component includes multiple contracts, the balance change must be aggregated to reflect how much tokens can be traded.
|
||||
bytes component_id = 5;
|
||||
}
|
||||
|
||||
message BalanceDeltas {
|
||||
repeated BalanceDelta balance_deltas = 1;
|
||||
}
|
||||
32
substreams/ethereum-curve/proto/tycho/evm/v1/entity.proto
Normal file
32
substreams/ethereum-curve/proto/tycho/evm/v1/entity.proto
Normal file
@@ -0,0 +1,32 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package tycho.evm.v1;
|
||||
|
||||
import "tycho/evm/v1/common.proto";
|
||||
|
||||
// This file contains the definition for the native integration of Substreams.
|
||||
|
||||
// A component is a set of attributes that are associated with a custom entity.
|
||||
message EntityChanges {
|
||||
// A unique identifier of the entity within the protocol.
|
||||
string component_id = 1;
|
||||
// The set of attributes that are associated with the entity.
|
||||
repeated Attribute attributes = 2;
|
||||
}
|
||||
|
||||
message TransactionEntityChanges {
|
||||
Transaction tx = 1;
|
||||
repeated EntityChanges entity_changes = 2;
|
||||
// An array of newly added components.
|
||||
repeated ProtocolComponent component_changes = 3;
|
||||
// An array of balance changes to components.
|
||||
repeated BalanceChange balance_changes = 4;
|
||||
}
|
||||
|
||||
// A set of transaction changes within a single block.
|
||||
message BlockEntityChanges {
|
||||
// The block for which these changes are collectively computed.
|
||||
Block block = 1;
|
||||
// The set of transaction changes observed in the specified block.
|
||||
repeated TransactionEntityChanges changes = 2;
|
||||
}
|
||||
50
substreams/ethereum-curve/proto/tycho/evm/v1/vm.proto
Normal file
50
substreams/ethereum-curve/proto/tycho/evm/v1/vm.proto
Normal file
@@ -0,0 +1,50 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package tycho.evm.v1;
|
||||
|
||||
import "tycho/evm/v1/common.proto";
|
||||
|
||||
// This file contains proto definitions specific to the VM integration.
|
||||
|
||||
// A key value entry into contract storage.
|
||||
message ContractSlot {
|
||||
// A contract's storage slot.
|
||||
bytes slot = 2;
|
||||
// The new value for this storage slot.
|
||||
bytes value = 3;
|
||||
}
|
||||
|
||||
// Changes made to a single contract's state.
|
||||
message ContractChange {
|
||||
// The contract's address
|
||||
bytes address = 1;
|
||||
// The new native balance of the contract, empty bytes indicates no change.
|
||||
bytes balance = 2;
|
||||
// The new code of the contract, empty bytes indicates no change.
|
||||
bytes code = 3;
|
||||
// The changes to this contract's slots, empty sequence indicates no change.
|
||||
repeated ContractSlot slots = 4;
|
||||
// Whether this is an update, a creation or a deletion.
|
||||
ChangeType change = 5;
|
||||
}
|
||||
|
||||
// A set of changes aggregated by transaction.
|
||||
message TransactionContractChanges {
|
||||
// The transaction instance that results in the changes.
|
||||
Transaction tx = 1;
|
||||
// Contains the changes induced by the above transaction, aggregated on a per-contract basis.
|
||||
// Must include changes to every contract that is tracked by all ProtocolComponents.
|
||||
repeated ContractChange contract_changes = 2;
|
||||
// An array of any component changes.
|
||||
repeated ProtocolComponent component_changes = 3;
|
||||
// An array of balance changes to components.
|
||||
repeated BalanceChange balance_changes = 4;
|
||||
}
|
||||
|
||||
// A set of transaction changes within a single block.
|
||||
message BlockContractChanges {
|
||||
// The block for which these changes are collectively computed.
|
||||
Block block = 1;
|
||||
// The set of transaction changes observed in the specified block.
|
||||
repeated TransactionContractChanges changes = 2;
|
||||
}
|
||||
3551
substreams/ethereum-curve/src/abi/crypto_pool_factory.rs
Normal file
3551
substreams/ethereum-curve/src/abi/crypto_pool_factory.rs
Normal file
File diff suppressed because it is too large
Load Diff
4839
substreams/ethereum-curve/src/abi/crypto_swap_registry.rs
Normal file
4839
substreams/ethereum-curve/src/abi/crypto_swap_registry.rs
Normal file
File diff suppressed because it is too large
Load Diff
5802
substreams/ethereum-curve/src/abi/main_registry.rs
Normal file
5802
substreams/ethereum-curve/src/abi/main_registry.rs
Normal file
File diff suppressed because it is too large
Load Diff
6618
substreams/ethereum-curve/src/abi/meta_pool_factory.rs
Normal file
6618
substreams/ethereum-curve/src/abi/meta_pool_factory.rs
Normal file
File diff suppressed because it is too large
Load Diff
5
substreams/ethereum-curve/src/abi/mod.rs
Normal file
5
substreams/ethereum-curve/src/abi/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
pub mod crypto_pool_factory;
|
||||
pub mod pool;
|
||||
pub mod main_registry;
|
||||
pub mod meta_pool_factory;
|
||||
pub mod crypto_swap_registry;
|
||||
4991
substreams/ethereum-curve/src/abi/pool.rs
Normal file
4991
substreams/ethereum-curve/src/abi/pool.rs
Normal file
File diff suppressed because it is too large
Load Diff
190
substreams/ethereum-curve/src/contract_changes.rs
Normal file
190
substreams/ethereum-curve/src/contract_changes.rs
Normal file
@@ -0,0 +1,190 @@
|
||||
/// This file contains helpers to capture contract changes from the expanded block model. These
|
||||
/// leverage the `code_changes`, `balance_changes`, and `storage_changes` fields available on the
|
||||
/// `Call` type provided by block model in a substream (i.e. `logs_and_calls`, etc).
|
||||
///
|
||||
/// ⚠️ These helpers *only* work if the **expanded block model** is available, more info blow.
|
||||
/// https://streamingfastio.medium.com/new-block-model-to-accelerate-chain-integration-9f65126e5425
|
||||
use std::collections::HashMap;
|
||||
|
||||
use substreams_ethereum::pb::eth;
|
||||
|
||||
use pb::tycho::evm::v1::{self as tycho};
|
||||
|
||||
use substreams::store::{StoreGet, StoreGetInt64};
|
||||
|
||||
use crate::pb;
|
||||
|
||||
struct SlotValue {
|
||||
new_value: Vec<u8>,
|
||||
start_value: Vec<u8>,
|
||||
}
|
||||
|
||||
impl SlotValue {
|
||||
fn has_changed(&self) -> bool {
|
||||
self.start_value != self.new_value
|
||||
}
|
||||
}
|
||||
|
||||
// Uses a map for slots, protobuf does not allow bytes in hashmap keys
|
||||
pub struct InterimContractChange {
|
||||
address: Vec<u8>,
|
||||
balance: Vec<u8>,
|
||||
code: Vec<u8>,
|
||||
slots: HashMap<Vec<u8>, SlotValue>,
|
||||
change: tycho::ChangeType,
|
||||
}
|
||||
|
||||
impl From<InterimContractChange> for tycho::ContractChange {
|
||||
fn from(value: InterimContractChange) -> Self {
|
||||
tycho::ContractChange {
|
||||
address: value.address,
|
||||
balance: value.balance,
|
||||
code: value.code,
|
||||
slots: value
|
||||
.slots
|
||||
.into_iter()
|
||||
.filter(|(_, value)| value.has_changed())
|
||||
.map(|(slot, value)| tycho::ContractSlot {
|
||||
slot,
|
||||
value: value.new_value,
|
||||
})
|
||||
.collect(),
|
||||
change: value.change.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extract_contract_changes(
|
||||
block: ð::v2::Block,
|
||||
contracts: StoreGetInt64,
|
||||
transaction_contract_changes: &mut HashMap<u64, tycho::TransactionContractChanges>,
|
||||
) {
|
||||
let mut changed_contracts: HashMap<Vec<u8>, InterimContractChange> = HashMap::new();
|
||||
|
||||
// Collect all accounts created in this block
|
||||
let created_accounts: HashMap<_, _> = block
|
||||
.transactions()
|
||||
.flat_map(|tx| {
|
||||
tx.calls.iter().flat_map(|call| {
|
||||
call.account_creations
|
||||
.iter()
|
||||
.map(|ac| (&ac.account, ac.ordinal))
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
block.transactions().for_each(|block_tx| {
|
||||
let mut storage_changes = Vec::new();
|
||||
let mut balance_changes = Vec::new();
|
||||
let mut code_changes = Vec::new();
|
||||
|
||||
block_tx
|
||||
.calls
|
||||
.iter()
|
||||
.filter(|call| {
|
||||
!call.state_reverted
|
||||
&& contracts
|
||||
.get_last(format!("pool:{0}", hex::encode(&call.address)))
|
||||
.is_some()
|
||||
})
|
||||
.for_each(|call| {
|
||||
storage_changes.extend(call.storage_changes.iter());
|
||||
balance_changes.extend(call.balance_changes.iter());
|
||||
code_changes.extend(call.code_changes.iter());
|
||||
});
|
||||
|
||||
storage_changes.sort_unstable_by_key(|change| change.ordinal);
|
||||
balance_changes.sort_unstable_by_key(|change| change.ordinal);
|
||||
code_changes.sort_unstable_by_key(|change| change.ordinal);
|
||||
|
||||
storage_changes.iter().for_each(|storage_change| {
|
||||
let contract_change = changed_contracts
|
||||
.entry(storage_change.address.clone())
|
||||
.or_insert_with(|| InterimContractChange {
|
||||
address: storage_change.address.clone(),
|
||||
balance: Vec::new(),
|
||||
code: Vec::new(),
|
||||
slots: HashMap::new(),
|
||||
change: if created_accounts.contains_key(&storage_change.address) {
|
||||
tycho::ChangeType::Creation
|
||||
} else {
|
||||
tycho::ChangeType::Update
|
||||
},
|
||||
});
|
||||
|
||||
let slot_value = contract_change
|
||||
.slots
|
||||
.entry(storage_change.key.clone())
|
||||
.or_insert_with(|| SlotValue {
|
||||
new_value: storage_change.new_value.clone(),
|
||||
start_value: storage_change.old_value.clone(),
|
||||
});
|
||||
|
||||
slot_value
|
||||
.new_value
|
||||
.copy_from_slice(&storage_change.new_value);
|
||||
});
|
||||
|
||||
balance_changes.iter().for_each(|balance_change| {
|
||||
let contract_change = changed_contracts
|
||||
.entry(balance_change.address.clone())
|
||||
.or_insert_with(|| InterimContractChange {
|
||||
address: balance_change.address.clone(),
|
||||
balance: Vec::new(),
|
||||
code: Vec::new(),
|
||||
slots: HashMap::new(),
|
||||
change: if created_accounts.contains_key(&balance_change.address) {
|
||||
tycho::ChangeType::Creation
|
||||
} else {
|
||||
tycho::ChangeType::Update
|
||||
},
|
||||
});
|
||||
|
||||
if let Some(new_balance) = &balance_change.new_value {
|
||||
contract_change.balance.clear();
|
||||
contract_change
|
||||
.balance
|
||||
.extend_from_slice(&new_balance.bytes);
|
||||
}
|
||||
});
|
||||
|
||||
code_changes.iter().for_each(|code_change| {
|
||||
let contract_change = changed_contracts
|
||||
.entry(code_change.address.clone())
|
||||
.or_insert_with(|| InterimContractChange {
|
||||
address: code_change.address.clone(),
|
||||
balance: Vec::new(),
|
||||
code: Vec::new(),
|
||||
slots: HashMap::new(),
|
||||
change: if created_accounts.contains_key(&code_change.address) {
|
||||
tycho::ChangeType::Creation
|
||||
} else {
|
||||
tycho::ChangeType::Update
|
||||
},
|
||||
});
|
||||
|
||||
contract_change.code.clear();
|
||||
contract_change
|
||||
.code
|
||||
.extend_from_slice(&code_change.new_code);
|
||||
});
|
||||
|
||||
if !storage_changes.is_empty() || !balance_changes.is_empty() || !code_changes.is_empty() {
|
||||
transaction_contract_changes
|
||||
.entry(block_tx.index.into())
|
||||
.or_insert_with(|| tycho::TransactionContractChanges {
|
||||
tx: Some(tycho::Transaction {
|
||||
hash: block_tx.hash.clone(),
|
||||
from: block_tx.from.clone(),
|
||||
to: block_tx.to.clone(),
|
||||
index: block_tx.index as u64,
|
||||
}),
|
||||
contract_changes: vec![],
|
||||
component_changes: vec![],
|
||||
balance_changes: vec![],
|
||||
})
|
||||
.contract_changes
|
||||
.extend(changed_contracts.drain().map(|(_, change)| change.into()));
|
||||
}
|
||||
});
|
||||
}
|
||||
5
substreams/ethereum-curve/src/lib.rs
Normal file
5
substreams/ethereum-curve/src/lib.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
mod abi;
|
||||
mod contract_changes;
|
||||
mod modules;
|
||||
mod pb;
|
||||
mod pool_factories;
|
||||
269
substreams/ethereum-curve/src/modules.rs
Normal file
269
substreams/ethereum-curve/src/modules.rs
Normal file
@@ -0,0 +1,269 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use anyhow::Result;
|
||||
use substreams::pb::substreams::StoreDeltas;
|
||||
use substreams::store::{
|
||||
StoreAdd, StoreAddBigInt, StoreAddInt64, StoreGet, StoreGetInt64, StoreNew,
|
||||
};
|
||||
use substreams::{hex, log};
|
||||
|
||||
use substreams::key;
|
||||
use substreams::scalar::BigInt;
|
||||
|
||||
use substreams_ethereum::block_view::LogView;
|
||||
use substreams_ethereum::pb::eth;
|
||||
|
||||
use itertools::Itertools;
|
||||
use pb::tycho::evm::v1::{self as tycho};
|
||||
|
||||
use contract_changes::extract_contract_changes;
|
||||
use substreams_ethereum::Event;
|
||||
|
||||
use crate::{abi, contract_changes, pb, pool_factories};
|
||||
use std::convert::TryInto;
|
||||
|
||||
/// This struct purely exists to spoof the `PartialEq` trait for `Transaction` so we can use it in
|
||||
/// a later groupby operation.
|
||||
#[derive(Debug)]
|
||||
struct TransactionWrapper(tycho::Transaction);
|
||||
|
||||
impl PartialEq for TransactionWrapper {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0.hash == other.0.hash
|
||||
}
|
||||
}
|
||||
|
||||
fn tx_from_log(log: &LogView) -> tycho::Transaction {
|
||||
tycho::Transaction {
|
||||
hash: log.receipt.transaction.hash.clone(),
|
||||
from: log.receipt.transaction.from.clone(),
|
||||
to: log.receipt.transaction.to.clone(),
|
||||
index: Into::<u64>::into(log.receipt.transaction.index),
|
||||
}
|
||||
}
|
||||
|
||||
#[substreams::handlers::map]
|
||||
pub fn map_pools_created(
|
||||
block: eth::v2::Block,
|
||||
) -> Result<tycho::GroupedTransactionProtocolComponents> {
|
||||
// Gather contract changes by indexing `PoolCreated` events and analysing the `Create` call
|
||||
// We store these as a hashmap by tx hash since we need to agg by tx hash later
|
||||
Ok(tycho::GroupedTransactionProtocolComponents {
|
||||
tx_components: block
|
||||
.transactions()
|
||||
.filter_map(|tx| {
|
||||
let components = tx
|
||||
.logs_with_calls()
|
||||
.filter(|(_, call)| !call.call.state_reverted)
|
||||
.filter_map(|(log, call)| {
|
||||
Some(pool_factories::address_map(
|
||||
call.call.address.as_slice().try_into().ok()?, // this shouldn't fail
|
||||
log,
|
||||
call.call,
|
||||
)?)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !components.is_empty() {
|
||||
Some(tycho::TransactionProtocolComponents {
|
||||
tx: Some(tycho::Transaction {
|
||||
hash: tx.hash.clone(),
|
||||
from: tx.from.clone(),
|
||||
to: tx.to.clone(),
|
||||
index: Into::<u64>::into(tx.index),
|
||||
}),
|
||||
components,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Simply stores the `ProtocolComponent`s with the pool id as the key
|
||||
#[substreams::handlers::store]
|
||||
pub fn store_pools_created(map: tycho::GroupedTransactionProtocolComponents, store: StoreAddInt64) {
|
||||
store.add_many(
|
||||
0,
|
||||
&map.tx_components
|
||||
.iter()
|
||||
.flat_map(|tx_components| &tx_components.components)
|
||||
.map(|component| format!("pool:{0}", component.id))
|
||||
.collect::<Vec<_>>(),
|
||||
1,
|
||||
);
|
||||
}
|
||||
|
||||
/// Since the `PoolBalanceChanged` events administer only deltas, we need to leverage a map and a
|
||||
/// store to be able to tally up final balances for tokens in a pool.
|
||||
#[substreams::handlers::map]
|
||||
pub fn map_balance_deltas(
|
||||
block: eth::v2::Block,
|
||||
store: StoreGetInt64,
|
||||
) -> Result<tycho::BalanceDeltas, anyhow::Error> {
|
||||
Ok(tycho::BalanceDeltas {
|
||||
balance_deltas: block
|
||||
.logs()
|
||||
.filter_map(|log| {
|
||||
let event = abi::pool::events::TokenExchange::match_and_decode(log)?;
|
||||
Some((log, event))
|
||||
})
|
||||
.filter(|(log, _)| {
|
||||
store
|
||||
.get_last(format!("pool:{0}", hex::encode(&log.address())))
|
||||
.is_some()
|
||||
})
|
||||
.flat_map(|(log, event)| {
|
||||
let tokens_bought_delta: BigInt = event.tokens_bought * -1;
|
||||
vec![
|
||||
tycho::BalanceDelta {
|
||||
ord: log.log.ordinal,
|
||||
tx: Some(tx_from_log(&log)),
|
||||
token: event.sold_id.to_signed_bytes_be(),
|
||||
delta: event.tokens_sold.to_signed_bytes_be(),
|
||||
component_id: log.address().into(),
|
||||
},
|
||||
tycho::BalanceDelta {
|
||||
ord: log.log.ordinal,
|
||||
tx: Some(tx_from_log(&log)),
|
||||
token: event.bought_id.to_signed_bytes_be(),
|
||||
delta: tokens_bought_delta.to_signed_bytes_be(),
|
||||
component_id: log.address().into(),
|
||||
},
|
||||
]
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
})
|
||||
}
|
||||
|
||||
/// It's significant to include both the `pool_id` and the `token_id` for each balance delta as the
|
||||
/// store key to ensure that there's a unique balance being tallied for each.
|
||||
#[substreams::handlers::store]
|
||||
pub fn store_balance_changes(deltas: tycho::BalanceDeltas, store: StoreAddBigInt) {
|
||||
deltas.balance_deltas.iter().for_each(|delta| {
|
||||
store.add(
|
||||
delta.ord,
|
||||
format!(
|
||||
"pool:{0}:token:{1}",
|
||||
hex::encode(&delta.component_id),
|
||||
hex::encode(&delta.token)
|
||||
),
|
||||
BigInt::from_signed_bytes_be(&delta.delta),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// This is the main map that handles most of the indexing of this substream.
|
||||
/// Every contract change is grouped by transaction index via the `transaction_contract_changes`
|
||||
/// map. Each block of code will extend the `TransactionContractChanges` struct with the
|
||||
/// cooresponding changes (balance, component, contract), inserting a new one if it doesn't exist.
|
||||
/// At the very end, the map can easily be sorted by index to ensure the final `BlockContractChanges`
|
||||
/// is ordered by transactions properly.
|
||||
#[substreams::handlers::map]
|
||||
pub fn map_changes(
|
||||
block: eth::v2::Block,
|
||||
grouped_components: tycho::GroupedTransactionProtocolComponents,
|
||||
deltas: tycho::BalanceDeltas,
|
||||
components_store: StoreGetInt64,
|
||||
balance_store: StoreDeltas, // Note, this map module is using the `deltas` mode for the store.
|
||||
) -> Result<tycho::BlockContractChanges> {
|
||||
// We merge contract changes by transaction (identified by transaction index) making it easy to
|
||||
// sort them at the very end.
|
||||
let mut transaction_contract_changes: HashMap<_, tycho::TransactionContractChanges> =
|
||||
HashMap::new();
|
||||
|
||||
// `ProtocolComponents` are gathered from `map_pools_created` which just need a bit of work to
|
||||
// convert into `TransactionContractChanges`
|
||||
grouped_components
|
||||
.tx_components
|
||||
.iter()
|
||||
.for_each(|tx_component| {
|
||||
let tx = tx_component.tx.as_ref().unwrap();
|
||||
|
||||
transaction_contract_changes
|
||||
.entry(tx.index)
|
||||
.or_insert_with(|| tycho::TransactionContractChanges {
|
||||
tx: Some(tx.clone()),
|
||||
contract_changes: vec![],
|
||||
component_changes: vec![],
|
||||
balance_changes: vec![],
|
||||
})
|
||||
.component_changes
|
||||
.extend_from_slice(&tx_component.components);
|
||||
});
|
||||
|
||||
// Balance changes are gathered by the `StoreDelta` based on `PoolBalanceChanged` 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.
|
||||
balance_store
|
||||
.deltas
|
||||
.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);
|
||||
(
|
||||
balance_delta.tx.unwrap(),
|
||||
tycho::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"),
|
||||
},
|
||||
)
|
||||
})
|
||||
// We need to group the balance changes by tx hash for the `TransactionContractChanges` agg
|
||||
.group_by(|(tx, _)| TransactionWrapper(tx.clone()))
|
||||
.into_iter()
|
||||
.for_each(|(tx_wrapped, group)| {
|
||||
let tx = tx_wrapped.0;
|
||||
|
||||
transaction_contract_changes
|
||||
.entry(tx.index)
|
||||
.or_insert_with(|| tycho::TransactionContractChanges {
|
||||
tx: Some(tx.clone()),
|
||||
contract_changes: vec![],
|
||||
component_changes: vec![],
|
||||
balance_changes: vec![],
|
||||
})
|
||||
.balance_changes
|
||||
.extend(group.map(|(_, change)| change));
|
||||
});
|
||||
|
||||
// General helper for extracting contract changes. Uses block, our component store which holds
|
||||
// all of our tracked deployed pool addresses, and the map of tx contract changes which we
|
||||
// output into for final processing later.
|
||||
extract_contract_changes(&block, components_store, &mut transaction_contract_changes);
|
||||
|
||||
// Process all `transaction_contract_changes` for final output in the `BlockContractChanges`,
|
||||
// sorted by transaction index (the key).
|
||||
Ok(tycho::BlockContractChanges {
|
||||
block: Some(tycho::Block {
|
||||
number: block.number,
|
||||
hash: block.hash.clone(),
|
||||
parent_hash: block
|
||||
.header
|
||||
.as_ref()
|
||||
.expect("Block header not present")
|
||||
.parent_hash
|
||||
.clone(),
|
||||
ts: block.timestamp_seconds(),
|
||||
}),
|
||||
changes: transaction_contract_changes
|
||||
.drain()
|
||||
.sorted_unstable_by_key(|(index, _)| index.clone())
|
||||
.filter_map(|(_, change)| {
|
||||
if change.contract_changes.is_empty()
|
||||
&& change.component_changes.is_empty()
|
||||
&& change.balance_changes.is_empty()
|
||||
{
|
||||
None
|
||||
} else {
|
||||
Some(change)
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
})
|
||||
}
|
||||
28
substreams/ethereum-curve/src/pb/eth.balancer.v1.rs
Normal file
28
substreams/ethereum-curve/src/pb/eth.balancer.v1.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
// @generated
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Pools {
|
||||
#[prost(message, repeated, tag="1")]
|
||||
pub pools: ::prost::alloc::vec::Vec<Pool>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Pool {
|
||||
#[prost(bytes="vec", tag="1")]
|
||||
pub pool_id: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(fixed64, tag="2")]
|
||||
pub log_ordinal: u64,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Transfer {
|
||||
#[prost(bytes="vec", tag="1")]
|
||||
pub from: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes="vec", tag="2")]
|
||||
pub to: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(string, tag="3")]
|
||||
pub token: ::prost::alloc::string::String,
|
||||
#[prost(string, tag="4")]
|
||||
pub amount: ::prost::alloc::string::String,
|
||||
}
|
||||
// @@protoc_insertion_point(module)
|
||||
28
substreams/ethereum-curve/src/pb/eth.factory.v1.rs
Normal file
28
substreams/ethereum-curve/src/pb/eth.factory.v1.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
// @generated
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Pools {
|
||||
#[prost(message, repeated, tag="1")]
|
||||
pub pools: ::prost::alloc::vec::Vec<Pool>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Pool {
|
||||
#[prost(bytes="vec", tag="1")]
|
||||
pub pool_id: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(fixed64, tag="2")]
|
||||
pub log_ordinal: u64,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Transfer {
|
||||
#[prost(bytes="vec", tag="1")]
|
||||
pub from: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bytes="vec", tag="2")]
|
||||
pub to: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(string, tag="3")]
|
||||
pub token: ::prost::alloc::string::String,
|
||||
#[prost(string, tag="4")]
|
||||
pub amount: ::prost::alloc::string::String,
|
||||
}
|
||||
// @@protoc_insertion_point(module)
|
||||
22
substreams/ethereum-curve/src/pb/eth.pool.v1.rs
Normal file
22
substreams/ethereum-curve/src/pb/eth.pool.v1.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
// @generated
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Transfers {
|
||||
#[prost(message, repeated, tag="1")]
|
||||
pub transfers: ::prost::alloc::vec::Vec<Transfer>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Transfer {
|
||||
#[prost(string, tag="1")]
|
||||
pub from: ::prost::alloc::string::String,
|
||||
#[prost(string, tag="2")]
|
||||
pub to: ::prost::alloc::string::String,
|
||||
#[prost(uint64, tag="3")]
|
||||
pub token_id: u64,
|
||||
#[prost(string, tag="4")]
|
||||
pub trx_hash: ::prost::alloc::string::String,
|
||||
#[prost(uint64, tag="5")]
|
||||
pub ordinal: u64,
|
||||
}
|
||||
// @@protoc_insertion_point(module)
|
||||
10
substreams/ethereum-curve/src/pb/mod.rs
Normal file
10
substreams/ethereum-curve/src/pb/mod.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
// @generated
|
||||
pub mod tycho {
|
||||
pub mod evm {
|
||||
// @@protoc_insertion_point(attribute:tycho.evm.v1)
|
||||
pub mod v1 {
|
||||
include!("tycho.evm.v1.rs");
|
||||
// @@protoc_insertion_point(tycho.evm.v1)
|
||||
}
|
||||
}
|
||||
}
|
||||
236
substreams/ethereum-curve/src/pb/tycho.evm.v1.rs
Normal file
236
substreams/ethereum-curve/src/pb/tycho.evm.v1.rs
Normal file
@@ -0,0 +1,236 @@
|
||||
// @generated
|
||||
// This file contains the proto definitions for Substreams common to all integrations.
|
||||
|
||||
/// A struct describing a block.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Block {
|
||||
/// The blocks hash.
|
||||
#[prost(bytes="vec", tag="1")]
|
||||
pub hash: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The parent blocks hash.
|
||||
#[prost(bytes="vec", tag="2")]
|
||||
pub parent_hash: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The block number.
|
||||
#[prost(uint64, tag="3")]
|
||||
pub number: u64,
|
||||
/// The block timestamp.
|
||||
#[prost(uint64, tag="4")]
|
||||
pub ts: u64,
|
||||
}
|
||||
/// A struct describing a transaction.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Transaction {
|
||||
/// The transaction hash.
|
||||
#[prost(bytes="vec", tag="1")]
|
||||
pub hash: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The sender of the transaction.
|
||||
#[prost(bytes="vec", tag="2")]
|
||||
pub from: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The receiver of the transaction.
|
||||
#[prost(bytes="vec", tag="3")]
|
||||
pub to: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The transactions index within the block.
|
||||
/// TODO: should this be uint32? to match the type from the native substream type?
|
||||
#[prost(uint64, tag="4")]
|
||||
pub index: u64,
|
||||
}
|
||||
/// A custom struct representing an arbitrary attribute of a protocol component.
|
||||
/// This is mainly used by the native integration to track the necessary information about the protocol.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Attribute {
|
||||
/// The name of the attribute.
|
||||
#[prost(string, tag="1")]
|
||||
pub name: ::prost::alloc::string::String,
|
||||
/// The value of the attribute.
|
||||
#[prost(bytes="vec", tag="2")]
|
||||
pub value: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The type of change the attribute underwent.
|
||||
#[prost(enumeration="ChangeType", tag="3")]
|
||||
pub change: i32,
|
||||
}
|
||||
/// A struct describing a part of the protocol.
|
||||
/// Note: For example this can be a UniswapV2 pair, that tracks the two ERC20 tokens used by the pair,
|
||||
/// the component would represent a single contract. In case of VM integration, such component would
|
||||
/// not need any attributes, because all the relevant info would be tracked via storage slots and balance changes.
|
||||
/// It can also be a wrapping contract, like WETH, that has a constant price, but it allows swapping tokens.
|
||||
/// This is why the name ProtocolComponent is used instead of "Pool" or "Pair".
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ProtocolComponent {
|
||||
/// A unique identifier for the component within the protocol.
|
||||
/// Can be e.g. a stringified address or a string describing the trading pair.
|
||||
#[prost(string, tag="1")]
|
||||
pub id: ::prost::alloc::string::String,
|
||||
/// Addresses of the ERC20 tokens used by the component.
|
||||
#[prost(bytes="vec", repeated, tag="2")]
|
||||
pub tokens: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
|
||||
/// Addresses of the contracts used by the component.
|
||||
/// Usually it is a single contract, but some protocols use multiple contracts.
|
||||
#[prost(bytes="vec", repeated, tag="3")]
|
||||
pub contracts: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
|
||||
/// Attributes of the component. Used mainly be the native integration.
|
||||
/// The inner ChangeType of the attribute has to match the ChangeType of the ProtocolComponent.
|
||||
#[prost(message, repeated, tag="4")]
|
||||
pub static_att: ::prost::alloc::vec::Vec<Attribute>,
|
||||
/// Type of change the component underwent.
|
||||
#[prost(enumeration="ChangeType", tag="5")]
|
||||
pub change: i32,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct TransactionProtocolComponents {
|
||||
#[prost(message, optional, tag="1")]
|
||||
pub tx: ::core::option::Option<Transaction>,
|
||||
#[prost(message, repeated, tag="2")]
|
||||
pub components: ::prost::alloc::vec::Vec<ProtocolComponent>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct GroupedTransactionProtocolComponents {
|
||||
#[prost(message, repeated, tag="1")]
|
||||
pub tx_components: ::prost::alloc::vec::Vec<TransactionProtocolComponents>,
|
||||
}
|
||||
/// A struct for following the changes of Total Value Locked (TVL) of a protocol component.
|
||||
/// Note that if a ProtocolComponent contains multiple contracts, the TVL is tracked for the component as a whole.
|
||||
/// E.g. for UniswapV2 pair WETH/USDC, this tracks the USDC and WETH balance of the pair contract.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BalanceChange {
|
||||
/// The address of the ERC20 token whose balance changed.
|
||||
#[prost(bytes="vec", tag="1")]
|
||||
pub token: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The new balance of the token.
|
||||
#[prost(bytes="vec", tag="2")]
|
||||
pub balance: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The id of the component whose TVL is tracked.
|
||||
/// If the protocol component includes multiple contracts, the balance change must be aggregated to reflect how much tokens can be traded.
|
||||
#[prost(bytes="vec", tag="3")]
|
||||
pub component_id: ::prost::alloc::vec::Vec<u8>,
|
||||
}
|
||||
/// A struct for following the changes of Total Value Locked (TVL) of a protocol component.
|
||||
/// Note that if a ProtocolComponent contains multiple contracts, the TVL is tracked for the component as a whole.
|
||||
/// E.g. for UniswapV2 pair WETH/USDC, this tracks the USDC and WETH balance of the pair contract.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BalanceDelta {
|
||||
#[prost(uint64, tag="1")]
|
||||
pub ord: u64,
|
||||
/// The tx hash of the transaction that caused the balance change.
|
||||
#[prost(message, optional, tag="2")]
|
||||
pub tx: ::core::option::Option<Transaction>,
|
||||
/// The address of the ERC20 token whose balance changed.
|
||||
#[prost(bytes="vec", tag="3")]
|
||||
pub token: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The delta balance of the token.
|
||||
#[prost(bytes="vec", tag="4")]
|
||||
pub delta: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The id of the component whose TVL is tracked.
|
||||
/// If the protocol component includes multiple contracts, the balance change must be aggregated to reflect how much tokens can be traded.
|
||||
#[prost(bytes="vec", tag="5")]
|
||||
pub component_id: ::prost::alloc::vec::Vec<u8>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BalanceDeltas {
|
||||
#[prost(message, repeated, tag="1")]
|
||||
pub balance_deltas: ::prost::alloc::vec::Vec<BalanceDelta>,
|
||||
}
|
||||
/// Enum to specify the type of a change.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
|
||||
#[repr(i32)]
|
||||
pub enum ChangeType {
|
||||
Unspecified = 0,
|
||||
Update = 1,
|
||||
Creation = 2,
|
||||
Deletion = 3,
|
||||
}
|
||||
impl ChangeType {
|
||||
/// String value of the enum field names used in the ProtoBuf definition.
|
||||
///
|
||||
/// The values are not transformed in any way and thus are considered stable
|
||||
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
|
||||
pub fn as_str_name(&self) -> &'static str {
|
||||
match self {
|
||||
ChangeType::Unspecified => "CHANGE_TYPE_UNSPECIFIED",
|
||||
ChangeType::Update => "CHANGE_TYPE_UPDATE",
|
||||
ChangeType::Creation => "CHANGE_TYPE_CREATION",
|
||||
ChangeType::Deletion => "CHANGE_TYPE_DELETION",
|
||||
}
|
||||
}
|
||||
/// Creates an enum from field names used in the ProtoBuf definition.
|
||||
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
|
||||
match value {
|
||||
"CHANGE_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
|
||||
"CHANGE_TYPE_UPDATE" => Some(Self::Update),
|
||||
"CHANGE_TYPE_CREATION" => Some(Self::Creation),
|
||||
"CHANGE_TYPE_DELETION" => Some(Self::Deletion),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
// This file contains proto definitions specific to the VM integration.
|
||||
|
||||
/// A key value entry into contract storage.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ContractSlot {
|
||||
/// A contract's storage slot.
|
||||
#[prost(bytes="vec", tag="2")]
|
||||
pub slot: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The new value for this storage slot.
|
||||
#[prost(bytes="vec", tag="3")]
|
||||
pub value: ::prost::alloc::vec::Vec<u8>,
|
||||
}
|
||||
/// Changes made to a single contract's state.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ContractChange {
|
||||
/// The contract's address
|
||||
#[prost(bytes="vec", tag="1")]
|
||||
pub address: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The new native balance of the contract, empty bytes indicates no change.
|
||||
#[prost(bytes="vec", tag="2")]
|
||||
pub balance: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The new code of the contract, empty bytes indicates no change.
|
||||
#[prost(bytes="vec", tag="3")]
|
||||
pub code: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The changes to this contract's slots, empty sequence indicates no change.
|
||||
#[prost(message, repeated, tag="4")]
|
||||
pub slots: ::prost::alloc::vec::Vec<ContractSlot>,
|
||||
/// Whether this is an update, a creation or a deletion.
|
||||
#[prost(enumeration="ChangeType", tag="5")]
|
||||
pub change: i32,
|
||||
}
|
||||
/// A set of changes aggregated by transaction.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct TransactionContractChanges {
|
||||
/// The transaction instance that results in the changes.
|
||||
#[prost(message, optional, tag="1")]
|
||||
pub tx: ::core::option::Option<Transaction>,
|
||||
/// Contains the changes induced by the above transaction, aggregated on a per-contract basis.
|
||||
/// Must include changes to every contract that is tracked by all ProtocolComponents.
|
||||
#[prost(message, repeated, tag="2")]
|
||||
pub contract_changes: ::prost::alloc::vec::Vec<ContractChange>,
|
||||
/// An array of any component changes.
|
||||
#[prost(message, repeated, tag="3")]
|
||||
pub component_changes: ::prost::alloc::vec::Vec<ProtocolComponent>,
|
||||
/// An array of balance changes to components.
|
||||
#[prost(message, repeated, tag="4")]
|
||||
pub balance_changes: ::prost::alloc::vec::Vec<BalanceChange>,
|
||||
}
|
||||
/// A set of transaction changes within a single block.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BlockContractChanges {
|
||||
/// The block for which these changes are collectively computed.
|
||||
#[prost(message, optional, tag="1")]
|
||||
pub block: ::core::option::Option<Block>,
|
||||
/// The set of transaction changes observed in the specified block.
|
||||
#[prost(message, repeated, tag="2")]
|
||||
pub changes: ::prost::alloc::vec::Vec<TransactionContractChanges>,
|
||||
}
|
||||
// @@protoc_insertion_point(module)
|
||||
386
substreams/ethereum-curve/src/pool_factories.rs
Normal file
386
substreams/ethereum-curve/src/pool_factories.rs
Normal file
@@ -0,0 +1,386 @@
|
||||
use substreams_ethereum::pb::eth::v2::{Call, Log};
|
||||
use substreams_ethereum::{Event, Function};
|
||||
|
||||
use crate::abi;
|
||||
use crate::pb;
|
||||
use pb::tycho::evm::v1::{self as tycho};
|
||||
use substreams::{hex, log};
|
||||
|
||||
use substreams::scalar::BigInt;
|
||||
|
||||
const EMPTY_BYTES32: [u8; 32] = [0; 32];
|
||||
const EMPTY_ADDRESS: [u8; 20] = hex!("0000000000000000000000000000000000000000");
|
||||
|
||||
const CRYPTO_SWAP_REGISTRY: [u8; 20] = hex!("897888115Ada5773E02aA29F775430BFB5F34c51");
|
||||
const MAIN_REGISTRY: [u8; 20] = hex!("90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5");
|
||||
const CRYPTO_POOL_FACTORY: [u8; 20] = hex!("F18056Bbd320E96A48e3Fbf8bC061322531aac99");
|
||||
const META_POOL_FACTORY: [u8; 20] = hex!("B9fC157394Af804a3578134A6585C0dc9cc990d4");
|
||||
|
||||
/// This trait defines some helpers for serializing and deserializing `Vec<BigInt` which is needed
|
||||
/// to be able to encode the `normalized_weights` and `weights` `Attribute`s. This should also be
|
||||
/// handled by any downstream application.
|
||||
trait SerializableVecBigInt {
|
||||
fn serialize_bytes(&self) -> Vec<u8>;
|
||||
fn deserialize_bytes(bytes: &[u8]) -> Vec<BigInt>;
|
||||
}
|
||||
|
||||
impl SerializableVecBigInt for Vec<BigInt> {
|
||||
fn serialize_bytes(&self) -> Vec<u8> {
|
||||
self.iter()
|
||||
.flat_map(|big_int| big_int.to_signed_bytes_be())
|
||||
.collect()
|
||||
}
|
||||
fn deserialize_bytes(bytes: &[u8]) -> Vec<BigInt> {
|
||||
bytes
|
||||
.chunks_exact(32)
|
||||
.map(|chunk| BigInt::from_signed_bytes_be(chunk))
|
||||
.collect::<Vec<BigInt>>()
|
||||
}
|
||||
}
|
||||
|
||||
/// This is the main function that handles the creation of `ProtocolComponent`s with `Attribute`s
|
||||
/// based on the specific factory address. There's 3 factory groups that are represented here:
|
||||
/// - Weighted Pool Factories
|
||||
/// - Linear Pool Factories
|
||||
/// - Stable Pool Factories
|
||||
/// (Balancer does have a bit more (esp. in the deprecated section) that could be implemented as
|
||||
/// desired.)
|
||||
/// We use the specific ABIs to decode both the log event and cooresponding call to gather
|
||||
/// `PoolCreated` event information alongside the `Create` calldata that provide us details to
|
||||
/// fufill both the required details + any extra `Attributes`
|
||||
/// Ref: https://docs.balancer.fi/reference/contracts/deployment-addresses/mainnet.html
|
||||
pub fn address_map(
|
||||
call_address: &[u8; 20],
|
||||
log: &Log,
|
||||
call: &Call,
|
||||
) -> Option<tycho::ProtocolComponent> {
|
||||
match *call_address {
|
||||
CRYPTO_SWAP_REGISTRY => {
|
||||
let pool_added = abi::crypto_swap_registry::events::PoolAdded::match_and_decode(log)?;
|
||||
|
||||
let add_pool = abi::crypto_swap_registry::functions::AddPool1::match_and_decode(call)
|
||||
.map(|add_pool| abi::crypto_swap_registry::functions::AddPool3 {
|
||||
pool: add_pool.pool,
|
||||
lp_token: add_pool.lp_token,
|
||||
gauge: add_pool.gauge,
|
||||
zap: add_pool.zap,
|
||||
n_coins: add_pool.n_coins,
|
||||
name: add_pool.name,
|
||||
base_pool: EMPTY_ADDRESS.clone().into(),
|
||||
has_positive_rebasing_tokens: false,
|
||||
})
|
||||
.or_else(|| {
|
||||
abi::crypto_swap_registry::functions::AddPool2::match_and_decode(call).map(
|
||||
|add_pool| abi::crypto_swap_registry::functions::AddPool3 {
|
||||
pool: add_pool.pool,
|
||||
lp_token: add_pool.lp_token,
|
||||
gauge: add_pool.gauge,
|
||||
zap: add_pool.zap,
|
||||
n_coins: add_pool.n_coins,
|
||||
name: add_pool.name,
|
||||
base_pool: add_pool.base_pool,
|
||||
has_positive_rebasing_tokens: false,
|
||||
},
|
||||
)
|
||||
})
|
||||
.or_else(|| {
|
||||
abi::crypto_swap_registry::functions::AddPool3::match_and_decode(call)
|
||||
})?;
|
||||
|
||||
// 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,
|
||||
};
|
||||
|
||||
let coins = coins_function.call(CRYPTO_SWAP_REGISTRY.to_vec())?;
|
||||
let trimmed_coins: Vec<_> = coins
|
||||
.get(0..add_pool.n_coins.to_i32() as usize)
|
||||
.unwrap_or(&[])
|
||||
.to_vec();
|
||||
|
||||
Some(tycho::ProtocolComponent {
|
||||
id: hex::encode(&pool_added.pool),
|
||||
tokens: trimmed_coins,
|
||||
contracts: vec![call_address.into(), pool_added.pool],
|
||||
static_att: vec![
|
||||
tycho::Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "CryptoSwap".into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "name".into(),
|
||||
value: add_pool.name.into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "lp_token".into(),
|
||||
value: add_pool.lp_token.into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
})
|
||||
}
|
||||
MAIN_REGISTRY => {
|
||||
let pool_created = abi::main_registry::events::PoolAdded::match_and_decode(log)?;
|
||||
let add_pool =
|
||||
abi::main_registry::functions::AddPoolWithoutUnderlying::match_and_decode(call)
|
||||
.map(|add_pool| abi::main_registry::functions::AddPool {
|
||||
pool: add_pool.pool,
|
||||
lp_token: add_pool.lp_token,
|
||||
rate_info: add_pool.rate_info,
|
||||
decimals: add_pool.decimals,
|
||||
n_coins: add_pool.n_coins,
|
||||
underlying_decimals: BigInt::from(0), // not needed
|
||||
has_initial_a: add_pool.has_initial_a,
|
||||
is_v1: add_pool.is_v1,
|
||||
name: add_pool.name,
|
||||
})
|
||||
.or_else(|| {
|
||||
abi::main_registry::functions::AddMetapool1::match_and_decode(call).map(
|
||||
|add_pool| abi::main_registry::functions::AddPool {
|
||||
pool: add_pool.pool,
|
||||
lp_token: add_pool.lp_token,
|
||||
rate_info: EMPTY_BYTES32.clone(),
|
||||
decimals: add_pool.decimals,
|
||||
n_coins: add_pool.n_coins,
|
||||
underlying_decimals: BigInt::from(0), // not needed
|
||||
has_initial_a: true,
|
||||
is_v1: false,
|
||||
name: add_pool.name,
|
||||
},
|
||||
)
|
||||
})
|
||||
.or_else(|| {
|
||||
abi::main_registry::functions::AddMetapool2::match_and_decode(call).map(
|
||||
|add_pool| abi::main_registry::functions::AddPool {
|
||||
pool: add_pool.pool,
|
||||
lp_token: add_pool.lp_token,
|
||||
rate_info: EMPTY_BYTES32.clone(),
|
||||
decimals: add_pool.decimals,
|
||||
n_coins: add_pool.n_coins,
|
||||
underlying_decimals: BigInt::from(0), // not needed
|
||||
has_initial_a: true,
|
||||
is_v1: false,
|
||||
name: add_pool.name,
|
||||
},
|
||||
)
|
||||
})
|
||||
.or_else(|| abi::main_registry::functions::AddPool::match_and_decode(call))?;
|
||||
|
||||
// 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,
|
||||
};
|
||||
|
||||
let coins = coins_function.call(CRYPTO_SWAP_REGISTRY.to_vec())?;
|
||||
let trimmed_coins: Vec<_> = coins
|
||||
.get(0..add_pool.n_coins.to_i32() as usize)
|
||||
.unwrap_or(&[])
|
||||
.to_vec();
|
||||
|
||||
Some(tycho::ProtocolComponent {
|
||||
id: hex::encode(&pool_created.pool),
|
||||
tokens: trimmed_coins,
|
||||
contracts: vec![call_address.into(), pool_created.pool],
|
||||
static_att: vec![
|
||||
tycho::Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "MainRegistry".into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "name".into(),
|
||||
value: add_pool.name.into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "lp_token".into(),
|
||||
value: add_pool.lp_token.into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
})
|
||||
}
|
||||
CRYPTO_POOL_FACTORY => {
|
||||
let pool_added =
|
||||
abi::crypto_pool_factory::events::CryptoPoolDeployed::match_and_decode(log)?;
|
||||
let deploy_call =
|
||||
abi::crypto_pool_factory::functions::DeployPool::match_and_decode(call)?;
|
||||
|
||||
Some(tycho::ProtocolComponent {
|
||||
id: hex::encode(&call.return_data),
|
||||
tokens: pool_added.coins.into(),
|
||||
contracts: vec![call_address.into(), call.return_data.clone()],
|
||||
static_att: vec![
|
||||
tycho::Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "CryptoPool".into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "name".into(),
|
||||
value: pool_added.a.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "lp_token".into(),
|
||||
value: pool_added.gamma.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "mid_fee".into(),
|
||||
value: deploy_call.mid_fee.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "out_fee".into(),
|
||||
value: deploy_call.out_fee.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "allowed_extra_profit".into(),
|
||||
value: deploy_call.allowed_extra_profit.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "fee_gamma".into(),
|
||||
value: deploy_call.fee_gamma.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "adjustment_step".into(),
|
||||
value: deploy_call.adjustment_step.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "admin_fee".into(),
|
||||
value: deploy_call.admin_fee.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "ma_half_time".into(),
|
||||
value: deploy_call.ma_half_time.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "initial_price".into(),
|
||||
value: deploy_call.initial_price.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
})
|
||||
}
|
||||
META_POOL_FACTORY => {
|
||||
if let Some(pool_added) =
|
||||
abi::meta_pool_factory::events::PlainPoolDeployed::match_and_decode(log)
|
||||
{
|
||||
let add_pool =
|
||||
abi::meta_pool_factory::functions::DeployPlainPool1::match_and_decode(call)
|
||||
.map(
|
||||
|add_pool| abi::meta_pool_factory::functions::DeployPlainPool3 {
|
||||
name: add_pool.name,
|
||||
symbol: add_pool.symbol,
|
||||
coins: add_pool.coins,
|
||||
a: add_pool.a,
|
||||
fee: add_pool.fee,
|
||||
asset_type: BigInt::from(0),
|
||||
implementation_idx: BigInt::from(0),
|
||||
},
|
||||
)
|
||||
.or_else(|| {
|
||||
abi::meta_pool_factory::functions::DeployPlainPool2::match_and_decode(
|
||||
call,
|
||||
)
|
||||
.map(|add_pool| {
|
||||
abi::meta_pool_factory::functions::DeployPlainPool3 {
|
||||
name: add_pool.name,
|
||||
symbol: add_pool.symbol,
|
||||
coins: add_pool.coins,
|
||||
a: add_pool.a,
|
||||
fee: add_pool.fee,
|
||||
asset_type: add_pool.asset_type,
|
||||
implementation_idx: BigInt::from(0),
|
||||
}
|
||||
})
|
||||
})
|
||||
.or_else(|| {
|
||||
abi::meta_pool_factory::functions::DeployPlainPool3::match_and_decode(
|
||||
call,
|
||||
)
|
||||
})?;
|
||||
Some(tycho::ProtocolComponent {
|
||||
id: hex::encode(&call.return_data),
|
||||
tokens: pool_added.coins.into(),
|
||||
contracts: vec![call_address.into(), call.return_data.clone()],
|
||||
static_att: vec![
|
||||
tycho::Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "PlainPool".into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "name".into(),
|
||||
value: add_pool.name.into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "fee".into(),
|
||||
value: add_pool.fee.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
tycho::Attribute {
|
||||
name: "a".into(),
|
||||
value: add_pool.a.to_string().into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
})
|
||||
} 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,
|
||||
)
|
||||
})?;
|
||||
Some(tycho::ProtocolComponent {
|
||||
id: hex::encode(&call.return_data),
|
||||
tokens: vec![pool_added.coin, add_pool.base_pool.clone()],
|
||||
contracts: vec![
|
||||
call_address.into(),
|
||||
call.return_data.clone(),
|
||||
add_pool.base_pool.clone(),
|
||||
],
|
||||
static_att: vec![tycho::Attribute {
|
||||
name: "pool_type".into(),
|
||||
value: "MetaPool".into(),
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
}],
|
||||
change: tycho::ChangeType::Creation.into(),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
64
substreams/ethereum-curve/substreams.yaml
Normal file
64
substreams/ethereum-curve/substreams.yaml
Normal file
@@ -0,0 +1,64 @@
|
||||
specVersion: v0.1.0
|
||||
package:
|
||||
name: "substreams_curve"
|
||||
version: v0.1.0
|
||||
|
||||
protobuf:
|
||||
files:
|
||||
- tycho/evm/v1/vm.proto
|
||||
- tycho/evm/v1/common.proto
|
||||
importPaths:
|
||||
- ../../proto/tycho/evm/v1/
|
||||
- ./proto
|
||||
|
||||
binaries:
|
||||
default:
|
||||
type: wasm/rust-v1
|
||||
file: target/wasm32-unknown-unknown/release/substreams_balancer.wasm
|
||||
|
||||
modules:
|
||||
- name: map_pools_created
|
||||
kind: map
|
||||
initialBlock: 19128828
|
||||
inputs:
|
||||
- source: sf.ethereum.type.v2.Block
|
||||
output:
|
||||
type: proto:tycho.evm.v1.GroupedTransactionProtocolComponents
|
||||
|
||||
- name: store_pools_created
|
||||
kind: store
|
||||
initialBlock: 19128828
|
||||
updatePolicy: add
|
||||
valueType: int64
|
||||
inputs:
|
||||
- map: map_pools_created
|
||||
|
||||
- name: map_balance_deltas
|
||||
kind: map
|
||||
initialBlock: 19128828 # An arbitrary block that should change based on your requirements
|
||||
inputs:
|
||||
- source: sf.ethereum.type.v2.Block
|
||||
- store: store_pools_created
|
||||
output:
|
||||
type: proto:tycho.evm.v1.BalanceDeltas
|
||||
|
||||
- name: store_balance_changes
|
||||
kind: store
|
||||
initialBlock: 19128828
|
||||
updatePolicy: add
|
||||
valueType: bigint
|
||||
inputs:
|
||||
- map: map_balance_deltas
|
||||
|
||||
- name: map_changes
|
||||
kind: map
|
||||
initialBlock: 19128828
|
||||
inputs:
|
||||
- source: sf.ethereum.type.v2.Block
|
||||
- map: map_pools_created
|
||||
- map: map_balance_deltas
|
||||
- store: store_pools_created
|
||||
- store: store_balance_changes
|
||||
mode: deltas # This is the key property that simplifies `BalanceChange` handling
|
||||
output:
|
||||
type: proto:tycho.evm.v1.BlockContractChanges
|
||||
Reference in New Issue
Block a user