From a117056c00c7117fc5761a1bdb239a98f030b657 Mon Sep 17 00:00:00 2001 From: fishTsai20 <123794723+fishTsai20@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:51:10 +0800 Subject: [PATCH 1/6] feat[curve-finance]:handle tricryptopool deployed --- subgraphs/curve-finance/abis/Registry.json | 1073 ++++++++++++++--- .../configurations.json | 5 + .../config/templates/curve.template.yaml | 38 +- .../src/mappings/registryMappings.ts | 47 +- 4 files changed, 974 insertions(+), 189 deletions(-) diff --git a/subgraphs/curve-finance/abis/Registry.json b/subgraphs/curve-finance/abis/Registry.json index 9f5a2a9c74..42db8aa87d 100644 --- a/subgraphs/curve-finance/abis/Registry.json +++ b/subgraphs/curve-finance/abis/Registry.json @@ -2,19 +2,71 @@ { "name": "CryptoPoolDeployed", "inputs": [ - { "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", "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", + "indexed": false + } ], "anonymous": false, "type": "event" @@ -22,41 +74,89 @@ { "name": "LiquidityGaugeDeployed", "inputs": [ - { "name": "pool", "type": "address", "indexed": false }, - { "name": "token", "type": "address", "indexed": false }, - { "name": "gauge", "type": "address", "indexed": false } + { + "name": "pool", + "type": "address", + "indexed": false + }, + { + "name": "token", + "type": "address", + "indexed": false + }, + { + "name": "gauge", + "type": "address", + "indexed": false + } ], "anonymous": false, "type": "event" }, { "name": "PoolAdded", - "inputs": [{ "name": "pool", "type": "address", "indexed": true }], + "inputs": [ + { + "name": "pool", + "type": "address", + "indexed": true + } + ], "anonymous": false, "type": "event" }, { "name": "PoolAdded", "inputs": [ - { "name": "pool", "type": "address", "indexed": true }, - { "name": "rate_method_id", "type": "bytes", "indexed": false } + { + "name": "pool", + "type": "address", + "indexed": true + }, + { + "name": "rate_method_id", + "type": "bytes", + "indexed": false + } ], "anonymous": false, "type": "event" }, { "name": "BasePoolAdded", - "inputs": [{ "name": "base_pool", "type": "address", "indexed": false }], + "inputs": [ + { + "name": "base_pool", + "type": "address", + "indexed": false + } + ], "anonymous": false, "type": "event" }, { "name": "PlainPoolDeployed", "inputs": [ - { "name": "coins", "type": "address[4]", "indexed": false }, - { "name": "A", "type": "uint256", "indexed": false }, - { "name": "fee", "type": "uint256", "indexed": false }, - { "name": "deployer", "type": "address", "indexed": false } + { + "name": "coins", + "type": "address[4]", + "indexed": false + }, + { + "name": "A", + "type": "uint256", + "indexed": false + }, + { + "name": "fee", + "type": "uint256", + "indexed": false + }, + { + "name": "deployer", + "type": "address", + "indexed": false + } ], "anonymous": false, "type": "event" @@ -64,11 +164,31 @@ { "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 } + { + "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" @@ -76,8 +196,88 @@ { "name": "LiquidityGaugeDeployed", "inputs": [ - { "name": "pool", "type": "address", "indexed": false }, - { "name": "gauge", "type": "address", "indexed": false } + { + "name": "pool", + "type": "address", + "indexed": false + }, + { + "name": "gauge", + "type": "address", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "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" @@ -85,15 +285,30 @@ { "stateMutability": "nonpayable", "type": "constructor", - "inputs": [{ "name": "_fee_receiver", "type": "address" }], + "inputs": [ + { + "name": "_fee_receiver", + "type": "address" + } + ], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "metapool_implementations", - "inputs": [{ "name": "_base_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "address[10]" }], + "inputs": [ + { + "name": "_base_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address[10]" + } + ], "gas": 21716 }, { @@ -101,46 +316,102 @@ "type": "function", "name": "find_pool_for_coins", "inputs": [ - { "name": "_from", "type": "address" }, - { "name": "_to", "type": "address" } + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + } ], - "outputs": [{ "name": "", "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" } + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "i", + "type": "uint256" + } ], - "outputs": [{ "name": "", "type": "address" }] + "outputs": [ + { + "name": "", + "type": "address" + } + ] }, { "stateMutability": "view", "type": "function", "name": "get_base_pool", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "address" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 2663 }, { "stateMutability": "view", "type": "function", "name": "get_n_coins", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "uint256" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], "gas": 2699 }, { "stateMutability": "view", "type": "function", "name": "get_meta_n_coins", - "inputs": [{ "name": "_pool", "type": "address" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], "outputs": [ - { "name": "", "type": "uint256" }, - { "name": "", "type": "uint256" } + { + "name": "", + "type": "uint256" + }, + { + "name": "", + "type": "uint256" + } ], "gas": 5201 }, @@ -148,74 +419,165 @@ "stateMutability": "view", "type": "function", "name": "get_coins", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "address[4]" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address[4]" + } + ], "gas": 9164 }, { "stateMutability": "view", "type": "function", "name": "get_underlying_coins", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "address[8]" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address[8]" + } + ], "gas": 21345 }, { "stateMutability": "view", "type": "function", "name": "get_decimals", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "uint256[4]" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256[4]" + } + ], "gas": 20185 }, { "stateMutability": "view", "type": "function", "name": "get_underlying_decimals", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "uint256[8]" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256[8]" + } + ], "gas": 19730 }, { "stateMutability": "view", "type": "function", "name": "get_metapool_rates", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "uint256[2]" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256[2]" + } + ], "gas": 5281 }, { "stateMutability": "view", "type": "function", "name": "get_balances", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "uint256[4]" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256[4]" + } + ], "gas": 20435 }, { "stateMutability": "view", "type": "function", "name": "get_underlying_balances", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "uint256[8]" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256[8]" + } + ], "gas": 39733 }, { "stateMutability": "view", "type": "function", "name": "get_A", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "uint256" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], "gas": 3135 }, { "stateMutability": "view", "type": "function", "name": "get_fees", - "inputs": [{ "name": "_pool", "type": "address" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], "outputs": [ - { "name": "", "type": "uint256" }, - { "name": "", "type": "uint256" } + { + "name": "", + "type": "uint256" + }, + { + "name": "", + "type": "uint256" + } ], "gas": 5821 }, @@ -223,8 +585,18 @@ "stateMutability": "view", "type": "function", "name": "get_admin_balances", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "uint256[4]" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256[4]" + } + ], "gas": 13535 }, { @@ -232,14 +604,32 @@ "type": "function", "name": "get_coin_indices", "inputs": [ - { "name": "_pool", "type": "address" }, - { "name": "_from", "type": "address" }, - { "name": "_to", "type": "address" } + { + "name": "_pool", + "type": "address" + }, + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + } ], "outputs": [ - { "name": "", "type": "int128" }, - { "name": "", "type": "int128" }, - { "name": "", "type": "bool" } + { + "name": "", + "type": "int128" + }, + { + "name": "", + "type": "int128" + }, + { + "name": "", + "type": "bool" + } ], "gas": 33407 }, @@ -247,40 +637,90 @@ "stateMutability": "view", "type": "function", "name": "get_gauge", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "address" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 3089 }, { "stateMutability": "view", "type": "function", "name": "get_implementation_address", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "address" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 3119 }, { "stateMutability": "view", "type": "function", "name": "is_meta", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "bool" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ], "gas": 3152 }, { "stateMutability": "view", "type": "function", "name": "get_pool_asset_type", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "uint256" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], "gas": 5450 }, { "stateMutability": "view", "type": "function", "name": "get_fee_receiver", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "address" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 5480 }, { @@ -288,78 +728,206 @@ "type": "function", "name": "deploy_plain_pool", "inputs": [ - { "name": "_name", "type": "string" }, - { "name": "_symbol", "type": "string" }, - { "name": "_coins", "type": "address[4]" }, - { "name": "_A", "type": "uint256" }, - { "name": "_fee", "type": "uint256" } + { + "name": "_name", + "type": "string" + }, + { + "name": "_symbol", + "type": "string" + }, + { + "name": "_coins", + "type": "address[4]" + }, + { + "name": "_A", + "type": "uint256" + }, + { + "name": "_fee", + "type": "uint256" + } ], - "outputs": [{ "name": "", "type": "address" }] + "outputs": [ + { + "name": "", + "type": "address" + } + ] }, { "stateMutability": "nonpayable", "type": "function", "name": "deploy_plain_pool", "inputs": [ - { "name": "_name", "type": "string" }, - { "name": "_symbol", "type": "string" }, - { "name": "_coins", "type": "address[4]" }, - { "name": "_A", "type": "uint256" }, - { "name": "_fee", "type": "uint256" }, - { "name": "_asset_type", "type": "uint256" } + { + "name": "_name", + "type": "string" + }, + { + "name": "_symbol", + "type": "string" + }, + { + "name": "_coins", + "type": "address[4]" + }, + { + "name": "_A", + "type": "uint256" + }, + { + "name": "_fee", + "type": "uint256" + }, + { + "name": "_asset_type", + "type": "uint256" + } ], - "outputs": [{ "name": "", "type": "address" }] + "outputs": [ + { + "name": "", + "type": "address" + } + ] }, { "stateMutability": "nonpayable", "type": "function", "name": "deploy_plain_pool", "inputs": [ - { "name": "_name", "type": "string" }, - { "name": "_symbol", "type": "string" }, - { "name": "_coins", "type": "address[4]" }, - { "name": "_A", "type": "uint256" }, - { "name": "_fee", "type": "uint256" }, - { "name": "_asset_type", "type": "uint256" }, - { "name": "_implementation_idx", "type": "uint256" } + { + "name": "_name", + "type": "string" + }, + { + "name": "_symbol", + "type": "string" + }, + { + "name": "_coins", + "type": "address[4]" + }, + { + "name": "_A", + "type": "uint256" + }, + { + "name": "_fee", + "type": "uint256" + }, + { + "name": "_asset_type", + "type": "uint256" + }, + { + "name": "_implementation_idx", + "type": "uint256" + } ], - "outputs": [{ "name": "", "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": "_base_pool", + "type": "address" + }, + { + "name": "_name", + "type": "string" + }, + { + "name": "_symbol", + "type": "string" + }, + { + "name": "_coin", + "type": "address" + }, + { + "name": "_A", + "type": "uint256" + }, + { + "name": "_fee", + "type": "uint256" + } ], - "outputs": [{ "name": "", "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": "_implementation_idx", "type": "uint256" } + { + "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": "_implementation_idx", + "type": "uint256" + } ], - "outputs": [{ "name": "", "type": "address" }] + "outputs": [ + { + "name": "", + "type": "address" + } + ] }, { "stateMutability": "nonpayable", "type": "function", "name": "deploy_gauge", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "address" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 93079 }, { @@ -367,10 +935,22 @@ "type": "function", "name": "add_base_pool", "inputs": [ - { "name": "_base_pool", "type": "address" }, - { "name": "_fee_receiver", "type": "address" }, - { "name": "_asset_type", "type": "uint256" }, - { "name": "_implementations", "type": "address[10]" } + { + "name": "_base_pool", + "type": "address" + }, + { + "name": "_fee_receiver", + "type": "address" + }, + { + "name": "_asset_type", + "type": "uint256" + }, + { + "name": "_implementations", + "type": "address[10]" + } ], "outputs": [], "gas": 1206132 @@ -380,8 +960,14 @@ "type": "function", "name": "set_metapool_implementations", "inputs": [ - { "name": "_base_pool", "type": "address" }, - { "name": "_implementations", "type": "address[10]" } + { + "name": "_base_pool", + "type": "address" + }, + { + "name": "_implementations", + "type": "address[10]" + } ], "outputs": [], "gas": 382072 @@ -391,8 +977,14 @@ "type": "function", "name": "set_plain_implementations", "inputs": [ - { "name": "_n_coins", "type": "uint256" }, - { "name": "_implementations", "type": "address[10]" } + { + "name": "_n_coins", + "type": "uint256" + }, + { + "name": "_implementations", + "type": "address[10]" + } ], "outputs": [], "gas": 379687 @@ -401,7 +993,12 @@ "stateMutability": "nonpayable", "type": "function", "name": "set_gauge_implementation", - "inputs": [{ "name": "_gauge_implementation", "type": "address" }], + "inputs": [ + { + "name": "_gauge_implementation", + "type": "address" + } + ], "outputs": [], "gas": 38355 }, @@ -410,8 +1007,14 @@ "type": "function", "name": "batch_set_pool_asset_type", "inputs": [ - { "name": "_pools", "type": "address[32]" }, - { "name": "_asset_types", "type": "uint256[32]" } + { + "name": "_pools", + "type": "address[32]" + }, + { + "name": "_asset_types", + "type": "uint256[32]" + } ], "outputs": [], "gas": 1139545 @@ -420,7 +1023,12 @@ "stateMutability": "nonpayable", "type": "function", "name": "commit_transfer_ownership", - "inputs": [{ "name": "_addr", "type": "address" }], + "inputs": [ + { + "name": "_addr", + "type": "address" + } + ], "outputs": [], "gas": 38415 }, @@ -436,7 +1044,12 @@ "stateMutability": "nonpayable", "type": "function", "name": "set_manager", - "inputs": [{ "name": "_manager", "type": "address" }], + "inputs": [ + { + "name": "_manager", + "type": "address" + } + ], "outputs": [], "gas": 40996 }, @@ -445,8 +1058,14 @@ "type": "function", "name": "set_fee_receiver", "inputs": [ - { "name": "_base_pool", "type": "address" }, - { "name": "_fee_receiver", "type": "address" } + { + "name": "_base_pool", + "type": "address" + }, + { + "name": "_fee_receiver", + "type": "address" + } ], "outputs": [], "gas": 38770 @@ -456,15 +1075,30 @@ "type": "function", "name": "convert_metapool_fees", "inputs": [], - "outputs": [{ "name": "", "type": "bool" }], + "outputs": [ + { + "name": "", + "type": "bool" + } + ], "gas": 12880 }, { "stateMutability": "nonpayable", "type": "function", "name": "add_existing_metapools", - "inputs": [{ "name": "_pools", "type": "address[10]" }], - "outputs": [{ "name": "", "type": "bool" }], + "inputs": [ + { + "name": "_pools", + "type": "address[10]" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ], "gas": 8610792 }, { @@ -472,7 +1106,12 @@ "type": "function", "name": "admin", "inputs": [], - "outputs": [{ "name": "", "type": "address" }], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 3438 }, { @@ -480,7 +1119,12 @@ "type": "function", "name": "future_admin", "inputs": [], - "outputs": [{ "name": "", "type": "address" }], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 3468 }, { @@ -488,15 +1132,30 @@ "type": "function", "name": "manager", "inputs": [], - "outputs": [{ "name": "", "type": "address" }], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 3498 }, { "stateMutability": "view", "type": "function", "name": "pool_list", - "inputs": [{ "name": "arg0", "type": "uint256" }], - "outputs": [{ "name": "", "type": "address" }], + "inputs": [ + { + "name": "arg0", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 3573 }, { @@ -504,15 +1163,30 @@ "type": "function", "name": "pool_count", "inputs": [], - "outputs": [{ "name": "", "type": "uint256" }], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], "gas": 3558 }, { "stateMutability": "view", "type": "function", "name": "base_pool_list", - "inputs": [{ "name": "arg0", "type": "uint256" }], - "outputs": [{ "name": "", "type": "address" }], + "inputs": [ + { + "name": "arg0", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 3633 }, { @@ -520,15 +1194,30 @@ "type": "function", "name": "base_pool_count", "inputs": [], - "outputs": [{ "name": "", "type": "uint256" }], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], "gas": 3618 }, { "stateMutability": "view", "type": "function", "name": "base_pool_assets", - "inputs": [{ "name": "arg0", "type": "address" }], - "outputs": [{ "name": "", "type": "bool" }], + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ], "gas": 3863 }, { @@ -536,10 +1225,21 @@ "type": "function", "name": "plain_implementations", "inputs": [ - { "name": "arg0", "type": "uint256" }, - { "name": "arg1", "type": "uint256" } + { + "name": "arg0", + "type": "uint256" + }, + { + "name": "arg1", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } ], - "outputs": [{ "name": "", "type": "address" }], "gas": 3838 }, { @@ -547,38 +1247,83 @@ "type": "function", "name": "gauge_implementation", "inputs": [], - "outputs": [{ "name": "", "type": "address" }], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 3708 }, { "stateMutability": "view", "type": "function", "name": "get_pool_name", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "string" }], + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "string" + } + ], "gas": 8323 }, { "stateMutability": "view", "type": "function", "name": "get_lp_token", - "inputs": [{ "name": "arg0", "type": "address" }], - "outputs": [{ "name": "", "type": "address" }], + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 2473 }, { "stateMutability": "view", "type": "function", "name": "get_token", - "inputs": [{ "name": "_pool", "type": "address" }], - "outputs": [{ "name": "", "type": "address" }] + "inputs": [ + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ] }, { "stateMutability": "view", "type": "function", "name": "get_pool_from_lp_token", - "inputs": [{ "name": "arg0", "type": "address" }], - "outputs": [{ "name": "", "type": "address" }], + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ], "gas": 2443 } ] diff --git a/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json b/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json index 12bb1682be..d6f2905850 100644 --- a/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json +++ b/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json @@ -36,6 +36,11 @@ "name": "CryptoPoolFactory", "address": "0xF18056Bbd320E96A48e3Fbf8bC061322531aac99", "startBlock": "14005321" + }, + { + "name": "CurveTricryptoFactory", + "address": "0x0c0e5f2ff0ff18a3be9b835635039256dc4b4963", + "startBlock": "17371439" } ], diff --git a/subgraphs/curve-finance/protocols/curve-finance/config/templates/curve.template.yaml b/subgraphs/curve-finance/protocols/curve-finance/config/templates/curve.template.yaml index d9bdd2aa1f..808ed6f3f8 100644 --- a/subgraphs/curve-finance/protocols/curve-finance/config/templates/curve.template.yaml +++ b/subgraphs/curve-finance/protocols/curve-finance/config/templates/curve.template.yaml @@ -45,7 +45,7 @@ dataSources: file: ./abis/AddressProvider.json - name: ERC20 file: ./abis/ERC20.json - + ########################################### ############## Price Oracle ############### ########################################### @@ -97,9 +97,11 @@ dataSources: handler: handleMetaPoolDeployed - event: LiquidityGaugeDeployed(address,address) handler: handleLiquidityGaugeDeployed - + - event: CryptoPoolDeployed(address,address[2],uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,address) handler: handleCryptoPoolDeployed + - event: TricryptoPoolDeployed(address,string,string,address,address[3],address,bytes32,uint256,uint256,uint256,uint256,uint256,address) + handler: handleTricryptoPoolDeployed - event: LiquidityGaugeDeployed(address,address,address) handler: handleLiquidityGaugeDeployedWithToken file: ./src/mappings/registryMappings.ts @@ -139,7 +141,7 @@ dataSources: file: ./abis/Minter.json - name: ERC20 file: ./abis/ERC20.json - + ########################################### ############## Price Oracle ############### ########################################### @@ -182,11 +184,11 @@ dataSources: handler: handleTokenExchange - event: TokenExchange(indexed address,uint256,uint256,uint256,uint256,uint256,uint256) handler: handleTokenExchangeWithPriceScale - + - event: TokenExchangeUnderlying(indexed address,int128,uint256,int128,uint256) handler: handleTokenExchangeUnderlying receipt: true - + - event: AddLiquidity(indexed address,uint256[3],uint256,uint256) handler: handleAddLiquidity - event: AddLiquidity(indexed address,uint256[3],uint256,uint256,uint256) @@ -197,7 +199,7 @@ dataSources: handler: handleAddLiquidityWithFees - event: AddLiquidity(indexed address,uint256[4],uint256[4],uint256,uint256) handler: handleAddLiquidityWithFees - + - event: RemoveLiquidity(indexed address,uint256[2],uint256) handler: handleRemoveLiquidity receipt: true @@ -213,7 +215,7 @@ dataSources: - event: RemoveLiquidity(indexed address,uint256[4],uint256[4],uint256) handler: handleRemoveLiquidityWithFees receipt: true - + - event: RemoveLiquidityOne(indexed address,uint256,uint256) handler: handleRemoveLiquidityOne receipt: true @@ -223,7 +225,7 @@ dataSources: - event: RemoveLiquidityOne(indexed address,uint256,uint256,uint256,uint256,uint256) handler: handleRemoveLiquidityOneWithPriceScale receipt: true - + - event: RemoveLiquidityImbalance(indexed address,uint256[2],uint256[2],uint256,uint256) handler: handleRemoveLiquidityImbalance receipt: true @@ -265,7 +267,7 @@ dataSources: file: ./abis/AddressProvider.json - name: ERC20 file: ./abis/ERC20.json - + ########################################### ############## Price Oracle ############### ########################################### @@ -309,7 +311,7 @@ dataSources: - event: DeployedGauge(indexed address,indexed address,indexed address,bytes32,address) handler: handleDeployedGauge file: ./src/mappings/gaugeControllerMappings.ts - + templates: - name: PoolTemplate @@ -343,7 +345,7 @@ templates: file: ./abis/Minter.json - name: ERC20 file: ./abis/ERC20.json - + ########################################### ############## Price Oracle ############### ########################################### @@ -386,11 +388,11 @@ templates: handler: handleTokenExchange - event: TokenExchange(indexed address,uint256,uint256,uint256,uint256,uint256,uint256) handler: handleTokenExchangeWithPriceScale - + - event: TokenExchangeUnderlying(indexed address,int128,uint256,int128,uint256) handler: handleTokenExchangeUnderlying receipt: true - + - event: AddLiquidity(indexed address,uint256[3],uint256,uint256) handler: handleAddLiquidity - event: AddLiquidity(indexed address,uint256[3],uint256,uint256,uint256) @@ -401,7 +403,7 @@ templates: handler: handleAddLiquidityWithFees - event: AddLiquidity(indexed address,uint256[4],uint256[4],uint256,uint256) handler: handleAddLiquidityWithFees - + - event: RemoveLiquidity(indexed address,uint256[2],uint256) handler: handleRemoveLiquidity receipt: true @@ -417,7 +419,7 @@ templates: - event: RemoveLiquidity(indexed address,uint256[4],uint256[4],uint256) handler: handleRemoveLiquidityWithFees receipt: true - + - event: RemoveLiquidityOne(indexed address,uint256,uint256) handler: handleRemoveLiquidityOne receipt: true @@ -427,7 +429,7 @@ templates: - event: RemoveLiquidityOne(indexed address,uint256,uint256,uint256,uint256,uint256) handler: handleRemoveLiquidityOneWithPriceScale receipt: true - + - event: RemoveLiquidityImbalance(indexed address,uint256[2],uint256[2],uint256,uint256) handler: handleRemoveLiquidityImbalance receipt: true @@ -438,7 +440,7 @@ templates: handler: handleRemoveLiquidityImbalance receipt: true file: ./src/mappings/poolMappings.ts - + - name: LiquidityGauge kind: ethereum/contract network: {{ network }} @@ -471,7 +473,7 @@ templates: file: ./abis/Minter.json - name: ERC20 file: ./abis/ERC20.json - + ########################################### ############## Price Oracle ############### ########################################### diff --git a/subgraphs/curve-finance/src/mappings/registryMappings.ts b/subgraphs/curve-finance/src/mappings/registryMappings.ts index 9ae1d106f2..0626f813ca 100644 --- a/subgraphs/curve-finance/src/mappings/registryMappings.ts +++ b/subgraphs/curve-finance/src/mappings/registryMappings.ts @@ -1,17 +1,19 @@ import { - getOrCreateLpToken, - getOrCreateLiquidityPool, getOrCreateLiquidityGauge, + getOrCreateLiquidityPool, + getOrCreateLpToken, + getOrCreateToken, } from "../common/initializers"; import { - PoolAdded, - PoolAdded1, BasePoolAdded, - MetaPoolDeployed, - PlainPoolDeployed, CryptoPoolDeployed, - LiquidityGaugeDeployed1 as LiquidityGaugeDeployed, LiquidityGaugeDeployed as LiquidityGaugeDeployedWithToken, + LiquidityGaugeDeployed1 as LiquidityGaugeDeployed, + MetaPoolDeployed, + PlainPoolDeployed, + PoolAdded, + PoolAdded1, + TricryptoPoolDeployed, } from "../../generated/templates/PoolTemplate/Registry"; import * as utils from "../common/utils"; import { Address, log } from "@graphprotocol/graph-ts"; @@ -207,6 +209,37 @@ export function handleLiquidityGaugeDeployed( ); } +export function handleTricryptoPoolDeployed( + event: TricryptoPoolDeployed +): void { + const poolAddress = event.params.pool; + const name = event.params.name; + const symbol = event.params.symbol; + const poolCoins = event.params.coins; + const registryAddress = event.address; + + const pool = getOrCreateLiquidityPool(poolAddress, event.block); + + pool._registryAddress = registryAddress.toHexString(); + pool.name = name; + pool.symbol = symbol; + const inputTokens: string[] = []; + for (let i = 0; i < poolCoins.length; i++) { + inputTokens.push(getOrCreateToken(poolCoins[i], event.block).id); + } + pool._inputTokensOrdered = inputTokens; + pool.save(); + + log.warning( + "[TricryptoPoolDeployed] PoolAddress: {}, registryAddress: {}, TxnHash: {}", + [ + pool.id, + registryAddress.toHexString(), + event.transaction.hash.toHexString(), + ] + ); +} + export function handleLiquidityGaugeDeployedWithToken( event: LiquidityGaugeDeployedWithToken ): void { From b0df1e6342ae2fe51f78705d42ffe029fc38fa7c Mon Sep 17 00:00:00 2001 From: fishTsai20 <123794723+fishTsai20@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:47:18 +0800 Subject: [PATCH 2/6] fix[curve-finance]:add old pool(cDai/cUSDC) which not deployed by factory address --- .../deployments/curve-finance-ethereum/configurations.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json b/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json index d6f2905850..a2550d92a0 100644 --- a/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json +++ b/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json @@ -314,6 +314,12 @@ "address": "0xed279fdd11ca84beef15af5d39bb4d4bee23f0ca", "lpToken": "0xed279fdd11ca84beef15af5d39bb4d4bee23f0ca", "startBlock": "12242627" + }, + { + "name": "oldcontract", + "address": "0x2e60cf74d81ac34eb21eeff58db4d385920ef419", + "lpToken": "0x2e60cf74d81ac34eb21eeff58db4d385920ef419", + "startBlock": "9325883" } ], From 922e0a73d7572949f32af3fcb5f759d0cf542725 Mon Sep 17 00:00:00 2001 From: fishTsai20 <123794723+fishTsai20@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:48:41 +0800 Subject: [PATCH 3/6] fix[curve-finance]:add old pool(cDai/cUSDC) which not deployed by factory address --- .../deployments/curve-finance-ethereum/configurations.json | 1 - 1 file changed, 1 deletion(-) diff --git a/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json b/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json index a2550d92a0..9ca650c3ed 100644 --- a/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json +++ b/subgraphs/curve-finance/protocols/curve-finance/config/deployments/curve-finance-ethereum/configurations.json @@ -318,7 +318,6 @@ { "name": "oldcontract", "address": "0x2e60cf74d81ac34eb21eeff58db4d385920ef419", - "lpToken": "0x2e60cf74d81ac34eb21eeff58db4d385920ef419", "startBlock": "9325883" } ], From 5914d91069c385c54175da1dcc34b01622d5bff5 Mon Sep 17 00:00:00 2001 From: fishTsai20 <123794723+fishTsai20@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:53:17 +0800 Subject: [PATCH 4/6] fix[curve-finance]:RemoveLiquidityOneWithPriceScale When pool is tricrypto-pool, sometimes not exist Transfer event that from_address = pool_address and to_address = provider, when RemoveLiquidityOneWithPriceScale event occured. Such as pool='0x7F86Bf177Dd4F3494b841a37e810A34dD56c829B', transaction_hash='0x1804be3e0c5ffa486baefd537b9e393e7d2b53f1abf829e98d10bfa8f12b1d6a'. But the event provide 2 args: coin_amount, coin_idx. When handle RemoveLiquidityOneWithPriceScale, there is no need to use transfer event to get the withdraw tokens and amounts. --- .../src/mappings/poolMappings.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/subgraphs/curve-finance/src/mappings/poolMappings.ts b/subgraphs/curve-finance/src/mappings/poolMappings.ts index f7217292d0..b8db7adfe6 100644 --- a/subgraphs/curve-finance/src/mappings/poolMappings.ts +++ b/subgraphs/curve-finance/src/mappings/poolMappings.ts @@ -20,6 +20,9 @@ import { import { Swap } from "../modules/Swap"; import { Deposit } from "../modules/Deposit"; import { Withdraw } from "../modules/Withdraw"; +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import * as constants from "../common/constants"; +import { getOrCreateLiquidityPool } from "../common/initializers"; export function handleTokenExchange(event: TokenExchange): void { const buyer = event.params.buyer; @@ -263,10 +266,24 @@ export function handleRemoveLiquidityOneWithPriceScale( const provider = event.params.provider; const liquidityPoolAddress = event.address; const outputTokenBurntAmount = event.params.token_amount; + const withdrawCoinAmount = event.params.coin_amount; + const withdrawCoinIndex = event.params.coin_index; + const pool = getOrCreateLiquidityPool(liquidityPoolAddress, event.block); + const inputTokens = pool._inputTokensOrdered; + const withdrawnTokenAmounts: BigInt[] = []; + + for (let idx = 0; idx < inputTokens.length; idx++) { + if ((idx = withdrawCoinIndex.toI32())) { + withdrawnTokenAmounts.push(withdrawCoinAmount); + continue; + } + + withdrawnTokenAmounts.push(constants.BIGINT_ZERO); + } Withdraw( liquidityPoolAddress, - [], + withdrawnTokenAmounts, outputTokenBurntAmount, null, provider, From a3ecde60af3400c0b864d282af3dbc92dfb636e4 Mon Sep 17 00:00:00 2001 From: fishTsai20 Date: Thu, 18 Jul 2024 17:41:02 +0800 Subject: [PATCH 5/6] fix[curve-finance]:RemoveLiquidityOneWithPriceScale When pool is tricrypto-pool, sometimes not exist Transfer event that from_address = pool_address and to_address = provider, when RemoveLiquidityOneWithPriceScale event occured. Such as pool='0x7F86Bf177Dd4F3494b841a37e810A34dD56c829B', transaction_hash='0x1804be3e0c5ffa486baefd537b9e393e7d2b53f1abf829e98d10bfa8f12b1d6a'. But the event provide 2 args: coin_amount, coin_idx. When handle RemoveLiquidityOneWithPriceScale, there is no need to use transfer event to get the withdraw tokens and amounts. --- deployment/deployment.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deployment.json b/deployment/deployment.json index ae553dd67e..28e502c732 100644 --- a/deployment/deployment.json +++ b/deployment/deployment.json @@ -2774,7 +2774,7 @@ "status": "prod", "versions": { "schema": "1.3.0", - "subgraph": "1.1.3", + "subgraph": "1.1.4", "methodology": "1.0.0" }, "files": { From 66f71b0b0572292a8e77991ec82c3edf796c63df Mon Sep 17 00:00:00 2001 From: fishTsai20 Date: Thu, 22 Aug 2024 17:24:44 +0800 Subject: [PATCH 6/6] fix[curve-finance]:Delete import Address --- subgraphs/curve-finance/src/mappings/poolMappings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subgraphs/curve-finance/src/mappings/poolMappings.ts b/subgraphs/curve-finance/src/mappings/poolMappings.ts index b8db7adfe6..9ab3ffa6a6 100644 --- a/subgraphs/curve-finance/src/mappings/poolMappings.ts +++ b/subgraphs/curve-finance/src/mappings/poolMappings.ts @@ -20,7 +20,7 @@ import { import { Swap } from "../modules/Swap"; import { Deposit } from "../modules/Deposit"; import { Withdraw } from "../modules/Withdraw"; -import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { BigInt } from "@graphprotocol/graph-ts"; import * as constants from "../common/constants"; import { getOrCreateLiquidityPool } from "../common/initializers";