This commit is contained in:
0xMochan
2024-05-08 19:35:25 -05:00
parent ec07703090
commit 16b9bac3ce
17 changed files with 31558 additions and 29 deletions

View File

@@ -1,5 +1,21 @@
# Instructions
The run command for our substream is a little different here due to the inclusion of the dynamic parameters for manually admitted pools.
This command will add extra parameters to the `map_components` module via the `python params.py` script. This embeds directly in the bash/zsh compatible command here. If `python` is not ideal, the script can be easily converted into `bash` but it would require the `jq` executable (I've used AI to convert it just fine in testing).
```bash
$ substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml map_protocol_changes --start-block 11507454 --stop-block +100 -p map_components=`python params.py`
```
## `params.json`
This json file is a top-level array containing objects that describe a specific `ProtocolComponent`. Each object contains the following fields:
- `name`: Just for documentation purposes
- `address`: The **lowercase** address of the component
- `tx_hash`: The hash of the transaction where the component was emitted
- `tokens`: A list of token addresses ordered in the exact same way as the Pool
- `attributes`: A nested object of key to value that represents the static attributes of the component.
Please see the included 3 examples for `3pool`, `steth`, and `tricrypto2`.

View File

@@ -0,0 +1,996 @@
[
{
"name": "BasePoolAdded",
"inputs": [
{
"name": "base_pool",
"type": "address",
"indexed": false
}
],
"anonymous": false,
"type": "event"
},
{
"name": "PlainPoolDeployed",
"inputs": [
{
"name": "coins",
"type": "address[]",
"indexed": false
},
{
"name": "A",
"type": "uint256",
"indexed": false
},
{
"name": "fee",
"type": "uint256",
"indexed": false
},
{
"name": "deployer",
"type": "address",
"indexed": false
}
],
"anonymous": false,
"type": "event"
},
{
"name": "MetaPoolDeployed",
"inputs": [
{
"name": "coin",
"type": "address",
"indexed": false
},
{
"name": "base_pool",
"type": "address",
"indexed": false
},
{
"name": "A",
"type": "uint256",
"indexed": false
},
{
"name": "fee",
"type": "uint256",
"indexed": false
},
{
"name": "deployer",
"type": "address",
"indexed": false
}
],
"anonymous": false,
"type": "event"
},
{
"name": "LiquidityGaugeDeployed",
"inputs": [
{
"name": "pool",
"type": "address",
"indexed": false
},
{
"name": "gauge",
"type": "address",
"indexed": false
}
],
"anonymous": false,
"type": "event"
},
{
"stateMutability": "nonpayable",
"type": "constructor",
"inputs": [
{
"name": "_fee_receiver",
"type": "address"
},
{
"name": "_owner",
"type": "address"
}
],
"outputs": []
},
{
"stateMutability": "view",
"type": "function",
"name": "find_pool_for_coins",
"inputs": [
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "find_pool_for_coins",
"inputs": [
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
},
{
"name": "i",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_base_pool",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_n_coins",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_meta_n_coins",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256"
},
{
"name": "",
"type": "uint256"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_coins",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "address[]"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_underlying_coins",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "address[]"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_decimals",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256[]"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_underlying_decimals",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256[]"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_metapool_rates",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256[]"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_balances",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256[]"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_underlying_balances",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256[]"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_A",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_fees",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256"
},
{
"name": "",
"type": "uint256"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_admin_balances",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256[]"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_coin_indices",
"inputs": [
{
"name": "_pool",
"type": "address"
},
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "int128"
},
{
"name": "",
"type": "int128"
},
{
"name": "",
"type": "bool"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_gauge",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_implementation_address",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "is_meta",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "bool"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "get_pool_asset_types",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint8[]"
}
]
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "deploy_plain_pool",
"inputs": [
{
"name": "_name",
"type": "string"
},
{
"name": "_symbol",
"type": "string"
},
{
"name": "_coins",
"type": "address[]"
},
{
"name": "_A",
"type": "uint256"
},
{
"name": "_fee",
"type": "uint256"
},
{
"name": "_offpeg_fee_multiplier",
"type": "uint256"
},
{
"name": "_ma_exp_time",
"type": "uint256"
},
{
"name": "_implementation_idx",
"type": "uint256"
},
{
"name": "_asset_types",
"type": "uint8[]"
},
{
"name": "_method_ids",
"type": "bytes4[]"
},
{
"name": "_oracles",
"type": "address[]"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "deploy_metapool",
"inputs": [
{
"name": "_base_pool",
"type": "address"
},
{
"name": "_name",
"type": "string"
},
{
"name": "_symbol",
"type": "string"
},
{
"name": "_coin",
"type": "address"
},
{
"name": "_A",
"type": "uint256"
},
{
"name": "_fee",
"type": "uint256"
},
{
"name": "_offpeg_fee_multiplier",
"type": "uint256"
},
{
"name": "_ma_exp_time",
"type": "uint256"
},
{
"name": "_implementation_idx",
"type": "uint256"
},
{
"name": "_asset_type",
"type": "uint8"
},
{
"name": "_method_id",
"type": "bytes4"
},
{
"name": "_oracle",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "deploy_gauge",
"inputs": [
{
"name": "_pool",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "add_base_pool",
"inputs": [
{
"name": "_base_pool",
"type": "address"
},
{
"name": "_base_lp_token",
"type": "address"
},
{
"name": "_asset_types",
"type": "uint8[]"
},
{
"name": "_n_coins",
"type": "uint256"
}
],
"outputs": []
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "set_pool_implementations",
"inputs": [
{
"name": "_implementation_index",
"type": "uint256"
},
{
"name": "_implementation",
"type": "address"
}
],
"outputs": []
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "set_metapool_implementations",
"inputs": [
{
"name": "_implementation_index",
"type": "uint256"
},
{
"name": "_implementation",
"type": "address"
}
],
"outputs": []
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "set_math_implementation",
"inputs": [
{
"name": "_math_implementation",
"type": "address"
}
],
"outputs": []
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "set_gauge_implementation",
"inputs": [
{
"name": "_gauge_implementation",
"type": "address"
}
],
"outputs": []
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "set_views_implementation",
"inputs": [
{
"name": "_views_implementation",
"type": "address"
}
],
"outputs": []
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "commit_transfer_ownership",
"inputs": [
{
"name": "_addr",
"type": "address"
}
],
"outputs": []
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "accept_transfer_ownership",
"inputs": [],
"outputs": []
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "set_fee_receiver",
"inputs": [
{
"name": "_pool",
"type": "address"
},
{
"name": "_fee_receiver",
"type": "address"
}
],
"outputs": []
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "add_asset_type",
"inputs": [
{
"name": "_id",
"type": "uint8"
},
{
"name": "_name",
"type": "string"
}
],
"outputs": []
},
{
"stateMutability": "view",
"type": "function",
"name": "admin",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "future_admin",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "asset_types",
"inputs": [
{
"name": "arg0",
"type": "uint8"
}
],
"outputs": [
{
"name": "",
"type": "string"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "pool_list",
"inputs": [
{
"name": "arg0",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "pool_count",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "base_pool_list",
"inputs": [
{
"name": "arg0",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "base_pool_count",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "base_pool_data",
"inputs": [
{
"name": "arg0",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "tuple",
"components": [
{
"name": "lp_token",
"type": "address"
},
{
"name": "coins",
"type": "address[]"
},
{
"name": "decimals",
"type": "uint256"
},
{
"name": "n_coins",
"type": "uint256"
},
{
"name": "asset_types",
"type": "uint8[]"
}
]
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "base_pool_assets",
"inputs": [
{
"name": "arg0",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "bool"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "pool_implementations",
"inputs": [
{
"name": "arg0",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "metapool_implementations",
"inputs": [
{
"name": "arg0",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "math_implementation",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "gauge_implementation",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "views_implementation",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "fee_receiver",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address"
}
]
}
]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -2,7 +2,7 @@
{
"name": "3pool",
"address": "bebc44782c7db0a1a60cb6fe97d0b483032ff1c7",
"tx_hash": "e90adc0e0a1ae9dde6c240b348adef761444e61f4194245a2096f7ca8310ac2f",
"tx_hash": "20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6",
"tokens": [
"6b175474e89094c44da98b954eedeac495271d0f",
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
@@ -13,11 +13,22 @@
{
"name": "steth",
"address": "dc24316b9ae028f1497c275eb9192a3ea0f67022",
"tx_hash": "d844051b63ce310f0f354e29e8c7f550a02fcd3bc642592a2eae6a2804e17d9c",
"tx_hash": "fac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa",
"tokens": [
"EeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"ae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
],
"attributes": {}
},
{
"name": "tricrypto2",
"address": "d51a44d3fae010294c616388b506acda1bfaae46",
"tx_hash": "dafb6385ed988ce8aacecfe1d97b38ea5e60b1ebce74d2423f71ddd621680138",
"tokens": [
"dAC17F958D2ee523a2206206994597C13D831ec7",
"2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
],
"attributes": {}
}
]

View File

@@ -1,11 +1,3 @@
"""
This script could be changed to used `jq` and bash. Usage:
```bash
python params.py | substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml map_protocol_changes --start-block 11942410 --stop-block +100 -p map_components=
```
"""
import json
from typing import Any

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,11 @@
pub mod crypto_pool_factory;
pub mod pool_tricrypto;
pub mod pool_crypto_swap_ng;
pub mod pool_tricrypto2;
pub mod crypto_swap_ng_factory;
pub mod pool_steth;
pub mod pool;
pub mod tricrypto_factory;
pub mod main_registry;
pub mod pool_3pool;
pub mod meta_pool_factory;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -227,7 +227,7 @@ pub fn map_protocol_changes(
&block,
|addr| {
components_store
.get_last(format!("pool:0x{0}", hex::encode(addr)))
.get_last(format!("pool:{0}", hex::encode(addr)))
.is_some()
},
&mut transaction_contract_changes,

View File

@@ -75,6 +75,46 @@ pub fn emit_deltas(
},
log,
)
} else if let Some(event) = abi::pool_tricrypto2::events::TokenExchange::match_and_decode(log) {
token_change_deltas(
tokens,
abi::pool::events::TokenExchange {
sold_id: event.sold_id,
bought_id: event.bought_id,
tokens_sold: event.tokens_sold,
tokens_bought: event.tokens_bought,
buyer: event.buyer,
},
log,
)
} else if let Some(event) =
abi::pool_crypto_swap_ng::events::TokenExchange::match_and_decode(log)
{
token_change_deltas(
tokens,
abi::pool::events::TokenExchange {
sold_id: event.sold_id,
bought_id: event.bought_id,
tokens_sold: event.tokens_sold,
tokens_bought: event.tokens_bought,
buyer: event.buyer,
},
log,
)
} else if let Some(event) =
abi::pool_crypto_swap_ng::events::TokenExchangeUnderlying::match_and_decode(log)
{
token_change_deltas(
tokens,
abi::pool::events::TokenExchange {
sold_id: event.sold_id,
bought_id: event.bought_id,
tokens_sold: event.tokens_sold,
tokens_bought: event.tokens_bought,
buyer: event.buyer,
},
log,
)
} else if let Some(event) = abi::pool::events::AddLiquidity::match_and_decode(log) {
add_liquidity_deltas(event.token_amounts.into(), &tokens, log)
} else if let Some(event) = abi::pool_3pool::events::AddLiquidity::match_and_decode(log) {
@@ -83,6 +123,12 @@ pub fn emit_deltas(
add_liquidity_deltas(event.token_amounts.into(), &tokens, log)
} else if let Some(event) = abi::pool_tricrypto::events::AddLiquidity::match_and_decode(log) {
add_liquidity_deltas(event.token_amounts.into(), &tokens, log)
} else if let Some(event) = abi::pool_tricrypto2::events::AddLiquidity::match_and_decode(log) {
add_liquidity_deltas(event.token_amounts.into(), &tokens, log)
} else if let Some(event) =
abi::pool_crypto_swap_ng::events::AddLiquidity::match_and_decode(log)
{
add_liquidity_deltas(event.token_amounts.into(), &tokens, log)
} else if let Some(event) = abi::pool::events::RemoveLiquidity::match_and_decode(log) {
remove_liquidity_deltas(event.token_amounts.into(), &tokens, log)
} else if let Some(event) = abi::pool_3pool::events::RemoveLiquidity::match_and_decode(log) {
@@ -92,6 +138,36 @@ pub fn emit_deltas(
} else if let Some(event) = abi::pool_tricrypto::events::RemoveLiquidity::match_and_decode(log)
{
remove_liquidity_deltas(event.token_amounts.into(), &tokens, log)
} else if let Some(event) = abi::pool_tricrypto2::events::RemoveLiquidity::match_and_decode(log)
{
remove_liquidity_deltas(event.token_amounts.into(), &tokens, log)
} else if let Some(event) =
abi::pool_crypto_swap_ng::events::RemoveLiquidity::match_and_decode(log)
{
remove_liquidity_deltas(event.token_amounts.into(), &tokens, log)
// } else if let Some(event) =
// abi::pool_crypto_swap_ng::events::RemoveLiquidityImbalance::match_and_decode(log)
// {
// remove_liquidity_deltas(event.token_amounts.into(), &tokens, log)
// } else if let Some(event) =
// abi::pool_crypto_swap_ng::events::RemoveLiquidityOne::match_and_decode(log)
// {
// Some(vec![
// BalanceDelta {
// ord: log.log.ordinal,
// tx: Some(tx_from_log(&log)),
// token: hex::decode(sold_token_id.clone()).unwrap(),
// delta: event.tokens_sold.to_signed_bytes_be(),
// component_id: hex::encode(log.address()).into(),
// },
// BalanceDelta {
// ord: log.log.ordinal,
// tx: Some(tx_from_log(&log)),
// token: hex::decode(sold_token_id.clone()).unwrap(),
// delta: event.tokens_sold.to_signed_bytes_be(),
// component_id: hex::encode(log.address()).into(),
// },
// ])
} else {
None
}
@@ -152,12 +228,15 @@ fn remove_liquidity_deltas(
amounts
.iter()
.zip(tokens)
.map(move |(token_amount, token_id)| BalanceDelta {
ord: log.log.ordinal,
tx: Some(tx_from_log(&log)),
token: hex::decode(token_id).unwrap(),
delta: token_amount.to_signed_bytes_be(),
component_id: hex::encode(log.address()).into(),
.map(move |(token_amount, token_id)| {
let token_amount_neg: BigInt = token_amount.clone() * -1;
BalanceDelta {
ord: log.log.ordinal,
tx: Some(tx_from_log(&log)),
token: hex::decode(token_id).unwrap(),
delta: token_amount_neg.to_signed_bytes_be(),
component_id: hex::encode(log.address()).into(),
}
})
.collect::<Vec<_>>(),
)

View File

@@ -16,6 +16,8 @@ const CRYPTO_SWAP_REGISTRY: [u8; 20] = hex!("897888115Ada5773E02aA29F775430BFB5F
const MAIN_REGISTRY: [u8; 20] = hex!("90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5");
const CRYPTO_POOL_FACTORY: [u8; 20] = hex!("F18056Bbd320E96A48e3Fbf8bC061322531aac99");
const META_POOL_FACTORY: [u8; 20] = hex!("B9fC157394Af804a3578134A6585C0dc9cc990d4");
const CRYPTO_SWAP_NG_FACTORY: [u8; 20] = hex!("6A8cbed756804B16E05E741eDaBd5cB544AE21bf");
const TRICRYPTO_FACTORY: [u8; 20] = hex!("0c0e5f2fF0ff18a3be9b835635039256dC4B4963");
/// This trait defines some helpers for serializing and deserializing `Vec<BigInt>` which is needed
/// to be able to encode some of the `Attribute`s. This should also be handled by any downstream
@@ -174,9 +176,9 @@ pub fn address_map(
// We need to perform an eth_call in order to actually get the pool's tokens
let coins_function =
abi::crypto_swap_registry::functions::GetCoins { pool: add_pool.pool };
abi::main_registry::functions::GetCoins { pool: add_pool.pool };
let coins = coins_function.call(CRYPTO_SWAP_REGISTRY.to_vec())?;
let coins = coins_function.call(MAIN_REGISTRY.to_vec())?;
let trimmed_coins: Vec<_> = coins
.get(0..add_pool.n_coins.to_i32() as usize)
.unwrap_or(&[])
@@ -227,7 +229,7 @@ pub fn address_map(
let component_id = &call.return_data[12..];
Some(ProtocolComponent {
id: format!("0x{0}", hex::encode(component_id)),
id: hex::encode(component_id),
tx: Some(Transaction {
to: tx.to.clone(),
from: tx.from.clone(),
@@ -354,7 +356,7 @@ pub fn address_map(
let component_id = &call.return_data[12..];
Some(ProtocolComponent {
id: format!("0x{0}", hex::encode(component_id)),
id: hex::encode(component_id),
tx: Some(Transaction {
to: tx.to.clone(),
from: tx.from.clone(),
@@ -442,6 +444,143 @@ pub fn address_map(
None
}
}
CRYPTO_SWAP_NG_FACTORY => {
if let Some(pool_added) =
abi::crypto_swap_ng_factory::events::PlainPoolDeployed::match_and_decode(log)
{
let add_pool =
abi::crypto_swap_ng_factory::functions::DeployPlainPool::match_and_decode(
call,
)?;
let component_id = &call.return_data[12..];
Some(ProtocolComponent {
id: hex::encode(component_id),
tx: Some(Transaction {
to: tx.to.clone(),
from: tx.from.clone(),
hash: tx.hash.clone(),
index: tx.index.into(),
}),
tokens: pool_added.coins.into(),
contracts: vec![component_id.into()],
static_att: vec![
Attribute {
name: "pool_type".into(),
value: "Pool".into(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "name".into(),
value: add_pool.name.into(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "fee".into(),
value: pool_added.fee.to_string().into(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "a".into(),
value: pool_added.a.to_string().into(),
change: ChangeType::Creation.into(),
},
],
change: ChangeType::Creation.into(),
protocol_type: Some(ProtocolType {
name: "crypto_swap_ng".into(),
financial_type: FinancialType::Swap.into(),
attribute_schema: Vec::new(),
implementation_type: ImplementationType::Vm.into(),
}),
})
} else if let Some(pool_added) =
abi::crypto_swap_ng_factory::events::MetaPoolDeployed::match_and_decode(log)
{
let add_pool =
abi::crypto_swap_ng_factory::functions::DeployMetapool::match_and_decode(call)?;
let component_id = &call.return_data[12..];
Some(ProtocolComponent {
id: hex::encode(component_id),
tx: Some(Transaction {
to: tx.to.clone(),
from: tx.from.clone(),
hash: tx.hash.clone(),
index: tx.index.into(),
}),
tokens: vec![pool_added.coin, pool_added.base_pool],
contracts: vec![component_id.into()],
static_att: vec![
Attribute {
name: "pool_type".into(),
value: "Pool".into(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "name".into(),
value: add_pool.name.into(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "fee".into(),
value: pool_added.fee.to_string().into(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "a".into(),
value: pool_added.a.to_string().into(),
change: ChangeType::Creation.into(),
},
],
change: ChangeType::Creation.into(),
protocol_type: Some(ProtocolType {
name: "crypto_swap_ng".into(),
financial_type: FinancialType::Swap.into(),
attribute_schema: Vec::new(),
implementation_type: ImplementationType::Vm.into(),
}),
})
} else {
None
}
}
TRICRYPTO_FACTORY => {
if let Some(pool_added) =
abi::tricrypto_factory::events::TricryptoPoolDeployed::match_and_decode(log)
{
Some(ProtocolComponent {
id: hex::encode(&pool_added.pool),
tx: Some(Transaction {
to: tx.to.clone(),
from: tx.from.clone(),
hash: tx.hash.clone(),
index: tx.index.into(),
}),
tokens: pool_added.coins.into(),
contracts: vec![pool_added.pool.into()],
static_att: vec![
Attribute {
name: "pool_type".into(),
value: "Pool".into(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "name".into(),
value: pool_added.name.into(),
change: ChangeType::Creation.into(),
},
],
change: ChangeType::Creation.into(),
protocol_type: Some(ProtocolType {
name: "tricrypto".into(),
financial_type: FinancialType::Swap.into(),
attribute_schema: Vec::new(),
implementation_type: ImplementationType::Vm.into(),
}),
})
} else {
None
}
}
_ => None,
}
}

View File

@@ -89,11 +89,11 @@ fn create_component(
}
}
fn parse_params(params: &String) -> Result<HashMap<String, PoolQueryParams>, anyhow::Error> {
fn parse_params(params: &str) -> Result<HashMap<String, PoolQueryParams>, anyhow::Error> {
let pools: HashMap<String, PoolQueryParams> = params
.split(PARAMS_SEPERATOR)
.map(|param| {
let pool: PoolQueryParams = serde_qs::from_str(&param)
let pool: PoolQueryParams = serde_qs::from_str(param)
.with_context(|| format!("Failed to parse pool query params: {0}", param))?;
Ok((pool.tx_hash.clone(), pool))
})

View File

@@ -19,7 +19,7 @@ binaries:
modules:
- name: map_components
kind: map
initialBlock: 19355224
initialBlock: 18830232
inputs:
- params: string
- source: sf.ethereum.type.v2.Block
@@ -28,7 +28,7 @@ modules:
- name: store_components
kind: store
initialBlock: 19355224
initialBlock: 18830232
updatePolicy: add
valueType: int64
inputs:
@@ -36,7 +36,7 @@ modules:
- name: store_component_tokens
kind: store
initialBlock: 19355224
initialBlock: 18830232
updatePolicy: set
valueType: string
inputs:
@@ -44,7 +44,7 @@ modules:
- name: map_relative_balances
kind: map
initialBlock: 19355224 # An arbitrary block that should change based on your requirements
initialBlock: 18830232 # An arbitrary block that should change based on your requirements
inputs:
- source: sf.ethereum.type.v2.Block
- store: store_components
@@ -54,7 +54,7 @@ modules:
- name: store_balances
kind: store
initialBlock: 19355224
initialBlock: 18830232
updatePolicy: add
valueType: bigint
inputs:
@@ -62,7 +62,7 @@ modules:
- name: map_protocol_changes
kind: map
initialBlock: 19355224
initialBlock: 18830232
inputs:
- source: sf.ethereum.type.v2.Block
- map: map_components