diff --git a/src/adaptors/balancer-v2/abis/balancer_token_admin.json b/src/adaptors/balancer-v2/abis/balancer_token_admin.json new file mode 100644 index 0000000000..b7483501aa --- /dev/null +++ b/src/adaptors/balancer-v2/abis/balancer_token_admin.json @@ -0,0 +1,243 @@ +[ + { + "inputs": [ + { "internalType": "contract IVault", "name": "vault", "type": "address" }, + { + "internalType": "contract IBalancerToken", + "name": "balancerToken", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supply", + "type": "uint256" + } + ], + "name": "MiningParametersUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "INITIAL_RATE", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATE_DENOMINATOR", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATE_REDUCTION_COEFFICIENT", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATE_REDUCTION_TIME", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "activate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "available_supply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "futureEpochTimeWrite", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "future_epoch_time_write", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes4", "name": "selector", "type": "bytes4" } + ], + "name": "getActionId", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { "internalType": "contract IAuthorizer", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAvailableSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBalancerToken", + "outputs": [ + { + "internalType": "contract IBalancerToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFutureEpochTime", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getInflationRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMiningEpoch", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStartEpochSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStartEpochTime", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVault", + "outputs": [ + { "internalType": "contract IVault", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "start", "type": "uint256" }, + { "internalType": "uint256", "name": "end", "type": "uint256" } + ], + "name": "mintableInTimeframe", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "start", "type": "uint256" }, + { "internalType": "uint256", "name": "end", "type": "uint256" } + ], + "name": "mintable_in_timeframe", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "snapshot", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "startEpochTimeWrite", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "start_epoch_time_write", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateMiningParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "update_mining_parameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/adaptors/balancer-v2/abis/gauge_arbitrum.json b/src/adaptors/balancer-v2/abis/gauge_arbitrum.json index 9bb7316e2c..dc3e730e30 100644 --- a/src/adaptors/balancer-v2/abis/gauge_arbitrum.json +++ b/src/adaptors/balancer-v2/abis/gauge_arbitrum.json @@ -1,130 +1,199 @@ [ { - "name": "Deposit", + "name": "Approval", "inputs": [ - { "name": "provider", "type": "address", "indexed": true }, - { "name": "value", "type": "uint256", "indexed": false } + { "name": "_owner", "type": "address", "indexed": true }, + { "name": "_spender", "type": "address", "indexed": true }, + { "name": "_value", "type": "uint256", "indexed": false } ], "anonymous": false, "type": "event" }, { - "name": "Withdraw", + "name": "Transfer", "inputs": [ - { "name": "provider", "type": "address", "indexed": true }, - { "name": "value", "type": "uint256", "indexed": false } + { "name": "_from", "type": "address", "indexed": true }, + { "name": "_to", "type": "address", "indexed": true }, + { "name": "_value", "type": "uint256", "indexed": false } ], "anonymous": false, "type": "event" }, { - "name": "Transfer", + "name": "Deposit", "inputs": [ - { "name": "_from", "type": "address", "indexed": true }, - { "name": "_to", "type": "address", "indexed": true }, + { "name": "_user", "type": "address", "indexed": true }, { "name": "_value", "type": "uint256", "indexed": false } ], "anonymous": false, "type": "event" }, { - "name": "Approval", + "name": "Withdraw", "inputs": [ - { "name": "_owner", "type": "address", "indexed": true }, - { "name": "_spender", "type": "address", "indexed": true }, + { "name": "_user", "type": "address", "indexed": true }, { "name": "_value", "type": "uint256", "indexed": false } ], "anonymous": false, "type": "event" }, + { + "name": "UpdateLiquidityLimit", + "inputs": [ + { "name": "_user", "type": "address", "indexed": true }, + { "name": "_original_balance", "type": "uint256", "indexed": false }, + { "name": "_original_supply", "type": "uint256", "indexed": false }, + { "name": "_working_balance", "type": "uint256", "indexed": false }, + { "name": "_working_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, { "stateMutability": "nonpayable", "type": "constructor", "inputs": [ - { "name": "_bal_token", "type": "address" }, - { "name": "_vault", "type": "address" }, - { "name": "_authorizerAdaptor", "type": "address" } + { "name": "_voting_escrow_delegation_proxy", "type": "address" }, + { "name": "_bal_pseudo_minter", "type": "address" }, + { "name": "_authorizer_adaptor", "type": "address" }, + { "name": "_version", "type": "string" } ], "outputs": [] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "decimals", - "inputs": [], - "outputs": [{ "name": "", "type": "uint256" }] + "name": "deposit", + "inputs": [{ "name": "_value", "type": "uint256" }], + "outputs": [] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "version", - "inputs": [], - "outputs": [{ "name": "", "type": "string" }] + "name": "deposit", + "inputs": [ + { "name": "_value", "type": "uint256" }, + { "name": "_user", "type": "address" } + ], + "outputs": [] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "reward_contract", - "inputs": [], - "outputs": [{ "name": "", "type": "address" }] + "name": "withdraw", + "inputs": [{ "name": "_value", "type": "uint256" }], + "outputs": [] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "last_claim", - "inputs": [], - "outputs": [{ "name": "", "type": "uint256" }] + "name": "withdraw", + "inputs": [ + { "name": "_value", "type": "uint256" }, + { "name": "_user", "type": "address" } + ], + "outputs": [] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "claimed_reward", + "name": "transferFrom", "inputs": [ - { "name": "_addr", "type": "address" }, - { "name": "_token", "type": "address" } + { "name": "_from", "type": "address" }, + { "name": "_to", "type": "address" }, + { "name": "_value", "type": "uint256" } ], - "outputs": [{ "name": "", "type": "uint256" }] + "outputs": [{ "name": "", "type": "bool" }] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "claimable_reward", + "name": "approve", "inputs": [ - { "name": "_addr", "type": "address" }, - { "name": "_token", "type": "address" } + { "name": "_spender", "type": "address" }, + { "name": "_value", "type": "uint256" } ], - "outputs": [{ "name": "", "type": "uint256" }] + "outputs": [{ "name": "", "type": "bool" }] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "reward_data", - "inputs": [{ "name": "_token", "type": "address" }], - "outputs": [ - { - "name": "", - "type": "tuple", - "components": [ - { "name": "token", "type": "address" }, - { "name": "distributor", "type": "address" }, - { "name": "period_finish", "type": "uint256" }, - { "name": "rate", "type": "uint256" }, - { "name": "last_update", "type": "uint256" }, - { "name": "integral", "type": "uint256" } - ] - } - ] + "name": "permit", + "inputs": [ + { "name": "_owner", "type": "address" }, + { "name": "_spender", "type": "address" }, + { "name": "_value", "type": "uint256" }, + { "name": "_deadline", "type": "uint256" }, + { "name": "_v", "type": "uint8" }, + { "name": "_r", "type": "bytes32" }, + { "name": "_s", "type": "bytes32" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "transfer", + "inputs": [ + { "name": "_to", "type": "address" }, + { "name": "_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "increaseAllowance", + "inputs": [ + { "name": "_spender", "type": "address" }, + { "name": "_added_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "decreaseAllowance", + "inputs": [ + { "name": "_spender", "type": "address" }, + { "name": "_subtracted_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] }, { "stateMutability": "nonpayable", "type": "function", - "name": "claimable_reward_write", + "name": "user_checkpoint", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claimable_tokens", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "claimed_reward", "inputs": [ { "name": "_addr", "type": "address" }, { "name": "_token", "type": "address" } ], "outputs": [{ "name": "", "type": "uint256" }] }, + { + "stateMutability": "view", + "type": "function", + "name": "claimable_reward", + "inputs": [ + { "name": "_user", "type": "address" }, + { "name": "_reward_token", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }] + }, { "stateMutability": "nonpayable", "type": "function", @@ -159,68 +228,64 @@ { "stateMutability": "nonpayable", "type": "function", - "name": "deposit", - "inputs": [{ "name": "_value", "type": "uint256" }], + "name": "claim_rewards", + "inputs": [ + { "name": "_addr", "type": "address" }, + { "name": "_receiver", "type": "address" }, + { "name": "_reward_indexes", "type": "uint256[]" } + ], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", - "name": "deposit", + "name": "add_reward", "inputs": [ - { "name": "_value", "type": "uint256" }, - { "name": "_addr", "type": "address" } + { "name": "_reward_token", "type": "address" }, + { "name": "_distributor", "type": "address" } ], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", - "name": "deposit", + "name": "set_reward_distributor", "inputs": [ - { "name": "_value", "type": "uint256" }, - { "name": "_addr", "type": "address" }, - { "name": "_claim_rewards", "type": "bool" } + { "name": "_reward_token", "type": "address" }, + { "name": "_distributor", "type": "address" } ], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", - "name": "withdraw", - "inputs": [{ "name": "_value", "type": "uint256" }], + "name": "deposit_reward_token", + "inputs": [ + { "name": "_reward_token", "type": "address" }, + { "name": "_amount", "type": "uint256" } + ], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", - "name": "withdraw", - "inputs": [ - { "name": "_value", "type": "uint256" }, - { "name": "_claim_rewards", "type": "bool" } - ], + "name": "killGauge", + "inputs": [], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", - "name": "transfer", - "inputs": [ - { "name": "_to", "type": "address" }, - { "name": "_value", "type": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "unkillGauge", + "inputs": [], + "outputs": [] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "transferFrom", - "inputs": [ - { "name": "_from", "type": "address" }, - { "name": "_to", "type": "address" }, - { "name": "_value", "type": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "decimals", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", @@ -233,60 +298,39 @@ "outputs": [{ "name": "", "type": "uint256" }] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "approve", - "inputs": [ - { "name": "_spender", "type": "address" }, - { "name": "_value", "type": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "integrate_checkpoint", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "permit", - "inputs": [ - { "name": "_owner", "type": "address" }, - { "name": "_spender", "type": "address" }, - { "name": "_value", "type": "uint256" }, - { "name": "_deadline", "type": "uint256" }, - { "name": "_v", "type": "uint8" }, - { "name": "_r", "type": "bytes32" }, - { "name": "_s", "type": "bytes32" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "bal_token", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "increaseAllowance", - "inputs": [ - { "name": "_spender", "type": "address" }, - { "name": "_added_value", "type": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "bal_pseudo_minter", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "decreaseAllowance", - "inputs": [ - { "name": "_spender", "type": "address" }, - { "name": "_subtracted_value", "type": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "voting_escrow_delegation_proxy", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "set_rewards", - "inputs": [ - { "name": "_reward_contract", "type": "address" }, - { "name": "_claim_sig", "type": "bytes32" }, - { "name": "_reward_tokens", "type": "address[8]" } - ], - "outputs": [] + "name": "authorizer_adaptor", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "nonpayable", @@ -294,17 +338,37 @@ "name": "initialize", "inputs": [ { "name": "_lp_token", "type": "address" }, - { "name": "_reward_contract", "type": "address" }, - { "name": "_claim_sig", "type": "bytes32" } + { "name": "_version", "type": "string" } ], "outputs": [] }, { "stateMutability": "view", "type": "function", - "name": "lp_token", + "name": "DOMAIN_SEPARATOR", "inputs": [], - "outputs": [{ "name": "", "type": "address" }] + "outputs": [{ "name": "", "type": "bytes32" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "nonces", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "name", + "inputs": [], + "outputs": [{ "name": "", "type": "string" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [{ "name": "", "type": "string" }] }, { "stateMutability": "view", @@ -323,66 +387,120 @@ { "stateMutability": "view", "type": "function", - "name": "name", + "name": "lp_token", "inputs": [], - "outputs": [{ "name": "", "type": "string" }] + "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", - "name": "symbol", + "name": "version", "inputs": [], "outputs": [{ "name": "", "type": "string" }] }, { "stateMutability": "view", "type": "function", - "name": "DOMAIN_SEPARATOR", + "name": "factory", "inputs": [], - "outputs": [{ "name": "", "type": "bytes32" }] + "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", - "name": "nonces", + "name": "working_balances", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", - "name": "reward_tokens", + "name": "working_supply", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "period", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "period_timestamp", "inputs": [{ "name": "arg0", "type": "uint256" }], - "outputs": [{ "name": "", "type": "address" }] + "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", - "name": "reward_balances", + "name": "integrate_checkpoint_of", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", - "name": "rewards_receiver", + "name": "integrate_fraction", "inputs": [{ "name": "arg0", "type": "address" }], - "outputs": [{ "name": "", "type": "address" }] + "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", - "name": "claim_sig", - "inputs": [], - "outputs": [{ "name": "", "type": "bytes" }] + "name": "integrate_inv_supply", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", - "name": "reward_integral", + "name": "integrate_inv_supply_of", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_count", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_tokens", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "address" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_data", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [ + { + "name": "", + "type": "tuple", + "components": [ + { "name": "distributor", "type": "address" }, + { "name": "period_finish", "type": "uint256" }, + { "name": "rate", "type": "uint256" }, + { "name": "last_update", "type": "uint256" }, + { "name": "integral", "type": "uint256" } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "rewards_receiver", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "address" }] + }, { "stateMutability": "view", "type": "function", @@ -392,5 +510,19 @@ { "name": "arg1", "type": "address" } ], "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "is_killed", + "inputs": [], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "inflation_rate", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }] } ] diff --git a/src/adaptors/balancer-v2/abis/gauge_base.json b/src/adaptors/balancer-v2/abis/gauge_base.json new file mode 100644 index 0000000000..dc3e730e30 --- /dev/null +++ b/src/adaptors/balancer-v2/abis/gauge_base.json @@ -0,0 +1,528 @@ +[ + { + "name": "Approval", + "inputs": [ + { "name": "_owner", "type": "address", "indexed": true }, + { "name": "_spender", "type": "address", "indexed": true }, + { "name": "_value", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "Transfer", + "inputs": [ + { "name": "_from", "type": "address", "indexed": true }, + { "name": "_to", "type": "address", "indexed": true }, + { "name": "_value", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "Deposit", + "inputs": [ + { "name": "_user", "type": "address", "indexed": true }, + { "name": "_value", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "Withdraw", + "inputs": [ + { "name": "_user", "type": "address", "indexed": true }, + { "name": "_value", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateLiquidityLimit", + "inputs": [ + { "name": "_user", "type": "address", "indexed": true }, + { "name": "_original_balance", "type": "uint256", "indexed": false }, + { "name": "_original_supply", "type": "uint256", "indexed": false }, + { "name": "_working_balance", "type": "uint256", "indexed": false }, + { "name": "_working_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "stateMutability": "nonpayable", + "type": "constructor", + "inputs": [ + { "name": "_voting_escrow_delegation_proxy", "type": "address" }, + { "name": "_bal_pseudo_minter", "type": "address" }, + { "name": "_authorizer_adaptor", "type": "address" }, + { "name": "_version", "type": "string" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "deposit", + "inputs": [{ "name": "_value", "type": "uint256" }], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "deposit", + "inputs": [ + { "name": "_value", "type": "uint256" }, + { "name": "_user", "type": "address" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "withdraw", + "inputs": [{ "name": "_value", "type": "uint256" }], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "withdraw", + "inputs": [ + { "name": "_value", "type": "uint256" }, + { "name": "_user", "type": "address" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "transferFrom", + "inputs": [ + { "name": "_from", "type": "address" }, + { "name": "_to", "type": "address" }, + { "name": "_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "approve", + "inputs": [ + { "name": "_spender", "type": "address" }, + { "name": "_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "permit", + "inputs": [ + { "name": "_owner", "type": "address" }, + { "name": "_spender", "type": "address" }, + { "name": "_value", "type": "uint256" }, + { "name": "_deadline", "type": "uint256" }, + { "name": "_v", "type": "uint8" }, + { "name": "_r", "type": "bytes32" }, + { "name": "_s", "type": "bytes32" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "transfer", + "inputs": [ + { "name": "_to", "type": "address" }, + { "name": "_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "increaseAllowance", + "inputs": [ + { "name": "_spender", "type": "address" }, + { "name": "_added_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "decreaseAllowance", + "inputs": [ + { "name": "_spender", "type": "address" }, + { "name": "_subtracted_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "user_checkpoint", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claimable_tokens", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "claimed_reward", + "inputs": [ + { "name": "_addr", "type": "address" }, + { "name": "_token", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "claimable_reward", + "inputs": [ + { "name": "_user", "type": "address" }, + { "name": "_reward_token", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "set_rewards_receiver", + "inputs": [{ "name": "_receiver", "type": "address" }], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_rewards", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_rewards", + "inputs": [{ "name": "_addr", "type": "address" }], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_rewards", + "inputs": [ + { "name": "_addr", "type": "address" }, + { "name": "_receiver", "type": "address" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_rewards", + "inputs": [ + { "name": "_addr", "type": "address" }, + { "name": "_receiver", "type": "address" }, + { "name": "_reward_indexes", "type": "uint256[]" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "add_reward", + "inputs": [ + { "name": "_reward_token", "type": "address" }, + { "name": "_distributor", "type": "address" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "set_reward_distributor", + "inputs": [ + { "name": "_reward_token", "type": "address" }, + { "name": "_distributor", "type": "address" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "deposit_reward_token", + "inputs": [ + { "name": "_reward_token", "type": "address" }, + { "name": "_amount", "type": "uint256" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "killGauge", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "unkillGauge", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "view", + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "allowance", + "inputs": [ + { "name": "owner", "type": "address" }, + { "name": "spender", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_checkpoint", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "bal_token", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "bal_pseudo_minter", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "voting_escrow_delegation_proxy", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "authorizer_adaptor", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "initialize", + "inputs": [ + { "name": "_lp_token", "type": "address" }, + { "name": "_version", "type": "string" } + ], + "outputs": [] + }, + { + "stateMutability": "view", + "type": "function", + "name": "DOMAIN_SEPARATOR", + "inputs": [], + "outputs": [{ "name": "", "type": "bytes32" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "nonces", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "name", + "inputs": [], + "outputs": [{ "name": "", "type": "string" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [{ "name": "", "type": "string" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "balanceOf", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "lp_token", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "version", + "inputs": [], + "outputs": [{ "name": "", "type": "string" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "factory", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "working_balances", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "working_supply", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "period", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "period_timestamp", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_checkpoint_of", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_fraction", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_inv_supply", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_inv_supply_of", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_count", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_tokens", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "address" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_data", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [ + { + "name": "", + "type": "tuple", + "components": [ + { "name": "distributor", "type": "address" }, + { "name": "period_finish", "type": "uint256" }, + { "name": "rate", "type": "uint256" }, + { "name": "last_update", "type": "uint256" }, + { "name": "integral", "type": "uint256" } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "rewards_receiver", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "address" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_integral_for", + "inputs": [ + { "name": "arg0", "type": "address" }, + { "name": "arg1", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "is_killed", + "inputs": [], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "inflation_rate", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }] + } +] diff --git a/src/adaptors/balancer-v2/abis/gauge_polygon.json b/src/adaptors/balancer-v2/abis/gauge_polygon.json index 9bb7316e2c..dc3e730e30 100644 --- a/src/adaptors/balancer-v2/abis/gauge_polygon.json +++ b/src/adaptors/balancer-v2/abis/gauge_polygon.json @@ -1,130 +1,199 @@ [ { - "name": "Deposit", + "name": "Approval", "inputs": [ - { "name": "provider", "type": "address", "indexed": true }, - { "name": "value", "type": "uint256", "indexed": false } + { "name": "_owner", "type": "address", "indexed": true }, + { "name": "_spender", "type": "address", "indexed": true }, + { "name": "_value", "type": "uint256", "indexed": false } ], "anonymous": false, "type": "event" }, { - "name": "Withdraw", + "name": "Transfer", "inputs": [ - { "name": "provider", "type": "address", "indexed": true }, - { "name": "value", "type": "uint256", "indexed": false } + { "name": "_from", "type": "address", "indexed": true }, + { "name": "_to", "type": "address", "indexed": true }, + { "name": "_value", "type": "uint256", "indexed": false } ], "anonymous": false, "type": "event" }, { - "name": "Transfer", + "name": "Deposit", "inputs": [ - { "name": "_from", "type": "address", "indexed": true }, - { "name": "_to", "type": "address", "indexed": true }, + { "name": "_user", "type": "address", "indexed": true }, { "name": "_value", "type": "uint256", "indexed": false } ], "anonymous": false, "type": "event" }, { - "name": "Approval", + "name": "Withdraw", "inputs": [ - { "name": "_owner", "type": "address", "indexed": true }, - { "name": "_spender", "type": "address", "indexed": true }, + { "name": "_user", "type": "address", "indexed": true }, { "name": "_value", "type": "uint256", "indexed": false } ], "anonymous": false, "type": "event" }, + { + "name": "UpdateLiquidityLimit", + "inputs": [ + { "name": "_user", "type": "address", "indexed": true }, + { "name": "_original_balance", "type": "uint256", "indexed": false }, + { "name": "_original_supply", "type": "uint256", "indexed": false }, + { "name": "_working_balance", "type": "uint256", "indexed": false }, + { "name": "_working_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, { "stateMutability": "nonpayable", "type": "constructor", "inputs": [ - { "name": "_bal_token", "type": "address" }, - { "name": "_vault", "type": "address" }, - { "name": "_authorizerAdaptor", "type": "address" } + { "name": "_voting_escrow_delegation_proxy", "type": "address" }, + { "name": "_bal_pseudo_minter", "type": "address" }, + { "name": "_authorizer_adaptor", "type": "address" }, + { "name": "_version", "type": "string" } ], "outputs": [] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "decimals", - "inputs": [], - "outputs": [{ "name": "", "type": "uint256" }] + "name": "deposit", + "inputs": [{ "name": "_value", "type": "uint256" }], + "outputs": [] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "version", - "inputs": [], - "outputs": [{ "name": "", "type": "string" }] + "name": "deposit", + "inputs": [ + { "name": "_value", "type": "uint256" }, + { "name": "_user", "type": "address" } + ], + "outputs": [] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "reward_contract", - "inputs": [], - "outputs": [{ "name": "", "type": "address" }] + "name": "withdraw", + "inputs": [{ "name": "_value", "type": "uint256" }], + "outputs": [] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "last_claim", - "inputs": [], - "outputs": [{ "name": "", "type": "uint256" }] + "name": "withdraw", + "inputs": [ + { "name": "_value", "type": "uint256" }, + { "name": "_user", "type": "address" } + ], + "outputs": [] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "claimed_reward", + "name": "transferFrom", "inputs": [ - { "name": "_addr", "type": "address" }, - { "name": "_token", "type": "address" } + { "name": "_from", "type": "address" }, + { "name": "_to", "type": "address" }, + { "name": "_value", "type": "uint256" } ], - "outputs": [{ "name": "", "type": "uint256" }] + "outputs": [{ "name": "", "type": "bool" }] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "claimable_reward", + "name": "approve", "inputs": [ - { "name": "_addr", "type": "address" }, - { "name": "_token", "type": "address" } + { "name": "_spender", "type": "address" }, + { "name": "_value", "type": "uint256" } ], - "outputs": [{ "name": "", "type": "uint256" }] + "outputs": [{ "name": "", "type": "bool" }] }, { - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", - "name": "reward_data", - "inputs": [{ "name": "_token", "type": "address" }], - "outputs": [ - { - "name": "", - "type": "tuple", - "components": [ - { "name": "token", "type": "address" }, - { "name": "distributor", "type": "address" }, - { "name": "period_finish", "type": "uint256" }, - { "name": "rate", "type": "uint256" }, - { "name": "last_update", "type": "uint256" }, - { "name": "integral", "type": "uint256" } - ] - } - ] + "name": "permit", + "inputs": [ + { "name": "_owner", "type": "address" }, + { "name": "_spender", "type": "address" }, + { "name": "_value", "type": "uint256" }, + { "name": "_deadline", "type": "uint256" }, + { "name": "_v", "type": "uint8" }, + { "name": "_r", "type": "bytes32" }, + { "name": "_s", "type": "bytes32" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "transfer", + "inputs": [ + { "name": "_to", "type": "address" }, + { "name": "_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "increaseAllowance", + "inputs": [ + { "name": "_spender", "type": "address" }, + { "name": "_added_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "decreaseAllowance", + "inputs": [ + { "name": "_spender", "type": "address" }, + { "name": "_subtracted_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }] }, { "stateMutability": "nonpayable", "type": "function", - "name": "claimable_reward_write", + "name": "user_checkpoint", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claimable_tokens", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "claimed_reward", "inputs": [ { "name": "_addr", "type": "address" }, { "name": "_token", "type": "address" } ], "outputs": [{ "name": "", "type": "uint256" }] }, + { + "stateMutability": "view", + "type": "function", + "name": "claimable_reward", + "inputs": [ + { "name": "_user", "type": "address" }, + { "name": "_reward_token", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }] + }, { "stateMutability": "nonpayable", "type": "function", @@ -159,68 +228,64 @@ { "stateMutability": "nonpayable", "type": "function", - "name": "deposit", - "inputs": [{ "name": "_value", "type": "uint256" }], + "name": "claim_rewards", + "inputs": [ + { "name": "_addr", "type": "address" }, + { "name": "_receiver", "type": "address" }, + { "name": "_reward_indexes", "type": "uint256[]" } + ], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", - "name": "deposit", + "name": "add_reward", "inputs": [ - { "name": "_value", "type": "uint256" }, - { "name": "_addr", "type": "address" } + { "name": "_reward_token", "type": "address" }, + { "name": "_distributor", "type": "address" } ], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", - "name": "deposit", + "name": "set_reward_distributor", "inputs": [ - { "name": "_value", "type": "uint256" }, - { "name": "_addr", "type": "address" }, - { "name": "_claim_rewards", "type": "bool" } + { "name": "_reward_token", "type": "address" }, + { "name": "_distributor", "type": "address" } ], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", - "name": "withdraw", - "inputs": [{ "name": "_value", "type": "uint256" }], + "name": "deposit_reward_token", + "inputs": [ + { "name": "_reward_token", "type": "address" }, + { "name": "_amount", "type": "uint256" } + ], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", - "name": "withdraw", - "inputs": [ - { "name": "_value", "type": "uint256" }, - { "name": "_claim_rewards", "type": "bool" } - ], + "name": "killGauge", + "inputs": [], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", - "name": "transfer", - "inputs": [ - { "name": "_to", "type": "address" }, - { "name": "_value", "type": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "unkillGauge", + "inputs": [], + "outputs": [] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "transferFrom", - "inputs": [ - { "name": "_from", "type": "address" }, - { "name": "_to", "type": "address" }, - { "name": "_value", "type": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "decimals", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", @@ -233,60 +298,39 @@ "outputs": [{ "name": "", "type": "uint256" }] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "approve", - "inputs": [ - { "name": "_spender", "type": "address" }, - { "name": "_value", "type": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "integrate_checkpoint", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "permit", - "inputs": [ - { "name": "_owner", "type": "address" }, - { "name": "_spender", "type": "address" }, - { "name": "_value", "type": "uint256" }, - { "name": "_deadline", "type": "uint256" }, - { "name": "_v", "type": "uint8" }, - { "name": "_r", "type": "bytes32" }, - { "name": "_s", "type": "bytes32" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "bal_token", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "increaseAllowance", - "inputs": [ - { "name": "_spender", "type": "address" }, - { "name": "_added_value", "type": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "bal_pseudo_minter", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "decreaseAllowance", - "inputs": [ - { "name": "_spender", "type": "address" }, - { "name": "_subtracted_value", "type": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool" }] + "name": "voting_escrow_delegation_proxy", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] }, { - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", - "name": "set_rewards", - "inputs": [ - { "name": "_reward_contract", "type": "address" }, - { "name": "_claim_sig", "type": "bytes32" }, - { "name": "_reward_tokens", "type": "address[8]" } - ], - "outputs": [] + "name": "authorizer_adaptor", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "nonpayable", @@ -294,17 +338,37 @@ "name": "initialize", "inputs": [ { "name": "_lp_token", "type": "address" }, - { "name": "_reward_contract", "type": "address" }, - { "name": "_claim_sig", "type": "bytes32" } + { "name": "_version", "type": "string" } ], "outputs": [] }, { "stateMutability": "view", "type": "function", - "name": "lp_token", + "name": "DOMAIN_SEPARATOR", "inputs": [], - "outputs": [{ "name": "", "type": "address" }] + "outputs": [{ "name": "", "type": "bytes32" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "nonces", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "name", + "inputs": [], + "outputs": [{ "name": "", "type": "string" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [{ "name": "", "type": "string" }] }, { "stateMutability": "view", @@ -323,66 +387,120 @@ { "stateMutability": "view", "type": "function", - "name": "name", + "name": "lp_token", "inputs": [], - "outputs": [{ "name": "", "type": "string" }] + "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", - "name": "symbol", + "name": "version", "inputs": [], "outputs": [{ "name": "", "type": "string" }] }, { "stateMutability": "view", "type": "function", - "name": "DOMAIN_SEPARATOR", + "name": "factory", "inputs": [], - "outputs": [{ "name": "", "type": "bytes32" }] + "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", - "name": "nonces", + "name": "working_balances", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", - "name": "reward_tokens", + "name": "working_supply", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "period", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "period_timestamp", "inputs": [{ "name": "arg0", "type": "uint256" }], - "outputs": [{ "name": "", "type": "address" }] + "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", - "name": "reward_balances", + "name": "integrate_checkpoint_of", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", - "name": "rewards_receiver", + "name": "integrate_fraction", "inputs": [{ "name": "arg0", "type": "address" }], - "outputs": [{ "name": "", "type": "address" }] + "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", - "name": "claim_sig", - "inputs": [], - "outputs": [{ "name": "", "type": "bytes" }] + "name": "integrate_inv_supply", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", - "name": "reward_integral", + "name": "integrate_inv_supply_of", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_count", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_tokens", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "address" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_data", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [ + { + "name": "", + "type": "tuple", + "components": [ + { "name": "distributor", "type": "address" }, + { "name": "period_finish", "type": "uint256" }, + { "name": "rate", "type": "uint256" }, + { "name": "last_update", "type": "uint256" }, + { "name": "integral", "type": "uint256" } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "rewards_receiver", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "address" }] + }, { "stateMutability": "view", "type": "function", @@ -392,5 +510,19 @@ { "name": "arg1", "type": "address" } ], "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "is_killed", + "inputs": [], + "outputs": [{ "name": "", "type": "bool" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "inflation_rate", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }] } ] diff --git a/src/adaptors/balancer-v2/childChainGauges.js b/src/adaptors/balancer-v2/childChainGauges.js new file mode 100644 index 0000000000..a730ff8ee9 --- /dev/null +++ b/src/adaptors/balancer-v2/childChainGauges.js @@ -0,0 +1,48 @@ +const { request, gql } = require('graphql-request'); +const { capitalizeFirstLetter } = require('../utils'); + +const urlBase = 'https://api.thegraph.com/subgraphs/name/balancer-labs'; +const urlGaugesEthereum = `${urlBase}/balancer-gauges`; + +// For reference - this is how chains are stored in the gauges subgraph +// const chainToEnum = { +// arbitrum: 0, +// xdai: 1, +// polygon: 2, +// optimism: 3, +// avalanche: 4, +// polygonZkEvm: 5, +// base: 6, +// }; + +const queryChildGauge = gql` + query ($chain: String!) { + rootGauges(where: { chain: $chain }) { + chain + id + recipient + relativeWeightCap + } + } +`; + +/** + * @param chain chainString + * @returns array of: {chain, id (root gauge address on ethereum), recipient (gauge on child chain), relativeWeightCap} + */ +const getChildChainRootGauge = async (chain) => { + chain = capitalizeFirstLetter(chain); + + const variables = { chain }; + const { rootGauges } = await request( + urlGaugesEthereum, + queryChildGauge, + variables + ); + + return rootGauges; +}; + +module.exports = { + getChildChainRootGauge, +}; diff --git a/src/adaptors/balancer-v2/index.js b/src/adaptors/balancer-v2/index.js index 7ff9749a9c..807c71f428 100755 --- a/src/adaptors/balancer-v2/index.js +++ b/src/adaptors/balancer-v2/index.js @@ -1,16 +1,19 @@ const superagent = require('superagent'); const { request, gql } = require('graphql-request'); -const sdk = require('@defillama/sdk'); +const sdk = require('@defillama/sdk4'); const utils = require('../utils'); const gaugeABIEthereum = require('./abis/gauge_ethereum.json'); const gaugeABIArbitrum = require('./abis/gauge_arbitrum.json'); const gaugeABIPolygon = require('./abis/gauge_polygon.json'); const gaugeABIGnosis = require('./abis/gauge_gnosis.json'); +const gaugeABIBase = require('./abis/gauge_base.json'); +const balTokenAdminABI = require('./abis/balancer_token_admin.json'); const gaugeControllerEthereum = require('./abis/gauge_controller_ethereum.json'); const protocolFeesCollectorABI = require('./abis/protocol_fees_collector.json'); const { lte } = require('lodash'); const { excludePools } = require('../../utils/exclude'); +const { getChildChainRootGauge } = require('./childChainGauges.js'); // Subgraph URLs const urlBase = 'https://api.thegraph.com/subgraphs/name/balancer-labs'; @@ -18,14 +21,17 @@ const urlEthereum = `${urlBase}/balancer-v2`; const urlPolygon = `${urlBase}/balancer-polygon-v2`; const urlGnosis = `${urlBase}/balancer-gnosis-chain-v2`; const urlArbitrum = `${urlBase}/balancer-arbitrum-v2`; +const urlBaseChain = `https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest`; const urlGaugesEthereum = `${urlBase}/balancer-gauges`; const urlGaugesPolygon = `${urlBase}/balancer-gauges-polygon`; const urlGaugesGnosis = `${urlBase}/balancer-gauges-gnosis-chain`; const urlGaugesArbitrum = `${urlBase}/balancer-gauges-arbitrum`; +const urlGaugesBase = `https://api.studio.thegraph.com/query/24660/balancer-gauges-base/version/latest`; const protocolFeesCollector = '0xce88686553686DA562CE7Cea497CE749DA109f9F'; const gaugeController = '0xC128468b7Ce63eA702C1f104D55A2566b13D3ABD'; +const balancerTokenAdmin = '0xf302f9F50958c5593770FDf4d4812309fF77414f'; const BAL = '0xba100000625a3754423978a60c9317c58a424e3d'; @@ -223,26 +229,30 @@ const aprLM = async (tvlData, urlLM, queryLM, chainString, gaugeABI) => { // get liquidity gauges for each pool const { liquidityGauges } = await request(urlLM, queryLM); - // get BAL inflation rate (constant among gauge contract ids) - let inflationRate; - let price; - if (chainString === 'ethereum') { - inflationRate = - ( - await sdk.api.abi.call({ - target: liquidityGauges[0].id, - abi: gaugeABI.find((n) => n.name === 'inflation_rate'), - chain: chainString, - }) - ).output / 1e18; - - // get BAL price - const key = `${chainString}:${BAL}`.toLowerCase(); - price = ( - await superagent.get(`https://coins.llama.fi/prices/current/${key}`) - ).body.coins[key].price; + let childChainRootGauges; + if (chainString != 'ethereum') { + childChainRootGauges = await getChildChainRootGauge(chainString); } + // Global source of truth for the inflation rate. All mainnet gauges use the BalancerTokenAdmin contract to update their locally stored inflation rate during checkpoints. + const inflationRate = + ( + await sdk.api.abi.call({ + target: balancerTokenAdmin, + abi: balTokenAdminABI.find((n) => n.name === 'getInflationRate'), + chain: 'ethereum', + }) + ).output / 1e18; + + // Price is used for additional non-BAL reward tokens + let price; + + // get BAL price + const balKey = `ethereum:${BAL}`.toLowerCase(); + const balPrice = ( + await superagent.get(`https://coins.llama.fi/prices/current/${balKey}`) + ).body.coins[balKey].price; + // add LM rewards if available to each pool in data for (const pool of liquidityGauges) { try { @@ -254,40 +264,52 @@ const aprLM = async (tvlData, urlLM, queryLM, chainString, gaugeABI) => { const aprLMRewards = []; const rewardTokens = []; - if (chainString === 'ethereum') { - // get relative weight (of base BAL token rewards for a pool) - const relativeWeight = + // pool.id returned for mainnet will be the correct gauge address required for the gauge_relative_weight call + let relativeWeightParams = pool.id; + + // pool.id returned for child chains is the child chain gauge, so we must replace this with it's mainnet root chain gauge that gauge_relative_weight expects. + if (chainString != 'ethereum') { + const poolGaugeOnEthereum = childChainRootGauges.find( + (gauge) => gauge.recipient == pool.id + ); + + if (poolGaugeOnEthereum) { + relativeWeightParams = poolGaugeOnEthereum.id; + } + } + + // get relative weight (of base BAL token rewards for a pool) + const relativeWeight = + ( + await sdk.api.abi.call({ + target: gaugeController, + abi: gaugeControllerEthereum.find( + (n) => n.name === 'gauge_relative_weight' + ), + params: [relativeWeightParams], + chain: 'ethereum', + }) + ).output / 1e18; + + // for base BAL rewards + if (relativeWeight !== 0) { + const workingSupply = ( await sdk.api.abi.call({ - target: gaugeController, - abi: gaugeControllerEthereum.find( - (n) => n.name === 'gauge_relative_weight' - ), - params: [pool.id], - chain: 'ethereum', + target: pool.id, + abi: gaugeABI.find((n) => n.name === 'working_supply'), + chain: chainString, }) ).output / 1e18; - // for base BAL rewards - if (relativeWeight !== 0) { - const workingSupply = - ( - await sdk.api.abi.call({ - target: pool.id, - abi: gaugeABI.find((n) => n.name === 'working_supply'), - chain: 'ethereum', - }) - ).output / 1e18; - - // bpt == balancer pool token - const bptPrice = x.tvl / x.totalShares; - const balPayable = inflationRate * 7 * 86400 * relativeWeight; - const weeklyReward = (0.4 / (workingSupply + 0.4)) * balPayable; - const yearlyReward = weeklyReward * 52 * price; - const aprLM = (yearlyReward / bptPrice) * 100; - aprLMRewards.push(aprLM === Infinity ? 0 : aprLM); - rewardTokens.push(BAL); - } + // bpt == balancer pool token + const bptPrice = x.tvl / x.totalShares; + const balPayable = inflationRate * 7 * 86400 * relativeWeight; + const weeklyReward = (0.4 / (workingSupply + 0.4)) * balPayable; + const yearlyReward = weeklyReward * 52 * balPrice; + const aprLM = (yearlyReward / bptPrice) * 100; + aprLMRewards.push(aprLM === Infinity ? 0 : aprLM); + rewardTokens.push(BAL); } // first need to find the reward token @@ -507,6 +529,16 @@ const main = async () => { gaugeABIGnosis, swapFeePercentage ), + topLvl( + 'base', + urlBaseChain, + query, + queryPrior, + urlGaugesBase, + queryGauge, + gaugeABIBase, + swapFeePercentage + ), ]); return data diff --git a/src/adaptors/basex/estimateFee.ts b/src/adaptors/basex/estimateFee.ts new file mode 100644 index 0000000000..b524af84e4 --- /dev/null +++ b/src/adaptors/basex/estimateFee.ts @@ -0,0 +1,322 @@ +// forked from uniswap.fish chads (see https://github.com/chunza2542/uniswap.fish) + +const bn = require('bignumber.js'); +const axios = require('axios'); + +interface Tick { + tickIdx: string; + liquidityNet: string; + price0: string; + price1: string; +} + +bn.config({ EXPONENTIAL_AT: 999999, DECIMAL_PLACES: 40 }); + +const Q96 = new bn(2).pow(96); + +const getTickFromPrice = ( + price: number, + token0Decimal: string, + token1Decimal: string +): number => { + const token0 = expandDecimals(price, Number(token0Decimal)); + const token1 = expandDecimals(1, Number(token1Decimal)); + const sqrtPrice = encodeSqrtPriceX96(token1).div(encodeSqrtPriceX96(token0)); + + return Math.log(sqrtPrice.toNumber()) / Math.log(Math.sqrt(1.0001)); +}; + +const getPriceFromTick = ( + tick: number, + token0Decimal: string, + token1Decimal: string +): number => { + const sqrtPrice = new bn(Math.pow(Math.sqrt(1.0001), tick)).multipliedBy( + new bn(2).pow(96) + ); + const token0 = expandDecimals(1, Number(token0Decimal)); + const token1 = expandDecimals(1, Number(token1Decimal)); + const L2 = mulDiv( + encodeSqrtPriceX96(token0), + encodeSqrtPriceX96(token1), + Q96 + ); + const price = mulDiv(L2, Q96, sqrtPrice) + .div(new bn(2).pow(96)) + .div(new bn(10).pow(token0Decimal)) + .pow(2); + + return price.toNumber(); +}; + +// for calculation detail, please visit README.md (Section: Calculation Breakdown, No. 1) +interface TokensAmount { + amount0: number; + amount1: number; +} +const getTokensAmountFromDepositAmountUSD = ( + P: number, + Pl: number, + Pu: number, + priceUSDX: number, + priceUSDY: number, + depositAmountUSD: number +): TokensAmount => { + const deltaL = + depositAmountUSD / + ((Math.sqrt(P) - Math.sqrt(Pl)) * priceUSDY + + (1 / Math.sqrt(P) - 1 / Math.sqrt(Pu)) * priceUSDX); + + let deltaY = deltaL * (Math.sqrt(P) - Math.sqrt(Pl)); + if (deltaY * priceUSDY < 0) deltaY = 0; + if (deltaY * priceUSDY > depositAmountUSD) + deltaY = depositAmountUSD / priceUSDY; + + let deltaX = deltaL * (1 / Math.sqrt(P) - 1 / Math.sqrt(Pu)); + if (deltaX * priceUSDX < 0) deltaX = 0; + if (deltaX * priceUSDX > depositAmountUSD) + deltaX = depositAmountUSD / priceUSDX; + + return { amount0: deltaX, amount1: deltaY }; +}; + +// for calculation detail, please visit README.md (Section: Calculation Breakdown, No. 2) +const getLiquidityForAmount0 = ( + sqrtRatioAX96: bn, + sqrtRatioBX96: bn, + amount0: bn +): bn => { + // amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) + const intermediate = mulDiv(sqrtRatioBX96, sqrtRatioAX96, Q96); + return mulDiv(amount0, intermediate, sqrtRatioBX96.minus(sqrtRatioAX96)); +}; + +const getLiquidityForAmount1 = ( + sqrtRatioAX96: bn, + sqrtRatioBX96: bn, + amount1: bn +): bn => { + // amount1 / (sqrt(upper) - sqrt(lower)) + return mulDiv(amount1, Q96, sqrtRatioBX96.minus(sqrtRatioAX96)); +}; + +const getSqrtPriceX96 = ( + price: number, + token0Decimal: number, + token1Decimal: number +): bn => { + const token0 = expandDecimals(price, token0Decimal); + const token1 = expandDecimals(1, token1Decimal); + + return token0.div(token1).sqrt().multipliedBy(Q96); +}; + +const getLiquidityDelta = ( + P: number, + lowerP: number, + upperP: number, + amount0: number, + amount1: number, + token0Decimal: number, + token1Decimal: number +): bn => { + const amt0 = expandDecimals(amount0, token1Decimal); + const amt1 = expandDecimals(amount1, token0Decimal); + + const sqrtRatioX96 = getSqrtPriceX96(P, token0Decimal, token1Decimal); + const sqrtRatioAX96 = getSqrtPriceX96(lowerP, token0Decimal, token1Decimal); + const sqrtRatioBX96 = getSqrtPriceX96(upperP, token0Decimal, token1Decimal); + + let liquidity: bn; + if (sqrtRatioX96.lte(sqrtRatioAX96)) { + liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amt0); + } else if (sqrtRatioX96.lt(sqrtRatioBX96)) { + const liquidity0 = getLiquidityForAmount0( + sqrtRatioX96, + sqrtRatioBX96, + amt0 + ); + const liquidity1 = getLiquidityForAmount1( + sqrtRatioAX96, + sqrtRatioX96, + amt1 + ); + + liquidity = bn.min(liquidity0, liquidity1); + } else { + liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amt1); + } + + return liquidity; +}; + +const estimateFee = ( + liquidityDelta: bn, + liquidity: bn, + volume24H: number, + feeTier: string +): number => { + const feeTierPercentage = getFeeTierPercentage(feeTier); + const liquidityPercentage = liquidityDelta + .div(liquidity.plus(liquidityDelta)) + .toNumber(); + + return feeTierPercentage * volume24H * liquidityPercentage; +}; + +const getLiquidityFromTick = (poolTicks: Tick[], tick: number): bn => { + // calculate a cumulative of liquidityNet from all ticks that poolTicks[i] <= tick + let liquidity: bn = new bn(0); + for (let i = 0; i < poolTicks.length - 1; ++i) { + liquidity = liquidity.plus(new bn(poolTicks[i].liquidityNet)); + + const lowerTick = Number(poolTicks[i].tickIdx); + const upperTick = Number(poolTicks[i + 1]?.tickIdx); + + if (lowerTick <= tick && tick <= upperTick) { + break; + } + } + + return liquidity; +}; + +// private helper functions +const encodeSqrtPriceX96 = (price: number | string | bn): bn => { + return new bn(price).sqrt().multipliedBy(Q96).integerValue(3); +}; + +const expandDecimals = (n: number | string | bn, exp: number): bn => { + return new bn(n).multipliedBy(new bn(10).pow(exp)); +}; + +const mulDiv = (a: bn, b: bn, multiplier: bn) => { + return a.multipliedBy(b).div(multiplier); +}; + +const getFeeTierPercentage = (tier: string): number => { + if (tier === '80') return 0.008 / 100; + if (tier === '450') return 0.045 / 100; + if (tier === '2500') return 0.25 / 100; + if (tier === '10000') return 1 / 100; + return 0; +}; + +const getPoolTicks = async ( + poolAddress: string, + url: string +): Promise => { + const PAGE_SIZE = 3; + let result: Tick[] = []; + let page = 0; + while (true) { + const pool1 = await _getPoolTicksByPage(poolAddress, page, url); + const pool2 = await _getPoolTicksByPage(poolAddress, page + 1, url); + const pool3 = await _getPoolTicksByPage(poolAddress, page + 2, url); + + result = [...result, ...pool1, ...pool2, ...pool3]; + if (pool1.length === 0 || pool2.length === 0 || pool3.length === 0) { + break; + } + page += PAGE_SIZE; + } + return result; +}; + +const _getPoolTicksByPage = async ( + poolAddress: string, + page: number, + url: string +): Promise => { + let res; + try { + res = await _queryUniswap( + `{ + ticks(first: 1000, skip: ${ + page * 1000 + }, where: { poolAddress: "${poolAddress}" }, orderBy: tickIdx) { + tickIdx + liquidityNet + price0 + price1 + } + }`, + url + ); + } catch (e) { + console.log('_getPoolTicksByPage failed for', poolAddress); + return []; + } + + return res === undefined ? [] : res.ticks; +}; + +const _queryUniswap = async (query: string, url: string): Promise => { + const { data } = await axios({ + url, + method: 'post', + data: { + query, + }, + }); + + return data.data; +}; + +module.exports.EstimatedFees = async ( + poolAddress, + priceAssumptionValue, + priceRangeValue, + currentPriceUSDToken1, + currentPriceUSDToken0, + depositAmountUSD, + decimalsToken0, + decimalsToken1, + feeTier, + url, + volume +) => { + const P = priceAssumptionValue; + let Pl = priceRangeValue[0]; + let Pu = priceRangeValue[1]; + const priceUSDX = currentPriceUSDToken1 || 1; + const priceUSDY = currentPriceUSDToken0 || 1; + + const { amount0, amount1 } = getTokensAmountFromDepositAmountUSD( + P, + Pl, + Pu, + priceUSDX, + priceUSDY, + depositAmountUSD + ); + + const deltaL = getLiquidityDelta( + P, + Pl, + Pu, + amount0, + amount1, + Number(decimalsToken0 || 18), + Number(decimalsToken1 || 18) + ); + + let currentTick = getTickFromPrice( + P, + decimalsToken0 || '18', + decimalsToken1 || '18' + ); + const poolTicks = await getPoolTicks(poolAddress, url); + + if (!poolTicks.length) { + console.log(`No pool ticks found for ${poolAddress}`); + return { poolAddress, estimatedFee: 0 }; + } + + const L = getLiquidityFromTick(poolTicks, currentTick); + + const estimatedFee = + P >= Pl && P <= Pu ? estimateFee(deltaL, L, volume, feeTier) : 0; + + return { poolAddress, estimatedFee }; +}; diff --git a/src/adaptors/basex/index.js b/src/adaptors/basex/index.js new file mode 100644 index 0000000000..a95974b31e --- /dev/null +++ b/src/adaptors/basex/index.js @@ -0,0 +1,246 @@ +const sdk = require('@defillama/sdk4'); +const { request, gql } = require('graphql-request'); +const superagent = require('superagent'); + +const utils = require('../utils'); +const { EstimatedFees } = require('./estimateFee'); +const { checkStablecoin } = require('../../handlers/triggerEnrichment'); +const { boundaries } = require('../../utils/exclude'); + +const url = 'https://api.thegraph.com/subgraphs/name/harleen-m/basex'; + +const query = gql` + { + pools(first: 1000, orderBy: totalValueLockedUSD, orderDirection: desc block: {number: }) { + id + totalValueLockedToken0 + totalValueLockedToken1 + volumeUSD + feeTier + token0 { + symbol + id + decimals + } + token1 { + symbol + id + decimals + } + } + } +`; + +const queryPrior = gql` + { + pools( first: 1000 orderBy: totalValueLockedUSD orderDirection:desc block: {number: }) { + id + volumeUSD + } + } +`; + +const topLvl = async ( + chainString, + url, + query, + queryPrior, + version, + timestamp, + stablecoins +) => { + try { + const [block, blockPrior] = await utils.getBlocks(chainString, timestamp, [ + url, + ]); + + const [_, blockPrior7d] = await utils.getBlocks( + chainString, + timestamp, + [url], + 604800 + ); + + // pull data + let queryC = query; + let dataNow = await request(url, queryC.replace('', block)); + dataNow = dataNow.pools; + + // uni v3 subgraph reserves values are wrong! + // instead of relying on subgraph values, gonna pull reserve data from contracts + // new tvl calc + // let + + const balanceCalls = []; + for (const pool of dataNow) { + balanceCalls.push({ + target: pool.token0.id, + params: pool.id, + }); + balanceCalls.push({ + target: pool.token1.id, + params: pool.id, + }); + } + + const tokenBalances = await sdk.api.abi.multiCall({ + abi: 'erc20:balanceOf', + calls: balanceCalls, + chain: chainString, + }); + + dataNow = dataNow.map((p) => { + const x = tokenBalances.output.filter((i) => i.input.params[0] === p.id); + return { + ...p, + reserve0: + x.find((i) => i.input.target === p.token0.id).output / + `1e${p.token0.decimals}`, + reserve1: + x.find((i) => i.input.target === p.token1.id).output / + `1e${p.token1.decimals}`, + }; + }); + + // pull 24h offset data to calculate fees from swap volume + let queryPriorC = queryPrior; + let dataPrior = await request( + url, + queryPriorC.replace('', blockPrior) + ); + dataPrior = dataPrior.pools; + + // calculate tvl + dataNow = await utils.tvl(dataNow, chainString); + + // to reduce the nb of subgraph calls for tick range, we apply the lb db filter in here + dataNow = dataNow.filter( + (p) => p.totalValueLockedUSD >= boundaries.tvlUsdDB.lb + ); + // add the symbol for the stablecoin (we need to distinguish btw stable and non stable pools + // so we apply the correct tick range) + dataNow = dataNow.map((p) => { + const symbol = utils.formatSymbol( + `${p.token0.symbol}-${p.token1.symbol}` + ); + const stablecoin = checkStablecoin({ ...p, symbol }, stablecoins); + return { + ...p, + symbol, + stablecoin, + }; + }); + + // for new v3 apy calc + const dataPrior7d = ( + await request(url, queryPriorC.replace('', blockPrior7d)) + ).pools; + + // calc apy (note: old way of using 24h fees * 365 / tvl. keeping this for now) and will store the + // new apy calc as a separate field + dataNow = dataNow.map((el) => + utils.apy(el, dataPrior, dataPrior7d, version) + ); + + dataNow = dataNow.map((p) => ({ + ...p, + token1_in_token0: p.price1 / p.price0, + })); + + // split up subgraph tick calls into n-batches + // (tick response can be in the thousands per pool) + const skip = 20; + let start = 0; + let stop = skip; + const pages = Math.floor(dataNow.length / skip); + + // tick range + const pct = 0.3; + const pctStablePool = 0.001; + + // assume an investment of 1e5 USD + const investmentAmount = 1e5; + let X = []; + for (let i = 0; i <= pages; i++) { + // console.log(i); + let promises = dataNow.slice(start, stop).map((p) => { + const delta = p.stablecoin ? pctStablePool : pct; + + const priceAssumption = p.stablecoin ? 1 : p.token1_in_token0; + + return EstimatedFees( + p.id, + priceAssumption, + [ + p.token1_in_token0 * (1 - delta), + p.token1_in_token0 * (1 + delta), + ], + p.price1, + p.price0, + investmentAmount, + p.token0.decimals, + p.token1.decimals, + p.feeTier, + url, + p.volumeUSD7d + ); + }); + X.push(await Promise.all(promises)); + start += skip; + stop += skip; + } + const d = {}; + X.flat().forEach((p) => { + d[p.poolAddress] = p.estimatedFee; + }); + + dataNow = dataNow.map((p) => ({ + ...p, + apy7d: ((d[p.id] * 52) / investmentAmount) * 100, + })); + + return dataNow.map((p) => { + const poolMeta = `${p.feeTier / 1e4}%`; + const underlyingTokens = [p.token0.id, p.token1.id]; + const token0 = underlyingTokens === undefined ? '' : underlyingTokens[0]; + const token1 = underlyingTokens === undefined ? '' : underlyingTokens[1]; + + const feeTier = Number(poolMeta.replace('%', '')) * 10000; + const url = `https://baseswap.fi/addV3?currencyIdA=${token0}¤cyIdB=${token1}&feeAmount=${feeTier}`; + + return { + pool: p.id, + chain: utils.formatChain(chainString), + project: 'basex', + poolMeta: `${poolMeta}, stablePool=${p.stablecoin}`, + symbol: p.symbol, + tvlUsd: p.totalValueLockedUSD, + apyBase: p.apy1d, + apyBase7d: p.apy7d, + underlyingTokens, + url, + volumeUsd1d: p.volumeUSD1d, + volumeUsd7d: p.volumeUSD7d, + }; + }); + } catch (e) { + console.log(chainString, e); + return []; + } +}; + +const main = async (timestamp = null) => { + const stablecoins = ( + await superagent.get( + 'https://stablecoins.llama.fi/stablecoins?includePrices=true' + ) + ).body.peggedAssets.map((s) => s.symbol.toLowerCase()); + + let data = await topLvl('base', url, query, queryPrior, 'v3', timestamp, stablecoins); + return data.filter((p) => utils.keepFinite(p)); +}; + +module.exports = { + timetravel: false, + apy: main, +}; diff --git a/src/adaptors/circuit-protocol/index.js b/src/adaptors/circuit-protocol/index.js new file mode 100644 index 0000000000..e2f02b8d5b --- /dev/null +++ b/src/adaptors/circuit-protocol/index.js @@ -0,0 +1,67 @@ +const utils = require('../utils'); + +const url = 'https://api.circuit.farm'; +const urlApy = `${url}/apy`; +const urlTvl = `${url}/tvl`; +const urlMeta = `${url}/vaults`; + +const networkMapping = { + 5000: 'mantle', +} + +const crctMapping = { + 5000: '0x0000000000000000000000000000000000000000' +} + + +const main = async () => { + const [apy, tvl, meta] = await Promise.all( + [urlApy, urlTvl, urlMeta].map((u) => utils.getData(u)) + ); + + let data = []; + for (const chain of Object.keys(networkMapping)) { + const poolData = tvl[chain]; + for (const pool of Object.keys(poolData)) { + if (apy[pool] === undefined) { + continue; + } + const poolMeta = meta.find((m) => m?.id === pool); + const platformId = poolMeta?.platformId; + + const poolId = + poolMeta === undefined + ? crctMapping[chain] + : poolMeta.earnedTokenAddress; + + const isActive = poolMeta === undefined || poolMeta.status == 'active'; + + if (!poolId) continue; + + const underlyingTokens = (!!poolMeta && poolMeta.assets.length === 1 && poolMeta.tokenAddress) ? [poolMeta.tokenAddress] : undefined; + + data.push({ + pool: `${poolId}-${networkMapping[chain]}`.toLowerCase(), + chain: utils.formatChain(networkMapping[chain]), + project: 'circuit-protocol', + symbol: + poolMeta === undefined + ? 'CRCT' + : utils.formatSymbol(poolMeta?.assets.join('-')), + tvlUsd: poolData[pool], + apy: isActive ? apy[pool] * 100 : 0, + poolMeta: + platformId === undefined ? null : utils.formatChain(platformId), + underlyingTokens, + }); + } + } + + return data; +}; + +module.exports = { + timetravel: false, + apy: main, + url: 'https://circuit.farm/', +}; diff --git a/src/adaptors/compound-v3/index.js b/src/adaptors/compound-v3/index.js index a613aa5b75..5f8eb59f90 100644 --- a/src/adaptors/compound-v3/index.js +++ b/src/adaptors/compound-v3/index.js @@ -1,7 +1,7 @@ const superagent = require('superagent'); const abi = require('./abi.js'); -const sdk = require('@defillama/sdk'); +const sdk = require('@defillama/sdk4'); const markets = [ { @@ -36,6 +36,30 @@ const markets = [ rewardToken: '0x354A6dA3fcde098F8389cad84b0182725c6C91dE', chain: 'arbitrum', }, + { + address: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf', + symbol: 'cUSDCv3-native', + underlying: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + underlyingSymbol: 'USDC', + rewardToken: '0x354A6dA3fcde098F8389cad84b0182725c6C91dE', + chain: 'arbitrum', + }, + { + address: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf', + symbol: 'cUSDbCv3', + underlying: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA', + underlyingSymbol: 'USDC', + rewardToken: '0x9e1028F5F1D5eDE59748FFceE5532509976840E0', + chain: 'base', + }, + { + address: '0x46e6b214b524310239732D51387075E0e70970bf', + symbol: 'cWETHv3', + underlying: '0x4200000000000000000000000000000000000006', + underlyingSymbol: 'WETH', + rewardToken: '0x9e1028F5F1D5eDE59748FFceE5532509976840E0', + chain: 'base', + }, ]; const main = async (pool) => { @@ -196,7 +220,7 @@ const main = async (pool) => { return [ ...collateralOnlyPools, { - pool: pool.address, + pool: pool.address === "0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf"?`${pool.address}-${pool.chain}`:pool.address, // Fix for duplicated pool id symbol: pool.underlyingSymbol, chain: pool.chain.charAt(0).toUpperCase() + pool.chain.slice(1), project: 'compound-v3', diff --git a/src/adaptors/concentrator/index.js b/src/adaptors/concentrator/index.js index d424362b30..8728304338 100755 --- a/src/adaptors/concentrator/index.js +++ b/src/adaptors/concentrator/index.js @@ -7,123 +7,54 @@ const AladdinConvexVaultABI = require('./abis/AladdinConvexVault.json'); const AladdinCRVABI = require('./abis/AladdinCRV.json'); const curvePools = require('./pools.js'); -const ALADDIN_API_BASE_URL = 'https://api.aladdin.club/' +const ALADDIN_API_BASE_URL = 'https://api.aladdin.club/'; -const concentratorVault = '0xc8fF37F7d057dF1BB9Ad681b53Fa4726f268E0e8'; -const concentratorNewVault = '0x3Cf54F3A1969be9916DAD548f3C084331C4450b5'; const concentratorAcrv = '0x2b95A1Dcc3D405535f9ed33c219ab38E8d7e0884'; - -function createIncrementArray(length) { - const arr = []; - for (let i = 0; i < length; i++) arr.push(i); - return arr; -} +const aladdinSdCRV = '0x43E54C2E7b3e294De3A155785F52AB49d87B9922'; const getAllPools = async () => { - let vaultsInfo = await utils.getData(`${ALADDIN_API_BASE_URL}api/getVaultsTvl`); - let pools = [] + let vaultsInfo = await utils.getData( + `${ALADDIN_API_BASE_URL}api1/concentrator_pool_tvl_apy` + ); + let pools = []; if (vaultsInfo.data) { - const { newVault: newVaultData, oldVault: oldVaultData, aFXSVault: aFXSVaultData, afrxETHVault: afrxETHVaultData } = vaultsInfo.data - for (let key in newVaultData) { - let _address = key; - let _tvl = parseInt(newVaultData[_address].tvl) + parseInt(oldVaultData[_address]?.tvl || 0) + parseInt(aFXSVaultData[_address]?.tvl || 0) + parseInt(afrxETHVaultData[_address]?.tvl || 0); - let _apy = Math.max(newVaultData[_address].apy.proApy, newVaultData[_address].apy.cureentApy) - const _data = { - tvl: _tvl, - apy: _apy, - symbol: newVaultData[_address].symbol, - lpToken: _address - } - pools.push(_data) - } + vaultsInfo.data.map((item) => { + pools.push({ + tvl: item.tvl, + apy: item.apy.proApy, + symbol: item.lpName, + lpToken: item.address, + }); + }); } return pools; }; -const getAcrvInfo = async () => { - let crvPrice = await utils.getData( - 'https://api.aladdin.club/api/coingecko/price?ids=convex-crv&vs_currencies=usd' - ); - crvPrice = crvPrice.data['convex-crv'].usd; - const acrvTotalUnderlying = ( - await sdk.api.abi.call({ - target: concentratorAcrv, - abi: AladdinCRVABI.totalUnderlying, - params: [], - }) - ).output; - - const acrvTotalSupply = ( - await sdk.api.abi.call({ - target: concentratorAcrv, - abi: AladdinCRVABI.totalSupply, - params: [], - }) - ).output; - - const rate = - acrvTotalSupply * 1 - ? BigNumber(acrvTotalUnderlying).div(acrvTotalSupply) - : 1; - const cvxcrvBalance = BigNumber(acrvTotalUnderlying) - .multipliedBy(rate) - .times(crvPrice) - .div(10 ** 18) - .toString(10); - - const acrvPrice = BigNumber(crvPrice).times(rate); - return { - cvxcrvBalance, - acrvPrice, - rate, - }; -}; - -const getAcrvPoolData = async () => { - let dataApy = await utils.getData( - `https://api.aladdin.club/api/convex` +const getATokenData = async () => { + let aTokenData = await utils.getData( + `${ALADDIN_API_BASE_URL}api1/concentrator_aToken_tvl_apy` ); - const acrvInfo = await getAcrvInfo() - const convexApy = getConvexInfo('CRV', dataApy)?.apy?.project || 0; - - const apy = BigNumber(parseFloat(convexApy)) - .dividedBy(100) - .dividedBy(365) - .plus(1) - .pow(365) - .minus(1) - .shiftedBy(2); - - const newObj = { - pool: `${concentratorAcrv}-concentrator`, - chain: utils.formatChain('ethereum'), - project: 'concentrator', - symbol: 'aCRV', - tvlUsd: parseInt(acrvInfo.cvxcrvBalance, 10), - apy: parseFloat(apy.toString(10)), - }; + const { aCRV, asdCRV } = aTokenData.data; + const newObj = [ + { + pool: `${concentratorAcrv}-concentrator`, + chain: utils.formatChain('ethereum'), + project: 'concentrator', + symbol: 'aCRV', + tvlUsd: parseInt(aCRV.tvl, 10), + apy: parseFloat(aCRV.apy), + }, + { + pool: `${aladdinSdCRV}-concentrator`, + chain: utils.formatChain('ethereum'), + project: 'concentrator', + symbol: 'asdCRV', + tvlUsd: parseInt(asdCRV.tvl, 10), + apy: parseFloat(asdCRV.apy), + }, + ]; return newObj; }; -const getConvexInfo = (tokenName, dataApy) => { - let data = dataApy; - try { - const info = - data.find( - (item) => - item.name.toLocaleLowerCase() === tokenName.toLocaleLowerCase() || - item.name === tokenName - ) || converWebsiteInfo.find((item) => item.name === tokenName); - - if (BigNumber(parseFloat(info.apy.current)).isNaN()) { - return converWebsiteInfo.find( - (item) => item.name === tokenName.toLocaleLowerCase() - ); - } - return info; - } catch (error) { - return null; - } -}; const buildPool = (entry, chainString) => { const newObj = { @@ -139,9 +70,9 @@ const buildPool = (entry, chainString) => { const main = async () => { const dataInfo = await getAllPools(); - const acrvData = await getAcrvPoolData(); - const data = dataInfo.map((el) => buildPool(el, 'ethereum')); - data.push(acrvData); + const aTokenData = await getATokenData(); + let data = dataInfo.map((el) => buildPool(el, 'ethereum')); + data = data.concat(aTokenData); return data.filter((p) => utils.keepFinite(p)); }; diff --git a/src/adaptors/extra-finance/compute.js b/src/adaptors/extra-finance/compute.js index 96c4916477..07fe0f1f9f 100644 --- a/src/adaptors/extra-finance/compute.js +++ b/src/adaptors/extra-finance/compute.js @@ -133,9 +133,10 @@ exports.getAllVeloPoolInfo = async function(vaults, chain, prices, lendingPools) price: token1price, } = getToken(token1) - const poolKey = `${stable ? 's' : 'v'}AMMV2-${token0_symbol}/${token1_symbol}` - // const poolInfo = veloPoolsInfo.find(veloPool => veloPool.lp.toLowerCase() === item.pair.toLowerCase()) - const poolInfo = veloPoolsInfo.find(veloPool => veloPool.symbol.toLowerCase() === poolKey.toLowerCase()) + const poolInfo = veloPoolsInfo.find(veloPool => veloPool.stable === stable && + veloPool.token1.toLowerCase() === token1.toLowerCase() && + veloPool.token0.toLowerCase() === token0.toLowerCase() + ) if (!poolInfo) { continue } @@ -152,7 +153,7 @@ exports.getAllVeloPoolInfo = async function(vaults, chain, prices, lendingPools) price: emissionsPrice, } = getToken(emissions_token) - const floorMaxLeverage = Math.floor(maxLeverage / 100) + // const floorMaxLeverage = Math.floor(maxLeverage / 100) const reserve0usd = toDecimals(reserve0, token0_decimals) * token0price const reserve1usd = toDecimals(reserve1, token1_decimals) * token1price const totalPoolTvlUsd = reserve0usd + reserve1usd diff --git a/src/adaptors/fx-protocol/abis/Common.json b/src/adaptors/fx-protocol/abis/Common.json new file mode 100644 index 0000000000..7f4cffdd96 --- /dev/null +++ b/src/adaptors/fx-protocol/abis/Common.json @@ -0,0 +1,58 @@ +{ + "totalAssets": { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + "totalSupply": { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + "getCurrentNav": { + "inputs": [], + "name": "getCurrentNav", + "outputs": [ + { + "internalType": "uint256", + "name": "_baseNav", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fNav", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_xNav", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + "tokensPerStEth": { + "inputs": [], + "name": "tokensPerStEth", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +} diff --git a/src/adaptors/fx-protocol/abis/reBalance.json b/src/adaptors/fx-protocol/abis/reBalance.json new file mode 100644 index 0000000000..d049275271 --- /dev/null +++ b/src/adaptors/fx-protocol/abis/reBalance.json @@ -0,0 +1,41 @@ +{ + "extraRewardState": { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "extraRewardState", + "outputs": [ + { + "internalType": "uint128", + "name": "rate", + "type": "uint128" + }, + { + "internalType": "uint32", + "name": "periodLength", + "type": "uint32" + }, + { + "internalType": "uint48", + "name": "lastUpdate", + "type": "uint48" + }, + { + "internalType": "uint48", + "name": "finishAt", + "type": "uint48" + }, + { + "internalType": "uint256", + "name": "queued", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +} diff --git a/src/adaptors/fx-protocol/index.js b/src/adaptors/fx-protocol/index.js new file mode 100644 index 0000000000..55034f6605 --- /dev/null +++ b/src/adaptors/fx-protocol/index.js @@ -0,0 +1,101 @@ +const superagent = require('superagent'); +const sdk = require('@defillama/sdk'); +const { default: BigNumber } = require('bignumber.js'); +const utils = require('../utils'); +const CommonAbi = require('./abis/Common.json'); +const reBalanceAbi = require('./abis/reBalance.json'); + +const ALADDIN_API_BASE_URL = 'https://api.aladdin.club/'; + +const fx_reBalancePool = '0xa677d95B91530d56791FbA72C01a862f1B01A49e'; +const fx_stETHTreasury = '0x0e5CAA5c889Bdf053c9A76395f62267E653AFbb0'; +const wstETH = '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0'; +const yearSecond = 31536000; +const cBN = (val) => new BigNumber(val); +const getTvlAndApy = async () => { + let _tvl = 0; + let _apy = 0; + try { + const rebalancesData = ( + await sdk.api.abi.call({ + target: fx_reBalancePool, + abi: CommonAbi.totalSupply, + }) + ).output; + const getCurrentNav = ( + await sdk.api.abi.call({ + target: fx_stETHTreasury, + abi: CommonAbi.getCurrentNav, + }) + ).output; + const rebalancesRewardData = ( + await sdk.api.abi.call({ + target: fx_reBalancePool, + params: wstETH, + abi: reBalanceAbi.extraRewardState, + }) + ).output; + const stETHRate = ( + await sdk.api.abi.call({ + target: wstETH, + abi: CommonAbi.tokensPerStEth, + }) + ).output; + const { _baseNav, _fNav, _xNav } = getCurrentNav; + _tvl = cBN(rebalancesData).div(1e18).times(_fNav).div(1e18).toFixed(0); + + const { finishAt, rate } = rebalancesRewardData || {}; + + const _currentTime = Math.ceil(new Date().getTime() / 1000); + if (_currentTime > finishAt) { + _apy = 0; + } else { + const apyWei = cBN(rate) + .div(1e18) + .multipliedBy(yearSecond) + .multipliedBy(_baseNav) + .div(1e18) + .multipliedBy(stETHRate) + .div(1e18) + .div(_tvl) + .times(100); + _apy = apyWei.multipliedBy(1.04).toFixed(2); + } + + return { + address: fx_reBalancePool, + tvl: _tvl, + apy: _apy, + }; + } catch (error) { + console.log(error); + return false; + } +}; + +const getPoolData = async () => { + let poolData = await getTvlAndApy(); + const { address: rebalancePool, tvl, apy } = poolData; + const newObj = [ + { + pool: `${rebalancePool}-f(x)`, + chain: utils.formatChain('ethereum'), + project: 'fx-protocol', + symbol: 'fETH', + tvlUsd: parseInt(tvl, 10), + apy: parseFloat(apy), + }, + ]; + return newObj; +}; + +const main = async () => { + const data = await getPoolData(); + return data.filter((p) => utils.keepFinite(p)); +}; + +module.exports = { + timetravel: false, + apy: main, + url: 'https://fx.aladdin.club/rebalance-pool/', +}; diff --git a/src/adaptors/gamma/index.js b/src/adaptors/gamma/index.js index 2d5516e0b6..fb6bbdcf7f 100644 --- a/src/adaptors/gamma/index.js +++ b/src/adaptors/gamma/index.js @@ -20,7 +20,8 @@ const EXCHANGES_API = { spiritswap: 'spiritswap/', fusionx: 'fusionx/', synthswap: 'synthswap/', - lynex: 'lynex/' + lynex: 'lynex/', + pegasys: 'pegasys/' }; const EXCHANGES_CHAINS = { uniswapv3: ["ethereum", "optimism", "polygon", "arbitrum", "celo", "bsc"], @@ -31,14 +32,15 @@ const EXCHANGES_CHAINS = { ascent: ["polygon"], camelot: ["arbitrum"], ramses: ["arbitrum"], - sushiswap: ["polygon", "arbitrum"], + sushiswap: ["polygon", "arbitrum", "base"], beamswap: ["moonbeam"], stellaswap: ["moonbeam"], glacier: ["avalanche"], spiritswap: ["fantom"], fusionx: ["mantle"], synthswap: ["base"], - lynex: ["linea"] + lynex: ["linea"], + pegasys: ["rollux"] }; const CHAINS_API = { ethereum: '', @@ -53,7 +55,8 @@ const CHAINS_API = { fantom: 'fantom/', mantle: 'mantle/', base: 'base/', - linea: 'linea/' + linea: 'linea/', + rollux: 'rollux/' }; const CHAIN_IDS = { ethereum: 1, @@ -68,7 +71,8 @@ const CHAIN_IDS = { fantom: 250, mantle: 5000, base: 8453, - linea: 59144 + linea: 59144, + rollux: 570 }; const UNISWAP_FEE = { "100": "0.01%", @@ -131,7 +135,8 @@ const blacklist = { fantom: [], mantle: [], base: [], - linea: [] + linea: [], + rollux: [] }; const masterchef_blacklist = { ethereum: [], @@ -146,7 +151,8 @@ const masterchef_blacklist = { fantom: [], mantle: [], base: [], - linea: [] + linea: [], + rollux: [] }; const getUrl_allData = (chain, exchange) => `https://wire2.gamma.xyz/${exchange}${chain}hypervisors/allData`; diff --git a/src/adaptors/glif-pools-infinity-pool/index.js b/src/adaptors/glif/index.js similarity index 96% rename from src/adaptors/glif-pools-infinity-pool/index.js rename to src/adaptors/glif/index.js index f3e94cd252..7e528913c2 100644 --- a/src/adaptors/glif-pools-infinity-pool/index.js +++ b/src/adaptors/glif/index.js @@ -22,7 +22,7 @@ const fetchApy = async () => { const filPool = { pool: '0x43dAe5624445e7679D16a63211c5ff368681500c-filecoin', chain: utils.formatChain('filecoin'), - project: 'glif-pools-infinity-pool', + project: 'glif', symbol: utils.formatSymbol('FIL'), tvlUsd: tvlFIL * filPrice, apy: Number(apyData.apy), diff --git a/src/adaptors/gmx-v1/index.js b/src/adaptors/gmx-v1/index.js index cd5d163c97..d14d10c2d5 100644 --- a/src/adaptors/gmx-v1/index.js +++ b/src/adaptors/gmx-v1/index.js @@ -135,10 +135,6 @@ async function getPoolGlp( apyReward: apyInflation, rewardTokens: chainString === 'arbitrum' ? [arbitrumGmxAddress] : [avalacheGmxAddress], - - underlyingTokens: [ - chainString === 'arbitrum' ? arbitrumGmxAddress : avalacheGmxAddress, - ], underlyingTokens: [ chainString === 'arbitrum' ? '0x4277f8F2c384827B5273592FF7CeBd9f2C1ac258' diff --git a/src/adaptors/gmx-v2/abi.js b/src/adaptors/gmx-v2/abi.js new file mode 100644 index 0000000000..3a02534487 --- /dev/null +++ b/src/adaptors/gmx-v2/abi.js @@ -0,0 +1,3756 @@ +const ABI = [ + { + inputs: [ + { + internalType: 'address', + name: 'market', + type: 'address', + }, + ], + name: 'DisabledMarket', + type: 'error', + }, + { + inputs: [], + name: 'EmptyMarket', + type: 'error', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint256', + name: 'start', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'end', + type: 'uint256', + }, + ], + name: 'getAccountOrders', + outputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'address', + name: 'receiver', + type: 'address', + }, + { + internalType: 'address', + name: 'callbackContract', + type: 'address', + }, + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + { + internalType: 'address', + name: 'market', + type: 'address', + }, + { + internalType: 'address', + name: 'initialCollateralToken', + type: 'address', + }, + { + internalType: 'address[]', + name: 'swapPath', + type: 'address[]', + }, + ], + internalType: 'struct Order.Addresses', + name: 'addresses', + type: 'tuple', + }, + { + components: [ + { + internalType: 'enum Order.OrderType', + name: 'orderType', + type: 'uint8', + }, + { + internalType: 'enum Order.DecreasePositionSwapType', + name: 'decreasePositionSwapType', + type: 'uint8', + }, + { + internalType: 'uint256', + name: 'sizeDeltaUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'initialCollateralDeltaAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'triggerPrice', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'acceptablePrice', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'executionFee', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'callbackGasLimit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'minOutputAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'updatedAtBlock', + type: 'uint256', + }, + ], + internalType: 'struct Order.Numbers', + name: 'numbers', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + { + internalType: 'bool', + name: 'shouldUnwrapNativeToken', + type: 'bool', + }, + { + internalType: 'bool', + name: 'isFrozen', + type: 'bool', + }, + ], + internalType: 'struct Order.Flags', + name: 'flags', + type: 'tuple', + }, + ], + internalType: 'struct Order.Props[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'contract IReferralStorage', + name: 'referralStorage', + type: 'address', + }, + { + internalType: 'bytes32[]', + name: 'positionKeys', + type: 'bytes32[]', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.MarketPrices[]', + name: 'prices', + type: 'tuple[]', + }, + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + ], + name: 'getAccountPositionInfoList', + outputs: [ + { + components: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'address', + name: 'market', + type: 'address', + }, + { + internalType: 'address', + name: 'collateralToken', + type: 'address', + }, + ], + internalType: 'struct Position.Addresses', + name: 'addresses', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'sizeInUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'sizeInTokens', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'collateralAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'fundingFeeAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'longTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'increasedAtBlock', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'decreasedAtBlock', + type: 'uint256', + }, + ], + internalType: 'struct Position.Numbers', + name: 'numbers', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + ], + internalType: 'struct Position.Flags', + name: 'flags', + type: 'tuple', + }, + ], + internalType: 'struct Position.Props', + name: 'position', + type: 'tuple', + }, + { + components: [ + { + components: [ + { + internalType: 'bytes32', + name: 'referralCode', + type: 'bytes32', + }, + { + internalType: 'address', + name: 'affiliate', + type: 'address', + }, + { + internalType: 'address', + name: 'trader', + type: 'address', + }, + { + internalType: 'uint256', + name: 'totalRebateFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'traderDiscountFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalRebateAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'traderDiscountAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'affiliateRewardAmount', + type: 'uint256', + }, + ], + internalType: + 'struct PositionPricingUtils.PositionReferralFees', + name: 'referral', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'fundingFeeAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'claimableLongTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'claimableShortTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'latestFundingFeeAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'latestLongTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'latestShortTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + ], + internalType: 'struct PositionPricingUtils.PositionFundingFees', + name: 'funding', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'borrowingFeeUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFeeAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFeeReceiverFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFeeAmountForFeeReceiver', + type: 'uint256', + }, + ], + internalType: + 'struct PositionPricingUtils.PositionBorrowingFees', + name: 'borrowing', + type: 'tuple', + }, + { + components: [ + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + { + internalType: 'uint256', + name: 'uiFeeReceiverFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'uiFeeAmount', + type: 'uint256', + }, + ], + internalType: 'struct PositionPricingUtils.PositionUiFees', + name: 'ui', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'collateralTokenPrice', + type: 'tuple', + }, + { + internalType: 'uint256', + name: 'positionFeeFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'protocolFeeAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'positionFeeReceiverFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'feeReceiverAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'feeAmountForPool', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'positionFeeAmountForPool', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'positionFeeAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalCostAmountExcludingFunding', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalCostAmount', + type: 'uint256', + }, + ], + internalType: 'struct PositionPricingUtils.PositionFees', + name: 'fees', + type: 'tuple', + }, + { + components: [ + { + internalType: 'int256', + name: 'priceImpactUsd', + type: 'int256', + }, + { + internalType: 'uint256', + name: 'priceImpactDiffUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'executionPrice', + type: 'uint256', + }, + ], + internalType: 'struct ReaderPricingUtils.ExecutionPriceResult', + name: 'executionPriceResult', + type: 'tuple', + }, + { + internalType: 'int256', + name: 'basePnlUsd', + type: 'int256', + }, + { + internalType: 'int256', + name: 'uncappedBasePnlUsd', + type: 'int256', + }, + { + internalType: 'int256', + name: 'pnlAfterPriceImpactUsd', + type: 'int256', + }, + ], + internalType: 'struct ReaderUtils.PositionInfo[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint256', + name: 'start', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'end', + type: 'uint256', + }, + ], + name: 'getAccountPositions', + outputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'address', + name: 'market', + type: 'address', + }, + { + internalType: 'address', + name: 'collateralToken', + type: 'address', + }, + ], + internalType: 'struct Position.Addresses', + name: 'addresses', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'sizeInUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'sizeInTokens', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'collateralAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'fundingFeeAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'longTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'increasedAtBlock', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'decreasedAtBlock', + type: 'uint256', + }, + ], + internalType: 'struct Position.Numbers', + name: 'numbers', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + ], + internalType: 'struct Position.Flags', + name: 'flags', + type: 'tuple', + }, + ], + internalType: 'struct Position.Props[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'address', + name: 'market', + type: 'address', + }, + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.MarketPrices', + name: 'prices', + type: 'tuple', + }, + ], + name: 'getAdlState', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'bool', + name: '', + type: 'bool', + }, + { + internalType: 'int256', + name: '', + type: 'int256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, + ], + name: 'getDeposit', + outputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'address', + name: 'receiver', + type: 'address', + }, + { + internalType: 'address', + name: 'callbackContract', + type: 'address', + }, + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + { + internalType: 'address', + name: 'market', + type: 'address', + }, + { + internalType: 'address', + name: 'initialLongToken', + type: 'address', + }, + { + internalType: 'address', + name: 'initialShortToken', + type: 'address', + }, + { + internalType: 'address[]', + name: 'longTokenSwapPath', + type: 'address[]', + }, + { + internalType: 'address[]', + name: 'shortTokenSwapPath', + type: 'address[]', + }, + ], + internalType: 'struct Deposit.Addresses', + name: 'addresses', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'initialLongTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'initialShortTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'minMarketTokens', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'updatedAtBlock', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'executionFee', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'callbackGasLimit', + type: 'uint256', + }, + ], + internalType: 'struct Deposit.Numbers', + name: 'numbers', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'shouldUnwrapNativeToken', + type: 'bool', + }, + ], + internalType: 'struct Deposit.Flags', + name: 'flags', + type: 'tuple', + }, + ], + internalType: 'struct Deposit.Props', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: 'market', + type: 'tuple', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.MarketPrices', + name: 'prices', + type: 'tuple', + }, + { + internalType: 'uint256', + name: 'longTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortTokenAmount', + type: 'uint256', + }, + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + ], + name: 'getDepositAmountOut', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'address', + name: 'marketKey', + type: 'address', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + internalType: 'uint256', + name: 'positionSizeInUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'positionSizeInTokens', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'sizeDeltaUsd', + type: 'int256', + }, + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + ], + name: 'getExecutionPrice', + outputs: [ + { + components: [ + { + internalType: 'int256', + name: 'priceImpactUsd', + type: 'int256', + }, + { + internalType: 'uint256', + name: 'priceImpactDiffUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'executionPrice', + type: 'uint256', + }, + ], + internalType: 'struct ReaderPricingUtils.ExecutionPriceResult', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'address', + name: 'key', + type: 'address', + }, + ], + name: 'getMarket', + outputs: [ + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'bytes32', + name: 'salt', + type: 'bytes32', + }, + ], + name: 'getMarketBySalt', + outputs: [ + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.MarketPrices', + name: 'prices', + type: 'tuple', + }, + { + internalType: 'address', + name: 'marketKey', + type: 'address', + }, + ], + name: 'getMarketInfo', + outputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: 'market', + type: 'tuple', + }, + { + internalType: 'uint256', + name: 'borrowingFactorPerSecondForLongs', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFactorPerSecondForShorts', + type: 'uint256', + }, + { + components: [ + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'long', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'short', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.PositionType', + name: 'fundingFeeAmountPerSize', + type: 'tuple', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'long', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'short', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.PositionType', + name: 'claimableFundingAmountPerSize', + type: 'tuple', + }, + ], + internalType: 'struct ReaderUtils.BaseFundingValues', + name: 'baseFunding', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'longsPayShorts', + type: 'bool', + }, + { + internalType: 'uint256', + name: 'fundingFactorPerSecond', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'nextSavedFundingFactorPerSecond', + type: 'int256', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'long', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'short', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.PositionType', + name: 'fundingFeeAmountPerSizeDelta', + type: 'tuple', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'long', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'short', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.PositionType', + name: 'claimableFundingAmountPerSizeDelta', + type: 'tuple', + }, + ], + internalType: + 'struct MarketUtils.GetNextFundingAmountPerSizeResult', + name: 'nextFunding', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'virtualPoolAmountForLongToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'virtualPoolAmountForShortToken', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'virtualInventoryForPositions', + type: 'int256', + }, + ], + internalType: 'struct ReaderUtils.VirtualInventory', + name: 'virtualInventory', + type: 'tuple', + }, + { + internalType: 'bool', + name: 'isDisabled', + type: 'bool', + }, + ], + internalType: 'struct ReaderUtils.MarketInfo', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.MarketPrices[]', + name: 'marketPricesList', + type: 'tuple[]', + }, + { + internalType: 'uint256', + name: 'start', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'end', + type: 'uint256', + }, + ], + name: 'getMarketInfoList', + outputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: 'market', + type: 'tuple', + }, + { + internalType: 'uint256', + name: 'borrowingFactorPerSecondForLongs', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFactorPerSecondForShorts', + type: 'uint256', + }, + { + components: [ + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'long', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'short', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.PositionType', + name: 'fundingFeeAmountPerSize', + type: 'tuple', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'long', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'short', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.PositionType', + name: 'claimableFundingAmountPerSize', + type: 'tuple', + }, + ], + internalType: 'struct ReaderUtils.BaseFundingValues', + name: 'baseFunding', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'longsPayShorts', + type: 'bool', + }, + { + internalType: 'uint256', + name: 'fundingFactorPerSecond', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'nextSavedFundingFactorPerSecond', + type: 'int256', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'long', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'short', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.PositionType', + name: 'fundingFeeAmountPerSizeDelta', + type: 'tuple', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'long', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'longToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortToken', + type: 'uint256', + }, + ], + internalType: 'struct MarketUtils.CollateralType', + name: 'short', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.PositionType', + name: 'claimableFundingAmountPerSizeDelta', + type: 'tuple', + }, + ], + internalType: + 'struct MarketUtils.GetNextFundingAmountPerSizeResult', + name: 'nextFunding', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'virtualPoolAmountForLongToken', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'virtualPoolAmountForShortToken', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'virtualInventoryForPositions', + type: 'int256', + }, + ], + internalType: 'struct ReaderUtils.VirtualInventory', + name: 'virtualInventory', + type: 'tuple', + }, + { + internalType: 'bool', + name: 'isDisabled', + type: 'bool', + }, + ], + internalType: 'struct ReaderUtils.MarketInfo[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: 'market', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + { + internalType: 'bytes32', + name: 'pnlFactorType', + type: 'bytes32', + }, + { + internalType: 'bool', + name: 'maximize', + type: 'bool', + }, + ], + name: 'getMarketTokenPrice', + outputs: [ + { + internalType: 'int256', + name: '', + type: 'int256', + }, + { + components: [ + { + internalType: 'int256', + name: 'poolValue', + type: 'int256', + }, + { + internalType: 'int256', + name: 'longPnl', + type: 'int256', + }, + { + internalType: 'int256', + name: 'shortPnl', + type: 'int256', + }, + { + internalType: 'int256', + name: 'netPnl', + type: 'int256', + }, + { + internalType: 'uint256', + name: 'longTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'longTokenUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortTokenUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalBorrowingFees', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFeePoolFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'impactPoolAmount', + type: 'uint256', + }, + ], + internalType: 'struct MarketPoolValueInfo.Props', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'uint256', + name: 'start', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'end', + type: 'uint256', + }, + ], + name: 'getMarkets', + outputs: [ + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: 'market', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + internalType: 'bool', + name: 'maximize', + type: 'bool', + }, + ], + name: 'getNetPnl', + outputs: [ + { + internalType: 'int256', + name: '', + type: 'int256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: 'market', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + { + internalType: 'bool', + name: 'maximize', + type: 'bool', + }, + ], + name: 'getOpenInterestWithPnl', + outputs: [ + { + internalType: 'int256', + name: '', + type: 'int256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, + ], + name: 'getOrder', + outputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'address', + name: 'receiver', + type: 'address', + }, + { + internalType: 'address', + name: 'callbackContract', + type: 'address', + }, + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + { + internalType: 'address', + name: 'market', + type: 'address', + }, + { + internalType: 'address', + name: 'initialCollateralToken', + type: 'address', + }, + { + internalType: 'address[]', + name: 'swapPath', + type: 'address[]', + }, + ], + internalType: 'struct Order.Addresses', + name: 'addresses', + type: 'tuple', + }, + { + components: [ + { + internalType: 'enum Order.OrderType', + name: 'orderType', + type: 'uint8', + }, + { + internalType: 'enum Order.DecreasePositionSwapType', + name: 'decreasePositionSwapType', + type: 'uint8', + }, + { + internalType: 'uint256', + name: 'sizeDeltaUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'initialCollateralDeltaAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'triggerPrice', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'acceptablePrice', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'executionFee', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'callbackGasLimit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'minOutputAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'updatedAtBlock', + type: 'uint256', + }, + ], + internalType: 'struct Order.Numbers', + name: 'numbers', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + { + internalType: 'bool', + name: 'shouldUnwrapNativeToken', + type: 'bool', + }, + { + internalType: 'bool', + name: 'isFrozen', + type: 'bool', + }, + ], + internalType: 'struct Order.Flags', + name: 'flags', + type: 'tuple', + }, + ], + internalType: 'struct Order.Props', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: 'market', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + { + internalType: 'bool', + name: 'maximize', + type: 'bool', + }, + ], + name: 'getPnl', + outputs: [ + { + internalType: 'int256', + name: '', + type: 'int256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'address', + name: 'marketAddress', + type: 'address', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.MarketPrices', + name: 'prices', + type: 'tuple', + }, + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + { + internalType: 'bool', + name: 'maximize', + type: 'bool', + }, + ], + name: 'getPnlToPoolFactor', + outputs: [ + { + internalType: 'int256', + name: '', + type: 'int256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, + ], + name: 'getPosition', + outputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'address', + name: 'market', + type: 'address', + }, + { + internalType: 'address', + name: 'collateralToken', + type: 'address', + }, + ], + internalType: 'struct Position.Addresses', + name: 'addresses', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'sizeInUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'sizeInTokens', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'collateralAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'fundingFeeAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'longTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'increasedAtBlock', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'decreasedAtBlock', + type: 'uint256', + }, + ], + internalType: 'struct Position.Numbers', + name: 'numbers', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + ], + internalType: 'struct Position.Flags', + name: 'flags', + type: 'tuple', + }, + ], + internalType: 'struct Position.Props', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'contract IReferralStorage', + name: 'referralStorage', + type: 'address', + }, + { + internalType: 'bytes32', + name: 'positionKey', + type: 'bytes32', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.MarketPrices', + name: 'prices', + type: 'tuple', + }, + { + internalType: 'uint256', + name: 'sizeDeltaUsd', + type: 'uint256', + }, + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + { + internalType: 'bool', + name: 'usePositionSizeAsSizeDeltaUsd', + type: 'bool', + }, + ], + name: 'getPositionInfo', + outputs: [ + { + components: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'address', + name: 'market', + type: 'address', + }, + { + internalType: 'address', + name: 'collateralToken', + type: 'address', + }, + ], + internalType: 'struct Position.Addresses', + name: 'addresses', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'sizeInUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'sizeInTokens', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'collateralAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'fundingFeeAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'longTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'shortTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'increasedAtBlock', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'decreasedAtBlock', + type: 'uint256', + }, + ], + internalType: 'struct Position.Numbers', + name: 'numbers', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'isLong', + type: 'bool', + }, + ], + internalType: 'struct Position.Flags', + name: 'flags', + type: 'tuple', + }, + ], + internalType: 'struct Position.Props', + name: 'position', + type: 'tuple', + }, + { + components: [ + { + components: [ + { + internalType: 'bytes32', + name: 'referralCode', + type: 'bytes32', + }, + { + internalType: 'address', + name: 'affiliate', + type: 'address', + }, + { + internalType: 'address', + name: 'trader', + type: 'address', + }, + { + internalType: 'uint256', + name: 'totalRebateFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'traderDiscountFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalRebateAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'traderDiscountAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'affiliateRewardAmount', + type: 'uint256', + }, + ], + internalType: + 'struct PositionPricingUtils.PositionReferralFees', + name: 'referral', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'fundingFeeAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'claimableLongTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'claimableShortTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'latestFundingFeeAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'latestLongTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'latestShortTokenClaimableFundingAmountPerSize', + type: 'uint256', + }, + ], + internalType: 'struct PositionPricingUtils.PositionFundingFees', + name: 'funding', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'borrowingFeeUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFeeAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFeeReceiverFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'borrowingFeeAmountForFeeReceiver', + type: 'uint256', + }, + ], + internalType: + 'struct PositionPricingUtils.PositionBorrowingFees', + name: 'borrowing', + type: 'tuple', + }, + { + components: [ + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + { + internalType: 'uint256', + name: 'uiFeeReceiverFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'uiFeeAmount', + type: 'uint256', + }, + ], + internalType: 'struct PositionPricingUtils.PositionUiFees', + name: 'ui', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'collateralTokenPrice', + type: 'tuple', + }, + { + internalType: 'uint256', + name: 'positionFeeFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'protocolFeeAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'positionFeeReceiverFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'feeReceiverAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'feeAmountForPool', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'positionFeeAmountForPool', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'positionFeeAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalCostAmountExcludingFunding', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalCostAmount', + type: 'uint256', + }, + ], + internalType: 'struct PositionPricingUtils.PositionFees', + name: 'fees', + type: 'tuple', + }, + { + components: [ + { + internalType: 'int256', + name: 'priceImpactUsd', + type: 'int256', + }, + { + internalType: 'uint256', + name: 'priceImpactDiffUsd', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'executionPrice', + type: 'uint256', + }, + ], + internalType: 'struct ReaderPricingUtils.ExecutionPriceResult', + name: 'executionPriceResult', + type: 'tuple', + }, + { + internalType: 'int256', + name: 'basePnlUsd', + type: 'int256', + }, + { + internalType: 'int256', + name: 'uncappedBasePnlUsd', + type: 'int256', + }, + { + internalType: 'int256', + name: 'pnlAfterPriceImpactUsd', + type: 'int256', + }, + ], + internalType: 'struct ReaderUtils.PositionInfo', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: 'market', + type: 'tuple', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.MarketPrices', + name: 'prices', + type: 'tuple', + }, + { + internalType: 'bytes32', + name: 'positionKey', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'sizeDeltaUsd', + type: 'uint256', + }, + ], + name: 'getPositionPnlUsd', + outputs: [ + { + internalType: 'int256', + name: '', + type: 'int256', + }, + { + internalType: 'int256', + name: '', + type: 'int256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: 'market', + type: 'tuple', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.MarketPrices', + name: 'prices', + type: 'tuple', + }, + { + internalType: 'address', + name: 'tokenIn', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + ], + name: 'getSwapAmountOut', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'int256', + name: '', + type: 'int256', + }, + { + components: [ + { + internalType: 'uint256', + name: 'feeReceiverAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'feeAmountForPool', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amountAfterFees', + type: 'uint256', + }, + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + { + internalType: 'uint256', + name: 'uiFeeReceiverFactor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'uiFeeAmount', + type: 'uint256', + }, + ], + internalType: 'struct SwapPricingUtils.SwapFees', + name: 'fees', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'address', + name: 'marketKey', + type: 'address', + }, + { + internalType: 'address', + name: 'tokenIn', + type: 'address', + }, + { + internalType: 'address', + name: 'tokenOut', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'tokenInPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'tokenOutPrice', + type: 'tuple', + }, + ], + name: 'getSwapPriceImpact', + outputs: [ + { + internalType: 'int256', + name: '', + type: 'int256', + }, + { + internalType: 'int256', + name: '', + type: 'int256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, + ], + name: 'getWithdrawal', + outputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'address', + name: 'receiver', + type: 'address', + }, + { + internalType: 'address', + name: 'callbackContract', + type: 'address', + }, + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + { + internalType: 'address', + name: 'market', + type: 'address', + }, + { + internalType: 'address[]', + name: 'longTokenSwapPath', + type: 'address[]', + }, + { + internalType: 'address[]', + name: 'shortTokenSwapPath', + type: 'address[]', + }, + ], + internalType: 'struct Withdrawal.Addresses', + name: 'addresses', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'marketTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'minLongTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'minShortTokenAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'updatedAtBlock', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'executionFee', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'callbackGasLimit', + type: 'uint256', + }, + ], + internalType: 'struct Withdrawal.Numbers', + name: 'numbers', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'shouldUnwrapNativeToken', + type: 'bool', + }, + ], + internalType: 'struct Withdrawal.Flags', + name: 'flags', + type: 'tuple', + }, + ], + internalType: 'struct Withdrawal.Props', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract DataStore', + name: 'dataStore', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'marketToken', + type: 'address', + }, + { + internalType: 'address', + name: 'indexToken', + type: 'address', + }, + { + internalType: 'address', + name: 'longToken', + type: 'address', + }, + { + internalType: 'address', + name: 'shortToken', + type: 'address', + }, + ], + internalType: 'struct Market.Props', + name: 'market', + type: 'tuple', + }, + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'indexTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'longTokenPrice', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint256', + name: 'min', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'max', + type: 'uint256', + }, + ], + internalType: 'struct Price.Props', + name: 'shortTokenPrice', + type: 'tuple', + }, + ], + internalType: 'struct MarketUtils.MarketPrices', + name: 'prices', + type: 'tuple', + }, + { + internalType: 'uint256', + name: 'marketTokenAmount', + type: 'uint256', + }, + { + internalType: 'address', + name: 'uiFeeReceiver', + type: 'address', + }, + ], + name: 'getWithdrawalAmountOut', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, +]; + +module.exports = { ABI }; diff --git a/src/adaptors/gmx-v2/index.js b/src/adaptors/gmx-v2/index.js new file mode 100644 index 0000000000..8e0130e288 --- /dev/null +++ b/src/adaptors/gmx-v2/index.js @@ -0,0 +1,253 @@ +const { ABI } = require('./abi'); +const utils = require('../utils'); + +const sdk = require('@defillama/sdk'); +const { gql, default: request } = require('graphql-request'); +const fetch = require('node-fetch'); +const { ethers } = require('ethers'); + +const { default: BigNumber } = require('bignumber.js'); +const BASIS_POINTS_DIVISOR = 10000; + +const SUBGRAPH_URL = { + arbitrum: + 'https://subgraph.satsuma-prod.com/3b2ced13c8d9/gmx/synthetics-arbitrum-stats/api', + avax: 'https://subgraph.satsuma-prod.com/3b2ced13c8d9/gmx/synthetics-avalanche-stats/api', +}; + +const CONTRACTS = { + arbitrum: { + syntheticsReader: '0xf60becbba223EEA9495Da3f606753867eC10d139', + dataStore: '0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8', + }, + avax: { + syntheticsReader: '0x73BA021ACF4Bb6741E82690DdB821e7936050f8C', + dataStore: '0x2F0b22339414ADeD7D5F06f9D604c7fF5b2fe3f6', + }, +}; + +const TICKERS_URL = { + arbitrum: 'https://arbitrum-api.gmxinfra.io/prices/tickers', + avax: 'https://avalanche-api.gmxinfra.io/prices/tickers', +}; + +const WETH = { + arbitrum: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1'.toLowerCase(), + avax: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7'.toLowerCase(), +}; + +function hashData(dataTypes, dataValues) { + const bytes = ethers.utils.defaultAbiCoder.encode(dataTypes, dataValues); + const hash = ethers.utils.keccak256(ethers.utils.arrayify(bytes)); + + return hash; +} + +function hashString(string) { + return hashData(['string'], [string]); +} + +const MAX_PNL_FACTOR_FOR_DEPOSITS_KEY = hashString( + 'MAX_PNL_FACTOR_FOR_DEPOSITS' +); + +const marketsQuery = gql` + query M { + marketInfos { + id + marketToken + indexToken + longToken + shortToken + } + } +`; +const nowInSecods = Math.floor(Date.now() / 1000); + +const marketFeesQuery = (marketAddress, tokenAddress) => ` + _${marketAddress}_${tokenAddress}: collectedMarketFeesInfos( + where: { + marketAddress: "${marketAddress.toLowerCase()}", + tokenAddress: "${tokenAddress.toLowerCase()}", + period: "1h", + timestampGroup_gte: ${nowInSecods - 3600 * 24 * 7} + }, + orderBy: timestampGroup, + orderDirection: desc, + first: 1000 + ) { + id + period + marketAddress + tokenAddress + feeUsdForPool + cummulativeFeeUsdForPool + timestampGroup + } + `; + +function bigNumberify(n) { + try { + return BigNumber(n); + } catch (e) { + console.error('bigNumberify error', e); + return undefined; + } +} + +function expandDecimals(n, decimals) { + return bigNumberify(n).times(bigNumberify(10).pow(decimals)); +} + +const getMarkets = async (chain) => { + const { marketInfos } = await request(SUBGRAPH_URL[chain], marketsQuery); + + const queryBody = marketInfos.reduce((acc, market) => { + const { longToken, shortToken, id } = market; + + acc += marketFeesQuery(id, longToken); + acc += marketFeesQuery(id, shortToken); + + return acc; + }, ''); + + const res = await request( + SUBGRAPH_URL[chain], + gql`query M { + ${queryBody} + }` + ); + + const tickers = ( + await fetch(TICKERS_URL[chain]).then((r) => r.json()) + ).reduce( + (acc, price) => ({ + ...acc, + [price?.tokenAddress?.toLowerCase()]: { + min: price.minPrice, + max: price.maxPrice, + data: price, + }, + }), + {} + ); + + const marketResults = {}; + + const marketCall = await Promise.all( + marketInfos.map(async (market) => { + const marketProps = { + marketToken: market.marketToken, + longToken: market.longToken, + shortToken: market.shortToken, + indexToken: market.indexToken, + }; + + const min = ( + await sdk.api.abi.call({ + target: CONTRACTS[chain].syntheticsReader, // synthetix, + abi: ABI.find((m) => m.name === 'getMarketTokenPrice'), + chain: chain, + params: [ + CONTRACTS[chain].dataStore, //datastore + marketProps, + tickers[market.indexToken?.toLowerCase()] || tickers[WETH[chain]], + tickers[market.longToken?.toLowerCase()], + tickers[market.shortToken?.toLowerCase()], + MAX_PNL_FACTOR_FOR_DEPOSITS_KEY, + false, + ], + }) + ).output; + const max = ( + await sdk.api.abi.call({ + target: CONTRACTS[chain].syntheticsReader, // synthetix, + abi: ABI.find((m) => m.name === 'getMarketTokenPrice'), + chain: chain, + params: [ + CONTRACTS[chain].dataStore, //datastore + marketProps, + tickers[market.indexToken?.toLowerCase()] || tickers[WETH[chain]], + tickers[market.longToken?.toLowerCase()], + tickers[market.shortToken?.toLowerCase()], + MAX_PNL_FACTOR_FOR_DEPOSITS_KEY, + true, + ], + }) + ).output; + + const supply = await sdk.api.erc20.totalSupply({ + target: market.marketToken, + chain: chain, + }); + + const tvl = ((supply.output / 1e18) * min[0]) / 1e30; + + marketResults[market.marketToken.toLowerCase()] = { + totalSupply: supply.output, + minPrice: min[0], + maxPrice: max[0], + tvl, + }; + return res; + }) + ); + + const marketTokensAPRData = marketInfos.map((market, i) => { + const marketAddress = market.id; + const marketToken = market.marketToken.toLowerCase(); + const marketData = marketResults[marketToken]; + + const feeItems = [ + ...res[`_${marketAddress}_${market.longToken}`], + ...res[`_${marketAddress}_${market.shortToken}`], + ]; + + const feesUsdForPeriod = feeItems.reduce((acc, rawCollectedFees) => { + return acc.plus(bigNumberify(rawCollectedFees.feeUsdForPool)); + }, BigNumber(0)); + + if (Number(marketData.totalSupply) > 0) { + const feesPerMarketToken = feesUsdForPeriod + .times(expandDecimals(1, 18)) + .div(marketData.totalSupply); + const weeksInYear = 52; + const apr = feesPerMarketToken + .times(BASIS_POINTS_DIVISOR) + .times(weeksInYear) + .div(marketData.minPrice); + + const longSymbol = + tickers[market.longToken.toLowerCase()]?.data?.tokenSymbol; + const shortSymbol = + tickers[market.shortToken.toLowerCase()]?.data?.tokenSymbol; + + return { + pool: marketAddress, + chain: utils.formatChain(chain === 'avax' ? 'avalanche' : chain), + project: 'gmx-v2', + symbol: `${longSymbol}-${shortSymbol}`, + tvlUsd: parseFloat(marketData.tvl), + apyBase: apr.toString() / 100, + apyReward: 0, + underlyingTokens: [market.longToken, market.shortToken], + }; + } else { + return; + } + }); + + console.log(marketTokensAPRData); + + return marketTokensAPRData.filter(Boolean); +}; + +const apy = async () => { + return (await Promise.all(['avax', 'arbitrum'].map(getMarkets))).flat(); +}; + +module.exports = { + timetravel: false, + apy, + url: 'https://app.gmx.io/#/earn', +}; diff --git a/src/adaptors/impermax-finance/abi.js b/src/adaptors/impermax-finance/abi.js new file mode 100644 index 0000000000..64f3c1b131 --- /dev/null +++ b/src/adaptors/impermax-finance/abi.js @@ -0,0 +1,193 @@ +module.exports = { + allLendingPools: { + constant: true, + inputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'allLendingPools', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + allLendingPoolsLength: { + constant: true, + inputs: [], + name: 'allLendingPoolsLength', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + getLendingPool: { + constant: true, + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'getLendingPool', + outputs: [ + { + internalType: 'bool', + name: 'initialized', + type: 'bool', + }, + { + internalType: 'uint24', + name: 'lendingPoolId', + type: 'uint24', + }, + { + internalType: 'address', + name: 'collateral', + type: 'address', + }, + { + internalType: 'address', + name: 'borrowable0', + type: 'address', + }, + { + internalType: 'address', + name: 'borrowable1', + type: 'address', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + underlying: { + constant: true, + inputs: [], + name: 'underlying', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + totalBorrows: { + constant: true, + inputs: [], + name: 'totalBorrows', + outputs: [{ internalType: 'uint112', name: '', type: 'uint112' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + underlying: { + constant: true, + inputs: [], + name: 'underlying', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + symbol: { + inputs: [], + name: 'symbol', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + getReserves: { + constant: true, + inputs: [], + name: 'getReserves', + outputs: [ + { internalType: 'uint112', name: 'reserve0', type: 'uint112' }, + { internalType: 'uint112', name: 'reserve1', type: 'uint112' }, + { internalType: 'uint32', name: 'blockTimestampLast', type: 'uint32' }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + token0: { + constant: true, + inputs: [], + name: 'token0', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + token1: { + constant: true, + inputs: [], + name: 'token1', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + decimals: { + constant: true, + inputs: [], + name: 'decimals', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + reserveFactor: { + constant: true, + inputs: [], + name: 'reserveFactor', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + borrowRate: { + constant: true, + inputs: [], + name: 'borrowRate', + outputs: [{ internalType: 'uint48', name: '', type: 'uint48' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + factory: { + inputs: [], + name: 'factory', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + totalSupply: { + constant: true, + inputs: [], + name: 'totalSupply', + outputs: [{ internalType:'uint256', name: '', 'type': 'uint256'}], + payable: false, + stateMutability:'view', + type: 'function' + }, +}; diff --git a/src/adaptors/impermax-finance/index.js b/src/adaptors/impermax-finance/index.js new file mode 100644 index 0000000000..9e29a7bac3 --- /dev/null +++ b/src/adaptors/impermax-finance/index.js @@ -0,0 +1,939 @@ +const axios = require('axios'); +const { default: BigNumber } = require('bignumber.js'); +const utils = require('../utils'); +const { tryUntilSucceed } = require('../../helper/utils'); +const abi = require('./abi'); +const SECONDS_IN_YEAR = BigNumber(365).times(24).times(3600); +const protocolSlug = 'impermax-finance'; +const sdk = require('@defillama/sdk4'); +const { getProvider } = require('@defillama/sdk4/build/general'); +const { da } = require('date-fns/locale'); +const { pool } = require('../rocifi-v2/abi'); + +const config = { + ethereum: { + factories: [ + '0x8C3736e2FE63cc2cD89Ee228D9dBcAb6CE5B767B' + ], + }, + polygon: { + factories: [ + '0xBB92270716C8c424849F17cCc12F4F24AD4064D6', + '0x7F7AD5b16c97Aa9C2B0447C2676ce7D5CEFEbCd3', + '0x7ED6eF7419cD9C00693d7A4F81c2a151F49c7aC2', + ], + }, + arbitrum: { + factories: [ + '0x8C3736e2FE63cc2cD89Ee228D9dBcAb6CE5B767B', + '0x97bc7fefb84a4654d4d3938751b5fe401e8771c2', + ] + }, + avax: { + factories: [ + '0x8C3736e2FE63cc2cD89Ee228D9dBcAb6CE5B767B', + '0x9708e0b216a88d38d469b255ce78c1369ad898e6', + '0xc7f24fd6329738320883ba429C6C8133e6492739', + ] + }, + moonriver: { + factories: [ + '0x8C3736e2FE63cc2cD89Ee228D9dBcAb6CE5B767B', + ] + }, + canto: { + factories: [ + '0x9708E0B216a88D38d469B255cE78c1369ad898e6', + ] + }, + era: { + factories: [ + '0x6ce1a2C079871e4d4b91Ff29E7D2acbD42b46E36', + ] + }, + fantom: { + factories: [ + '0x60aE5F446AE1575534A5F234D6EC743215624556', + '0x9b4ae930255CB8695a9F525dA414F80C4C7a945B', + ] + }, +}; + +const blackListedPools = { + ethereum: [ + '0xa00d47b4b304792eb07b09233467b690db847c91'.toLowerCase(), // IMX-WETH + '0x46af8ac1b82f73db6aacc1645d40c56191ab787b'.toLowerCase(), // NDX-ETH + '0x8dcba0b75c1038c4babbdc0ff3bd9a8f6979dd13'.toLowerCase(), // DEFI5-ETH + '0x08650bb9dc722c9c8c62e79c2bafa2d3fc5b3293'.toLowerCase(), // AMP-ETH + '0xdf5096804705d135656b50b62f9ee13041253d97'.toLowerCase(), // YPIE-ETH + ], + polygon: [ + '0x76483d4ba1177f69fa1448db58d2f1dbe0fb65fa'.toLowerCase(), // IMX-WETH + '0x8ce3bf56767dd87e87487f3fae63e557b821ea32'.toLowerCase(), // IMX-WETH + '0xd4f5f9643a4368324ac920414781b1c5655baed1'.toLowerCase(), // IMX-WETH + '0x5f819f510ca9b1469e6a3ffe4ecd7f0c1126f8f5'.toLowerCase(), // IMX-WETH + '0x23312fceadb118381c33b34343a61c7812f7a6a3'.toLowerCase(), // IMX-WETH + '0x5ed3147f07708a269f744b43c489e6cf3b60aec4'.toLowerCase(), // USDT-DAI + '0xb957d5a232eebd7c4c4b0a1af9f2043430304e65'.toLowerCase(), // USDC-rUSD + '0x87B94444d0f2c1e4610A2De8504D5d7b81898221'.toLowerCase(), // QUICK-POLYDOGE + '0xEC07dD093007AaE16508F76C07d26217B7db9f1b'.toLowerCase(), // DarkX-XONE + ], + arbitrum: [ + '0xb7e5e74b52b9ada1042594cfd8abbdee506cc6c5'.toLowerCase(), // IMX-WETH + '0xcc5c1540683aff992201d8922df44898e1cc9806'.toLowerCase(), // IMX-WETH + '0x8884cc766b43ca10ea41b30192324c77efdd04cd'.toLowerCase(), // NYAN-ETH + '0x4062f4775bc001595838fbaae38908b250ee07cf'.toLowerCase(), // SWPR-ETH + ], + avax: [ + '0xde0037afbe805c00d3cec67093a40882880779b7', // IMX-WETH + '0xe9439f67201894c30f1c1c6b362f0e9195fb8e2c', // IMX-WETH + '0xa34862a7de51a0e1aee6d3912c3767594390586d', // IMX-WETH + '0x69c1c44e8742b66d892294a7eeb9aac51891b0eb', // USDC-UST + ], + moonriver: [ + '0x6ed3bc66dfcc5ac05daec840a75836da935fac97', // IMX-WETH + ], + canto: [], + era: [], + fantom: [ + '0x877a330af63094d88792b9ca28ac36c71673eb1c', // IMX-FTM + '0xb97b6ed451480fe6466a558e9c54eaac32e6c696', // OXD-FTM + ], +}; + +const coinGeckoChainMapping = { + ethereum: 'ethereum', + arbitrum: 'arbitrum-one', + optimism: 'optimism', + polygon: 'polygon-pos', + fantom: 'fantom', + avax: 'avalanche', + moonriver: 'moonriver', + canto: 'canto', +}; + +const factoryToProtocolMapping = { + 'ethereum': { + 'Uniswap': [ + '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f'.toLowerCase(), + ], + }, + 'polygon': { + 'QuickSwap': [ + '0x5671B249391cA5E6a8FE28CEb1e85Dc41c12Ba7D'.toLowerCase(), + '0xF47B652cDE9b30D6aDd0b13027Bb7AD2F7AF04f4'.toLowerCase(), + '0xdB76318C5C5151A4578e2Aafa11a2A2e0B03A4E5'.toLowerCase(), + ], + 'QuickSwap V2': [ + '0x846019FB6f136fC98b80e527C3d34F39D16a38c4'.toLowerCase(), + '0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32'.toLowerCase(), + '0xc4505cc6125d61e2a352ce5cf2129f2fb19259a8'.toLowerCase(), + ], + 'ApeSwap': [ + '0xCf083Be4164828f00cAE704EC15a36D711491284'.toLowerCase(), + ], + 'Tetu': [ + '0x8E45622663Bb01dc285B4F51Eb8F9FE4fa7b5899'.toLowerCase(), + ], + 'Satin': [ + '0xCaF3Fb1b03F1D71A110167327f5106bE82beE209'.toLowerCase(), + ], + 'Pearl': [ + '0xB07C75e3DB03Eb69F047b92274019912014Ba78e'.toLowerCase(), + '0x1A645bfb46b00bb2dCE6a1A517D7dE2999155fe4'.toLowerCase(), + '0xCD9277EE36594fd8bDbE0dfCF0aFD60403e632B5'.toLowerCase(), + ], + 'Sushi': [ + '0xcb30A66e72Ed90D1b34f78fc0655895FC28bB6CF'.toLowerCase(), + '0xc35DADB65012eC5796536bD9864eD8773aBc74C4'.toLowerCase(), + '0x3fDB0c33A86249ed689e497219acE3B80aFf5C0D'.toLowerCase(), + ], + }, + 'arbitrum': { + 'Swapr': [ + '0x5643C3aCEC0D4970a385fb9Cc1555bec1d912bb8'.toLowerCase(), + '0x4AE8915A8D11178154248C692e31710191053466'.toLowerCase(), + ], + 'SolidLizard': [ + '0x30d7ef0d94b43BFa4Ff5935DBC608D7fc0116BB7'.toLowerCase(), + ], + 'Ramses': [ + '0x78a2251F1AAEaA8Fc1EaFcC379663cCa3F894708'.toLowerCase(), + ], + 'Auragi': [ + '0x268bb0220aB61Abd9BD42C5Db49470bb3E6B0b2F'.toLowerCase(), + ], + 'Solunea': [ + '0xf540E9C05ea1b54e310644Fc48E491d365bf86ba'.toLowerCase(), + ], + 'Chronos': [ + '0x111eEEb6bfAb9e8d0E87E45DB15031d89846e5d7'.toLowerCase(), + ], + 'Sushi': [ + '0x270250F59C1ffA06C9e3234D528858Ff59aFCE68'.toLowerCase(), + '0xc35DADB65012eC5796536bD9864eD8773aBc74C4'.toLowerCase(), + '0x3fDB0c33A86249ed689e497219acE3B80aFf5C0D'.toLowerCase(), + ], + }, + 'avax': { + 'Pangolin': [ + '0xBB92270716C8c424849F17cCc12F4F24AD4064D6'.toLowerCase(), + '0xC596f6455054D8cdDE627096bE671e377791E295'.toLowerCase(), + '0x0aD3E5Ff1A410610Ca2eAbfEcF703c9460766Fd3'.toLowerCase(), + '0xca45c0b54a59C63c15b8CF436512E8Fec78d0f49'.toLowerCase(), + ], + 'TraderJoe': [ + '0x16ED59ffbfbe62ebA9a69a304D38901F86461282'.toLowerCase(), + '0x58Fde5bdB2C6Bd828Bc41c12a68189C7cd93dCE2'.toLowerCase(), + '0x87da8bab9FbD09593F2368DC2F6fac3F80C2A845'.toLowerCase(), + '0xad587138E72fc2Bc29dA99471ce4d995425d8f0a'.toLowerCase(), + '0xbC1Bb900e34aDbb99957672361433c6ad62a0cAC'.toLowerCase(), + ], + 'Thorus': [ + '0x9141B3d02443a84793794f661Ae1e6607A03A201'.toLowerCase(), + ], + 'Flair': [ + '0x462bCeBb3743E5c0B126985D82782025bdeD23ca'.toLowerCase(), + ], + 'Glacier': [ + '0x7EB705bC12f488af3310d8166D3C577ACDBC619c'.toLowerCase(), + ], + }, + 'moonriver': { + 'Solarbeam': [ + '0xBB92270716C8c424849F17cCc12F4F24AD4064D6'.toLowerCase(), + '0x95887654d8646C26fAb33F344576E2E74b211256'.toLowerCase(), + '0x23bdECdB7073D5f899708f33FCaFff787b81e287'.toLowerCase(), + ], + }, + 'canto': { + 'Velocimeter': [ + '0x1c813cDd6dAecE2CB83C52F0798504e42816E9C5'.toLowerCase(), + ], + }, + 'era': { + 'Velocore': [ + '0x36BbDb0DEA4Aa211Dd76dF0a3201c89FD530851b'.toLowerCase(), + ], + 'VeSync': [ + '0xCF3CAD85885254CBD445d6511c502Da095863f11'.toLowerCase(), + ], + 'DraculaFi': [ + '0x589a63C2242c8E60cdACF6802AB04a721bA6049d'.toLowerCase(), + ], + }, + 'fantom': { + 'Solidex': [ + '0x8610Dc1912a55761a713D827a1a1ad131bE8f579'.toLowerCase(), + '0xF14f98E6F34C12Bd74fcEAC1668aF749fc269cFf'.toLowerCase(), + '0x9B1434a02Ee86302d463bB6B365EbdFAc56e067A'.toLowerCase(), + '0x95887654d8646C26fAb33F344576E2E74b211256'.toLowerCase(), + '0xB83D21F60B73B21506c69DEcdBcF7Ab5AB737eB2'.toLowerCase(), + ], + }, +}; + +let allCoins = []; + +const getAllLendingPoolsForChain = async (chain, block) => { + const { factories } = config[chain]; + + // looping through all factories to get all lending pools + let allLendingPoolAddresses = []; + let allLendingPoolAddressesParamsCalls = []; + let allLendingPoolAddressesTargetCalls = []; + let allLendingPoolsDetails = []; + let allToken0s = []; + let allToken1s = []; + let allLendingPoolDecimals = []; + let allLendingPoolReserves = []; + for (const factory of factories) { + // get the data for the current factory + const { + lendingPoolAddresses, + lendingPoolAddressesParamsCalls, + lendingPoolAddressesTargetCalls, + lendingPoolsDetails, + token0s, + token1s, + lendingPoolDecimals, + lendingPoolReserves, + } = await getAllLendingPools(factory, chain, block); + + // add the data to the arrays + allLendingPoolAddresses = [...allLendingPoolAddresses, ...lendingPoolAddresses]; + allLendingPoolAddressesParamsCalls = [...allLendingPoolAddressesParamsCalls, ...lendingPoolAddressesParamsCalls]; + allLendingPoolAddressesTargetCalls = [...allLendingPoolAddressesTargetCalls, ...lendingPoolAddressesTargetCalls]; + allLendingPoolsDetails = [...allLendingPoolsDetails, ...lendingPoolsDetails]; + allToken0s = [...allToken0s, ...token0s]; + allToken1s = [...allToken1s, ...token1s]; + allLendingPoolDecimals = [...allLendingPoolDecimals, ...lendingPoolDecimals]; + allLendingPoolReserves = [...allLendingPoolReserves, ...lendingPoolReserves]; + } + + const lendingPoolAddresses = allLendingPoolAddresses; + const lendingPoolAddressesParamsCalls = allLendingPoolAddressesParamsCalls; + const lendingPoolAddressesTargetCalls = allLendingPoolAddressesTargetCalls; + const lendingPoolsDetails = allLendingPoolsDetails; + const token0s = allToken0s; + const token1s = allToken1s; + const lendingPoolDecimals = allLendingPoolDecimals; + const lendingPoolReserves = allLendingPoolReserves; + + return { + lendingPoolAddresses: allLendingPoolAddresses, + lendingPoolAddressesParamsCalls: allLendingPoolAddressesParamsCalls, + lendingPoolAddressesTargetCalls: allLendingPoolAddressesTargetCalls, + lendingPoolsDetails: allLendingPoolsDetails, + token0s: allToken0s, + token1s: allToken1s, + lendingPoolDecimals: allLendingPoolDecimals, + lendingPoolReserves: allLendingPoolReserves, + }; +} + +const getAllLendingPools = async (factory, chain, block) => { + const { output: allLendingPoolsLength } = await tryUntilSucceed(() => + sdk.api.abi.call({ + target: factory, + abi: abi.allLendingPoolsLength, + chain, + block, + requery: true, + }) + ); + + // get all of the lending pools from the factory contract + const poolCalls = []; + for (let i = 0; i < +allLendingPoolsLength; i++) + poolCalls.push({ params: i }); + const { output: lendingPoolsResults } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + target: factory, + abi: abi.allLendingPools, + calls: poolCalls, + chain, + block, + requery: true, + }) + ); + let lendingPoolAddresses = lendingPoolsResults.map((i) => i.output); + // let lendingPoolAddresses = ['0xE4702e545F4bF51FD383d00F01Bc284Ec9B8aa64', '0x06D3AE1Cfe7D3D27B8b9f541E2d76e5f33778923']; + + // remove blacklisted pools + lendingPoolAddresses = lendingPoolAddresses.filter( + (i) => !blackListedPools[chain].includes(i.toLowerCase()) + ); + + // make sure the params and target are also filtered + let lendingPoolAddressesParamsCalls = lendingPoolAddresses.map((i) => ({ + params: i, + })); + let lendingPoolAddressesTargetCalls = lendingPoolAddresses.map((i) => ({ + target: i, + })); + let { output: getLendingPools } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + target: factory, + abi: abi.getLendingPool, + calls: lendingPoolAddressesParamsCalls, + chain, + block, + requery: true, + }) + ); + + let lendingPoolsDetails = getLendingPools.map((i) => i.output); + + // Removing all pool that are not initialized + lendingPoolAddresses = lendingPoolAddresses.filter( + (i, index) => lendingPoolsDetails[index].initialized + ); + lendingPoolAddressesParamsCalls = lendingPoolAddressesParamsCalls.filter( + (i, index) => lendingPoolsDetails[index].initialized + ); + lendingPoolAddressesTargetCalls = lendingPoolAddressesTargetCalls.filter( + (i, index) => lendingPoolsDetails[index].initialized + ); + lendingPoolsDetails = lendingPoolsDetails.filter( + (i, index) => lendingPoolsDetails[index].initialized + ) + + // get tokens 0 and 1 of all lending pools + const { output: token0sResults } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + calls: lendingPoolAddressesTargetCalls, + abi: abi.token0, + chain, + block, + requery: true, + }) + ); + const token0s = token0sResults.map((i) => i.output); + const { output: token1sResults } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + calls: lendingPoolAddressesTargetCalls, + abi: abi.token1, + chain, + block, + requery: true, + }) + ); + const token1s = token1sResults.map((i) => i.output); + // get lending pool address decimals + const { output: lendingPoolDecimalsResults } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + calls: lendingPoolAddressesTargetCalls, + abi: abi.decimals, + chain, + block, + requery: true, + }) + ); + const lendingPoolDecimals = lendingPoolDecimalsResults.map((i) => i.output); + const lendingPoolReserves = await getBorrowableTokensReserves(lendingPoolAddressesTargetCalls, chain, block, lendingPoolsDetails); + + return { + lendingPoolAddresses, + lendingPoolAddressesParamsCalls, + lendingPoolAddressesTargetCalls, + lendingPoolsDetails, + token0s, + token1s, + lendingPoolDecimals, + lendingPoolReserves, + }; +}; + +const getBorrowableTokensReserves = async (lendingPoolAddressesTargetCalls, chain, block, lendingPoolsDetails) => { + let lendingPoolReserves = []; + + const callTargets = []; + for (let i = 0; i < lendingPoolsDetails.length; i++) { + const borrowable0 = lendingPoolsDetails[i].borrowable0; + const borrowable1 = lendingPoolsDetails[i].borrowable1; + callTargets.push([borrowable0, borrowable1].map((i) => ({ target: i }))); + } + + const { output: getReservesResults } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + calls: callTargets.flat(), + abi: abi.totalBorrows, + chain, + block, + requery: true, + }) + ); + + for (let i = 0; i < getReservesResults.length; i += 2) { + lendingPoolReserves.push([getReservesResults[i].output, getReservesResults[i + 1].output]); + } + + return lendingPoolReserves; +} + +const getUnderlyingLiquidityPoolAddresses = async ( + lendingPoolAddresses, + lendingPoolAddressesTargetCalls, + chain, + block +) => { + const { output: lendingPoolSymbolsResults } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + calls: lendingPoolAddressesTargetCalls, + abi: abi.symbol, + chain, + block, + requery: true, + }) + ); + const lendingPoolSymbols = lendingPoolSymbolsResults.map((i) => i.output); + + // get underlying LP related info + let lpAddressesCalls = []; + let lpAddressesCallsIndex = []; + for (let index = 0; index < lendingPoolAddresses.length; index++) { + lpAddressesCalls.push({ target: lendingPoolAddresses[index] }); + lpAddressesCallsIndex.push(index); + } + + let underlyingLpAddresses = lendingPoolAddresses; + + if (chain !== 'ethereum') { + const { output: underlyingLpAddressesResults } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + abi: abi.underlying, + calls: lpAddressesCalls, + chain, + block, + permitFailure: true, + }), + ); + underlyingLpAddresses = underlyingLpAddressesResults.map((i) => i.output); + } + + if (lpAddressesCalls.length > 0) { + for (let x = 0; x < lpAddressesCalls.length; x++) { + underlyingLpAddresses[lpAddressesCallsIndex[x]] = + lendingPoolAddresses[lpAddressesCallsIndex[x]]; + } + } + const underlyingLpAddressesTargetCalls = underlyingLpAddresses.map((i) => ({ + target: i, + })); + const { output: underlyingLiquidityPoolSymbolsResults } = + await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + calls: underlyingLpAddressesTargetCalls, + abi: abi.symbol, + chain, + block, + requery: true, + }) + ); + const underlyingLiquidityPoolSymbols = + underlyingLiquidityPoolSymbolsResults.map((i) => i.output); + return { + lendingPoolSymbols, + underlyingLpAddresses, + underlyingLiquidityPoolSymbols, + }; +}; + +const removeDuplicatesFromArray = (arr) => { + return [...new Set([].concat(...arr))]; +}; + +const checkIfTokenKeyExists = (fetchedData, key) => { + return ( + fetchedData[key] + ); +}; + +const buildPoolMetadata = async ( + poolData, + tokenDetailsDict, + chain, + block, +) => { + const underlyingLiquidityPoolSymbols = poolData.map((i) => i.underlyingLiquidityPoolSymbol); + let lendingPoolAddresses = poolData.map((i) => i.lendingPoolAddress); + const token0Symbols = poolData.map((i) => tokenDetailsDict[i.token0].symbol); + const token1Symbols = poolData.map((i) => tokenDetailsDict[i.token1].symbol); + const tokenSymbols = poolData.map((i) => i.tokenSymbol); + + // picking every other record + const lendingPoolAddressesNoDuplicates = lendingPoolAddresses.filter((_, i) => i % 2 === 0); + + // use the factory to determine the pool name + const { output: lendingPoolFactory } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + calls: lendingPoolAddressesNoDuplicates.map((i) => ({ target: i })), + abi: abi.factory, + chain, + block, + requery: true, + }) + ); + const lendingPoolFactoriesNoDuplicates = lendingPoolFactory.map((i) => i.output); + + // augment the factories to match the number of pools so that factories are valid for 2 entries in the lending pool addresses + const lendingPoolFactories = []; + for (let i = 0; i < lendingPoolFactoriesNoDuplicates.length; i++) { + lendingPoolFactories.push(lendingPoolFactoriesNoDuplicates[i]); + lendingPoolFactories.push(lendingPoolFactoriesNoDuplicates[i]); + } + + // map factories to protocol using factoryToProtocolMapping + let formatedPoolMeta = lendingPoolFactories.map((i, fIndex) => { + const poolId = `${lendingPoolAddresses[fIndex]}-${tokenSymbols[fIndex]}-${chain}`; + let poolMeta; + for (const [key, value] of Object.entries(factoryToProtocolMapping[chain])) { + if (i !== undefined && value.includes(i.toLowerCase())) { + poolMeta = `${key} ${token0Symbols[fIndex]}/${token1Symbols[fIndex]}`; + } + } + + if (poolMeta === undefined) { + // console.log('unknown factory for pool ', poolId, ' with factory ', i); + poolMeta = `${i} ${token0Symbols[fIndex]}/${token1Symbols[fIndex]}`; + } + + return { poolId, poolMeta }; + }); + + return formatedPoolMeta; +}; + +async function getTokenPrices(tokens, chain, allCoins) { + const chainCoins = allCoins.data.filter( + (coin) => coin && coin.platforms && coin.platforms[coinGeckoChainMapping[chain]] + ); + + const tokenAddresses = tokens.map((a) => a.toLowerCase()); + const coins = chainCoins.filter((coin) => + tokenAddresses.includes(coin.platforms[coinGeckoChainMapping[chain]].toLowerCase()) + ); + + const markets = ( + await axios.get( + `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=${coins + .map((c) => c.id) + .join(',')}` + ) + ).data; + + async function getPriceFromDexScreener(token) { + let pairs = ( + await axios.get(`https://api.dexscreener.com/latest/dex/tokens/${token}`) + ).data.pairs; + if (!pairs?.length) return undefined; + // remove pairs with no liquidity + pairs = pairs.filter((p) => p.liquidity && p.liquidity.usd > 0); + + const totalLiquidity = pairs + .map((p) => p.liquidity.usd) + .reduce((a, b) => a + b); + return ( + pairs.map((p) => p.priceUsd * p.liquidity.usd).reduce((a, b) => a + b) / + totalLiquidity + ); + } + + function getPriceFromCoinGecko(token) { + const id = chainCoins.find( + (coin) => + coin.platforms[coinGeckoChainMapping[chain]].toLowerCase() === token.toLowerCase() + )?.id; + if (id === undefined) return undefined; + const marketData = markets.find((m) => m.id === id); + return marketData?.current_price; + } + + async function getPrice(token) { + return ( + getPriceFromCoinGecko(token) ?? (await getPriceFromDexScreener(token)) + ); + } + + const pricePromises = tokenAddresses.map((t) => + getPrice(t).then((p) => [t, p]) + ); + const prices = await Promise.all(pricePromises).then((results) => + Object.fromEntries(results) + ); + + return prices; +} + +const getTokenDetails = async (allUniqueTokens, chain, block) => { + let results = {}; + const tokensCalls = allUniqueTokens.map((i) => ({ target: i })); + const { output: getTokenDecimals } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + abi: `erc20:decimals`, + calls: tokensCalls, + chain, + block, + requery: true, + }) + ); + // underlying tokens symbol just reference from bulk + const { output: getTokenSymbols } = await tryUntilSucceed(() => + sdk.api.abi.multiCall({ + abi: `erc20:symbol`, + calls: tokensCalls, + chain, + block, + requery: true, + }) + ); + const tokensSymbols = getTokenSymbols.map((i) => i.output); + + for (let i = 0; i < getTokenDecimals.length; i++) { + tokensDecimalResult = getTokenDecimals[i]; + tokenSymbolResult = getTokenSymbols[i]; + let key = tokensDecimalResult.input.target; + results[key] = { + decimals: tokensDecimalResult.output, + symbol: tokenSymbolResult.output, + }; + } + return results; +}; + +// calculate tvl function +const caculateTvl = ( + excessSupply, + tokenDecimals, + underlyingTokenPriceUsd, + lpReserve +) => { + const excessSupplyUsd = BigNumber(excessSupply) + .div(BigNumber(10).pow(BigNumber(tokenDecimals))) + .times(BigNumber(underlyingTokenPriceUsd)); + const lpTvlUsd = BigNumber(lpReserve) + .div(BigNumber(10).pow(BigNumber(tokenDecimals))) + .times(BigNumber(underlyingTokenPriceUsd)); + const totalTvl = excessSupplyUsd.plus(lpTvlUsd); + + // Impermax being a lending protocol, ltvUsd is actually the available liquidity + // in our case, this translates directly to the excess supply + // return ltvUsd; + return excessSupplyUsd; +}; + +// calculate apy function +const calculateApy = ( + borrowRate, + borrowableDecimal, + totalBorrows, + totalSupply, + reserveFactor +) => { + const borrowRateAPY = BigNumber(borrowRate) + .div(BigNumber(10).pow(BigNumber(borrowableDecimal))) + .times(SECONDS_IN_YEAR); + const utilization = BigNumber(totalBorrows).div(BigNumber(totalSupply)); + const supplyRateAPY = BigNumber(borrowRate) + .times(BigNumber(utilization)) + .times( + BigNumber(10) + .pow(BigNumber(borrowableDecimal)) + .minus(BigNumber(reserveFactor)) + ) + .times(SECONDS_IN_YEAR) + .div( + BigNumber(10) + .pow(BigNumber(borrowableDecimal)) + .times(BigNumber(10).pow(BigNumber(borrowableDecimal))) + ); + return { borrowRateAPY, utilization, supplyRateAPY }; +}; + +const main = async () => { + let data = []; + + allCoins = ( + await axios.get( + 'https://api.coingecko.com/api/v3/coins/list?include_platform=true' + ) + ); + + for (const chain of Object.keys(config)) { + let collaterals = []; + let borrowables = []; + + const provider = getProvider(chain); + const block = await provider.getBlockNumber(); + + const { + lendingPoolAddresses, + lendingPoolAddressesParamsCalls, + lendingPoolAddressesTargetCalls, + lendingPoolsDetails, + token0s, + token1s, + lendingPoolDecimals, + lendingPoolReserves, + } = await getAllLendingPoolsForChain(chain, block); + + // get underlying LP related info + const { + lendingPoolSymbols, + underlyingLpAddresses, + underlyingLiquidityPoolSymbols, + } = await getUnderlyingLiquidityPoolAddresses( + lendingPoolAddresses, + lendingPoolAddressesTargetCalls, + chain, + block + ); + + const allTokens = [...token0s, ...token1s]; + const allUniqueTokens = removeDuplicatesFromArray(allTokens); + + let fetchedPrices = await getTokenPrices(allUniqueTokens, chain, allCoins); + + // go to the next factory contract since no tokens were found here. + if (Object.keys(fetchedPrices) === 0) { + continue; + } + const tokenDetailsDict = await getTokenDetails( + allUniqueTokens, + chain, + block + ); + + let allBorrowables = lendingPoolsDetails.flatMap( + (lendingPoolDetails, i) => { + const reserves = lendingPoolReserves[i]; + const lendingPoolAddress = lendingPoolAddresses[i]; + if (reserves === null) { + return null; + } + const underlyingLiquidityPoolSymbol = + underlyingLiquidityPoolSymbols[i]; + // check if the lending pool has a name + if (underlyingLiquidityPoolSymbol === null) { + return null; + } + const borrowable0 = lendingPoolDetails.borrowable0; + const borrowable1 = lendingPoolDetails.borrowable1; + const collateral = lendingPoolDetails.collateral; + const token0 = token0s[i]; + const token1 = token1s[i]; + const lendingPoolDecimal = lendingPoolDecimals[i]; + + return [ + { + lpReserve: reserves[0], + lendingPoolAddress, + underlyingLiquidityPoolSymbol, + underlyingTokenAddress: token0, + borrowableTokenAddress: borrowable0, + collateral, + token0, + token1, + lendingPoolDecimal, + tokenSymbol: tokenDetailsDict[token0].symbol, + tokenDecimals: tokenDetailsDict[token0].decimals, + }, + { + lpReserve: reserves[1], + lendingPoolAddress, + underlyingLiquidityPoolSymbol, + underlyingTokenAddress: token1, + borrowableTokenAddress: borrowable1, + collateral, + token0, + token1, + lendingPoolDecimal, + tokenSymbol: tokenDetailsDict[token1].symbol, + tokenDecimals: tokenDetailsDict[token1].decimals, + }, + ]; + } + ); + + // remove null + allBorrowables = allBorrowables.filter((p) => p); + + const excessSupplyRes = await sdk.api.abi.multiCall({ + abi: 'erc20:balanceOf', + calls: allBorrowables.map((b) => ({ + target: b.underlyingTokenAddress, + params: b.borrowableTokenAddress, + })), + chain, + }); + const excessSupply = excessSupplyRes.output.map((res) => res.output); + + const [ + reserveFactorRes, + totalBorrowsRes, + borrowRateRes, + borrowableDecimalRes, + ] = await Promise.all( + ['reserveFactor', 'totalBorrows', 'borrowRate', 'decimals'].map( + (method) => + sdk.api.abi.multiCall({ + abi: abi[method], + calls: allBorrowables.map((b) => ({ + target: b.borrowableTokenAddress, + params: null, + })), + chain: chain, + requery: true, + }) + ) + ); + const reserveFactor = reserveFactorRes.output.map((res) => res.output); + const totalBorrows = totalBorrowsRes.output.map((res) => res.output); + const borrowRate = borrowRateRes.output.map((res) => res.output); + const borrowableDecimal = borrowableDecimalRes.output.map( + (res) => res.output + ); + + const poolMetaData = await buildPoolMetadata( + allBorrowables, + tokenDetailsDict, + chain, + block, + ); + + // calculate the tvl and yields for each borrowables + data = [ + ...data, + ...allBorrowables + .map((borrowable, i) => { + // skip if no data + if (!borrowable) { + return null; + } + const totalSupply = BigNumber(totalBorrows[i]).plus( + BigNumber(excessSupply[i]) + ); + //apy calculations + const { borrowRateAPY, utilization, supplyRateAPY } = calculateApy( + borrowRate[i], + borrowableDecimal[i], + totalBorrows[i], + totalSupply, + reserveFactor[i] + ); + const { poolId, poolMeta } = poolMetaData[i]; + // if poolId is undefined, probably abi is not published so skip + if (poolId === undefined) { + return null; + } + + if (!checkIfTokenKeyExists(fetchedPrices, borrowable.underlyingTokenAddress.toLowerCase())) { + return null; + } + // tvl calculations + const underlyingTokenPriceUsd = + fetchedPrices[borrowable.underlyingTokenAddress.toLowerCase()]; + const totalTvl = caculateTvl( + excessSupply[i], + borrowable.tokenDecimals, + underlyingTokenPriceUsd, + borrowable.lpReserve + ); + let poolData = { + pool: `${poolId}`, + poolMeta: `${poolMeta}`, + chain: chain, + project: protocolSlug, + symbol: utils.formatSymbol(borrowable.tokenSymbol), + tvlUsd: totalTvl.toNumber(), + apyBase: supplyRateAPY.times(BigNumber(100)).toNumber(), + underlyingTokens: [borrowable.token0, borrowable.token1], + }; + // add the data if the supply apy exists and the total tvl is under the threshold + if (!supplyRateAPY.isNaN()) { + return poolData; + } else { + return null; + } + }) + .filter((data) => { + return data !== null; + }), + ]; + + } + + // remove potential dupliates based on pool ID + data = data.filter( + (v, i, a) => a.findIndex((t) => t.pool === v.pool) === i + ); + + return data; +} + +module.exports = { + timetravel: false, + apy: main, + url: 'https://www.impermax.finance/', +}; diff --git a/src/adaptors/liquis/abis/BalancerToken.json b/src/adaptors/liquis/abis/BalancerToken.json new file mode 100644 index 0000000000..5c9e9ee493 --- /dev/null +++ b/src/adaptors/liquis/abis/BalancerToken.json @@ -0,0 +1,672 @@ +[ + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IVault", + "name": "vault", + "type": "address" + }, + { "internalType": "string", "name": "name", "type": "string" }, + { "internalType": "string", "name": "symbol", "type": "string" }, + { + "internalType": "contract IERC20", + "name": "token0", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint256", + "name": "normalizedWeight0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "normalizedWeight1", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pauseWindowDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bufferPeriodDuration", + "type": "uint256" + }, + { "internalType": "bool", "name": "oracleEnabled", "type": "bool" }, + { "internalType": "address", "name": "owner", "type": "address" } + ], + "internalType": "struct WeightedPool2Tokens.NewPoolParams", + "name": "params", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "name": "OracleEnabledChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "PausedStateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "name": "SwapFeePercentageChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "decreaseApproval", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "enableOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes4", "name": "selector", "type": "bytes4" } + ], + "name": "getActionId", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { "internalType": "contract IAuthorizer", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getInvariant", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLargestSafeQueryWindow", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getLastInvariant", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IPriceOracle.Variable", + "name": "variable", + "type": "uint8" + } + ], + "name": "getLatest", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMiscData", + "outputs": [ + { "internalType": "int256", "name": "logInvariant", "type": "int256" }, + { "internalType": "int256", "name": "logTotalSupply", "type": "int256" }, + { + "internalType": "uint256", + "name": "oracleSampleCreationTimestamp", + "type": "uint256" + }, + { "internalType": "uint256", "name": "oracleIndex", "type": "uint256" }, + { "internalType": "bool", "name": "oracleEnabled", "type": "bool" }, + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getNormalizedWeights", + "outputs": [ + { "internalType": "uint256[]", "name": "", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOwner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum IPriceOracle.Variable", + "name": "variable", + "type": "uint8" + }, + { "internalType": "uint256", "name": "ago", "type": "uint256" } + ], + "internalType": "struct IPriceOracle.OracleAccumulatorQuery[]", + "name": "queries", + "type": "tuple[]" + } + ], + "name": "getPastAccumulators", + "outputs": [ + { "internalType": "int256[]", "name": "results", "type": "int256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPausedState", + "outputs": [ + { "internalType": "bool", "name": "paused", "type": "bool" }, + { + "internalType": "uint256", + "name": "pauseWindowEndTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bufferPeriodEndTime", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolId", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "index", "type": "uint256" } + ], + "name": "getSample", + "outputs": [ + { "internalType": "int256", "name": "logPairPrice", "type": "int256" }, + { "internalType": "int256", "name": "accLogPairPrice", "type": "int256" }, + { "internalType": "int256", "name": "logBptPrice", "type": "int256" }, + { "internalType": "int256", "name": "accLogBptPrice", "type": "int256" }, + { "internalType": "int256", "name": "logInvariant", "type": "int256" }, + { "internalType": "int256", "name": "accLogInvariant", "type": "int256" }, + { "internalType": "uint256", "name": "timestamp", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSwapFeePercentage", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum IPriceOracle.Variable", + "name": "variable", + "type": "uint8" + }, + { "internalType": "uint256", "name": "secs", "type": "uint256" }, + { "internalType": "uint256", "name": "ago", "type": "uint256" } + ], + "internalType": "struct IPriceOracle.OracleAverageQuery[]", + "name": "queries", + "type": "tuple[]" + } + ], + "name": "getTimeWeightedAverage", + "outputs": [ + { "internalType": "uint256[]", "name": "results", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalSamples", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getVault", + "outputs": [ + { "internalType": "contract IVault", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "increaseApproval", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" } + ], + "name": "nonces", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "name": "onExitPool", + "outputs": [ + { "internalType": "uint256[]", "name": "", "type": "uint256[]" }, + { "internalType": "uint256[]", "name": "", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "name": "onJoinPool", + "outputs": [ + { "internalType": "uint256[]", "name": "amountsIn", "type": "uint256[]" }, + { + "internalType": "uint256[]", + "name": "dueProtocolFeeAmounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum IVault.SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "contract IERC20", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "tokenOut", + "type": "address" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "internalType": "struct IPoolSwapStructs.SwapRequest", + "name": "request", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "balanceTokenIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceTokenOut", + "type": "uint256" + } + ], + "name": "onSwap", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "name": "queryExit", + "outputs": [ + { "internalType": "uint256", "name": "bptIn", "type": "uint256" }, + { "internalType": "uint256[]", "name": "amountsOut", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "name": "queryJoin", + "outputs": [ + { "internalType": "uint256", "name": "bptOut", "type": "uint256" }, + { "internalType": "uint256[]", "name": "amountsIn", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bool", "name": "paused", "type": "bool" }], + "name": "setPaused", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "name": "setSwapFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/adaptors/liquis/abis/Booster.json b/src/adaptors/liquis/abis/Booster.json new file mode 100644 index 0000000000..bf07793e97 --- /dev/null +++ b/src/adaptors/liquis/abis/Booster.json @@ -0,0 +1,915 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_staker", "type": "address" }, + { "internalType": "address", "name": "_minter", "type": "address" }, + { "internalType": "address", "name": "_crv", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newArbitrator", + "type": "address" + } + ], + "name": "ArbitratorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "poolid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Deposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "rewardFactory", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "stashFactory", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "tokenFactory", + "type": "address" + } + ], + "name": "FactoriesUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "feeDistro", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "active", + "type": "bool" + } + ], + "name": "FeeInfoChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "feeDistro", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "lockFees", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "feeToken", + "type": "address" + } + ], + "name": "FeeInfoUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newFeeManager", + "type": "address" + } + ], + "name": "FeeManagerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "lockIncentive", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stakerIncentive", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "earmarkIncentive", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "platformFee", + "type": "uint256" + } + ], + "name": "FeesUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "lpToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "gauge", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "rewardPool", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "stash", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + } + ], + "name": "PoolAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newPoolManager", + "type": "address" + } + ], + "name": "PoolManagerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "PoolShutdown", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "lockRewards", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "stakerRewards", + "type": "address" + } + ], + "name": "RewardContractsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newTreasury", + "type": "address" + } + ], + "name": "TreasuryUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "votingContract", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "active", + "type": "bool" + } + ], + "name": "UpdateVotingContract", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newVoteDelegate", + "type": "address" + } + ], + "name": "VoteDelegateUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newVoteManager", + "type": "address" + } + ], + "name": "VoteManagerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "poolid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Withdrawn", + "type": "event" + }, + { + "inputs": [], + "name": "FEE_DENOMINATOR", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MaxFees", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "REWARD_MULTIPLIER_DENOMINATOR", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_lptoken", "type": "address" }, + { "internalType": "address", "name": "_gauge", "type": "address" }, + { "internalType": "uint256", "name": "_stashVersion", "type": "uint256" } + ], + "name": "addPool", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "bridgeDelegate", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "address", "name": "_gauge", "type": "address" } + ], + "name": "claimRewards", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "crv", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "internalType": "bool", "name": "_stake", "type": "bool" } + ], + "name": "deposit", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "bool", "name": "_stake", "type": "bool" } + ], + "name": "depositAll", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "distributeL2Fees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_feeToken", "type": "address" } + ], + "name": "earmarkFees", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "earmarkIncentive", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" } + ], + "name": "earmarkRewards", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "feeManager", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "feeTokens", + "outputs": [ + { "internalType": "address", "name": "distro", "type": "address" }, + { "internalType": "address", "name": "rewards", "type": "address" }, + { "internalType": "bool", "name": "active", "type": "bool" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "gaugeMap", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "getRewardMultipliers", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isShutdown", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "l2FeesHistory", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lockIncentive", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lockRewards", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minter", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "platformFee", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "poolInfo", + "outputs": [ + { "internalType": "address", "name": "lptoken", "type": "address" }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "address", "name": "gauge", "type": "address" }, + { "internalType": "address", "name": "crvRewards", "type": "address" }, + { "internalType": "address", "name": "stash", "type": "address" }, + { "internalType": "bool", "name": "shutdown", "type": "bool" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolLength", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolManager", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardArbitrator", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "address", "name": "_address", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "rewardClaimed", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardFactory", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_arb", "type": "address" } + ], + "name": "setArbitrator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_bridgeDelegate", + "type": "address" + } + ], + "name": "setBridgeDelegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_delegateContract", + "type": "address" + }, + { "internalType": "address", "name": "_delegate", "type": "address" }, + { "internalType": "bytes32", "name": "_space", "type": "bytes32" } + ], + "name": "setDelegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_rfactory", "type": "address" }, + { "internalType": "address", "name": "_sfactory", "type": "address" }, + { "internalType": "address", "name": "_tfactory", "type": "address" } + ], + "name": "setFactories", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_feeToken", "type": "address" }, + { "internalType": "address", "name": "_feeDistro", "type": "address" } + ], + "name": "setFeeInfo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_feeM", "type": "address" } + ], + "name": "setFeeManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_lockFees", "type": "uint256" }, + { "internalType": "uint256", "name": "_stakerFees", "type": "uint256" }, + { "internalType": "uint256", "name": "_callerFees", "type": "uint256" }, + { "internalType": "uint256", "name": "_platform", "type": "uint256" } + ], + "name": "setFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" } + ], + "name": "setGaugeRedirect", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "setOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_poolM", "type": "address" } + ], + "name": "setPoolManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_rewards", "type": "address" }, + { "internalType": "address", "name": "_stakerRewards", "type": "address" } + ], + "name": "setRewardContracts", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "rewardContract", + "type": "address" + }, + { "internalType": "uint256", "name": "multiplier", "type": "uint256" } + ], + "name": "setRewardMultiplier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_treasury", "type": "address" } + ], + "name": "setTreasury", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "_hash", "type": "bytes32" } + ], + "name": "setVote", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_voteDelegate", "type": "address" } + ], + "name": "setVoteDelegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_voteManager", "type": "address" } + ], + "name": "setVoteManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" } + ], + "name": "shutdownPool", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "shutdownSystem", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "staker", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stakerIncentive", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stakerRewards", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stashFactory", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tokenFactory", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "treasury", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_feeToken", "type": "address" }, + { "internalType": "bool", "name": "_active", "type": "bool" } + ], + "name": "updateFeeInfo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_votingContract", + "type": "address" + }, + { "internalType": "bool", "name": "_active", "type": "bool" } + ], + "name": "updateVotingContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "validVotingContracts", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_voteId", "type": "uint256" }, + { + "internalType": "address", + "name": "_votingAddress", + "type": "address" + }, + { "internalType": "bool", "name": "_support", "type": "bool" } + ], + "name": "vote", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "voteDelegate", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address[]", "name": "_gauge", "type": "address[]" }, + { "internalType": "uint256[]", "name": "_weight", "type": "uint256[]" } + ], + "name": "voteGaugeWeight", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "voteManager", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "withdraw", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" } + ], + "name": "withdrawAll", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "internalType": "address", "name": "_to", "type": "address" } + ], + "name": "withdrawTo", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/adaptors/liquis/abis/BunniHub.json b/src/adaptors/liquis/abis/BunniHub.json new file mode 100644 index 0000000000..3e70e2a2fa --- /dev/null +++ b/src/adaptors/liquis/abis/BunniHub.json @@ -0,0 +1,812 @@ +[ + { + "inputs": [ + { + "internalType": "contract IUniswapV3Factory", + "name": "factory_", + "type": "address" + }, + { + "internalType": "address", + "name": "owner_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "protocolFee_", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "T", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "bunniKeyHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Compound", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "bunniKeyHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IBunniToken", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "bunniKeyHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "contract IUniswapV3Pool", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "indexed": false, + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "name": "NewBunni", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "PayProtocolFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newProtocolFee", + "type": "uint256" + } + ], + "name": "SetProtocolFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "bunniKeyHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IUniswapV3Pool", + "name": "pool", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "internalType": "struct BunniKey", + "name": "key", + "type": "tuple" + } + ], + "name": "compound", + "outputs": [ + { + "internalType": "uint128", + "name": "addedLiquidity", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IUniswapV3Pool", + "name": "pool", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "internalType": "struct BunniKey", + "name": "key", + "type": "tuple" + } + ], + "name": "deployBunniToken", + "outputs": [ + { + "internalType": "contract IBunniToken", + "name": "token", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "contract IUniswapV3Pool", + "name": "pool", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "internalType": "struct BunniKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "amount0Desired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Desired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "internalType": "struct IBunniHub.DepositParams", + "name": "params", + "type": "tuple" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "addedLiquidity", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "contract IUniswapV3Factory", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IUniswapV3Pool", + "name": "pool", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "internalType": "struct BunniKey", + "name": "key", + "type": "tuple" + } + ], + "name": "getBunniToken", + "outputs": [ + { + "internalType": "contract IBunniToken", + "name": "token", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitAllowed", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitAllowedIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "setOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "setProtocolFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokenList", + "type": "address[]" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "sweepTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount0Owed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Owed", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "uniswapV3MintCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "contract IUniswapV3Pool", + "name": "pool", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "internalType": "struct BunniKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "internalType": "struct IBunniHub.WithdrawParams", + "name": "params", + "type": "tuple" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint128", + "name": "removedLiquidity", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/adaptors/liquis/abis/BunniLens.json b/src/adaptors/liquis/abis/BunniLens.json new file mode 100644 index 0000000000..b493afba9c --- /dev/null +++ b/src/adaptors/liquis/abis/BunniLens.json @@ -0,0 +1,118 @@ +[ + { + "inputs": [ + { + "internalType": "contract IBunniHub", + "name": "hub_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "T", + "type": "error" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IUniswapV3Pool", + "name": "pool", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "internalType": "struct BunniKey", + "name": "key", + "type": "tuple" + } + ], + "name": "getReserves", + "outputs": [ + { + "internalType": "uint112", + "name": "reserve0", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "reserve1", + "type": "uint112" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hub", + "outputs": [ + { + "internalType": "contract IBunniHub", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IUniswapV3Pool", + "name": "pool", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "internalType": "struct BunniKey", + "name": "key", + "type": "tuple" + } + ], + "name": "pricePerFullShare", + "outputs": [ + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/adaptors/liquis/abis/GaugeController.json b/src/adaptors/liquis/abis/GaugeController.json new file mode 100644 index 0000000000..eaee92db1f --- /dev/null +++ b/src/adaptors/liquis/abis/GaugeController.json @@ -0,0 +1,825 @@ +[ + { + "name": "AddType", + "inputs": [ + { + "name": "name", + "type": "string", + "indexed": false + }, + { + "name": "type_id", + "type": "int128", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewTypeWeight", + "inputs": [ + { + "name": "type_id", + "type": "int128", + "indexed": false + }, + { + "name": "time", + "type": "uint256", + "indexed": false + }, + { + "name": "weight", + "type": "uint256", + "indexed": false + }, + { + "name": "total_weight", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewGaugeWeight", + "inputs": [ + { + "name": "gauge_address", + "type": "address", + "indexed": false + }, + { + "name": "time", + "type": "uint256", + "indexed": false + }, + { + "name": "weight", + "type": "uint256", + "indexed": false + }, + { + "name": "total_weight", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "VoteForGauge", + "inputs": [ + { + "name": "time", + "type": "uint256", + "indexed": false + }, + { + "name": "user", + "type": "address", + "indexed": false + }, + { + "name": "gauge_addr", + "type": "address", + "indexed": false + }, + { + "name": "weight", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewGauge", + "inputs": [ + { + "name": "addr", + "type": "address", + "indexed": false + }, + { + "name": "gauge_type", + "type": "int128", + "indexed": false + }, + { + "name": "weight", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewPendingAdmin", + "inputs": [ + { + "name": "new_pending_admin", + "type": "address", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewAdmin", + "inputs": [ + { + "name": "new_admin", + "type": "address", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "stateMutability": "nonpayable", + "type": "constructor", + "inputs": [ + { + "name": "_voting_escrow", + "type": "address" + }, + { + "name": "_admin", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "view", + "type": "function", + "name": "token", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "voting_escrow", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauge_exists", + "inputs": [ + { + "name": "_addr", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauge_types", + "inputs": [ + { + "name": "_addr", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "int128" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "add_gauge", + "inputs": [ + { + "name": "addr", + "type": "address" + }, + { + "name": "gauge_type", + "type": "int128" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "add_gauge", + "inputs": [ + { + "name": "addr", + "type": "address" + }, + { + "name": "gauge_type", + "type": "int128" + }, + { + "name": "weight", + "type": "uint256" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "checkpoint", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "checkpoint_gauge", + "inputs": [ + { + "name": "addr", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauge_relative_weight", + "inputs": [ + { + "name": "addr", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauge_relative_weight", + "inputs": [ + { + "name": "addr", + "type": "address" + }, + { + "name": "time", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "gauge_relative_weight_write", + "inputs": [ + { + "name": "addr", + "type": "address" + }, + { + "name": "time", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "add_type", + "inputs": [ + { + "name": "_name", + "type": "string" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "add_type", + "inputs": [ + { + "name": "_name", + "type": "string" + }, + { + "name": "weight", + "type": "uint256" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "change_type_weight", + "inputs": [ + { + "name": "type_id", + "type": "int128" + }, + { + "name": "weight", + "type": "uint256" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "change_gauge_weight", + "inputs": [ + { + "name": "addr", + "type": "address" + }, + { + "name": "weight", + "type": "uint256" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "vote_for_many_gauge_weights", + "inputs": [ + { + "name": "_gauge_addrs", + "type": "address[8]" + }, + { + "name": "_user_weight", + "type": "uint256[8]" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "vote_for_gauge_weights", + "inputs": [ + { + "name": "_gauge_addr", + "type": "address" + }, + { + "name": "_user_weight", + "type": "uint256" + } + ], + "outputs": [] + }, + { + "stateMutability": "view", + "type": "function", + "name": "get_gauge_weight", + "inputs": [ + { + "name": "addr", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "get_type_weight", + "inputs": [ + { + "name": "type_id", + "type": "int128" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "get_total_weight", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "get_weights_sum_per_type", + "inputs": [ + { + "name": "type_id", + "type": "int128" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "change_pending_admin", + "inputs": [ + { + "name": "new_pending_admin", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_admin", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "view", + "type": "function", + "name": "pending_admin", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "admin", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "n_gauge_types", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "int128" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "n_gauges", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "int128" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauge_type_names", + "inputs": [ + { + "name": "arg0", + "type": "int128" + } + ], + "outputs": [ + { + "name": "", + "type": "string" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauges", + "inputs": [ + { + "name": "arg0", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "vote_user_slopes", + "inputs": [ + { + "name": "arg0", + "type": "address" + }, + { + "name": "arg1", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "components": [ + { + "name": "slope", + "type": "uint256" + }, + { + "name": "power", + "type": "uint256" + }, + { + "name": "end", + "type": "uint256" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "vote_user_power", + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "last_user_vote", + "inputs": [ + { + "name": "arg0", + "type": "address" + }, + { + "name": "arg1", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "points_weight", + "inputs": [ + { + "name": "arg0", + "type": "address" + }, + { + "name": "arg1", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "components": [ + { + "name": "bias", + "type": "uint256" + }, + { + "name": "slope", + "type": "uint256" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "time_weight", + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "points_sum", + "inputs": [ + { + "name": "arg0", + "type": "int128" + }, + { + "name": "arg1", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "components": [ + { + "name": "bias", + "type": "uint256" + }, + { + "name": "slope", + "type": "uint256" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "time_sum", + "inputs": [ + { + "name": "arg0", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "points_total", + "inputs": [ + { + "name": "arg0", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "time_total", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "points_type_weight", + "inputs": [ + { + "name": "arg0", + "type": "int128" + }, + { + "name": "arg1", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "time_type_weight", + "inputs": [ + { + "name": "arg0", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + } +] diff --git a/src/adaptors/liquis/abis/LiquidityGauge.json b/src/adaptors/liquis/abis/LiquidityGauge.json new file mode 100644 index 0000000000..7f3a098ca9 --- /dev/null +++ b/src/adaptors/liquis/abis/LiquidityGauge.json @@ -0,0 +1,1229 @@ +[ + { + "name": "Deposit", + "inputs": [ + { + "name": "provider", + "type": "address", + "indexed": true + }, + { + "name": "value", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "Withdraw", + "inputs": [ + { + "name": "provider", + "type": "address", + "indexed": true + }, + { + "name": "value", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateLiquidityLimit", + "inputs": [ + { + "name": "user", + "type": "address", + "indexed": true + }, + { + "name": "original_balance", + "type": "uint256", + "indexed": false + }, + { + "name": "original_supply", + "type": "uint256", + "indexed": false + }, + { + "name": "working_balance", + "type": "uint256", + "indexed": false + }, + { + "name": "working_supply", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "Transfer", + "inputs": [ + { + "name": "_from", + "type": "address", + "indexed": true + }, + { + "name": "_to", + "type": "address", + "indexed": true + }, + { + "name": "_value", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "Approval", + "inputs": [ + { + "name": "_owner", + "type": "address", + "indexed": true + }, + { + "name": "_spender", + "type": "address", + "indexed": true + }, + { + "name": "_value", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RewardDistributorUpdated", + "inputs": [ + { + "name": "reward_token", + "type": "address", + "indexed": true + }, + { + "name": "distributor", + "type": "address", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RelativeWeightCapChanged", + "inputs": [ + { + "name": "new_relative_weight_cap", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewPendingAdmin", + "inputs": [ + { + "name": "new_pending_admin", + "type": "address", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewAdmin", + "inputs": [ + { + "name": "new_admin", + "type": "address", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewTokenlessProduction", + "inputs": [ + { + "name": "new_tokenless_production", + "type": "uint8", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, + { + "stateMutability": "nonpayable", + "type": "constructor", + "inputs": [ + { + "name": "minter", + "type": "address" + }, + { + "name": "uniswap_poor_oracle", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "deposit", + "inputs": [ + { + "name": "_value", + "type": "uint256" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "deposit", + "inputs": [ + { + "name": "_value", + "type": "uint256" + }, + { + "name": "_addr", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "deposit", + "inputs": [ + { + "name": "_value", + "type": "uint256" + }, + { + "name": "_addr", + "type": "address" + }, + { + "name": "_claim_rewards", + "type": "bool" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "withdraw", + "inputs": [ + { + "name": "_value", + "type": "uint256" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "withdraw", + "inputs": [ + { + "name": "_value", + "type": "uint256" + }, + { + "name": "_claim_rewards", + "type": "bool" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_rewards", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_rewards", + "inputs": [ + { + "name": "_addr", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_rewards", + "inputs": [ + { + "name": "_addr", + "type": "address" + }, + { + "name": "_receiver", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "transferFrom", + "inputs": [ + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "transfer", + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "permit", + "inputs": [ + { + "name": "_owner", + "type": "address" + }, + { + "name": "_spender", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + }, + { + "name": "_deadline", + "type": "uint256" + }, + { + "name": "_v", + "type": "uint8" + }, + { + "name": "_r", + "type": "bytes32" + }, + { + "name": "_s", + "type": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "increaseAllowance", + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_added_value", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "decreaseAllowance", + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_subtracted_value", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "user_checkpoint", + "inputs": [ + { + "name": "addr", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "set_rewards_receiver", + "inputs": [ + { + "name": "_receiver", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "kick", + "inputs": [ + { + "name": "addr", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "deposit_reward_token", + "inputs": [ + { + "name": "_reward_token", + "type": "address" + }, + { + "name": "_amount", + "type": "uint256" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "add_reward", + "inputs": [ + { + "name": "_reward_token", + "type": "address" + }, + { + "name": "_distributor", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "set_reward_distributor", + "inputs": [ + { + "name": "_reward_token", + "type": "address" + }, + { + "name": "_distributor", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "makeGaugePermissionless", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "killGauge", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "unkillGauge", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "change_pending_admin", + "inputs": [ + { + "name": "new_pending_admin", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_admin", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "set_tokenless_production", + "inputs": [ + { + "name": "new_tokenless_production", + "type": "uint8" + } + ], + "outputs": [] + }, + { + "stateMutability": "view", + "type": "function", + "name": "claimed_reward", + "inputs": [ + { + "name": "_addr", + "type": "address" + }, + { + "name": "_token", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "claimable_reward", + "inputs": [ + { + "name": "_user", + "type": "address" + }, + { + "name": "_reward_token", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claimable_tokens", + "inputs": [ + { + "name": "addr", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_checkpoint", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_epoch_time", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "inflation_rate", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "allowance", + "inputs": [ + { + "name": "owner", + "type": "address" + }, + { + "name": "spender", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "is_killed", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bool" + } + ] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "initialize", + "inputs": [ + { + "name": "_lp_token", + "type": "address" + }, + { + "name": "relative_weight_cap", + "type": "uint256" + }, + { + "name": "_voting_escrow_delegation", + "type": "address" + }, + { + "name": "_admin", + "type": "address" + }, + { + "name": "_position_key", + "type": "bytes32" + } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "setRelativeWeightCap", + "inputs": [ + { + "name": "relative_weight_cap", + "type": "uint256" + } + ], + "outputs": [] + }, + { + "stateMutability": "view", + "type": "function", + "name": "getRelativeWeightCap", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "getCappedRelativeWeight", + "inputs": [ + { + "name": "time", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "pure", + "type": "function", + "name": "getMaxRelativeWeightCap", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "tokenless_production", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint8" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "pending_admin", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "admin", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "voting_escrow_delegation", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "DOMAIN_SEPARATOR", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "nonces", + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "lp_token", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauge_state", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint8" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "position_key", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_count", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_data", + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "components": [ + { + "name": "token", + "type": "address" + }, + { + "name": "distributor", + "type": "address" + }, + { + "name": "period_finish", + "type": "uint256" + }, + { + "name": "rate", + "type": "uint256" + }, + { + "name": "last_update", + "type": "uint256" + }, + { + "name": "integral", + "type": "uint256" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "rewards_receiver", + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_integral_for", + "inputs": [ + { + "name": "arg0", + "type": "address" + }, + { + "name": "arg1", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "working_balances", + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "working_supply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_inv_supply_of", + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_checkpoint_of", + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_fraction", + "inputs": [ + { + "name": "arg0", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "period", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "int128" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_tokens", + "inputs": [ + { + "name": "arg0", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "period_timestamp", + "inputs": [ + { + "name": "arg0", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_inv_supply", + "inputs": [ + { + "name": "arg0", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + } +] diff --git a/src/adaptors/liquis/abis/OptionsOracle.json b/src/adaptors/liquis/abis/OptionsOracle.json new file mode 100644 index 0000000000..5cb26c9c0c --- /dev/null +++ b/src/adaptors/liquis/abis/OptionsOracle.json @@ -0,0 +1,225 @@ +[ + { + "inputs": [ + { + "internalType": "contract IBalancerTwapOracle", + "name": "balancerTwapOracle_", + "type": "address" + }, + { + "internalType": "address", + "name": "owner_", + "type": "address" + }, + { + "internalType": "uint16", + "name": "multiplier_", + "type": "uint16" + }, + { + "internalType": "uint56", + "name": "secs_", + "type": "uint56" + }, + { + "internalType": "uint56", + "name": "ago_", + "type": "uint56" + }, + { + "internalType": "uint128", + "name": "minPrice_", + "type": "uint128" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "BalancerOracle__TWAPOracleNotReady", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "multiplier", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint56", + "name": "secs", + "type": "uint56" + }, + { + "indexed": false, + "internalType": "uint56", + "name": "ago", + "type": "uint56" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "minPrice", + "type": "uint128" + } + ], + "name": "SetParams", + "type": "event" + }, + { + "inputs": [], + "name": "ago", + "outputs": [ + { + "internalType": "uint56", + "name": "", + "type": "uint56" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "balancerTwapOracle", + "outputs": [ + { + "internalType": "contract IBalancerTwapOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "price", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minPrice", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "multiplier", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "secs", + "outputs": [ + { + "internalType": "uint56", + "name": "", + "type": "uint56" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "multiplier_", + "type": "uint16" + }, + { + "internalType": "uint56", + "name": "secs_", + "type": "uint56" + }, + { + "internalType": "uint56", + "name": "ago_", + "type": "uint56" + }, + { + "internalType": "uint128", + "name": "minPrice_", + "type": "uint128" + } + ], + "name": "setParams", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/adaptors/liquis/abis/TokenAdmin.json b/src/adaptors/liquis/abis/TokenAdmin.json new file mode 100644 index 0000000000..efab4125bb --- /dev/null +++ b/src/adaptors/liquis/abis/TokenAdmin.json @@ -0,0 +1,390 @@ +[ + { + "inputs": [ + { + "internalType": "contract IERC20Mintable", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "owner_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supply", + "type": "uint256" + } + ], + "name": "MiningParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "INITIAL_RATE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATE_DENOMINATOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATE_REDUCTION_COEFFICIENT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATE_REDUCTION_TIME", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "activate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "available_supply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "futureEpochTimeWrite", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "future_epoch_time_write", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getAvailableSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFutureEpochTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getInflationRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMiningEpoch", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStartEpochSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStartEpochTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getToken", + "outputs": [ + { + "internalType": "contract IERC20Mintable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "end", + "type": "uint256" + } + ], + "name": "mintableInTimeframe", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "end", + "type": "uint256" + } + ], + "name": "mintable_in_timeframe", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "startEpochTimeWrite", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "start_epoch_time_write", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateMiningParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "update_mining_parameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/adaptors/liquis/abis/Vault.json b/src/adaptors/liquis/abis/Vault.json new file mode 100644 index 0000000000..03668f92a5 --- /dev/null +++ b/src/adaptors/liquis/abis/Vault.json @@ -0,0 +1,918 @@ +[ + { + "inputs": [ + { + "internalType": "contract IAuthorizer", + "name": "authorizer", + "type": "address" + }, + { "internalType": "contract IWETH", "name": "weth", "type": "address" }, + { + "internalType": "uint256", + "name": "pauseWindowDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bufferPeriodDuration", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IAuthorizer", + "name": "newAuthorizer", + "type": "address" + } + ], + "name": "AuthorizerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ExternalBalanceTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IFlashLoanRecipient", + "name": "recipient", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + } + ], + "name": "FlashLoan", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "delta", + "type": "int256" + } + ], + "name": "InternalBalanceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "PausedStateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "liquidityProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "int256[]", + "name": "deltas", + "type": "int256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "protocolFeeAmounts", + "type": "uint256[]" + } + ], + "name": "PoolBalanceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "assetManager", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "cashDelta", + "type": "int256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "managedDelta", + "type": "int256" + } + ], + "name": "PoolBalanceManaged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "enum IVault.PoolSpecialization", + "name": "specialization", + "type": "uint8" + } + ], + "name": "PoolRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "RelayerApprovalChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "tokenIn", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "tokenOut", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "name": "Swap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "TokensDeregistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "assetManagers", + "type": "address[]" + } + ], + "name": "TokensRegistered", + "type": "event" + }, + { + "inputs": [], + "name": "WETH", + "outputs": [ + { "internalType": "contract IWETH", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IVault.SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "components": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "uint256", + "name": "assetInIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "assetOutIndex", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "internalType": "struct IVault.BatchSwapStep[]", + "name": "swaps", + "type": "tuple[]" + }, + { + "internalType": "contract IAsset[]", + "name": "assets", + "type": "address[]" + }, + { + "components": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { + "internalType": "bool", + "name": "fromInternalBalance", + "type": "bool" + }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bool", + "name": "toInternalBalance", + "type": "bool" + } + ], + "internalType": "struct IVault.FundManagement", + "name": "funds", + "type": "tuple" + }, + { "internalType": "int256[]", "name": "limits", "type": "int256[]" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "batchSwap", + "outputs": [ + { "internalType": "int256[]", "name": "assetDeltas", "type": "int256[]" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "deregisterTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "components": [ + { + "internalType": "contract IAsset[]", + "name": "assets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "minAmountsOut", + "type": "uint256[]" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" }, + { + "internalType": "bool", + "name": "toInternalBalance", + "type": "bool" + } + ], + "internalType": "struct IVault.ExitPoolRequest", + "name": "request", + "type": "tuple" + } + ], + "name": "exitPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IFlashLoanRecipient", + "name": "recipient", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "name": "flashLoan", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes4", "name": "selector", "type": "bytes4" } + ], + "name": "getActionId", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { "internalType": "contract IAuthorizer", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDomainSeparator", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "getInternalBalance", + "outputs": [ + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" } + ], + "name": "getNextNonce", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPausedState", + "outputs": [ + { "internalType": "bool", "name": "paused", "type": "bool" }, + { + "internalType": "uint256", + "name": "pauseWindowEndTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bufferPeriodEndTime", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" } + ], + "name": "getPool", + "outputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { + "internalType": "enum IVault.PoolSpecialization", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "contract IERC20", "name": "token", "type": "address" } + ], + "name": "getPoolTokenInfo", + "outputs": [ + { "internalType": "uint256", "name": "cash", "type": "uint256" }, + { "internalType": "uint256", "name": "managed", "type": "uint256" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { "internalType": "address", "name": "assetManager", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" } + ], + "name": "getPoolTokens", + "outputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getProtocolFeesCollector", + "outputs": [ + { + "internalType": "contract ProtocolFeesCollector", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" }, + { "internalType": "address", "name": "relayer", "type": "address" } + ], + "name": "hasApprovedRelayer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { + "components": [ + { + "internalType": "contract IAsset[]", + "name": "assets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "maxAmountsIn", + "type": "uint256[]" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" }, + { + "internalType": "bool", + "name": "fromInternalBalance", + "type": "bool" + } + ], + "internalType": "struct IVault.JoinPoolRequest", + "name": "request", + "type": "tuple" + } + ], + "name": "joinPool", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum IVault.PoolBalanceOpKind", + "name": "kind", + "type": "uint8" + }, + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "internalType": "struct IVault.PoolBalanceOp[]", + "name": "ops", + "type": "tuple[]" + } + ], + "name": "managePoolBalance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum IVault.UserBalanceOpKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "contract IAsset", + "name": "asset", + "type": "address" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + } + ], + "internalType": "struct IVault.UserBalanceOp[]", + "name": "ops", + "type": "tuple[]" + } + ], + "name": "manageUserBalance", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IVault.SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "components": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "uint256", + "name": "assetInIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "assetOutIndex", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "internalType": "struct IVault.BatchSwapStep[]", + "name": "swaps", + "type": "tuple[]" + }, + { + "internalType": "contract IAsset[]", + "name": "assets", + "type": "address[]" + }, + { + "components": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { + "internalType": "bool", + "name": "fromInternalBalance", + "type": "bool" + }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bool", + "name": "toInternalBalance", + "type": "bool" + } + ], + "internalType": "struct IVault.FundManagement", + "name": "funds", + "type": "tuple" + } + ], + "name": "queryBatchSwap", + "outputs": [{ "internalType": "int256[]", "name": "", "type": "int256[]" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IVault.PoolSpecialization", + "name": "specialization", + "type": "uint8" + } + ], + "name": "registerPool", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "assetManagers", + "type": "address[]" + } + ], + "name": "registerTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IAuthorizer", + "name": "newAuthorizer", + "type": "address" + } + ], + "name": "setAuthorizer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bool", "name": "paused", "type": "bool" }], + "name": "setPaused", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "relayer", "type": "address" }, + { "internalType": "bool", "name": "approved", "type": "bool" } + ], + "name": "setRelayerApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "enum IVault.SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "contract IAsset", + "name": "assetIn", + "type": "address" + }, + { + "internalType": "contract IAsset", + "name": "assetOut", + "type": "address" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "internalType": "struct IVault.SingleSwap", + "name": "singleSwap", + "type": "tuple" + }, + { + "components": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { + "internalType": "bool", + "name": "fromInternalBalance", + "type": "bool" + }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bool", + "name": "toInternalBalance", + "type": "bool" + } + ], + "internalType": "struct IVault.FundManagement", + "name": "funds", + "type": "tuple" + }, + { "internalType": "uint256", "name": "limit", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swap", + "outputs": [ + { + "internalType": "uint256", + "name": "amountCalculated", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } +] diff --git a/src/adaptors/liquis/abis/ViewHelper.json b/src/adaptors/liquis/abis/ViewHelper.json new file mode 100644 index 0000000000..b41aa88e98 --- /dev/null +++ b/src/adaptors/liquis/abis/ViewHelper.json @@ -0,0 +1,647 @@ +[ + { + "inputs": [], + "name": "balancerVault", + "outputs": [ + { + "internalType": "contract IBalancerVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "convertLitToLiq", + "outputs": [ + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_cvxCrvRewards", "type": "address" } + ], + "name": "getCvxCrvRewards", + "outputs": [ + { + "components": [ + { "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "internalType": "address", "name": "lptoken", "type": "address" }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "address", "name": "gauge", "type": "address" }, + { + "internalType": "address", + "name": "crvRewards", + "type": "address" + }, + { "internalType": "address", "name": "stash", "type": "address" }, + { "internalType": "bool", "name": "shutdown", "type": "bool" }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { "internalType": "address", "name": "uniV3Pool", "type": "address" }, + { + "internalType": "address[]", + "name": "poolTokens", + "type": "address[]" + }, + { "internalType": "int24[]", "name": "ticks", "type": "int24[]" }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "periodFinish", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastUpdateTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardPerTokenStored", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "queuedRewards", + "type": "uint256" + } + ], + "internalType": "struct LiquisViewHelpers.RewardsData", + "name": "rewardsData", + "type": "tuple" + }, + { + "components": [ + { "internalType": "address", "name": "addr", "type": "address" }, + { + "internalType": "address", + "name": "rewardsToken", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "periodFinish", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastUpdateTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardPerTokenStored", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "queuedRewards", + "type": "uint256" + } + ], + "internalType": "struct LiquisViewHelpers.RewardsData", + "name": "rewardsData", + "type": "tuple" + } + ], + "internalType": "struct LiquisViewHelpers.ExtraRewards[]", + "name": "extraRewards", + "type": "tuple[]" + } + ], + "internalType": "struct LiquisViewHelpers.Pool", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "pool", "type": "uint256" }, + { "internalType": "address", "name": "booster", "type": "address" }, + { "internalType": "address", "name": "token", "type": "address" } + ], + "name": "getEarmarkingReward", + "outputs": [ + { "internalType": "uint256", "name": "pending", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_locker", "type": "address" } + ], + "name": "getLocker", + "outputs": [ + { + "components": [ + { "internalType": "uint256", "name": "epoch", "type": "uint256" }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lockedSupply", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "periodFinish", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastUpdateTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardPerTokenStored", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "queuedRewards", + "type": "uint256" + } + ], + "internalType": "struct LiquisViewHelpers.RewardsData", + "name": "rewardsData", + "type": "tuple" + } + ], + "internalType": "struct LiquisViewHelpers.Locker", + "name": "locker", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_locker", "type": "address" }, + { "internalType": "address", "name": "_account", "type": "address" } + ], + "name": "getLockerAccount", + "outputs": [ + { + "components": [ + { "internalType": "address", "name": "addr", "type": "address" }, + { "internalType": "uint256", "name": "total", "type": "uint256" }, + { + "internalType": "uint256", + "name": "unlockable", + "type": "uint256" + }, + { "internalType": "uint256", "name": "locked", "type": "uint256" }, + { + "internalType": "uint256", + "name": "nextUnlockIndex", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "rewardPerTokenPaid", + "type": "uint128" + }, + { "internalType": "uint128", "name": "rewards", "type": "uint128" }, + { "internalType": "address", "name": "delegate", "type": "address" }, + { "internalType": "uint256", "name": "votes", "type": "uint256" }, + { + "components": [ + { + "internalType": "uint112", + "name": "amount", + "type": "uint112" + }, + { + "internalType": "uint32", + "name": "unlockTime", + "type": "uint32" + } + ], + "internalType": "struct LiqLocker.LockedBalance[]", + "name": "lockData", + "type": "tuple[]" + }, + { + "components": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "internalType": "struct LiqLocker.EarnedData[]", + "name": "claimableRewards", + "type": "tuple[]" + } + ], + "internalType": "struct LiquisViewHelpers.LockerAccount", + "name": "lockerAccount", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256[]", "name": "pools", "type": "uint256[]" }, + { "internalType": "address", "name": "booster", "type": "address" }, + { "internalType": "address", "name": "token", "type": "address" } + ], + "name": "getMultipleEarmarkingRewards", + "outputs": [ + { "internalType": "uint256[]", "name": "pendings", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "address", "name": "lptoken", "type": "address" }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "address", "name": "gauge", "type": "address" }, + { + "internalType": "address", + "name": "crvRewards", + "type": "address" + }, + { "internalType": "address", "name": "stash", "type": "address" }, + { "internalType": "bool", "name": "shutdown", "type": "bool" } + ], + "internalType": "struct IBooster.PoolInfo", + "name": "poolInfo", + "type": "tuple" + }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" } + ], + "name": "getPool", + "outputs": [ + { + "components": [ + { "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "internalType": "address", "name": "lptoken", "type": "address" }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "address", "name": "gauge", "type": "address" }, + { + "internalType": "address", + "name": "crvRewards", + "type": "address" + }, + { "internalType": "address", "name": "stash", "type": "address" }, + { "internalType": "bool", "name": "shutdown", "type": "bool" }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { "internalType": "address", "name": "uniV3Pool", "type": "address" }, + { + "internalType": "address[]", + "name": "poolTokens", + "type": "address[]" + }, + { "internalType": "int24[]", "name": "ticks", "type": "int24[]" }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "periodFinish", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastUpdateTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardPerTokenStored", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "queuedRewards", + "type": "uint256" + } + ], + "internalType": "struct LiquisViewHelpers.RewardsData", + "name": "rewardsData", + "type": "tuple" + }, + { + "components": [ + { "internalType": "address", "name": "addr", "type": "address" }, + { + "internalType": "address", + "name": "rewardsToken", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "periodFinish", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastUpdateTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardPerTokenStored", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "queuedRewards", + "type": "uint256" + } + ], + "internalType": "struct LiquisViewHelpers.RewardsData", + "name": "rewardsData", + "type": "tuple" + } + ], + "internalType": "struct LiquisViewHelpers.ExtraRewards[]", + "name": "extraRewards", + "type": "tuple[]" + } + ], + "internalType": "struct LiquisViewHelpers.Pool", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_rewardPool", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "address", "name": "_account", "type": "address" } + ], + "name": "getPoolBalances", + "outputs": [ + { + "components": [ + { "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "internalType": "uint256", "name": "earned", "type": "uint256" }, + { + "internalType": "uint256[]", + "name": "extraRewardsEarned", + "type": "uint256[]" + }, + { "internalType": "uint256", "name": "staked", "type": "uint256" } + ], + "internalType": "struct LiquisViewHelpers.PoolBalances", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_booster", "type": "address" } + ], + "name": "getPools", + "outputs": [ + { + "components": [ + { "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "internalType": "address", "name": "lptoken", "type": "address" }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "address", "name": "gauge", "type": "address" }, + { + "internalType": "address", + "name": "crvRewards", + "type": "address" + }, + { "internalType": "address", "name": "stash", "type": "address" }, + { "internalType": "bool", "name": "shutdown", "type": "bool" }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { "internalType": "address", "name": "uniV3Pool", "type": "address" }, + { + "internalType": "address[]", + "name": "poolTokens", + "type": "address[]" + }, + { "internalType": "int24[]", "name": "ticks", "type": "int24[]" }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "periodFinish", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastUpdateTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardPerTokenStored", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "queuedRewards", + "type": "uint256" + } + ], + "internalType": "struct LiquisViewHelpers.RewardsData", + "name": "rewardsData", + "type": "tuple" + }, + { + "components": [ + { "internalType": "address", "name": "addr", "type": "address" }, + { + "internalType": "address", + "name": "rewardsToken", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "periodFinish", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastUpdateTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardPerTokenStored", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "queuedRewards", + "type": "uint256" + } + ], + "internalType": "struct LiquisViewHelpers.RewardsData", + "name": "rewardsData", + "type": "tuple" + } + ], + "internalType": "struct LiquisViewHelpers.ExtraRewards[]", + "name": "extraRewards", + "type": "tuple[]" + } + ], + "internalType": "struct LiquisViewHelpers.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_booster", "type": "address" }, + { "internalType": "address", "name": "_account", "type": "address" } + ], + "name": "getPoolsBalances", + "outputs": [ + { + "components": [ + { "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "internalType": "uint256", "name": "earned", "type": "uint256" }, + { + "internalType": "uint256[]", + "name": "extraRewardsEarned", + "type": "uint256[]" + }, + { "internalType": "uint256", "name": "staked", "type": "uint256" } + ], + "internalType": "struct LiquisViewHelpers.PoolBalances[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address[]", "name": "_addresses", "type": "address[]" } + ], + "name": "getTokens", + "outputs": [ + { + "components": [ + { "internalType": "address", "name": "addr", "type": "address" }, + { "internalType": "uint8", "name": "decimals", "type": "uint8" }, + { "internalType": "string", "name": "symbol", "type": "string" }, + { "internalType": "string", "name": "name", "type": "string" } + ], + "internalType": "struct LiquisViewHelpers.Token[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "liq", + "outputs": [ + { + "internalType": "contract IERC20Detailed", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/adaptors/liquis/abis/VirtualPool.json b/src/adaptors/liquis/abis/VirtualPool.json new file mode 100644 index 0000000000..31ede7aa03 --- /dev/null +++ b/src/adaptors/liquis/abis/VirtualPool.json @@ -0,0 +1,274 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "deposit_", "type": "address" }, + { "internalType": "address", "name": "reward_", "type": "address" }, + { "internalType": "address", "name": "op_", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "reward", + "type": "uint256" + } + ], + "name": "RewardAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reward", + "type": "uint256" + } + ], + "name": "RewardPaid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Staked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Withdrawn", + "type": "event" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "currentRewards", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "deposits", + "outputs": [ + { "internalType": "contract IDeposit", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "duration", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "earned", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "epochRewards", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" } + ], + "name": "getReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "historicalRewards", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastTimeRewardApplicable", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastUpdateTime", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newRewardRatio", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "operator", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "periodFinish", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_rewards", "type": "uint256" } + ], + "name": "queueNewRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "queuedRewards", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardPerToken", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardPerTokenStored", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardToken", + "outputs": [ + { "internalType": "contract IERC20", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "rewards", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "stake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "userRewardPerTokenPaid", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/adaptors/liquis/index.js b/src/adaptors/liquis/index.js new file mode 100644 index 0000000000..869e9649ff --- /dev/null +++ b/src/adaptors/liquis/index.js @@ -0,0 +1,697 @@ +const sdk = require('@defillama/sdk'); +const utils = require('../utils'); +const superagent = require('superagent'); +const { request, gql } = require('graphql-request'); + +const hub = '0xb5087f95643a9a4069471a28d32c569d9bd57fe4'; +const lens = '0xb73f303472c4fd4ff3b9f59ce0f9b13e47fbfd19'; +const zeroAddress = '0x0000000000000000000000000000000000000000'; +const weth = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'; +const bal = '0xba100000625a3754423978a60c9317c58a424e3D'; + +const rewardPool = { + ethereum: '0x7Ea6930a9487ce8d039f7cC89432435E6D5AcB23', +}; + +const lit80weth20 = { + ethereum: '0x9232a548DD9E81BaC65500b5e0d918F8Ba93675C', +}; + +const voterProxy = { + ethereum: '0x37aeB332D6E57112f1BFE36923a7ee670Ee9278b', +}; + +const viewHelper = { + ethereum: '0xD58dd6deF2d0e8E16ffc537c7f269719e19b9fE4', +}; + +const booster = { + ethereum: '0x631e58246A88c3957763e1469cb52f93BC1dDCF2', +}; + +const admin = { + ethereum: '0x4cc39af0d46b0f66fd33778c6629a696bdc310a0', +}; + +const controller = { + ethereum: '0x901c8aa6a61f74ac95e7f397e22a0ac7c1242218', +}; + +const lit = { + ethereum: '0xfd0205066521550D7d7AB19DA8F72bb004b4C341', +}; + +const liq = { + ethereum: '0xD82fd4D6D62f89A1E50b1db69AD19932314aa408', +}; + +const veLit = { + ethereum: '0xf17d23136B4FeAd139f54fB766c8795faae09660', +}; + +const liqLIT = { + ethereum: '0x03C6F0Ca0363652398abfb08d154F114e61c4Ad8', +}; + +const olit = { + ethereum: '0x627fee87d0d9d2c55098a06ac805db8f98b158aa', +}; + +const oracle = { + ethereum: '0x9d43ccb1ad7e0081cc8a8f1fd54d16e54a637e30', +}; + +const balVirtualPool = { + ethereum: '0x85C0DB72927cf20896ED1332a14C4e2818C1ebA9', +}; + +const wethVirtualPool = { + ethereum: '0x271B96395f53fb14cDD41C654ef15e83DE57dEDf', +}; + +const litLiqStaker = { + ethereum: '0x7Ea6930a9487ce8d039f7cC89432435E6D5AcB23', +}; + +const hubABI = require('./abis/BunniHub.json'); +const lensABI = require('./abis/BunniLens.json'); +const adminABI = require('./abis/TokenAdmin.json'); +const gaugeABI = require('./abis/LiquidityGauge.json'); +const controllerABI = require('./abis/GaugeController.json'); +const oracleABI = require('./abis/OptionsOracle.json'); +const boosterABI = require('./abis/Booster.json'); +const viewHelperABI = require('./abis/ViewHelper.json'); +const virtualPoolABI = require('./abis/VirtualPool.json'); +const balancerTokenABI = require('./abis/BalancerToken.json'); +const vaultABI = require('./abis/Vault.json'); +const { default: bunni } = require('../bunni'); + +const baseUrl = 'https://api.thegraph.com/subgraphs/name/bunniapp'; +const chains = { + ethereum: `${baseUrl}/bunni-mainnet`, +}; + +const query = gql` + { + bunniTokens(first: 1000, block: {number: }) { + address + liquidity + pool { + fee + tick + liquidity + totalFeesToken0 + totalFeesToken1 + totalVolumeToken0 + totalVolumeToken1 + } + } + } +`; + +const queryPrior = gql` + { + pools(first: 1000, block: {number: }) { + address + totalFeesToken0 + totalFeesToken1 + totalVolumeToken0 + totalVolumeToken1 + } + } +`; + +const apy = (apr, num_periods) => { + const periodic_rate = apr / num_periods / 100; + const apy = Math.pow(1 + periodic_rate, num_periods) - 1; + return apy * 100; +}; + +const liqLitPool = async (chain, olitprice, liqprice) => { + const keys = [weth, bal, lit[chain]] + .map((token) => `${chain}:${token}`) + .join(','); + const prices = ( + await superagent.get(`https://coins.llama.fi/prices/current/${keys}`) + ).body.coins; + const balPrice = prices[`${chain}:${bal}`].price; + const wethPrice = prices[`${chain}:${weth}`].price; + + // Compute tvl + let tvlUsd = 0; + const { output: veBalance } = await sdk.api.erc20.totalSupply({ + target: rewardPool[chain], + }); + const balancerToken = lit80weth20[chain]; + const owner = veLit[chain]; + const lpSupply = ( + await sdk.api.abi.call({ abi: 'erc20:totalSupply', target: balancerToken }) + )?.output; + const lpTokens = ( + await sdk.api.abi.call({ + abi: 'erc20:balanceOf', + target: balancerToken, + params: owner, + }) + )?.output; + const poolId = ( + await sdk.api.abi.call({ + abi: balancerTokenABI.find((n) => n.name == 'getPoolId'), + target: balancerToken, + }) + )?.output; + const vault = ( + await sdk.api.abi.call({ + abi: balancerTokenABI.find((n) => n.name == 'getVault'), + target: balancerToken, + }) + )?.output; + const pools = ( + await sdk.api.abi.call({ + abi: vaultABI.find((n) => n.name == 'getPoolTokens'), + target: vault, + params: poolId, + }) + )?.output; + pools.tokens.forEach((v, i) => { + tvlUsd += + (pools.balances[i] / lpSupply) * + (veBalance / 1e18) * + prices[`${chain}:${v}`].price; + }); + + const balRate = ( + await sdk.api.abi.call({ + target: balVirtualPool[chain], + abi: virtualPoolABI.find((n) => n.name === 'rewardRate'), + chain: chain, + }) + )?.output; + const wethRate = ( + await sdk.api.abi.call({ + target: wethVirtualPool[chain], + abi: virtualPoolABI.find((n) => n.name === 'rewardRate'), + chain: chain, + }) + )?.output; + const olitRate = ( + await sdk.api.abi.call({ + target: litLiqStaker[chain], + abi: virtualPoolABI.find((n) => n.name === 'rewardRate'), + chain: chain, + }) + )?.output; + const liqrate = ( + await sdk.api.abi.call({ + target: viewHelper[chain], + abi: viewHelperABI.find((n) => n.name === 'convertLitToLiq'), + params: [olitRate], + chain: chain, + }) + )?.output; + + const balAmount = (balRate / 1e18) * 60 * 60 * 24 * 365; + const wethAmount = (wethRate / 1e18) * 60 * 60 * 24 * 365; + const olitAmount = (olitRate / 1e18) * 60 * 60 * 24 * 365; + const liqAmount = (liqrate / 1e18) * 60 * 60 * 24 * 365; + + const balUsd = balAmount * balPrice; + const wethUsd = wethAmount * wethPrice; + const olitUsd = olitAmount * olitprice; + const liqUsd = liqAmount * liqprice; + + const apyBase = (balUsd / tvlUsd + wethUsd / tvlUsd) * 100; + const apyReward = (liqUsd / tvlUsd + olitUsd / tvlUsd) * 100; + + return { + pool: liqLIT[chain], + chain: utils.formatChain(chain), + project: 'liquis', + symbol: 'LIQLIT', + tvlUsd, + apyBase, + apyReward, + rewardTokens: [liq[chain], lit[chain]], + underlyingTokens: [lit[chain], weth], + url: `https://www.liquis.app/liqlit`, + }; +}; + +const topLvl = async (chainString, url, timestamp) => { + try { + const [block, blockPrior] = await utils.getBlocks(chainString, timestamp, [ + url, + ]); + + let [ + dataNowSubgraph, + dataNow, + dataPriorSubgraph, + dataPrior, + { output: protocolFee }, + { output: inflationRate }, + { output: multiplier }, + ] = await Promise.all([ + request(url, query.replace('', block)), + sdk.api.abi.call({ + target: viewHelper[chainString], + abi: viewHelperABI.find((n) => n.name === 'getPools'), + params: [booster[chainString]], + chain: chainString, + block, + }), + request(url, queryPrior.replace('', blockPrior)), + sdk.api.abi.call({ + target: viewHelper[chainString], + abi: viewHelperABI.find((n) => n.name === 'getPools'), + params: [booster[chainString]], + chain: chainString, + block: blockPrior, + }), + sdk.api.abi.call({ + target: hub, + abi: hubABI.find((n) => n.name === 'protocolFee'), + chain: chainString, + }), + + admin[chainString] && + sdk.api.abi.call({ + target: admin[chainString], + abi: adminABI.find((n) => n.name === 'rate'), + chain: chainString, + }), + oracle[chainString] && + sdk.api.abi.call({ + target: oracle[chainString], + abi: oracleABI.find((n) => n.name === 'multiplier'), + chain: chainString, + }), + ]); + + dataNow = dataNow.output.map((b) => ({ + ...b, + ...dataNowSubgraph.bunniTokens.find( + (t) => t.address.toLowerCase() === b.lptoken.toLowerCase() + ), + })); + dataPrior = dataPrior.output.map((b) => ({ + ...b, + ...dataPriorSubgraph.pools.find( + (p) => p.address.toLowerCase() === b.uniV3Pool.toLowerCase() + ), + })); + + dataNow = dataNow + .filter((b) => !b.shutdown) + .filter((b) => b.token != liqLIT[chainString]); + dataPrior = dataPrior + .filter((b) => !b.shutdown) + .filter((b) => b.token != liqLIT[chainString]); + + protocolFee = protocolFee / 1e18; + inflationRate = inflationRate ? inflationRate / 1e18 : null; + multiplier = multiplier ? multiplier / 10000 : null; + + // create a list of unique tokens + let tokens = dataNow.reduce((tokens, b) => { + if (!tokens.includes(b.poolTokens[0])) tokens.push(b.poolTokens[0]); + if (!tokens.includes(b.poolTokens[1])) tokens.push(b.poolTokens[1]); + return tokens; + }, []); + + // add LIT to the token list (used for calculating oLIT price) + if (lit[chainString] && !tokens.includes(lit[chainString])) + tokens.push(lit[chainString]); + + // add LIQ to the token list + if (liq[chainString] && !tokens.includes(liq[chainString])) + tokens.push(liq[chainString]); + + // create of list of gauges + const gauges = dataNow.reduce((gauges, b) => { + if (b.gauge) gauges.push(b.gauge); + return gauges; + }, []); + + const week = 604800 * 1000; + const this_period_timestamp = (Math.floor(Date.now() / week) * week) / 1000; + + const [ + { output: veLITBalance }, + { output: veLITotalSupply }, + { output: tokenSymbols }, + { output: tokenDecimals }, + { output: poolTotalSupplies }, + { output: reserves }, + { output: shares }, + { output: gaugesWorkingSupply }, + { output: gaugesTotalSupply }, + { output: gaugesWorkingBalance }, + { output: gaugesUserLiquidity }, + { output: gaugesTokenlessProduction }, + { output: gaugesIsKilled }, + { output: gaugesRelativeWeight }, + { output: gaugesExists }, + ] = await Promise.all([ + sdk.api.abi.call({ + target: veLit[chainString], + abi: 'erc20:balanceOf', + params: [voterProxy[chainString]], + chain: chainString, + }), + sdk.api.abi.call({ + target: veLit[chainString], + abi: 'erc20:totalSupply', + chain: chainString, + }), + sdk.api.abi.multiCall({ + abi: 'erc20:symbol', + calls: tokens.map((token) => ({ target: token })), + chain: chainString, + }), + sdk.api.abi.multiCall({ + abi: 'erc20:decimals', + calls: tokens.map((token) => ({ target: token })), + chain: chainString, + }), + sdk.api.abi.multiCall({ + abi: 'erc20:totalSupply', + calls: dataNow.map((token) => ({ target: token.lptoken })), + chain: chainString, + }), + sdk.api.abi.multiCall({ + abi: lensABI.find((n) => n.name === 'getReserves'), + target: lens, + calls: dataNow.map((b) => ({ + params: [ + { pool: b.uniV3Pool, tickLower: b.ticks[0], tickUpper: b.ticks[1] }, + ], + })), + chain: chainString, + }), + sdk.api.abi.multiCall({ + abi: lensABI.find((n) => n.name === 'pricePerFullShare'), + target: lens, + calls: dataNow.map((b) => ({ + params: [ + { pool: b.uniV3Pool, tickLower: b.ticks[0], tickUpper: b.ticks[1] }, + ], + })), + chain: chainString, + }), + gauges.length && + sdk.api.abi.multiCall({ + abi: gaugeABI.find((n) => n.name === 'working_supply'), + calls: gauges.map((gauge) => ({ target: gauge })), + chain: chainString, + }), + gauges.length && + sdk.api.abi.multiCall({ + abi: gaugeABI.find((n) => n.name === 'totalSupply'), + calls: gauges.map((gauge) => ({ target: gauge })), + chain: chainString, + }), + gauges.length && + sdk.api.abi.multiCall({ + abi: gaugeABI.find((n) => n.name === 'working_balances'), + calls: gauges.map((gauge) => ({ + target: gauge, + params: [voterProxy[chainString]], + })), + chain: chainString, + }), + gauges.length && + sdk.api.abi.multiCall({ + abi: gaugeABI.find((n) => n.name === 'balanceOf'), + calls: gauges.map((gauge) => ({ + target: gauge, + params: [voterProxy[chainString]], + })), + chain: chainString, + }), + gauges.length && + sdk.api.abi.multiCall({ + abi: gaugeABI.find((n) => n.name === 'tokenless_production'), + calls: gauges.map((gauge) => ({ target: gauge })), + chain: chainString, + }), + gauges.length && + sdk.api.abi.multiCall({ + abi: gaugeABI.find((n) => n.name === 'is_killed'), + calls: gauges.map((gauge) => ({ target: gauge })), + chain: chainString, + }), + gauges.length && + sdk.api.abi.multiCall({ + abi: gaugeABI.find((n) => n.name === 'getCappedRelativeWeight'), + calls: gauges.map((gauge) => ({ + target: gauge, + params: [this_period_timestamp], + })), + chain: chainString, + }), + gauges.length && + sdk.api.abi.multiCall({ + abi: controllerABI.find((n) => n.name === 'gauge_exists'), + target: controller[chainString], + calls: gauges.map((gauge) => ({ params: [gauge] })), + chain: chainString, + }), + ]); + + // fetch token prices + const keys = tokens.map((token) => `${chainString}:${token}`).join(','); + const prices = ( + await superagent.get(`https://coins.llama.fi/prices/current/${keys}`) + ).body.coins; + + // calculate the price of oLIT + let optionPrice = 0; + if (lit[chainString]) { + const litPrice = prices[`${chainString}:${lit[chainString]}`] + ? prices[`${chainString}:${lit[chainString]}`].price + : 0; + optionPrice = litPrice * multiplier; + } + + const liqPrice = prices[`${chainString}:${liq[chainString]}`] + ? prices[`${chainString}:${liq[chainString]}`].price + : 0; + + let poolData = []; + poolData.push(liqLitPool(chainString, optionPrice, liqPrice)); + poolData = poolData.concat( + dataNow.map(async (b) => { + // reserve info + const reserve = reserves.find( + (r) => + r.input.params[0].pool == b.uniV3Pool && + r.input.params[0].tickLower == b.ticks[0] && + r.input.params[0].tickUpper == b.ticks[1] + ).output; + + // share info + const share = shares.find( + (s) => + s.input.params[0].pool == b.uniV3Pool && + s.input.params[0].tickLower == b.ticks[0] && + s.input.params[0].tickUpper == b.ticks[1] + ).output; + + // token0 info + const token0Decimals = tokenDecimals.find( + (d) => d.input.target == b.poolTokens[0] + ).output; + const token0Price = prices[`${chainString}:${b.poolTokens[0]}`] + ? prices[`${chainString}:${b.poolTokens[0]}`].price + : 0; + const token0Redeem = share.amount0 / Math.pow(10, token0Decimals); + const token0Reserve = reserve.reserve0 / Math.pow(10, token0Decimals); + const token0Symbol = tokenSymbols.find( + (s) => s.input.target == b.poolTokens[0] + ).output; + + // token1 info + const token1Decimals = tokenDecimals.find( + (d) => d.input.target == b.poolTokens[1] + ).output; + const token1Price = prices[`${chainString}:${b.poolTokens[1]}`] + ? prices[`${chainString}:${b.poolTokens[1]}`].price + : 0; + const token1Redeem = share.amount1 / Math.pow(10, token1Decimals); + const token1Reserve = reserve.reserve1 / Math.pow(10, token1Decimals); + const token1Symbol = tokenSymbols.find( + (s) => s.input.target == b.poolTokens[1] + ).output; + + // calculate swap fee apr + let baseApr = 0; + + const tickLower = parseInt(b.ticks[0]); + const tickUpper = parseInt(b.ticks[1]); + const tick = parseInt(b.pool.tick); + const poolTotalSupply = poolTotalSupplies.find( + (t) => t.input.target == b.lptoken + ).output; + let tvl = + poolTotalSupply == 0 + ? 0 + : (token0Reserve * token0Price + token1Reserve * token1Price) * + (b.totalSupply / b.liquidity); + + if (b.pool.liquidity > 0 && tickLower <= tick && tick <= tickUpper) { + const prior = dataPrior.find( + (d) => d.address.toLowerCase() === b.uniV3Pool.toLowerCase() + ); + + if (prior) { + const fee0 = + ((b.pool.totalFeesToken0 - prior.totalFeesToken0) / + Math.pow(10, token0Decimals)) * + token0Price; + const fee1 = + ((b.pool.totalFeesToken1 - prior.totalFeesToken1) / + Math.pow(10, token1Decimals)) * + token1Price; + const fee = Math.min(fee0, fee1) * 365; + + baseApr = + ((fee * parseInt(b.liquidity)) / + parseInt(b.pool.liquidity) / + (token0Reserve * token0Price + token1Reserve * token1Price)) * + (1 - protocolFee) * + 100; + } + } + + // calculate reward apr + let rewardApr = null; + let rewardTokens = null; + + if (b.gauge) { + const exists = gaugesExists.find( + (g) => g.input.params[0].toLowerCase() == b.gauge.toLowerCase() + )?.output; + const killed = gaugesIsKilled.find( + (g) => g.input.target.toLowerCase() == b.gauge.toLowerCase() + )?.output; + + // we only care about gauges that have been whitelisted and have not been killed + if (exists && !killed) { + const relativeWeight = + gaugesRelativeWeight.find( + (g) => g.input.target.toLowerCase() == b.gauge.toLowerCase() + )?.output / 1e18; + const tokenlessProduction = + gaugesTokenlessProduction.find( + (g) => g.input.target.toLowerCase() == b.gauge.toLowerCase() + )?.output / 1e18; + const workingSupply = + gaugesWorkingSupply.find( + (g) => g.input.target.toLowerCase() == b.gauge.toLowerCase() + )?.output / 1e18; + const workingBalance = + gaugesWorkingBalance.find( + (g) => g.input.target.toLowerCase() == b.gauge.toLowerCase() + )?.output / 1e18; + const totalSupply = + gaugesTotalSupply.find( + (g) => g.input.target.toLowerCase() == b.gauge.toLowerCase() + )?.output / 1e18; + const userLiquidity = + gaugesUserLiquidity.find( + (g) => g.input.target.toLowerCase() == b.gauge.toLowerCase() + )?.output / 1e18; + const veLitBalance = veLITBalance / 1e18; + const veLitTotalSupply = veLITotalSupply / 1e18; + const relativeInflation = inflationRate * relativeWeight; + + // we only care about gauges that receive rewards (ie those that receive votes) + if (relativeInflation > 0 && workingBalance > 0) { + const t = tokenlessProduction / 100; + const T = 1 - t; + const l = userLiquidity; + const L = + (b.liquidity / 1e18) * (veLitBalance / veLitTotalSupply); + const working_balance = Math.min(t * l + T * L, l); + + // calculate the working supply + const working_ratio = workingSupply / totalSupply; + const new_total_liquidity = b.liquidity / 1e18 - totalSupply; + const new_working_supply = working_ratio * new_total_liquidity; + + const working_supply = + workingSupply + + new_working_supply - + workingBalance + + working_balance; + if (working_supply > 0) { + const bunniPrice = + token0Redeem * token0Price + token1Redeem * token1Price; + + const userSupplyUsd = userLiquidity * bunniPrice; + const userAnnualReward = + ((relativeInflation * 86400 * 365) / working_supply) * + working_balance; + const userAnnualRewardUSD = userAnnualReward * optionPrice; + + const userAnnualLiqReward = ( + await sdk.api.abi.call({ + target: viewHelper[chainString], + abi: viewHelperABI.find( + (n) => n.name === 'convertLitToLiq' + ), + params: [(userAnnualReward * 0.75).toFixed(0)], + chain: chainString, + }) + )?.output; + const userAnnualLiqRewardUSD = userAnnualLiqReward * liqPrice; + + rewardApr = + (userAnnualRewardUSD / userSupplyUsd) * 100 * 0.75 + + (userAnnualLiqRewardUSD / userSupplyUsd) * 100; + rewardTokens = [lit[chainString], liq[chainString]]; + } + } + } + } + + return { + pool: b.token, + chain: utils.formatChain(chainString), + project: 'liquis', + symbol: `${token0Symbol}-${token1Symbol}`, + tvlUsd: tvl, + apyBase: apy(baseApr, 365), + ...(rewardApr && { apyReward: rewardApr }), + ...(rewardTokens && { rewardTokens: rewardTokens }), + underlyingTokens: [b.poolTokens[0], b.poolTokens[1]], + poolMeta: `${parseInt(b.pool.fee) / 10000}%, tickLower: ${ + b.ticks[0] + }, tickUpper: ${b.ticks[1]}`, + url: `https://www.liquis.app/stake/${b.crvRewards}`, + }; + }) + ); + + poolData = await Promise.all(poolData); + return poolData; + } catch (e) { + console.log(e); + return []; + } +}; + +const main = async (timestamp = null) => { + const data = []; + for (const [chain, url] of Object.entries(chains)) { + data.push(await topLvl(chain, url, timestamp)); + } + return data.flat().filter((p) => utils.keepFinite(p)); +}; + +module.exports = { + timetravel: false, + apy: main, + url: `https://www.liquis.app/stake`, +}; diff --git a/src/adaptors/liqwid/index.js b/src/adaptors/liqwid/index.js index 3e7be85bfe..1f19034849 100644 --- a/src/adaptors/liqwid/index.js +++ b/src/adaptors/liqwid/index.js @@ -15,36 +15,46 @@ const apy = async () => { utilization borrowApy borrowLqDistributionApy - supplyLqDistributionApy + supplyMarketParticipationAPR maxLoanToValue } + info { + scripts { + batchFinal { + hash + } + } + } price { price } decimals } } + adaStakingAPY } ` + const data = await request(endpoint, query) + const markets = data.Page.market; + const adaStakingAPY = data.adaStakingAPY; // ada liquid staking - const markets = (await request(endpoint, query)).Page.market; - - const getPool = (tokenName, address) => { + const getPool = (tokenName) => { const market = markets.filter((market) => market.asset.name === tokenName)[0]; return { - pool: address, // market batch final + // FIXME(Kylix, 20th Sep 2023): Construct Shelley address from hex scripthash + pool: market.info.scripts.batchFinal.hash.value0, // market batch final hash chain: "Cardano", project: "liqwid", symbol: market.asset.name, tvlUsd: market.state.totalSupply / Math.pow(10, market.decimals) * market.price.price, - apyBase: Number(market.state.supplyApy), - apyReward: Number(market.state.supplyLqDistributionApy), + apyBase: (tokenName == "ADA" ? adaStakingAPY : 0 + Number(market.state.supplyApy)) * 100, + apyReward: Number(market.state.supplyMarketParticipationAPR) * 100, rewardTokens: [tokenName, "LQ"], underlyingTokens: [tokenName], // lending protocol fields - apyBaseBorrow: Number(market.state.borrowApy), - apyRewardBorrow: Number(market.state.borrowLqDistributionApy), + apyBaseBorrow: Number(market.state.borrowApy) * 100, + apyRewardBorrow: Number(market.state.borrowLqDistributionApy) * 100, totalSupplyUsd: market.state.totalSupply / (1 - market.state.utilization) / Math.pow(10, market.decimals) * market.price.price, totalBorrowUsd: market.state.totalSupply / (1 - market.state.utilization) / Math.pow(10, market.decimals) * market.state.utilization * market.price.price, ltv: Number(market.state.maxLoanToValue) @@ -52,11 +62,12 @@ const apy = async () => { }; return [ - getPool("ADA", "addr1wyf3xpvwjd82wtnax8tw8u5k6r5yfh0sza76k7c3y3pgpjcye7ar2"), - getPool("DJED", "addr1wx5sg32ljez3t25jjr9yg0h7j0lg6e2vr67z9v2k9tc8cwgtw4pw3"), - getPool("SHEN", "addr1w89fy5nrmfx9n0m8tu7vfpwgj3t4el5m9dg2uhp6xc9x9ng8f88h2"), - getPool("iUSD", "addr1wyr3h4l5khs9n65sua35vl84tyt8kgwg9mcukhlrf7m6negqfmr8f"), - getPool("USDC", "addr1wxx955evvve0shn2jfm4pcff4w54fmkxatfqnntj6z845vsk0nq0d") + getPool("ADA"), + getPool("DJED"), + getPool("SHEN"), + getPool("iUSD"), + getPool("USDC"), + getPool("USDT") ]; }; diff --git a/src/adaptors/openleverage/abis/LPool.json b/src/adaptors/openleverage/abis/LPool.json new file mode 100644 index 0000000000..79ddc7882a --- /dev/null +++ b/src/adaptors/openleverage/abis/LPool.json @@ -0,0 +1,41 @@ +{ + "decimals": { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + "totalBorrows": { + "inputs": [], + "name": "totalBorrows", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + "supplyRatePerBlock": { + "inputs": [], + "name": "supplyRatePerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +} \ No newline at end of file diff --git a/src/adaptors/openleverage/abis/OplContract.json b/src/adaptors/openleverage/abis/OplContract.json new file mode 100644 index 0000000000..6be078a082 --- /dev/null +++ b/src/adaptors/openleverage/abis/OplContract.json @@ -0,0 +1,75 @@ +{ + "numPairs": { + "inputs": [], + "name": "numPairs", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + "markets": { + "inputs": [ + { "internalType": "uint16", "name": "", "type": "uint16" } + ], + "name": "markets", + "outputs": [ + { + "internalType": "address", + "name": "pool0", + "type": "address" + }, + { + "internalType": "address", + "name": "pool1", + "type": "address" + }, + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint16", + "name": "marginLimit", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "feesRate", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "priceDiffientRatio", + "type": "uint16" + }, + { + "internalType": "address", + "name": "priceUpdater", + "type": "address" + }, + { + "internalType": "uint256", + "name": "pool0Insurance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pool1Insurance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +} \ No newline at end of file diff --git a/src/adaptors/openleverage/abis/erc20.json b/src/adaptors/openleverage/abis/erc20.json new file mode 100644 index 0000000000..c6a8f22a3b --- /dev/null +++ b/src/adaptors/openleverage/abis/erc20.json @@ -0,0 +1,33 @@ +{ + "balanceOf": { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + "symbol": { + "type": "function", + "stateMutability": "view", + "payable": false, + "outputs": [{ "type": "string", "name": "" }], + "name": "symbol", + "inputs": [], + "constant": true + }, + "decimals": { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + } +} \ No newline at end of file diff --git a/src/adaptors/openleverage/index.js b/src/adaptors/openleverage/index.js new file mode 100644 index 0000000000..0ba7e440d9 --- /dev/null +++ b/src/adaptors/openleverage/index.js @@ -0,0 +1,200 @@ +const sdk = require('@defillama/sdk'); +const erc20 = require("./abis/erc20.json"); +const LPool = require("./abis/LPool.json"); +const OplContract = require("./abis/OplContract.json"); +const axios = require("axios"); +const utils = require('../utils'); +const {default: BigNumber} = require('bignumber.js'); + +openleve_address = { + "eth": '0x03bf707deb2808f711bb0086fc17c5cafa6e8aaf', + "bsc": '0x6A75aC4b8d8E76d15502E69Be4cb6325422833B4', + "arb": '0x2925671dc7f2def9e4ad3fa878afd997f0b4db45' +} + +llama_chain_name = { + "bsc": "Binance", + "arb": "Arbitrum", + "eth": "Ethereum" +} + +coins_llama_name = { + "bsc": "bsc", + "arb": "arbitrum", + "eth": "ethereum" +} + +opl_chain_name = { + "bsc": "bnb", + "arb": "arbitrum", + "eth": "eth" +} + +block_of_year = { + "eth": 2102400, + "bsc": 10512000, + "arb": 2628000 +} + + +async function getTokenPriceInUsdt(chain, tokenAddr) { + const tokenPrice = ( + await axios.get( + `https://coins.llama.fi/prices/current/${coins_llama_name[chain]}:${tokenAddr}` + ) + ).data; + return tokenPrice.coins[`${coins_llama_name[chain]}:${tokenAddr}`].price; +} + + +async function getPoolInfo(chain) { + const poolInfo = await axios.get(`https://${opl_chain_name[chain]}.openleverage.finance/api/info/pools/interest`) + return poolInfo +} + + +async function getDecimals(addr, chain, abi) { + const decimals = ( + await sdk.api.abi.call({ + abi: abi, + target: addr, + chain: coins_llama_name[chain] + }) + ).output; + return decimals; +} + +async function getSymbol(addr, chain) { + const decimals = ( + await sdk.api.abi.call({ + abi: erc20.symbol, + target: addr, + chain: coins_llama_name[chain] + }) + ).output; + return decimals; +} + +const main = async () => { + const result = [] + for (const chain of Object.keys(openleve_address)) { + const poolInfo = await getPoolListByUrl(chain); + for (const pool of Object.keys(poolInfo)) { + const poolDetails = poolInfo[pool] + const poolBalance = ( + await sdk.api.abi.call({ + abi: erc20.balanceOf, + target: poolDetails.token, + chain: coins_llama_name[chain], + params: pool + }) + ).output; + const totalBorrow = ( + await sdk.api.abi.call({ + abi: LPool.totalBorrows, + target: pool, + chain: coins_llama_name[chain] + }) + ).output; + const poolAPYPerBlock = ( + await sdk.api.abi.call({ + abi: LPool.supplyRatePerBlock, + target: pool, + chain: coins_llama_name[chain] + }) + ).output; + + let tokenPriceInUsdt = 0; + try { + tokenPriceInUsdt = await getTokenPriceInUsdt(chain, poolDetails.token); + } catch (e) { + // console.error(e) + } + + const poolValues = { + pool: `${pool}-${llama_chain_name[chain]}`.toLowerCase(), + chain: utils.formatChain(llama_chain_name[chain]), + project: 'openleverage', + symbol: utils.formatSymbol(poolDetails.name), + tvlUsd: (new BigNumber(poolBalance).plus(new BigNumber(totalBorrow))).multipliedBy(new BigNumber(tokenPriceInUsdt)).dividedBy(new BigNumber(10).pow(poolDetails.tokenDecimal)).toNumber(), + apyBase: new BigNumber(poolAPYPerBlock).multipliedBy(new BigNumber(block_of_year[chain])).dividedBy(new BigNumber(10).pow(16)).toNumber(), // in % format + url: `https://${opl_chain_name[chain]}.openleverage.finance/app/pool/${pool}` + }; + console.log(poolValues) + result.push(poolValues) + } + } + + return result +} + + +async function getPoolListByUrl(chain) { + const poolList = (await getPoolInfo(chain)).data + let pools = {} + for (let i=0; i< poolList.length; i++ ){ + if (poolList[i].tvl > 8000){ + const token0Decimal = await getDecimals(poolList[i].token0Address, chain, erc20.decimals); + const token0Symbol = await getSymbol(poolList[i].token0Address, chain); + let poolInfo = {} + poolInfo["name"] = poolList[i].poolName + poolInfo["token"] = poolList[i].token0Address + poolInfo["symbol"] = token0Symbol + poolInfo["tokenDecimal"] = token0Decimal + pools[poolList[i].poolAddress] = poolInfo + console.log(`Pool ${poolList[i].poolName}(${poolList[i].poolAddress}) on Chain ${chain} TVL > 8000`) + } + } + return pools; +} + +async function getPoolListByContract(chain) { + const numPairs = ( + await sdk.api.abi.call({ + abi: OplContract.numPairs, + target: openleve_address[chain], + chain: coins_llama_name[chain] + }) + ).output; + + let pools = {} + for (var i = 0; i < numPairs; i++) { + const market = ( + await sdk.api.abi.call({ + abi: OplContract.markets, + target: openleve_address[chain], + chain: coins_llama_name[chain], + params: i + }) + ).output; + const token0Decimal = await getDecimals(market.token0, chain, erc20.decimals); + const token1Decimal = await getDecimals(market.token1, chain, erc20.decimals); + + const token0Symbol = await getSymbol(market.token0, chain); + const token1Symbol = await getSymbol(market.token1, chain); + let poolInfo = {} + poolInfo["name"] = `${token0Symbol}` + poolInfo["token"] = market.token0 + poolInfo["symbol"] = token0Symbol + poolInfo["tokenDecimal"] = token0Decimal + pools[market.pool0] = poolInfo + + poolInfo = {} + poolInfo["name"] = `${token1Symbol}` + poolInfo["token"] = market.token1 + poolInfo["symbol"] = token1Symbol + poolInfo["tokenDecimal"] = token1Decimal + pools[market.pool1] = poolInfo + + } + return pools + +} + +module.exports = { + timetravel: false, + apy: main, // Main function, returns pools + url: 'https://openleverage.finance/', +}; + + diff --git a/src/adaptors/raft/abis/RSavingsRate.json b/src/adaptors/raft/abis/RSavingsRate.json new file mode 100644 index 0000000000..7c123b88c9 --- /dev/null +++ b/src/adaptors/raft/abis/RSavingsRate.json @@ -0,0 +1,28 @@ +{ + "issuanceRate": { + "inputs": [], + "name": "issuanceRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + "totalAssets": { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +} diff --git a/src/adaptors/raft/index.js b/src/adaptors/raft/index.js index fd57e64ad0..db3d558091 100644 --- a/src/adaptors/raft/index.js +++ b/src/adaptors/raft/index.js @@ -1,51 +1,49 @@ const { default: BigNumber } = require('bignumber.js'); -const sdk = require('@defillama/sdk'); +const sdk = require('@defillama/sdk4'); +const utils = require('../utils'); +const rSavingsRateAbi = require('./abis/RSavingsRate.json'); -const RR = '0x2ba26baE6dF1153e29813d7f926143f9c94402f3'; +const RR = { + ethereum: '0x2ba26baE6dF1153e29813d7f926143f9c94402f3', + base: '0xA5b3FEe253f9DE67201dC8572Bd2CbB4a81c1bEc', +}; const HOUR = 60 * 60; const DAY = 24 * HOUR; const SECONDS_PER_YEAR = 365 * DAY; -async function apy() { +async function chainApy(chain) { const issuanceRate = await sdk.api.abi.call({ - target: RR, - abi: { - inputs: [], - name: 'issuanceRate', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - }, + target: RR[chain], + chain, + abi: rSavingsRateAbi.issuanceRate, }); const totalAssets = await sdk.api.abi.call({ - target: RR, - abi: { - inputs: [], - name: 'totalAssets', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - }, + target: RR[chain], + chain, + abi: rSavingsRateAbi.totalAssets, }); - const apy = 100 * BigNumber(issuanceRate.output) - .times(SECONDS_PER_YEAR) - .div(1e18) - .toNumber(); + const apy = + 100 * + BigNumber(issuanceRate.output).times(SECONDS_PER_YEAR).div(1e18).toNumber(); const tvlUsd = BigNumber(totalAssets.output).div(1e18).toNumber(); - return [ - { - pool: RR, - project: 'raft', - symbol: 'R', - chain: 'ethereum', - poolMeta: 'R Savings Rate', - apy, - tvlUsd, - }, - ]; + return { + pool: `${RR[chain]}-${chain}`.toLowerCase(), + project: 'raft', + symbol: 'R', + chain: utils.formatChain(chain), + poolMeta: 'R Savings Rate', + apy, + tvlUsd, + }; +} + +async function apy() { + return Promise.all(['ethereum', 'base'].map(chainApy)); } module.exports = { apy, - url: 'https://app.raft.com/savings', + url: 'https://app.raft.fi/savings', }; diff --git a/src/adaptors/reaper-farm/index.js b/src/adaptors/reaper-farm/index.js index de66ca2239..d260ab8be3 100644 --- a/src/adaptors/reaper-farm/index.js +++ b/src/adaptors/reaper-farm/index.js @@ -1,50 +1,55 @@ const utils = require('../utils'); -const baseUrl = 'https://yzo0r3ahok.execute-api.us-east-1.amazonaws.com/dev/api'; -const ftmUrl = baseUrl+'/crypts'; -const optUrl = baseUrl+'/optimism/crypts'; +const baseUrl = 'https://2ch9hbg8hh.execute-api.us-east-1.amazonaws.com/dev/api'; +const ftmUrl = baseUrl+'/vaults/0xfa'; +const optUrl = baseUrl+'/vaults/0xa'; +const arbUrl = baseUrl+'/vaults/0xa4b1'; const networkMapping = { 10: 'optimism', 250: 'fantom', + 42161: 'arbitrum', }; const main = async () => { - const [ftmCrypts, optCrypts] = await Promise.all( - [ftmUrl, optUrl].map((u) => utils.getData(u)) + const [ftmVaults, optVaults, arbVaults] = await Promise.all( + [ftmUrl, optUrl, arbUrl].map((u) => utils.getData(u)) ); - const cryptsMapping = { - 10: optCrypts.data, - 250: ftmCrypts.data, + const vaultsMapping = { + 10: optVaults.data, + 250: ftmVaults.data, + 42161: arbVaults.data, }; let data = []; for (const chain of Object.keys(networkMapping)) { - let poolData = cryptsMapping[chain]; - for (const pool of poolData) { - const cryptObj = pool.cryptContent; - const vaultId = cryptObj.vault.address; - let symbol = cryptObj.tokens[0].name; - let underlyingTokens = [cryptObj.tokens[0].address]; - for (let i=1; i { + const vaultId = pool.address; + let symbol = pool.tokens.lpToken.symbol; + let underlyingTokens = []; + if (pool.tokens.underlyingTokens.length !== 0) { + underlyingTokens = pool.tokens.underlyingTokens.map((tokenObj) => { + return tokenObj.address; + }) + } else { + underlyingTokens.push(pool.tokens.lpToken.address); } - if (pool.analytics.yields.year !== 0 && !cryptObj.dead) { + if (pool.yields.apy != 0) { data.push({ pool: `${vaultId}-${networkMapping[chain]}`.toLowerCase(), chain: utils.formatChain(networkMapping[chain]), project: 'reaper-farm', symbol: symbol, - tvlUsd: pool.analytics.tvl, - apy: pool.analytics.yields.year*100, + tvlUsd: pool.tvl.tvl, + apy: pool.yields.apy*100, underlyingTokens: underlyingTokens, }); } - } + }) } return data.filter( (p) => diff --git a/src/adaptors/reservoir/index.js b/src/adaptors/reservoir/index.js new file mode 100644 index 0000000000..b996c2ab5b --- /dev/null +++ b/src/adaptors/reservoir/index.js @@ -0,0 +1,48 @@ +const { request, gql } = require('graphql-request'); + +const GRAPHQL_URL = 'https://data.staging.arkiver.net/robolabs/reservoir-mainnet-v2/graphql'; + +const graphQuery = gql` + query GetStats { + PairSnapshots { + swapApr + managedApy + pair { + address + curveId + token0 + token1 + token0Symbol + token1Symbol + tvlUSD + } + } + } +`; + +const getApy = async () => { + const { PairSnapshots } = await request(GRAPHQL_URL, graphQuery); + + return PairSnapshots.map((snapshot) => { + const symbols = snapshot.pair.token0Symbol + '-' + snapshot.pair.token1Symbol + const poolType = snapshot.pair.curveId === 0 ? 'Constant Product' : 'Stable' + return { + pool: snapshot.pair.address, + chain: 'Avalanche', + project: 'reservoir', + symbol: symbols, + tvlUsd: snapshot.pair.tvlUSD, + apyBase: (snapshot.swapApr + snapshot.managedApy) * 100, // to convert into percentage form + apyReward: 0, + rewardTokens: [], // we do not have incentive tokens at this point + underlyingTokens: [snapshot.pair.token0, snapshot.pair.token1], + poolMeta: poolType + } + }) +} + +module.exports = { + timetravel: false, + apy: getApy, + url: 'https://analytics.reservoir.fi/', +}; diff --git a/src/adaptors/sdai/bridgeinterestreceiver.js b/src/adaptors/sdai/bridgeinterestreceiver.js new file mode 100644 index 0000000000..159104362e --- /dev/null +++ b/src/adaptors/sdai/bridgeinterestreceiver.js @@ -0,0 +1,216 @@ +module.exports=[ + { + "inputs": [ + { + "internalType": "address", + "name": "_vault", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Claimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "inputs": [], + "name": "claim", + "outputs": [ + { + "internalType": "uint256", + "name": "claimed", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "claimer", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "currentEpochBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "dripRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "epochLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "lastClaimTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextClaimEpoch", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "previewClaimable", + "outputs": [ + { + "internalType": "uint256", + "name": "claimable", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newClaimer", + "type": "address" + } + ], + "name": "setClaimer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vaultAPY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "wxdai", + "outputs": [ + { + "internalType": "contract IWXDAI", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ] \ No newline at end of file diff --git a/src/adaptors/sdai/erc20.js b/src/adaptors/sdai/erc20.js new file mode 100644 index 0000000000..5365f21bc7 --- /dev/null +++ b/src/adaptors/sdai/erc20.js @@ -0,0 +1,222 @@ +module.exports= [ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "balance", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + }, + { + "name": "_spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + } +] \ No newline at end of file diff --git a/src/adaptors/sdai/index.js b/src/adaptors/sdai/index.js new file mode 100644 index 0000000000..ad9f947c71 --- /dev/null +++ b/src/adaptors/sdai/index.js @@ -0,0 +1,53 @@ +const utils = require('../utils'); +const bridgeInterestReceiverABI = require('./bridgeinterestreceiver'); +const sdk = require('@defillama/sdk'); + +const chains = { + xdai: { + sDAI: '0xaf204776c7245bF4147c2612BF6e5972Ee483701', + wxDAI: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', + interestreceiver: '0x670daeaF0F1a5e336090504C68179670B5059088', + } +}; + +async function getApy() { + const vaultAPY = ( + await sdk.api.abi.call({ + chain: 'xdai', + abi: bridgeInterestReceiverABI.find((m) => m.name === 'vaultAPY'), + target: chains.xdai.interestreceiver, + }) + ).output; + return vaultAPY / 1e16; +} +async function getTVL() { + // wxDAI balance of sDAI vault + const tvl = ( + await sdk.api.abi.call({ + chain: 'xdai', + abi: 'erc20:balanceOf', + target: chains.xdai.wxDAI, + params: chains.xdai.sDAI, + }) + ).output; + // get wxDAI price + const wxDAIPrice = await utils.getPrices([chains.xdai.wxDAI], 'xdai'); + const tvlUSD = (tvl * wxDAIPrice.pricesBySymbol.wxdai) / 1e18; + return tvlUSD; +} +async function sDAIPool() { + const sDAIPoolData = { + pool: chains.xdai.sDAI, + chain: utils.formatChain('xdai'), + project: 'sdai', + symbol: 'sDAI', + apy: await getApy(), + tvlUsd: await getTVL(), + }; + return [sDAIPoolData]; +} +module.exports = { + timetravel: false, + apy: sDAIPool, + url: 'https://agave.finance/sdai/', +}; diff --git a/src/adaptors/shoebill-finance/abi.js b/src/adaptors/shoebill-v1/abi.js similarity index 100% rename from src/adaptors/shoebill-finance/abi.js rename to src/adaptors/shoebill-v1/abi.js diff --git a/src/adaptors/shoebill-finance/externalData.js b/src/adaptors/shoebill-v1/externalData.js similarity index 100% rename from src/adaptors/shoebill-finance/externalData.js rename to src/adaptors/shoebill-v1/externalData.js diff --git a/src/adaptors/shoebill-finance/index.js b/src/adaptors/shoebill-v1/index.js similarity index 95% rename from src/adaptors/shoebill-finance/index.js rename to src/adaptors/shoebill-v1/index.js index e576adfb9a..96855bce32 100644 --- a/src/adaptors/shoebill-finance/index.js +++ b/src/adaptors/shoebill-v1/index.js @@ -110,7 +110,7 @@ async function poolsFunction() { return { pool: `${e.token.externalAddress}-Klaytn`?.toLowerCase(), chain: 'Klaytn', - project: 'shoebill-finance', + project: 'shoebill-v1', symbol: e.token.externalSymbol, tvlUsd: Number(e.overview.availableLiquidity.mul(e.oraclePrice)) / diff --git a/src/adaptors/solidly-v3/abi.js b/src/adaptors/solidly-v3/abi.js new file mode 100644 index 0000000000..76cb8b068a --- /dev/null +++ b/src/adaptors/solidly-v3/abi.js @@ -0,0 +1,628 @@ +module.exports = [ + { inputs: [], stateMutability: 'nonpayable', type: 'constructor' }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'int24', + name: 'tickLower', + type: 'int24', + }, + { + indexed: true, + internalType: 'int24', + name: 'tickUpper', + type: 'int24', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amount', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount0', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount1', + type: 'uint256', + }, + ], + name: 'Burn', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + indexed: true, + internalType: 'int24', + name: 'tickLower', + type: 'int24', + }, + { + indexed: true, + internalType: 'int24', + name: 'tickUpper', + type: 'int24', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amount0', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amount1', + type: 'uint128', + }, + ], + name: 'Collect', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amount0', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amount1', + type: 'uint128', + }, + ], + name: 'CollectProtocol', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount0', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount1', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'paid0', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'paid1', + type: 'uint256', + }, + ], + name: 'Flash', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint160', + name: 'sqrtPriceX96', + type: 'uint160', + }, + { indexed: false, internalType: 'int24', name: 'tick', type: 'int24' }, + ], + name: 'Initialize', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'int24', + name: 'tickLower', + type: 'int24', + }, + { + indexed: true, + internalType: 'int24', + name: 'tickUpper', + type: 'int24', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amount', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount0', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount1', + type: 'uint256', + }, + ], + name: 'Mint', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint24', + name: 'feeOld', + type: 'uint24', + }, + { + indexed: false, + internalType: 'uint24', + name: 'feeNew', + type: 'uint24', + }, + ], + name: 'SetFee', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + indexed: false, + internalType: 'int256', + name: 'amount0', + type: 'int256', + }, + { + indexed: false, + internalType: 'int256', + name: 'amount1', + type: 'int256', + }, + { + indexed: false, + internalType: 'uint160', + name: 'sqrtPriceX96', + type: 'uint160', + }, + { + indexed: false, + internalType: 'uint128', + name: 'liquidity', + type: 'uint128', + }, + { indexed: false, internalType: 'int24', name: 'tick', type: 'int24' }, + ], + name: 'Swap', + type: 'event', + }, + { + inputs: [ + { internalType: 'int24', name: 'tickLower', type: 'int24' }, + { internalType: 'int24', name: 'tickUpper', type: 'int24' }, + { internalType: 'uint128', name: 'amount', type: 'uint128' }, + { internalType: 'uint256', name: 'amount0Min', type: 'uint256' }, + { internalType: 'uint256', name: 'amount1Min', type: 'uint256' }, + { internalType: 'uint256', name: 'deadline', type: 'uint256' }, + ], + name: 'burn', + outputs: [ + { internalType: 'uint256', name: 'amount0', type: 'uint256' }, + { internalType: 'uint256', name: 'amount1', type: 'uint256' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'int24', name: 'tickLower', type: 'int24' }, + { internalType: 'int24', name: 'tickUpper', type: 'int24' }, + { internalType: 'uint128', name: 'amount', type: 'uint128' }, + ], + name: 'burn', + outputs: [ + { internalType: 'uint256', name: 'amount0', type: 'uint256' }, + { internalType: 'uint256', name: 'amount1', type: 'uint256' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'int24', name: 'tickLower', type: 'int24' }, + { internalType: 'int24', name: 'tickUpper', type: 'int24' }, + { internalType: 'uint128', name: 'amountToBurn', type: 'uint128' }, + { internalType: 'uint128', name: 'amount0ToCollect', type: 'uint128' }, + { internalType: 'uint128', name: 'amount1ToCollect', type: 'uint128' }, + ], + name: 'burnAndCollect', + outputs: [ + { internalType: 'uint256', name: 'amount0FromBurn', type: 'uint256' }, + { internalType: 'uint256', name: 'amount1FromBurn', type: 'uint256' }, + { internalType: 'uint128', name: 'amount0Collected', type: 'uint128' }, + { internalType: 'uint128', name: 'amount1Collected', type: 'uint128' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'int24', name: 'tickLower', type: 'int24' }, + { internalType: 'int24', name: 'tickUpper', type: 'int24' }, + { internalType: 'uint128', name: 'amountToBurn', type: 'uint128' }, + { internalType: 'uint256', name: 'amount0FromBurnMin', type: 'uint256' }, + { internalType: 'uint256', name: 'amount1FromBurnMin', type: 'uint256' }, + { internalType: 'uint128', name: 'amount0ToCollect', type: 'uint128' }, + { internalType: 'uint128', name: 'amount1ToCollect', type: 'uint128' }, + { internalType: 'uint256', name: 'deadline', type: 'uint256' }, + ], + name: 'burnAndCollect', + outputs: [ + { internalType: 'uint256', name: 'amount0FromBurn', type: 'uint256' }, + { internalType: 'uint256', name: 'amount1FromBurn', type: 'uint256' }, + { internalType: 'uint128', name: 'amount0Collected', type: 'uint128' }, + { internalType: 'uint128', name: 'amount1Collected', type: 'uint128' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'int24', name: 'tickLower', type: 'int24' }, + { internalType: 'int24', name: 'tickUpper', type: 'int24' }, + { internalType: 'uint128', name: 'amount0Requested', type: 'uint128' }, + { internalType: 'uint128', name: 'amount1Requested', type: 'uint128' }, + ], + name: 'collect', + outputs: [ + { internalType: 'uint128', name: 'amount0', type: 'uint128' }, + { internalType: 'uint128', name: 'amount1', type: 'uint128' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'uint128', name: 'amount0Requested', type: 'uint128' }, + { internalType: 'uint128', name: 'amount1Requested', type: 'uint128' }, + ], + name: 'collectProtocol', + outputs: [ + { internalType: 'uint128', name: 'amount0', type: 'uint128' }, + { internalType: 'uint128', name: 'amount1', type: 'uint128' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'factory', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'uint256', name: 'amount0', type: 'uint256' }, + { internalType: 'uint256', name: 'amount1', type: 'uint256' }, + { internalType: 'bytes', name: 'data', type: 'bytes' }, + ], + name: 'flash', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint160', name: 'sqrtPriceX96', type: 'uint160' }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'liquidity', + outputs: [{ internalType: 'uint128', name: '', type: 'uint128' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'maxLiquidityPerTick', + outputs: [{ internalType: 'uint128', name: '', type: 'uint128' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'int24', name: 'tickLower', type: 'int24' }, + { internalType: 'int24', name: 'tickUpper', type: 'int24' }, + { internalType: 'uint128', name: 'amount', type: 'uint128' }, + { internalType: 'uint256', name: 'amount0Min', type: 'uint256' }, + { internalType: 'uint256', name: 'amount1Min', type: 'uint256' }, + { internalType: 'uint256', name: 'deadline', type: 'uint256' }, + ], + name: 'mint', + outputs: [ + { internalType: 'uint256', name: 'amount0', type: 'uint256' }, + { internalType: 'uint256', name: 'amount1', type: 'uint256' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'int24', name: 'tickLower', type: 'int24' }, + { internalType: 'int24', name: 'tickUpper', type: 'int24' }, + { internalType: 'uint128', name: 'amount', type: 'uint128' }, + ], + name: 'mint', + outputs: [ + { internalType: 'uint256', name: 'amount0', type: 'uint256' }, + { internalType: 'uint256', name: 'amount1', type: 'uint256' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'poolFees', + outputs: [ + { internalType: 'uint128', name: 'token0', type: 'uint128' }, + { internalType: 'uint128', name: 'token1', type: 'uint128' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + name: 'positions', + outputs: [ + { internalType: 'uint128', name: 'liquidity', type: 'uint128' }, + { internalType: 'uint128', name: 'tokensOwed0', type: 'uint128' }, + { internalType: 'uint128', name: 'tokensOwed1', type: 'uint128' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'bool', name: 'zeroForOne', type: 'bool' }, + { internalType: 'int256', name: 'amountSpecified', type: 'int256' }, + { internalType: 'uint160', name: 'sqrtPriceLimitX96', type: 'uint160' }, + ], + name: 'quoteSwap', + outputs: [ + { internalType: 'int256', name: 'amount0', type: 'int256' }, + { internalType: 'int256', name: 'amount1', type: 'int256' }, + { internalType: 'uint160', name: 'sqrtPriceX96After', type: 'uint160' }, + { internalType: 'int24', name: 'tickAfter', type: 'int24' }, + { internalType: 'uint128', name: 'liquidityAfter', type: 'uint128' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint24', name: 'fee', type: 'uint24' }], + name: 'setFee', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'slot0', + outputs: [ + { internalType: 'uint160', name: 'sqrtPriceX96', type: 'uint160' }, + { internalType: 'int24', name: 'tick', type: 'int24' }, + { internalType: 'uint24', name: 'fee', type: 'uint24' }, + { internalType: 'bool', name: 'unlocked', type: 'bool' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'bool', name: 'zeroForOne', type: 'bool' }, + { internalType: 'int256', name: 'amountSpecified', type: 'int256' }, + { internalType: 'uint160', name: 'sqrtPriceLimitX96', type: 'uint160' }, + { internalType: 'uint256', name: 'amountLimit', type: 'uint256' }, + { internalType: 'uint256', name: 'deadline', type: 'uint256' }, + { internalType: 'bytes', name: 'data', type: 'bytes' }, + ], + name: 'swap', + outputs: [ + { internalType: 'int256', name: 'amount0', type: 'int256' }, + { internalType: 'int256', name: 'amount1', type: 'int256' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'bool', name: 'zeroForOne', type: 'bool' }, + { internalType: 'int256', name: 'amountSpecified', type: 'int256' }, + { internalType: 'uint160', name: 'sqrtPriceLimitX96', type: 'uint160' }, + { internalType: 'bytes', name: 'data', type: 'bytes' }, + ], + name: 'swap', + outputs: [ + { internalType: 'int256', name: 'amount0', type: 'int256' }, + { internalType: 'int256', name: 'amount1', type: 'int256' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'bool', name: 'zeroForOne', type: 'bool' }, + { internalType: 'int256', name: 'amountSpecified', type: 'int256' }, + { internalType: 'uint160', name: 'sqrtPriceLimitX96', type: 'uint160' }, + { internalType: 'uint256', name: 'amountLimit', type: 'uint256' }, + { internalType: 'uint256', name: 'deadline', type: 'uint256' }, + ], + name: 'swap', + outputs: [ + { internalType: 'int256', name: 'amount0', type: 'int256' }, + { internalType: 'int256', name: 'amount1', type: 'int256' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'bool', name: 'zeroForOne', type: 'bool' }, + { internalType: 'int256', name: 'amountSpecified', type: 'int256' }, + { internalType: 'uint160', name: 'sqrtPriceLimitX96', type: 'uint160' }, + ], + name: 'swap', + outputs: [ + { internalType: 'int256', name: 'amount0', type: 'int256' }, + { internalType: 'int256', name: 'amount1', type: 'int256' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'int16', name: '', type: 'int16' }], + name: 'tickBitmap', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'tickSpacing', + outputs: [{ internalType: 'int24', name: '', type: 'int24' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'int24', name: '', type: 'int24' }], + name: 'ticks', + outputs: [ + { internalType: 'uint128', name: 'liquidityGross', type: 'uint128' }, + { internalType: 'int128', name: 'liquidityNet', type: 'int128' }, + { internalType: 'bool', name: 'initialized', type: 'bool' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'token0', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'token1', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, +]; diff --git a/src/adaptors/solidly-v3/estimateActiveLiq.ts b/src/adaptors/solidly-v3/estimateActiveLiq.ts new file mode 100644 index 0000000000..221efa7288 --- /dev/null +++ b/src/adaptors/solidly-v3/estimateActiveLiq.ts @@ -0,0 +1,250 @@ +// forked from uniswap.fish chads (see https://github.com/chunza2542/uniswap.fish) +// modified univ3 adapter to just return the active liq fraction +const bn = require('bignumber.js'); +const axios = require('axios'); + +bn.config({ EXPONENTIAL_AT: 999999, DECIMAL_PLACES: 40 }); + +const Q96 = new bn(2).pow(96); + +const getTickFromPrice = (price, token0Decimal, token1Decimal) => { + const token0 = expandDecimals(price, Number(token0Decimal)); + const token1 = expandDecimals(1, Number(token1Decimal)); + const sqrtPrice = encodeSqrtPriceX96(token1).div(encodeSqrtPriceX96(token0)); + + return Math.log(sqrtPrice.toNumber()) / Math.log(Math.sqrt(1.0001)); +}; + +const getTokensAmountFromDepositAmountUSD = ( + P, + Pl, + Pu, + priceUSDX, + priceUSDY, + depositAmountUSD +) => { + const deltaL = + depositAmountUSD / + ((Math.sqrt(P) - Math.sqrt(Pl)) * priceUSDY + + (1 / Math.sqrt(P) - 1 / Math.sqrt(Pu)) * priceUSDX); + + let deltaY = deltaL * (Math.sqrt(P) - Math.sqrt(Pl)); + if (deltaY * priceUSDY < 0) deltaY = 0; + if (deltaY * priceUSDY > depositAmountUSD) + deltaY = depositAmountUSD / priceUSDY; + + let deltaX = deltaL * (1 / Math.sqrt(P) - 1 / Math.sqrt(Pu)); + if (deltaX * priceUSDX < 0) deltaX = 0; + if (deltaX * priceUSDX > depositAmountUSD) + deltaX = depositAmountUSD / priceUSDX; + + return { amount0: deltaX, amount1: deltaY }; +}; + +// for calculation detail, please visit README.md (Section: Calculation Breakdown, No. 2) +const getLiquidityForAmount0 = (sqrtRatioAX96, sqrtRatioBX96, amount0) => { + // amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) + const intermediate = mulDiv(sqrtRatioBX96, sqrtRatioAX96, Q96); + return mulDiv(amount0, intermediate, sqrtRatioBX96.minus(sqrtRatioAX96)); +}; + +const getLiquidityForAmount1 = (sqrtRatioAX96, sqrtRatioBX96, amount1) => { + // amount1 / (sqrt(upper) - sqrt(lower)) + return mulDiv(amount1, Q96, sqrtRatioBX96.minus(sqrtRatioAX96)); +}; + +const getSqrtPriceX96 = (price, token0Decimal, token1Decimal) => { + const token0 = expandDecimals(price, token0Decimal); + const token1 = expandDecimals(1, token1Decimal); + + return token0.div(token1).sqrt().multipliedBy(Q96); +}; + +const getLiquidityDelta = ( + P, + lowerP, + upperP, + amount0, + amount1, + token0Decimal, + token1Decimal +) => { + const amt0 = expandDecimals(amount0, token1Decimal); + const amt1 = expandDecimals(amount1, token0Decimal); + + const sqrtRatioX96 = getSqrtPriceX96(P, token0Decimal, token1Decimal); + const sqrtRatioAX96 = getSqrtPriceX96(lowerP, token0Decimal, token1Decimal); + const sqrtRatioBX96 = getSqrtPriceX96(upperP, token0Decimal, token1Decimal); + + let liquidity; + if (sqrtRatioX96.lte(sqrtRatioAX96)) { + liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amt0); + } else if (sqrtRatioX96.lt(sqrtRatioBX96)) { + const liquidity0 = getLiquidityForAmount0( + sqrtRatioX96, + sqrtRatioBX96, + amt0 + ); + const liquidity1 = getLiquidityForAmount1( + sqrtRatioAX96, + sqrtRatioX96, + amt1 + ); + + liquidity = bn.min(liquidity0, liquidity1); + } else { + liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amt1); + } + + return liquidity; +}; + +/// get the percentage of active liquidity from the price assumption +const liquidityPercentage = (liquidityDelta, liquidity) => { + // console.log("DELTA", liquidityDelta, "LIQ", liquidity) + const liquidityPercentage = liquidityDelta + .div(liquidity.plus(liquidityDelta)) + .toNumber(); + return liquidityPercentage; +}; + +// get 'active' liquidity +const getLiquidityFromTick = (poolTicks, tick) => { + // calculate a cumulative of liquidityNet from all ticks that poolTicks[i] <= tick + let liquidity = new bn(0); + for (let i = 0; i < poolTicks.length - 1; ++i) { + liquidity = liquidity.plus(new bn(poolTicks[i].liquidityNet)); + + const lowerTick = Number(poolTicks[i].tickIdx); + const upperTick = Number(poolTicks[i + 1]?.tickIdx); + + if (lowerTick <= tick && tick <= upperTick) { + break; + } + } + + return liquidity; +}; + +// private helper functions +const encodeSqrtPriceX96 = (price) => { + return new bn(price).sqrt().multipliedBy(Q96).integerValue(3); +}; + +const expandDecimals = (n, exp) => { + return new bn(n).multipliedBy(new bn(10).pow(exp)); +}; + +const mulDiv = (a, b, multiplier) => { + return a.multipliedBy(b).div(multiplier); +}; + +const getPoolTicks = async (poolAddress, url) => { + const PAGE_SIZE = 3; + let result = []; + let page = 0; + while (true) { + const pool1 = await _getPoolTicksByPage(poolAddress, page, url); + const pool2 = await _getPoolTicksByPage(poolAddress, page + 1, url); + const pool3 = await _getPoolTicksByPage(poolAddress, page + 2, url); + + result = [...result, ...pool1, ...pool2, ...pool3]; + if (pool1.length === 0 || pool2.length === 0 || pool3.length === 0) { + break; + } + page += PAGE_SIZE; + } + return result; +}; + +const _getPoolTicksByPage = async (poolAddress, page, url) => { + let res; + try { + res = await _queryUniswap( + `{ + ticks(first: 1000, skip: ${ + page * 1000 + }, where: { poolAddress: "${poolAddress}" }, orderBy: tickIdx) { + tickIdx + liquidityNet + price0 + price1 + } + }`, + url + ); + } catch (e) { + console.log('_getPoolTicksByPage failed for', poolAddress); + return []; + } + + return res === undefined ? [] : res.ticks; +}; + +const _queryUniswap = async (query, url) => { + const { data } = await axios({ + url, + method: 'post', + data: { + query, + }, + }); + + return data.data; +}; + +module.exports.EstimateActiveLiq = async ( + poolAddress, + priceAssumptionValue, + priceRangeValue, + currentPriceUSDToken1, + currentPriceUSDToken0, + depositAmountUSD, + decimalsToken0, + decimalsToken1, + url +) => { + const P = priceAssumptionValue; + let Pl = priceRangeValue[0]; + let Pu = priceRangeValue[1]; + const priceUSDX = currentPriceUSDToken1 || 1; + const priceUSDY = currentPriceUSDToken0 || 1; + + const { amount0, amount1 } = getTokensAmountFromDepositAmountUSD( + P, + Pl, + Pu, + priceUSDX, + priceUSDY, + depositAmountUSD + ); + + const deltaL = getLiquidityDelta( + P, + Pl, + Pu, + amount0, + amount1, + Number(decimalsToken0 || 18), + Number(decimalsToken1 || 18) + ); + + let currentTick = getTickFromPrice( + P, + decimalsToken0 || '18', + decimalsToken1 || '18' + ); + const poolTicks = await getPoolTicks(poolAddress, url); + + if (!poolTicks.length) { + console.log(`No pool ticks found for ${poolAddress}`); + return { poolAddress, estimatedFee: 0 }; + } + + const L = getLiquidityFromTick(poolTicks, currentTick); + + const liq_percentage = + P >= Pl && P <= Pu ? liquidityPercentage(deltaL, L) : 0; + + return liq_percentage; +}; diff --git a/src/adaptors/solidly-v3/index.js b/src/adaptors/solidly-v3/index.js new file mode 100644 index 0000000000..60eb5e2927 --- /dev/null +++ b/src/adaptors/solidly-v3/index.js @@ -0,0 +1,192 @@ +const utils = require('../utils'); +const { + fetch_pools, + fetch_prices, + block_24h_ago, + pool_state_changes, + get_solid, + bn_to_float, + getPoolTicks, + get_graph_url, +} = require('./queries.ts'); +const { EstimateActiveLiq } = require('./estimateActiveLiq.ts'); +const sdk = require('@defillama/sdk'); +const ethers = require('ethers'); + +const ZERO = ethers.BigNumber.from(0); + +// - All pools (subgraph) [X] +// - Solid Emissions per pool (subgraph) [X] +// - lp token incentives per pool (subgraph) [X] +// - prices of tokens in usd (the defilama api call) [X] +// - Fee change events for pools (on chain call) [X] +// - Swap events for pools (on chain call) [X] +// - get fee of the pool at start of the period [X] +// - get total fee for each token for period (accounted for pool fee changes) [X] +// - get start liq of the pool for tvl [X] +// - get how much token the active liq is worth [X] -> Use uniswap v3 adapter code +// then active liq range can be inferred from swaps +// - price the token liq and fee liq [X] +// - get active token emissions [X] +// - get active solidly emissions [X] +// +// - Balances of pools (range inferred from swap events and use total liquidity indexed by tick then added) + +function pool_input(pool, x) { + let price = Math.abs( + ethers.FixedNumber.from(x.amount1.toString()) + .divUnsafe(ethers.FixedNumber.from(x.amount0.toString())) + .toUnsafeFloat() + ); + if (x.amount0 > ZERO) { + return { token: pool.token0.id.toLowerCase(), input: x.amount0, price }; + } else { + return { token: pool.token1.id.toLowerCase(), input: x.amount1, price }; + } +} + +const main = async (timestamp = null) => { + if (timestamp == null) { + timestamp = Math.floor(Date.now() / 1000.0); + } + const block_start = await block_24h_ago(timestamp); + let { pools, touched_tokens } = await fetch_pools(timestamp); + let prices = await fetch_prices(touched_tokens); + pools = pools + .map((x) => { + let t0 = x.token0.id.toLowerCase(); + let t1 = x.token1.id.toLowerCase(); + if (!(t0 in prices) || !(t1 in prices)) { + return []; + } + x.t0 = prices[t0]; + x.t1 = prices[t1]; + x[t0] = prices[t0]; + x[t1] = prices[t1]; + x.t0_usd = parseFloat(x.totalValueLockedToken0) * x.t0.price; + x.t1_usd = parseFloat(x.totalValueLockedToken1) * x.t1.price; + x.tvl = x.t0_usd + x.t1_usd; + return [x]; + }) + .flat(); + // console.log('pools lenght', pools.length); + + let data = ( + await Promise.all( + pools.map(async (pool) => { + let { begin_fee, state_changes, begin_liq } = await pool_state_changes( + pool.id, + block_start + ); + let current_fee = begin_fee; + let fee_per_token = {}; + + fee_per_token[pool.token0.id.toLowerCase()] = ZERO; + fee_per_token[pool.token1.id.toLowerCase()] = ZERO; + + let touched_prices = []; + for (let s of state_changes) { + // console.log(s); + if (s.event == 'Swap') { + // have to take fee from the positive amount + let pool_in = pool_input(pool, s.args); + touched_prices.push(pool_in.price); + let swap_fee = pool_in.input + .mul(current_fee) + .div(ethers.BigNumber.from(1_000_000)); + + fee_per_token[pool_in.token] = + fee_per_token[pool_in.token].add(swap_fee); + + // console.log('got swap'); + } else if (s.event == 'SetFee') { + current_fee = ethers.BigNumber.from(s.args.feeNew); + } + } + + let delta = 0.3; + // get the more accurate delta using the prices from the swaps + // if (touched_prices.length > 2) { + // let min = Math.min(...touched_prices); + // let max = Math.max(...touched_prices); + // delta = min / max; + // // console.log('NEW DELTA', pool.id, delta); + // } + let price_assumption = pool.t1.price / pool.t0.price; + pool.active_liq_fraction = await EstimateActiveLiq( + pool.id, + price_assumption, + [price_assumption * (1 - delta), price_assumption * (1 + delta)], + pool.t1.price, + pool.t0.price, + pool.tvl, + pool.t0.decimals, + pool.t1.decimals, + get_graph_url() + ); + // console.log('ACTIVE LIQ', pool.id, delta, pool.active_liq_fraction); + + // reduce token fees to total fees in window + let total_fee_usd = 0.0; + for (let [k, v] of Object.entries(fee_per_token)) { + let fee_usd = bn_to_float(v, pool[k].decimals) * pool[k].price; + total_fee_usd += fee_usd; + } + pool.solid_per_year_usd = + bn_to_float(pool.solid_per_year, 18) * prices[get_solid()].price; + pool.rewardTokens = []; + pool.apyReward = 0.0; + if (pool.tvl != 0) { + // the active tvl adjustment for apy + // to undo just don't multiply by `active_liq_fraction` + pool.active_tvl = pool.tvl * pool.active_liq_fraction; + // 20% goes to protocol + pool.apyBase = (total_fee_usd / pool.active_tvl) * 365 * 100 * 0.8; + pool.apySolid = (pool.solid_per_year_usd / pool.tvl) * 100; + if (pool.apySolid != 0.0) { + pool.apyReward = pool.apySolid; + pool.rewardTokens.push(get_solid()); + } + pool.apyEmissions = 0.0; + for (let emission of pool.emissions_per_year) { + if (emission.token in prices) { + let token_obj = prices[emission.token]; + let per_year_usd = + bn_to_float(emission.per_year, token_obj.decimals) * + token_obj.price; + pool.apyEmissions += (per_year_usd / pool.tvl) * 100; + pool.rewardTokens.push(emission.token); + pool.apyReward += pool.apyEmissions; + } + } + } + pool.symbol = `${pool.t0.symbol}-${pool.t1.symbol}`; + // console.log(pool); + return pool; + }) + ) + ).map((pool) => { + return { + pool: pool.id, + chain: 'ethereum', + project: 'solidly-v3', + symbol: pool.symbol, + tvlUsd: pool.tvl, + apyBase: pool.apyBase, + apyReward: pool.apyReward, + rewardTokens: [...new Set(pool.rewardTokens)], + url: `https://solidly.com/liquidity/manage/${pool.id}/`, + underlyingTokens: [pool.token0.id, pool.token1.id], + }; + }); + // console.log(data); + + // throw ''; + // console.log(data); + return data.flat().filter((p) => utils.keepFinite(p)); +}; + +module.exports = { + timetravel: false, + apy: main, +}; diff --git a/src/adaptors/solidly-v3/queries.ts b/src/adaptors/solidly-v3/queries.ts new file mode 100644 index 0000000000..c0e17216ba --- /dev/null +++ b/src/adaptors/solidly-v3/queries.ts @@ -0,0 +1,199 @@ +const { gql, request } = require('graphql-request'); +const axios = require('axios'); +const ethers = require('ethers'); +const ABI = require('./abi'); + +const ZERO = ethers.BigNumber.from(0); + +const GRAPH = 'https://api.thegraph.com/subgraphs/name/solidlylabs/solidly-v3'; +module.exports.get_graph_url = () => GRAPH; + +const GET_POOLS = gql` + { + pools(where: { sqrtPrice_gt: "0", liquidity_gt: "0" }) { + id + tick + totalValueLockedToken0 + totalValueLockedToken1 + tickSpacing + sqrtPrice + liquidity + token0 { + id + } + token1 { + id + } + lpSolidEmissions(where: {period_lte: }) { + period + amount + } + lpTokenIncentives(where: {periodStart_lte: }) { + periodStart + periodEnd + amount + token + } + } + } +`; + +module.exports.pool_state_changes = async (pool_id, block_start) => { + let provider = new ethers.providers.JsonRpcProvider( + process.env.ALCHEMY_CONNECTION_ETHEREUM, + 1 + ); + const contract = new ethers.Contract(pool_id, ABI, provider); + const begin_fee = ( + await contract.functions.slot0({ blockTag: block_start }) + )[2]; + // const begin_liq = ( + // await contract.functions.liquidity({ blockTag: block_start }) + // )[0]; + // console.log("begin liq", begin_liq); + const swaps = await contract.queryFilter( + contract.filters.Swap(), + block_start + ); + const fee_change = await contract.queryFilter( + contract.filters.SetFee(), + block_start + ); + let state_changes = [...swaps, ...fee_change]; + // Sort the state_changes array + state_changes.sort((a, b) => { + // Compare by blockNumber first + if (a.blockNumber < b.blockNumber) return -1; + if (a.blockNumber > b.blockNumber) return 1; + // If blockNumbers are the same, compare by logIndex + if (a.logIndex < b.logIndex) return -1; + if (a.logIndex > b.logIndex) return 1; + return 0; + }); + return { + begin_fee, + // begin_liq, + state_changes, + }; +}; + +module.exports.block_24h_ago = async (now) => { + const end_24h = now; + const start_24h = end_24h - 3600 * 24; + return (await axios.get(`https://coins.llama.fi/block/ethereum/${start_24h}`)) + .data.height; +}; + +const SOLID = '0x777172d858dc1599914a1c4c6c9fc48c99a60990'.toLowerCase(); + +// wow js what a concept +function bn_to_float(v, decimals) { + v = ethers.FixedNumber.from(v.toString()); + return v + .divUnsafe( + ethers.FixedNumber.from(ethers.BigNumber.from(10.0).pow(decimals)) + ) + .toUnsafeFloat(); +} + +module.exports.bn_to_float = bn_to_float; +module.exports.get_solid = () => SOLID; + +// fetch all pools avb up to timestamp from subgraph +module.exports.fetch_pools = async (now) => { + const end_24h = now; + let week = 3600 * 24 * 7; + const one_week_before = end_24h - week; + const in_one_week = end_24h + week; + // const start_24h = end_24h - (3600 * 24); + // console.log("start_24h end_24h", start_24h, end_24h); + let holder = ''; + let res = await request( + GRAPH, + GET_POOLS.replace(holder, end_24h).replace(holder, end_24h) + ); + let touched_tokens = res.pools.flatMap((x) => [x.token0.id, x.token1.id]); + // add SOLID due to solid emissions + touched_tokens = [...touched_tokens, SOLID]; + return { + pools: res.pools.map((x) => { + // SOLID EMISSIONS + let latest = x.lpSolidEmissions + .map((x) => { + x.period = parseInt(x.period); + x.amount = ethers.BigNumber.from(x.amount); + return x; + }) + .filter((x) => x.period > one_week_before && x.period < in_one_week) + .reduce( + (max, current) => (current.period > max.period ? current : max), + { period: 0, amount: ZERO } + ); + x.solid_per_year = latest.amount.mul(ethers.BigNumber.from(52)); + + // TOKEN EMISSIONS = BRIBES + let now = end_24h; // for test: - 3600 * 24; + latest = x.lpTokenIncentives + .map((x) => { + x.periodStart = parseInt(x.periodStart); + x.periodEnd = parseInt(x.periodEnd); + x.amount = ethers.BigNumber.from(x.amount); + return x; + }) + .filter((x) => x.periodStart < x.periodEnd) + // start is smaller than now, end is bigger than now + .filter((x) => x.periodStart < now && x.periodEnd > now); + + x.emissions_per_year = []; + if (latest.length > 0) { + for (let emission of latest) { + // so that its available in prices + touched_tokens.push(emission.token); + x.emissions_per_year.push({ + ...emission, + // there is an edgecase here if emissions are for longer than year and token has little decimals + per_year: emission.amount + .mul(ethers.BigNumber.from(3600 * 24 * 365)) + .div( + ethers.BigNumber.from(emission.periodEnd - emission.periodStart) + ), + }); + } + } + + return x; + }), + touched_tokens, + }; +}; + +// fetch all prices now .. yes it is inaccurate for past queries +module.exports.fetch_prices = async (token_addr) => { + const set = new Set(token_addr.map((x) => x.toLowerCase())); + token_addr = [...set]; + // ex: https://coins.llama.fi/prices/current/ethereum:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 + let idsSet = token_addr.map((x) => `ethereum:${x}`); + const maxSize = 50; + const pages = Math.ceil(idsSet.length / maxSize); + let prices = {}; + let x = ''; + for (const p of [...Array(pages).keys()]) { + x = idsSet + .slice(p * maxSize, maxSize * (p + 1)) + .join(',') + .replaceAll('/', ''); + prices = { + ...prices, + ...(await axios.get(`https://coins.llama.fi/prices/current/${x}`)).data + .coins, + }; + } + let res = {}; + + Object.keys(prices).forEach((key) => { + // remove eth chain prefix + res[key.split(':')[1].toLowerCase()] = prices[key]; + }); + + return res; +}; diff --git a/src/adaptors/tangible/abis/Caviar.json b/src/adaptors/tangible-rwa/abis/Caviar.json similarity index 100% rename from src/adaptors/tangible/abis/Caviar.json rename to src/adaptors/tangible-rwa/abis/Caviar.json diff --git a/src/adaptors/tangible/abis/CaviarRebaseChef.json b/src/adaptors/tangible-rwa/abis/CaviarRebaseChef.json similarity index 100% rename from src/adaptors/tangible/abis/CaviarRebaseChef.json rename to src/adaptors/tangible-rwa/abis/CaviarRebaseChef.json diff --git a/src/adaptors/tangible/abis/CaviarStakingChef.json b/src/adaptors/tangible-rwa/abis/CaviarStakingChef.json similarity index 100% rename from src/adaptors/tangible/abis/CaviarStakingChef.json rename to src/adaptors/tangible-rwa/abis/CaviarStakingChef.json diff --git a/src/adaptors/tangible/abis/Pair.json b/src/adaptors/tangible-rwa/abis/Pair.json similarity index 100% rename from src/adaptors/tangible/abis/Pair.json rename to src/adaptors/tangible-rwa/abis/Pair.json diff --git a/src/adaptors/tangible/abis/PairFactory.json b/src/adaptors/tangible-rwa/abis/PairFactory.json similarity index 100% rename from src/adaptors/tangible/abis/PairFactory.json rename to src/adaptors/tangible-rwa/abis/PairFactory.json diff --git a/src/adaptors/tangible/abis/Pearl.json b/src/adaptors/tangible-rwa/abis/Pearl.json similarity index 100% rename from src/adaptors/tangible/abis/Pearl.json rename to src/adaptors/tangible-rwa/abis/Pearl.json diff --git a/src/adaptors/tangible/abis/USDR.json b/src/adaptors/tangible-rwa/abis/USDR.json similarity index 100% rename from src/adaptors/tangible/abis/USDR.json rename to src/adaptors/tangible-rwa/abis/USDR.json diff --git a/src/adaptors/tangible/abis/WrappedUSDR.json b/src/adaptors/tangible-rwa/abis/WrappedUSDR.json similarity index 100% rename from src/adaptors/tangible/abis/WrappedUSDR.json rename to src/adaptors/tangible-rwa/abis/WrappedUSDR.json diff --git a/src/adaptors/tangible/caviar.js b/src/adaptors/tangible-rwa/caviar.js similarity index 100% rename from src/adaptors/tangible/caviar.js rename to src/adaptors/tangible-rwa/caviar.js diff --git a/src/adaptors/tangible/index.js b/src/adaptors/tangible-rwa/index.js similarity index 96% rename from src/adaptors/tangible/index.js rename to src/adaptors/tangible-rwa/index.js index b657dd910f..bc393b8c40 100644 --- a/src/adaptors/tangible/index.js +++ b/src/adaptors/tangible-rwa/index.js @@ -8,6 +8,7 @@ const usdr = require('./abis/USDR.json'); const CHAIN_NAME = 'polygon'; const TNGBL_ADDRESS = '0x49e6A20f1BBdfEeC2a8222E052000BbB14EE6007'; +const project = 'tangible-rwa'; const poolsFunction = async () => { const apyData = await utils.getData( @@ -25,7 +26,7 @@ const poolsFunction = async () => { const usdrPool = { pool: usdr.address, chain: utils.formatChain('polygon'), - project: 'tangible', + project, symbol: utils.formatSymbol('USDR'), tvlUsd: Number(totalSupply) / 1e9, apyBase: Number(apyData.usdr), @@ -40,7 +41,7 @@ const poolsFunction = async () => { const caviarPool = { pool: caviarStakingChef.address, chain: utils.formatChain('polygon'), - project: 'tangible', + project, symbol: utils.formatSymbol('CVR'), tvlUsd: Number(tvl), apyBase: Number(utils.aprToApy(aprBase, 52)), diff --git a/src/adaptors/tangible/pearl.js b/src/adaptors/tangible-rwa/pearl.js similarity index 100% rename from src/adaptors/tangible/pearl.js rename to src/adaptors/tangible-rwa/pearl.js diff --git a/src/adaptors/thorchain/index.js b/src/adaptors/thorchain/index.js index 1339991a67..854c69b7ca 100644 --- a/src/adaptors/thorchain/index.js +++ b/src/adaptors/thorchain/index.js @@ -32,6 +32,27 @@ const buildPool = (entry, runePrice) => { return newObj; }; +const buildSavers= (entry, runePrice) => { + const asset = entry.asset.split('.'); + const chain = chainMapping[asset[0]]; + const symbol = `${asset[1].split('-')[0]}`; + + const balanceAsset = + (Number(entry.saversDepth) / 1e8) * Number(entry.assetPriceUSD); + + const newObj = { + pool: `${entry.asset}-thorchain-savers`, + chain: chain !== undefined ? utils.formatChain(chain) : null, + project: 'thorchain', + symbol: utils.formatSymbol(symbol), + tvlUsd: balanceAsset, + apy: Number(entry.saversAPR) * 100, + url: 'https://app.thorswap.finance/earn' + }; + + return newObj; +}; + const topLvl = async () => { // https://midgard.ninerealms.com/v2/doc (for more info) const url = 'https://midgard.ninerealms.com/v2/pools'; @@ -41,9 +62,10 @@ const topLvl = async () => { ); // build pool objects - data = data.map((el) => buildPool(el, Number(runePrice.runePriceUSD))); + const pools = data.map((el) => buildPool(el, Number(runePrice.runePriceUSD))); + const savers = data.map((el) => buildSavers(el, Number(runePrice.runePriceUSD))); - return data.filter((p) => p.chain); + return [...savers, ...pools].filter((p) => p.chain); }; const main = async () => { diff --git a/src/adaptors/utils.js b/src/adaptors/utils.js index c809aed9d3..a0c94f425e 100755 --- a/src/adaptors/utils.js +++ b/src/adaptors/utils.js @@ -103,7 +103,8 @@ const getLatestBlockSubgraph = async (url) => { url.includes('48211/uniswap-v3-base') || url.includes('horizondex/block') || url.includes('exchange-v3-polygon-zkevm/version/latest') || - url.includes('exchange-v3-zksync/version/latest') + url.includes('exchange-v3-zksync/version/latest') || + url.includes('balancer-base-v2/version/latest') ? await request(url, queryGraph) : await request( `https://api.thegraph.com/subgraphs/name/${url.split('name/')[1]}`, @@ -419,3 +420,9 @@ const makeMulticall = async (abi, addresses, chain, params = null) => { }; exports.makeMulticall = makeMulticall; + +const capitalizeFirstLetter = (str) => { + return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); +}; + +exports.capitalizeFirstLetter = capitalizeFirstLetter; diff --git a/src/adaptors/vaultka/index.js b/src/adaptors/vaultka/index.js index 3e25e3a83e..d23b55b3b7 100644 --- a/src/adaptors/vaultka/index.js +++ b/src/adaptors/vaultka/index.js @@ -29,9 +29,7 @@ const latestAnswer = { stateMutability: 'view', type: 'function', }; - //reward tracker - const totalSupply = { inputs: [], name: 'totalSupply', @@ -190,9 +188,9 @@ const poolsFunction = async () => { pool: '0x0081772FD29E4838372CbcCdD020f53954f5ECDE', chain: utils.formatChain('arbitrum'), project: 'vaultka', - symbol: 'VODKA', + symbol: 'DN-VODKA', tvlUsd: tvls.vodkaVault, - poolMeta: 'VAULTKA_VODKA', + poolMeta: 'Delta Neutral GLP Vault', underlyingTokens: ['0x2F546AD4eDD93B956C8999Be404cdCAFde3E89AE'], apy: vodkaApy, }; @@ -203,7 +201,7 @@ const poolsFunction = async () => { project: 'vaultka', symbol: 'V-WATER', tvlUsd: tvls.waterVault - usdcBorrowed / 10e5, - poolMeta: 'VAULTKA_WATER', + poolMeta: 'Diluted Vodka Lending Vault', underlyingTokens: ['0xff970a61a04b1ca14834a43f5de4533ebddb5cc8'], apy: waterApy, totalSupplyUsd: tvls.waterVault, @@ -217,6 +215,9 @@ const poolsFunction = async () => { sakeWater: '0x6b367F9EB22B2E6074E9548689cddaF9224FC0Ab', sakeV2: '0xc53A53552191BeE184557A15f114a87a757e5b6F', sakeWaterV2: '0x806e8538FC05774Ea83d9428F778E423F6492475', + vodkaV1_Water: '0xC99C6427cB0B824207606dC2745A512C6b066E7C', + vodka1: '0x88D7500aF99f11fF52E9f185C7aAFBdF9acabD93', + fsGlp: '0x1aDDD80E6039594eE970E5872D247bf0414C8903', }; const contractAbis = { @@ -227,9 +228,13 @@ const poolsFunction = async () => { stakedVlpBalance: 'function getStakedVlpBalance() public view returns (uint256)', vlpPrice: 'function getVLPPrice() public view returns (uint256)', + glpPrice: 'function getGLPPrice(bool) public view returns (uint256)', waterUSDCBal: 'function balanceOfUSDC() public view returns (uint256)', waterTotalAssets: 'function totalAssets() public view returns (uint256)', feeSplit: 'function fixedFeeSplit() public view returns (uint256)', + balanceOf: 'function balanceOf(address) view returns (uint256)', + vodkaUtilizationRate: + 'function getUtilizationRate() view returns (uint256)', }; //calculation of tvls const whiskeyGainsBalance = await api2.abi.call({ @@ -328,6 +333,60 @@ const poolsFunction = async () => { chain: 'arbitrum', }); + //calculate vodka leverage and water vault + + const vodkaWaterUSDCBal = await api2.abi.call({ + abi: contractAbis.waterUSDCBal, + target: newAddresses.vodkaV1_Water, + chain: 'arbitrum', + }); + + const vodkaGLPBalV1 = await api2.abi.call({ + abi: contractAbis.balanceOf, + target: newAddresses.fsGlp, + chain: 'arbitrum', + params: [newAddresses.vodka1], + }); + + const vodkaGLPPrice = await api2.abi.call({ + abi: contractAbis.glpPrice, + target: newAddresses.vodka1, + params: [true], + chain: 'arbitrum', + }); + + const vodkaTvl = (vodkaGLPBalV1 * vodkaGLPPrice) / 1e36; + + const vodkaWaterTotalAssets = await api2.abi.call({ + abi: contractAbis.waterTotalAssets, + target: newAddresses.vodkaV1_Water, + chain: 'arbitrum', + }); + + let vodkaUtilizationRate = await api2.abi.call({ + abi: contractAbis.vodkaUtilizationRate, + target: newAddresses.vodka1, + chain: 'arbitrum', + }); + + vodkaUtilizationRate = Number(ethers.utils.formatUnits(vodkaUtilizationRate)); + + const vodkaFeeSplit = + (vodkaUtilizationRate <= 0.9 + ? 30 + : vodkaUtilizationRate >= 0.95 + ? 70 + : Math.round(30 + (vodkaUtilizationRate - 0.9) * 800)) / 100; + + console.log('vodkaFeeSplit', vodkaFeeSplit); + console.log('glpApr', glpApr); + + const vodkaApr = glpApr <= 0 ? 0 : glpApr * 5 * (1 - vodkaFeeSplit); + const vodkaWaterApr = + glpApr <= 0 + ? 0 + : (vodkaTvl * glpApr * vodkaFeeSplit) / (vodkaWaterTotalAssets / 1e6); + //calculation of Whiskey apys const response = (await axios.get(`https://backend-arbitrum.gains.trade/apr`)) .data; @@ -380,13 +439,35 @@ const poolsFunction = async () => { //info of the pools + const vodkaLeverageVault = { + pool: '0x88D7500aF99f11fF52E9f185C7aAFBdF9acabD93', + chain: utils.formatChain('arbitrum'), + project: 'vaultka', + symbol: 'VODKA-V1', + tvlUsd: vodkaTvl, + poolMeta: 'GLP Leverage Vault', + apy: vodkaApr, + }; + + const vodkaWaterVault = { + pool: '0xC99C6427cB0B824207606dC2745A512C6b066E7C', + chain: utils.formatChain('arbitrum'), + project: 'vaultka', + symbol: 'V1-WATER', + tvlUsd: vodkaWaterUSDCBal / 1e6, + poolMeta: 'Vodka Lending Vault', + apy: vodkaWaterApr, + totalSupplyUsd: vodkaWaterTotalAssets / 1e6, + totalBorrowUsd: (vodkaWaterTotalAssets - vodkaWaterUSDCBal) / 1e6, + }; + const whiskeyVault = { pool: '0x6532eFCC1d617e094957247d188Ae6d54093718A', chain: utils.formatChain('arbitrum'), project: 'vaultka', symbol: 'WHISKEY', tvlUsd: (whiskeyGainsBalance * whiskeyGTokenPrice) / 1e36, - poolMeta: 'VAULTKA_WHISKEY', + poolMeta: 'GDAI Leverage Vault', apy: whiskeyApy, }; @@ -396,7 +477,7 @@ const poolsFunction = async () => { project: 'vaultka', symbol: 'W-WATER', tvlUsd: whiskeyWaterDaiBal / 1e18, - poolMeta: 'VAULTKA_W-WATER', + poolMeta: 'Whiskey Lending Vault', apy: whiskeyWaterApy, totalSupplyUsd: WhiskeyWaterTotalAssets / 1e18, totalBorrowUsd: (WhiskeyWaterTotalAssets - whiskeyWaterDaiBal) / 1e18, @@ -408,7 +489,7 @@ const poolsFunction = async () => { project: 'vaultka', symbol: 'SAKE', tvlUsd: ((vlpBal + StakedVLPBal) * sakeVLPPrice) / 1e18 / 1e5, - poolMeta: 'VAULTKA_SAKE', + poolMeta: 'VLP Leverage Vault', apy: sakeApr, }; @@ -418,7 +499,7 @@ const poolsFunction = async () => { project: 'vaultka', symbol: 'S-WATER', tvlUsd: sakeWaterUSDCBal / 1e6, - poolMeta: 'VAULTKA_S-WATER', + poolMeta: 'Sake Lending Vault', apy: sakeWaterApr, totalSupplyUsd: SakeWaterTotalAssets / 1e6, totalBorrowUsd: (SakeWaterTotalAssets - sakeWaterUSDCBal) / 1e6, @@ -428,9 +509,9 @@ const poolsFunction = async () => { pool: '0xc53A53552191BeE184557A15f114a87a757e5b6F', chain: utils.formatChain('arbitrum'), project: 'vaultka', - symbol: 'SAKEV2', + symbol: 'SAKE-V2', tvlUsd: ((vlpBalV2 + StakedVLPBalV2) * sakeVLPPrice) / 1e18 / 1e5, - poolMeta: 'VAULTKA_SAKEV2', + poolMeta: 'VLP Leverage Vault V2', apy: sakeApr, }; @@ -438,9 +519,9 @@ const poolsFunction = async () => { pool: '0x806e8538FC05774Ea83d9428F778E423F6492475', chain: utils.formatChain('arbitrum'), project: 'vaultka', - symbol: 'S-WATERV2', + symbol: 'S2-WATER', tvlUsd: sakeWaterUSDCBalV2 / 1e6, - poolMeta: 'VAULTKA_S-WATERV2', + poolMeta: 'SakeV2 Lending Vault', apy: sakeWaterAprV2, totalSupplyUsd: SakeWaterTotalAssetsV2 / 1e6, totalBorrowUsd: (SakeWaterTotalAssetsV2 - sakeWaterUSDCBalV2) / 1e6, @@ -455,6 +536,8 @@ const poolsFunction = async () => { sakeWaterVault, sakeVaultV2, sakeWaterVaultV2, + vodkaLeverageVault, + vodkaWaterVault, ]; }; diff --git a/src/adaptors/vela-exchange/TokenFarmABI.json b/src/adaptors/vela-exchange/TokenFarmABI.json new file mode 100644 index 0000000000..943751dfd8 --- /dev/null +++ b/src/adaptors/vela-exchange/TokenFarmABI.json @@ -0,0 +1,55 @@ +[ + { + "inputs": [ + { + "internalType": "bool", + "name": "_isVelaPool", + "type": "bool" + } + ], + "name": "poolRewardsPerSec", + "outputs": [ + { + "internalType": "address[]", + "name": "addresses", + "type": "address[]" + }, + { + "internalType": "string[]", + "name": "symbols", + "type": "string[]" + }, + { + "internalType": "uint256[]", + "name": "decimals", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "rewardsPerSec", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "poolTotalLp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/adaptors/vela-exchange/index.js b/src/adaptors/vela-exchange/index.js index c2c3ad977e..7186e4de46 100644 --- a/src/adaptors/vela-exchange/index.js +++ b/src/adaptors/vela-exchange/index.js @@ -3,68 +3,137 @@ const sdk = require('@defillama/sdk'); const utils = require('../utils'); const VaultABI = require('./VaultABI.json'); const VLPABI = require('./VLPABI.json'); +const TokenFarmABI = require('./TokenFarmABI.json'); const axios = require('axios'); -const BRIDGED_USDC_ADDRESS = '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8'; +const VELA_ADDRESS = { + ['arbitrum']: '0x088cd8f5eF3652623c22D48b1605DCfE860Cd704', + ['base']: '0x5A76A56ad937335168b30dF3AA1327277421C6Ae', +}; +const BRIDGED_USDC_ADDRESS = { + ['arbitrum']: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8', + ['base']: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA', +}; const VAULT_ADDRESS = '0xC4ABADE3a15064F9E3596943c699032748b13352'; -const VLP_ADDRESS = '0xC5b2D9FDa8A82E8DcECD5e9e6e99b78a9188eB05'; +const VLP_ADDRESS = { + ['arbitrum']: '0xC5b2D9FDa8A82E8DcECD5e9e6e99b78a9188eB05', + ['base']: '0xEBf154Ee70de5237aB07Bd6428310CbC5e5c7C6E', +}; +const TOKEN_FARM_ADDRESS = { + ['arbitrum']: '0x60b8C145235A31f1949a831803768bF37d7Ab7AA', + ['base']: '0x00B01710c2098b883C4F93dD093bE8Cf605a7BDe', +}; +const RPC = { + ['arbitrum']: 'https://arbitrum.llamarpc.com', + ['base']: 'https://mainnet.base.org', +}; +const chains = ['arbitrum', 'base']; const poolsFunction = async () => { - // 14 days - let distance = await axios( - `https://coins.llama.fi/block/arbitrum/${Math.floor( - new Date(new Date(Date.now() - 12096e5)).getTime() / 1000 - )}` - ); - - sdk.api.config.setProvider( - 'arbitrum', - new ethers.providers.JsonRpcProvider( - 'https://arb-mainnet.g.alchemy.com/v2/demo' - ) - ); - - const current = ( - await sdk.api.abi.call({ - target: VAULT_ADDRESS, - abi: VaultABI.filter(({ name }) => name === 'getVLPPrice')[0], - chain: 'arbitrum', - }) - ).output; - - const totalSupply = ( - await sdk.api.abi.call({ - target: VLP_ADDRESS, - abi: VLPABI.filter(({ name }) => name === 'totalSupply')[0], - chain: 'arbitrum', - }) - ).output; - - const historical = ( - await sdk.api.abi.call({ - target: VAULT_ADDRESS, - abi: VaultABI.filter(({ name }) => name === 'getVLPPrice')[0], - chain: 'arbitrum', - block: distance.data.height, - }) - ).output; - - const diff = current - historical; - - const APR = 365 * (diff / historical / 14) * 100; - - const VLPPool = { - pool: `${VAULT_ADDRESS}-arbitrum`.toLowerCase(), - chain: utils.formatChain('arbitrum'), - project: 'vela-exchange', - symbol: 'USDC', - poolMeta: 'VLP', - tvlUsd: (Number(totalSupply) / 1e18) * (Number(current) / 1e5), - apyBase: APR, - underlyingTokens: [BRIDGED_USDC_ADDRESS], - }; - - return [VLPPool]; + const pools = []; + const secondsPerYear = 31536000; + + for (let i = 0; i < chains.length; i++) { + const chain = chains[i]; + // 14 days + let distance = await axios( + `https://coins.llama.fi/block/${chain}/${Math.floor( + new Date(new Date(Date.now() - 12096e5)).getTime() / 1000 + )}` + ); + + sdk.api.config.setProvider( + `${chain}`, + new ethers.providers.JsonRpcProvider(`${RPC[chain]}`) + ); + + const velaPrice = ( + await utils.getPrices( + ['0x088cd8f5eF3652623c22D48b1605DCfE860Cd704'], + 'arbitrum' + ) + ).pricesBySymbol.vela; + + const current = ( + await sdk.api.abi.call({ + target: VAULT_ADDRESS, + abi: VaultABI.filter(({ name }) => name === 'getVLPPrice')[0], + chain: `${chain}`, + }) + ).output; + + const totalSupply = ( + await sdk.api.abi.call({ + target: VLP_ADDRESS[chain], + abi: VLPABI.filter(({ name }) => name === 'totalSupply')[0], + chain: `${chain}`, + }) + ).output; + + const historical = ( + await sdk.api.abi.call({ + target: VAULT_ADDRESS, + abi: VaultABI.filter(({ name }) => name === 'getVLPPrice')[0], + chain: `${chain}`, + block: distance.data.height, + }) + ).output; + + const rewardsPerSecond = ethers.utils.formatEther( + ( + await sdk.api.abi.call({ + target: TOKEN_FARM_ADDRESS[chain], + abi: TokenFarmABI.filter( + ({ name }) => name === 'poolRewardsPerSec' + )[0], + chain: `${chain}`, + params: [0], + }) + ).output[3].toString() + ); + + const poolTotal = ethers.utils.formatEther( + ( + await sdk.api.abi.call({ + target: TOKEN_FARM_ADDRESS[chain], + abi: TokenFarmABI.filter(({ name }) => name === 'poolTotalLp')[0], + chain: `${chain}`, + params: [1], + }) + ).output + ); + + const diff = current - historical; + const APR = 365 * (diff / historical / 14) * 100; + + if (poolTotal > 0) { + VELA_APR = + ((rewardsPerSecond * secondsPerYear * velaPrice) / + (poolTotal * parseFloat(ethers.utils.formatUnits(current, 5)))) * + 100; + } else { + VELA_APR = 0; + } + + const VLPPool = { + pool: `${VAULT_ADDRESS}-${chain}`.toLowerCase(), + chain: utils.formatChain(`${chain}`), + project: 'vela-exchange', + symbol: 'USDC', + poolMeta: 'VLP', + tvlUsd: (Number(totalSupply) / 1e18) * (Number(current) / 1e5), + apyBase: APR, + underlyingTokens: [BRIDGED_USDC_ADDRESS[chain]], + rewardTokens: [VELA_ADDRESS[chain]], + apyReward: VELA_APR, + poolMeta: + 'Reward tokens are issued after staking VLP and rewards are in $esVela. Users can deposit $esVELA into the vesting contract in order to claim the same amount of $VELA. This is unlocked continuously throughout a one year (365 days) linear vesting period.', + }; + + pools.push(VLPPool); + } + + return pools; }; module.exports = { diff --git a/src/adaptors/venus/abiPool.js b/src/adaptors/venus-core-pool/abiPool.js similarity index 100% rename from src/adaptors/venus/abiPool.js rename to src/adaptors/venus-core-pool/abiPool.js diff --git a/src/adaptors/venus/abiUnitroller.js b/src/adaptors/venus-core-pool/abiUnitroller.js similarity index 100% rename from src/adaptors/venus/abiUnitroller.js rename to src/adaptors/venus-core-pool/abiUnitroller.js diff --git a/src/adaptors/venus/index.js b/src/adaptors/venus-core-pool/index.js similarity index 99% rename from src/adaptors/venus/index.js rename to src/adaptors/venus-core-pool/index.js index 6f6e720090..914db98645 100644 --- a/src/adaptors/venus/index.js +++ b/src/adaptors/venus-core-pool/index.js @@ -224,7 +224,7 @@ function exportFormatter( return { pool: pool.toLowerCase(), chain, - project: 'venus', + project: 'venus-core-pool', symbol, tvlUsd, apyBase, diff --git a/src/adaptors/vvs-finance/abis.js b/src/adaptors/vvs-standard/abis.js similarity index 100% rename from src/adaptors/vvs-finance/abis.js rename to src/adaptors/vvs-standard/abis.js diff --git a/src/adaptors/vvs-finance/index.js b/src/adaptors/vvs-standard/index.js similarity index 99% rename from src/adaptors/vvs-finance/index.js rename to src/adaptors/vvs-standard/index.js index e505ba7c26..08e606bf17 100644 --- a/src/adaptors/vvs-finance/index.js +++ b/src/adaptors/vvs-standard/index.js @@ -254,7 +254,7 @@ const main = async () => { const pool = { pool: pairInfo.id, chain: utils.formatChain('cronos'), - project: 'vvs-finance', + project: 'vvs-standard', symbol: pairInfo.name, tvlUsd: Number(reserveUSD), apyBase, diff --git a/src/adaptors/wombat-exchange/index.js b/src/adaptors/wombat-exchange/index.js index 6ff59737f9..3379309fcb 100644 --- a/src/adaptors/wombat-exchange/index.js +++ b/src/adaptors/wombat-exchange/index.js @@ -106,7 +106,11 @@ const apy = async () => { }); }); } - return apy_export; + + // remove dupes on lptoken + return apy_export.filter( + (v, i, a) => a.findIndex((v2) => v2.pool === v.pool) === i + ); }; module.exports = { diff --git a/src/adaptors/zkswap-finance/abis.js b/src/adaptors/zkswap-finance/abis.js new file mode 100644 index 0000000000..6418c19dcb --- /dev/null +++ b/src/adaptors/zkswap-finance/abis.js @@ -0,0 +1,1334 @@ +module.exports = { + zfFarmABI: [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "user", + type: "address" + }, + { + indexed: true, + internalType: "uint256", + name: "pid", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "Deposit", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "user", + type: "address" + }, + { + indexed: true, + internalType: "uint256", + name: "pid", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "EmergencyWithdraw", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "caller", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "previousAmount", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "newAmount", + type: "uint256" + } + ], + name: "EmissionRateUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "OwnershipTransferred", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "user", + type: "address" + }, + { + indexed: true, + internalType: "uint256", + name: "pid", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "Withdraw", + type: "event" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_allocPoint", + type: "uint256" + }, + { + internalType: "contract IERC20", + name: "_lpToken", + type: "address" + }, + { + internalType: "bool", + name: "_withUpdate", + type: "bool" + } + ], + name: "add", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "currentTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_pid", + type: "uint256" + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256" + } + ], + name: "deposit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_pid", + type: "uint256" + } + ], + name: "emergencyWithdraw", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_from", + type: "uint256" + }, + { + internalType: "uint256", + name: "_to", + type: "uint256" + } + ], + name: "getMultiplier", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [], + name: "massUpdatePools", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_pid", + type: "uint256" + }, + { + internalType: "address", + name: "_user", + type: "address" + } + ], + name: "pendingZF", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "poolInfo", + outputs: [ + { + internalType: "contract IERC20", + name: "lpToken", + type: "address" + }, + { + internalType: "uint256", + name: "allocPoint", + type: "uint256" + }, + { + internalType: "uint256", + name: "lastRewardTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "accZFPerShare", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "poolLength", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_pid", + type: "uint256" + }, + { + internalType: "uint256", + name: "_allocPoint", + type: "uint256" + }, + { + internalType: "bool", + name: "_withUpdate", + type: "bool" + } + ], + name: "set", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "startTime", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalAllocPoint", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_zfPerSecond", + type: "uint256" + } + ], + name: "updateEmissionRate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_pid", + type: "uint256" + } + ], + name: "updatePool", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_startTime", + type: "uint256" + } + ], + name: "updateStartTime", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + }, + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "userInfo", + outputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "rewardDebt", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_pid", + type: "uint256" + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256" + } + ], + name: "withdraw", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "zf", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "zfPerSecond", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + } + ], + zfTokenABI: [ + { + inputs: [ + { + internalType: "address", + name: "_token0", + type: "address" + }, + { + internalType: "address", + name: "_token1", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Burn", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256" + } + ], + name: "Mint", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "amount0In", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount1In", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount0Out", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount1Out", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Swap", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint112", + name: "reserve0", + type: "uint112" + }, + { + indexed: false, + internalType: "uint112", + name: "reserve1", + type: "uint112" + } + ], + name: "Sync", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [], + name: "DOMAIN_SEPARATOR", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "PERMIT_TYPEHASH", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "burn", + outputs: [ + { + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + internalType: "uint256", + name: "amount1", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "subtractedValue", + type: "uint256" + } + ], + name: "decreaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "factory", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "getPrincipal", + outputs: [ + { + internalType: "uint112", + name: "principal0", + type: "uint112" + }, + { + internalType: "uint112", + name: "principal1", + type: "uint112" + }, + { + internalType: "uint32", + name: "timeLastUpdate", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getReserves", + outputs: [ + { + internalType: "uint112", + name: "_reserve0", + type: "uint112" + }, + { + internalType: "uint112", + name: "_reserve1", + type: "uint112" + }, + { + internalType: "uint32", + name: "_blockTimestampLast", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getReservesAndParameters", + outputs: [ + { + internalType: "uint112", + name: "_reserve0", + type: "uint112" + }, + { + internalType: "uint112", + name: "_reserve1", + type: "uint112" + }, + { + internalType: "uint16", + name: "_swapFee", + type: "uint16" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getReservesSimple", + outputs: [ + { + internalType: "uint112", + name: "", + type: "uint112" + }, + { + internalType: "uint112", + name: "", + type: "uint112" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getSwapFee", + outputs: [ + { + internalType: "uint16", + name: "", + type: "uint16" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "addedValue", + type: "uint256" + } + ], + name: "increaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "kLast", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "mint", + outputs: [ + { + internalType: "uint256", + name: "liquidity", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "nonces", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "permit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "price0CumulativeLast", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "price1CumulativeLast", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint16", + name: "_swapFeeOverride", + type: "uint16" + } + ], + name: "setSwapFeeOverride", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "skim", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount0Out", + type: "uint256" + }, + { + internalType: "uint256", + name: "amount1Out", + type: "uint256" + }, + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "swap", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "swapFeeOverride", + outputs: [ + { + internalType: "uint16", + name: "", + type: "uint16" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount0Out", + type: "uint256" + }, + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "swapFor0", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount1Out", + type: "uint256" + }, + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "swapFor1", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "sync", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "token0", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "token1", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } + ], + erc20ABI: [ + { + constant: true, + inputs: [{ name: '_owner', type: 'address' }], + name: 'balanceOf', + outputs: [{ name: 'balance', type: 'uint256' }], + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'decimals', + outputs: [{ name: '', type: 'uint8' }], + type: 'function', + }, + ], + } + \ No newline at end of file diff --git a/src/adaptors/zkswap-finance/index.js b/src/adaptors/zkswap-finance/index.js new file mode 100644 index 0000000000..d3407cc1fa --- /dev/null +++ b/src/adaptors/zkswap-finance/index.js @@ -0,0 +1,229 @@ +const Web3 = require('web3'); +const { default: BigNumber } = require('bignumber.js'); +const sdk = require('@defillama/sdk4'); +const { request, gql, batchRequests } = require('graphql-request'); +const superagent = require('superagent'); +const { chunk } = require('lodash'); + +const { zfFarmABI, zfTokenABI, erc20ABI } = require('./abis'); +const utils = require('../utils'); +const { TokenProvider } = require('@uniswap/smart-order-router'); + +const ZFFarm = '0x9f9d043fb77a194b4216784eb5985c471b979d67'; +const ZFToken = '0x31c2c031fdc9d33e974f327ab0d9883eae06ca4a'; + +const RPC_URL = 'https://mainnet.era.zksync.io'; +const API_URL = 'https://api.studio.thegraph.com/query/49271/zkswap/0.0.9'; + +const SECOND_PER_YEAR = 60 * 60 * 24 * 365; +const WEEKS_PER_YEAR = 52; +const FEE_RATE = 0.0004; +const CHAIN = 'era'; + + +const web3 = new Web3(RPC_URL); + +const apy = async () => { + const nonLpPools = [0]; + const zfFarm = new web3.eth.Contract(zfFarmABI, ZFFarm); + + const poolsCount = await zfFarm.methods.poolLength().call(); + const totalAllocPoint = await zfFarm.methods.totalAllocPoint().call(); + const zfPerSecond = (await zfFarm.methods.zfPerSecond().call()) / 1e18; + + const poolsRes = await sdk.api.abi.multiCall({ + abi: zfFarmABI.filter(({ name }) => name === 'poolInfo')[0], + calls: [...Array(Number(poolsCount)).keys()].map((i) => ({ + target: ZFFarm, + params: i, + })), + chain: CHAIN, + requery: true, + }); + const pools = poolsRes.output + .map(({ output }, i) => ({ ...output, i })) + .filter(({ i }) => !nonLpPools.includes(i)); + + const lpTokens = pools.map(({ lpToken }) => lpToken); + + const nonLpPoolList = poolsRes.output + .map(({ output }, i) => ({ ...output, i })) + .filter(({ i }) => nonLpPools.includes(i)); + + const nonLpToken = nonLpPoolList.map(({ lpToken }) => lpToken); + + const [reservesData, supplyData, zfFarmBalData] = await Promise.all( + ['getReserves', 'totalSupply', 'balanceOf'].map((method) => + makeMulticall( + zfTokenABI.filter(({ name }) => name === method)[0], + lpTokens, + CHAIN, + method === 'balanceOf' ? [ZFFarm] : null + ) + ) + ); + const [tokens0, tokens1] = await Promise.all( + ['token0', 'token1'].map((method) => + makeMulticall( + zfTokenABI.filter(({ name }) => name === method)[0], + lpTokens, + CHAIN + ) + ) + ); + + const { pricesByAddress: tokensPrices } = await utils.getPrices( + [...new Set([...tokens0, ...tokens1])], + CHAIN + ); + + + const pairsInfo = await utils.uniswap.getPairsInfo(lpTokens, API_URL); + const lpChunks = chunk(lpTokens, 10); + + + const pairVolumes = await Promise.all( + lpChunks.map((lpsChunk) => + request( + API_URL, + gql` + query volumesQuery { + ${lpsChunk + .slice(0, 10) + .map( + (token, i) => `token_${token.toLowerCase()}:pairDayDatas( + orderBy: date + orderDirection: desc + first: 7 + where: { pairAddress: "${token.toLowerCase()}" } + ) { + dailyVolumeUSD + }`).join('\n')} + } + ` + ) + ) + ); + + + const volumesMap = pairVolumes.flat().reduce( + (acc, curChunk) => ({ + ...acc, + ...Object.entries(curChunk).reduce((innerAcc, [key, val]) => ({ + ...innerAcc, + [key.split('_')[1]]: val, + })), + }), + {} + ); + + const [tvl] = await + makeMulticall( + zfTokenABI.filter(({ name }) => name === 'balanceOf')[0], + nonLpToken, + CHAIN, + [ZFFarm] + ); + const nonLpTvl = tvl / 1e18 + const nonLpRes = nonLpPoolList.map((pool, i) => { + const poolInfo = pool; + const poolWeight = poolInfo.allocPoint/totalAllocPoint + const totalRewardPricePerYear = tokensPrices[ZFToken] * poolWeight * zfPerSecond * SECOND_PER_YEAR + const totalStakingTokenInPool = tokensPrices[ZFToken] * nonLpTvl + const apyReward = (totalRewardPricePerYear / totalStakingTokenInPool) * 100 + return { + pool: poolInfo.lpToken, + chain: CHAIN, + project: 'zkswap-finance', + symbol: 'ZF', + tvlUsd: totalStakingTokenInPool, + apyBase: 0, + apyReward, + underlyingTokens: [poolInfo.lpToken.toLowerCase()], + rewardTokens: [ZFToken], + url: 'https://zkswap.finance/earn', + }; + }) + + const res = pools.map((pool, i) => { + const poolInfo = pool; + const reserves = reservesData[i]; + const pairInfo = pairsInfo[pool.lpToken.toLowerCase()]; + + if (!pairInfo) return {}; + + const supply = supplyData[i]; + const zfFarmBalance = zfFarmBalData[i]; + + const zfFarmReservesUsd = utils.uniswap + .calculateReservesUSD( + reserves, + zfFarmBalance / supply, + pairInfo?.token0, + pairInfo?.token1, + tokensPrices + ) + .toString(); + + const lpReservesUsd = utils.uniswap + .calculateReservesUSD( + reserves, + 1, + pairInfo?.token0, + pairInfo?.token1, + tokensPrices + ) + .toString(); + + const lpFees7D = + (volumesMap[pool.lpToken.toLowerCase()] || []).reduce( + (acc, { dailyVolumeUSD }) => acc + Number(dailyVolumeUSD), + 0 + ) * FEE_RATE; + const apyBase = ((lpFees7D * WEEKS_PER_YEAR) / lpReservesUsd) * 100; + + const apyReward = utils.uniswap.calculateApy( + poolInfo, + totalAllocPoint, + zfPerSecond, + tokensPrices[ZFToken], + zfFarmReservesUsd, + SECOND_PER_YEAR + ); + + return { + pool: pool.lpToken, + chain: CHAIN, + project: 'zkswap-finance', + symbol: pairInfo.name, + tvlUsd: Number(zfFarmReservesUsd), + apyBase, + apyReward, + underlyingTokens: tokens0[i] && tokens1[i] ? [tokens0[i], tokens1[i]] : [poolInfo.address.toLowerCase()], + rewardTokens: [ZFToken], + url: 'https://zkswap.finance/earn', + }; + }); + return [...nonLpRes, ...res]; +}; + +const makeMulticall = async (abi, addresses, chain, params = null) => { + const data = await sdk.api.abi.multiCall({ + abi, + calls: addresses.map((address) => ({ + target: address, + params, + })), + chain, + }); + + const res = data.output.map(({ output }) => output); + + return res; +}; + + +module.exports = { + timetravel: false, + apy: apy, +}; diff --git a/src/handlers/triggerEnrichment.js b/src/handlers/triggerEnrichment.js index b62681359b..a7db220de5 100644 --- a/src/handlers/triggerEnrichment.js +++ b/src/handlers/triggerEnrichment.js @@ -488,6 +488,7 @@ const addPoolInfo = (el, stablecoins, config) => { 'gmd-protocol', 'y2k-v1', 'y2k-v2', + 'o3-swap', ].includes(el.project) ? 'yes' : ['mycelium-perpetual-swaps', 'gmx', 'rage-trade'].includes( diff --git a/src/utils/exclude.js b/src/utils/exclude.js index 51155ce486..92afe2e62a 100644 --- a/src/utils/exclude.js +++ b/src/utils/exclude.js @@ -33,6 +33,7 @@ const excludeAdaptors = [ // removing cause a) curve pool is redundant cause we already have that on curve adapter // and the rebonding strategy is targeting a max apy 'lusd-chickenbonds', + 'eternal-finance' ]; const excludePools = [ @@ -389,6 +390,7 @@ const excludePools = [ '0x4c36a9a52ca3baf1069e3531d57d96c171a66a230002000000000000000001e9', '0x3035917be42af437cbdd774be26b9ec90a2bd677000200000000000000000543', '0xc963ef7d977ECb0Ab71d835C4cb1Bf737f28d010', // rdnt-weth sushi pool in radiant v1 adapter, redundant + '0x7007535de9f864f0c15fe6fa288ce3feb842f72c' ]; const boundaries = {