From 9f14959406f2b757a0de5f67b0585ee468f94545 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Wed, 4 Oct 2023 14:34:12 -0700 Subject: [PATCH 1/6] add initializable-abstract-strategy abi rename other abis to match their contract name (kebab cased) --- abi/README.md | 14 +- abi/initializable-abstract-strategy.json | 532 ++++++++++++++++++ abi/{liquid-staked-eth-2.0.json => lido.json} | 0 ...urve-lp-token.json => vyper-contract.json} | 0 .../initializable-abstract-strategy.abi.ts | 513 +++++++++++++++++ src/abi/initializable-abstract-strategy.ts | 153 +++++ ...quid-staked-eth-2.0.abi.ts => lido.abi.ts} | 0 src/abi/{liquid-staked-eth-2.0.ts => lido.ts} | 2 +- ...-lp-token.abi.ts => vyper-contract.abi.ts} | 0 .../{curve-lp-token.ts => vyper-contract.ts} | 2 +- src/processors/curve-lp/curve-lp.ts | 26 +- src/processors/vault/vault.ts | 8 +- src/utils/addresses.ts | 3 + tsconfig.json | 3 +- 14 files changed, 1235 insertions(+), 21 deletions(-) create mode 100644 abi/initializable-abstract-strategy.json rename abi/{liquid-staked-eth-2.0.json => lido.json} (100%) rename abi/{curve-lp-token.json => vyper-contract.json} (100%) create mode 100644 src/abi/initializable-abstract-strategy.abi.ts create mode 100644 src/abi/initializable-abstract-strategy.ts rename src/abi/{liquid-staked-eth-2.0.abi.ts => lido.abi.ts} (100%) rename src/abi/{liquid-staked-eth-2.0.ts => lido.ts} (99%) rename src/abi/{curve-lp-token.abi.ts => vyper-contract.abi.ts} (100%) rename src/abi/{curve-lp-token.ts => vyper-contract.ts} (99%) diff --git a/abi/README.md b/abi/README.md index 55d19492..ba28569a 100644 --- a/abi/README.md +++ b/abi/README.md @@ -1,9 +1,21 @@ # ABI folder -This is a dedicated folder for ABI files. Place you contract ABI here and generate facade classes for type-safe decoding of the event, function data and contract state queries with +This is a dedicated folder for ABI files. Place you contract ABI here and generate facade classes for type-safe decoding +of the event, function data and contract state queries with ```sh sqd typegen ``` This `typegen` command is defined in `commands.json`. + +## Note: + +Use lowercase filenames to avoid problems with generated code. + +``` +Vyper_contract > vyper-contract +OETHVault > oeth-vault +OETH > oeth +BaseRewardPool > base-reward-pool +``` \ No newline at end of file diff --git a/abi/initializable-abstract-strategy.json b/abi/initializable-abstract-strategy.json new file mode 100644 index 00000000..ce372861 --- /dev/null +++ b/abi/initializable-abstract-strategy.json @@ -0,0 +1,532 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_pToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousGovernor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernor", + "type": "address" + } + ], + "name": "GovernorshipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_oldHarvesterAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_newHarvesterAddress", + "type": "address" + } + ], + "name": "HarvesterAddressesUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_pToken", + "type": "address" + } + ], + "name": "PTokenAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_pToken", + "type": "address" + } + ], + "name": "PTokenRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousGovernor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernor", + "type": "address" + } + ], + "name": "PendingGovernorshipTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address[]", + "name": "_oldAddresses", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "_newAddresses", + "type": "address[]" + } + ], + "name": "RewardTokenAddressesUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RewardTokenCollected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_pToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "Withdrawal", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "assetToPToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + } + ], + "name": "checkBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claimGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collectRewardTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "depositAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getRewardTokenAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "harvesterAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_rewardTokenAddresses", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "_assets", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "_pTokens", + "type": "address[]" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isGovernor", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "platformAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_assetIndex", + "type": "uint256" + } + ], + "name": "removePToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "rewardTokenAddresses", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "safeApproveAllTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_harvesterAddress", + "type": "address" + } + ], + "name": "setHarvesterAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "address", + "name": "_pToken", + "type": "address" + } + ], + "name": "setPTokenAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_rewardTokenAddresses", + "type": "address[]" + } + ], + "name": "setRewardTokenAddresses", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + } + ], + "name": "supportsAsset", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newGovernor", + "type": "address" + } + ], + "name": "transferGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "transferToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vaultAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/liquid-staked-eth-2.0.json b/abi/lido.json similarity index 100% rename from abi/liquid-staked-eth-2.0.json rename to abi/lido.json diff --git a/abi/curve-lp-token.json b/abi/vyper-contract.json similarity index 100% rename from abi/curve-lp-token.json rename to abi/vyper-contract.json diff --git a/src/abi/initializable-abstract-strategy.abi.ts b/src/abi/initializable-abstract-strategy.abi.ts new file mode 100644 index 00000000..48e5aa06 --- /dev/null +++ b/src/abi/initializable-abstract-strategy.abi.ts @@ -0,0 +1,513 @@ +export const ABI_JSON = [ + { + "type": "event", + "anonymous": false, + "name": "Deposit", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": true + }, + { + "type": "address", + "name": "_pToken", + "indexed": false + }, + { + "type": "uint256", + "name": "_amount", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "GovernorshipTransferred", + "inputs": [ + { + "type": "address", + "name": "previousGovernor", + "indexed": true + }, + { + "type": "address", + "name": "newGovernor", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "HarvesterAddressesUpdated", + "inputs": [ + { + "type": "address", + "name": "_oldHarvesterAddress", + "indexed": false + }, + { + "type": "address", + "name": "_newHarvesterAddress", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PTokenAdded", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": true + }, + { + "type": "address", + "name": "_pToken", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PTokenRemoved", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": true + }, + { + "type": "address", + "name": "_pToken", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PendingGovernorshipTransfer", + "inputs": [ + { + "type": "address", + "name": "previousGovernor", + "indexed": true + }, + { + "type": "address", + "name": "newGovernor", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "RewardTokenAddressesUpdated", + "inputs": [ + { + "type": "address[]", + "name": "_oldAddresses" + }, + { + "type": "address[]", + "name": "_newAddresses" + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "RewardTokenCollected", + "inputs": [ + { + "type": "address", + "name": "recipient", + "indexed": false + }, + { + "type": "address", + "name": "rewardToken", + "indexed": false + }, + { + "type": "uint256", + "name": "amount", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Withdrawal", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": true + }, + { + "type": "address", + "name": "_pToken", + "indexed": false + }, + { + "type": "uint256", + "name": "_amount", + "indexed": false + } + ] + }, + { + "type": "function", + "name": "assetToPToken", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + } + ], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "checkBalance", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "balance" + } + ] + }, + { + "type": "function", + "name": "claimGovernance", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "collectRewardTokens", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "deposit", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + }, + { + "type": "uint256", + "name": "_amount" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "depositAll", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "getRewardTokenAddresses", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address[]", + "name": "" + } + ] + }, + { + "type": "function", + "name": "governor", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "harvesterAddress", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "initialize", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address[]", + "name": "_rewardTokenAddresses" + }, + { + "type": "address[]", + "name": "_assets" + }, + { + "type": "address[]", + "name": "_pTokens" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "isGovernor", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "platformAddress", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "removePToken", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_assetIndex" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "rewardTokenAddresses", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "" + } + ], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "safeApproveAllTokens", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "setHarvesterAddress", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_harvesterAddress" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setPTokenAddress", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + }, + { + "type": "address", + "name": "_pToken" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setRewardTokenAddresses", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address[]", + "name": "_rewardTokenAddresses" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "supportsAsset", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "transferGovernance", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_newGovernor" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "transferToken", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + }, + { + "type": "uint256", + "name": "_amount" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "vaultAddress", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "withdraw", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_recipient" + }, + { + "type": "address", + "name": "_asset" + }, + { + "type": "uint256", + "name": "_amount" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "withdrawAll", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + } +] diff --git a/src/abi/initializable-abstract-strategy.ts b/src/abi/initializable-abstract-strategy.ts new file mode 100644 index 00000000..12cfdcf0 --- /dev/null +++ b/src/abi/initializable-abstract-strategy.ts @@ -0,0 +1,153 @@ +import * as ethers from 'ethers' +import {LogEvent, Func, ContractBase} from './abi.support' +import {ABI_JSON} from './initializable-abstract-strategy.abi' + +export const abi = new ethers.Interface(ABI_JSON); + +export const events = { + Deposit: new LogEvent<([_asset: string, _pToken: string, _amount: bigint] & {_asset: string, _pToken: string, _amount: bigint})>( + abi, '0x5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62' + ), + GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( + abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' + ), + HarvesterAddressesUpdated: new LogEvent<([_oldHarvesterAddress: string, _newHarvesterAddress: string] & {_oldHarvesterAddress: string, _newHarvesterAddress: string})>( + abi, '0xe48386b84419f4d36e0f96c10cc3510b6fb1a33795620c5098b22472bbe90796' + ), + PTokenAdded: new LogEvent<([_asset: string, _pToken: string] & {_asset: string, _pToken: string})>( + abi, '0xef6485b84315f9b1483beffa32aae9a0596890395e3d7521f1c5fbb51790e765' + ), + PTokenRemoved: new LogEvent<([_asset: string, _pToken: string] & {_asset: string, _pToken: string})>( + abi, '0x16b7600acff27e39a8a96056b3d533045298de927507f5c1d97e4accde60488c' + ), + PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( + abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' + ), + RewardTokenAddressesUpdated: new LogEvent<([_oldAddresses: Array, _newAddresses: Array] & {_oldAddresses: Array, _newAddresses: Array})>( + abi, '0x04c0b9649497d316554306e53678d5f5f5dbc3a06f97dec13ff4cfe98b986bbc' + ), + RewardTokenCollected: new LogEvent<([recipient: string, rewardToken: string, amount: bigint] & {recipient: string, rewardToken: string, amount: bigint})>( + abi, '0xf6c07a063ed4e63808eb8da7112d46dbcd38de2b40a73dbcc9353c5a94c72353' + ), + Withdrawal: new LogEvent<([_asset: string, _pToken: string, _amount: bigint] & {_asset: string, _pToken: string, _amount: bigint})>( + abi, '0x2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b6398' + ), +} + +export const functions = { + assetToPToken: new Func<[_: string], {}, string>( + abi, '0x0fc3b4c4' + ), + checkBalance: new Func<[_asset: string], {_asset: string}, bigint>( + abi, '0x5f515226' + ), + claimGovernance: new Func<[], {}, []>( + abi, '0x5d36b190' + ), + collectRewardTokens: new Func<[], {}, []>( + abi, '0x5a063f63' + ), + deposit: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( + abi, '0x47e7ef24' + ), + depositAll: new Func<[], {}, []>( + abi, '0xde5f6268' + ), + getRewardTokenAddresses: new Func<[], {}, Array>( + abi, '0xf6ca71b0' + ), + governor: new Func<[], {}, string>( + abi, '0x0c340a24' + ), + harvesterAddress: new Func<[], {}, string>( + abi, '0x67c7066c' + ), + initialize: new Func<[_rewardTokenAddresses: Array, _assets: Array, _pTokens: Array], {_rewardTokenAddresses: Array, _assets: Array, _pTokens: Array}, []>( + abi, '0x435356d1' + ), + isGovernor: new Func<[], {}, boolean>( + abi, '0xc7af3352' + ), + platformAddress: new Func<[], {}, string>( + abi, '0xdbe55e56' + ), + removePToken: new Func<[_assetIndex: bigint], {_assetIndex: bigint}, []>( + abi, '0x9136616a' + ), + rewardTokenAddresses: new Func<[_: bigint], {}, string>( + abi, '0x7b2d9b2c' + ), + safeApproveAllTokens: new Func<[], {}, []>( + abi, '0xad1728cb' + ), + setHarvesterAddress: new Func<[_harvesterAddress: string], {_harvesterAddress: string}, []>( + abi, '0xc2e1e3f4' + ), + setPTokenAddress: new Func<[_asset: string, _pToken: string], {_asset: string, _pToken: string}, []>( + abi, '0x0ed57b3a' + ), + setRewardTokenAddresses: new Func<[_rewardTokenAddresses: Array], {_rewardTokenAddresses: Array}, []>( + abi, '0x96d538bb' + ), + supportsAsset: new Func<[_asset: string], {_asset: string}, boolean>( + abi, '0xaa388af6' + ), + transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( + abi, '0xd38bfff4' + ), + transferToken: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( + abi, '0x1072cbea' + ), + vaultAddress: new Func<[], {}, string>( + abi, '0x430bf08a' + ), + withdraw: new Func<[_recipient: string, _asset: string, _amount: bigint], {_recipient: string, _asset: string, _amount: bigint}, []>( + abi, '0xd9caed12' + ), + withdrawAll: new Func<[], {}, []>( + abi, '0x853828b6' + ), +} + +export class Contract extends ContractBase { + + assetToPToken(arg0: string): Promise { + return this.eth_call(functions.assetToPToken, [arg0]) + } + + checkBalance(_asset: string): Promise { + return this.eth_call(functions.checkBalance, [_asset]) + } + + getRewardTokenAddresses(): Promise> { + return this.eth_call(functions.getRewardTokenAddresses, []) + } + + governor(): Promise { + return this.eth_call(functions.governor, []) + } + + harvesterAddress(): Promise { + return this.eth_call(functions.harvesterAddress, []) + } + + isGovernor(): Promise { + return this.eth_call(functions.isGovernor, []) + } + + platformAddress(): Promise { + return this.eth_call(functions.platformAddress, []) + } + + rewardTokenAddresses(arg0: bigint): Promise { + return this.eth_call(functions.rewardTokenAddresses, [arg0]) + } + + supportsAsset(_asset: string): Promise { + return this.eth_call(functions.supportsAsset, [_asset]) + } + + vaultAddress(): Promise { + return this.eth_call(functions.vaultAddress, []) + } +} diff --git a/src/abi/liquid-staked-eth-2.0.abi.ts b/src/abi/lido.abi.ts similarity index 100% rename from src/abi/liquid-staked-eth-2.0.abi.ts rename to src/abi/lido.abi.ts diff --git a/src/abi/liquid-staked-eth-2.0.ts b/src/abi/lido.ts similarity index 99% rename from src/abi/liquid-staked-eth-2.0.ts rename to src/abi/lido.ts index 5fc72ec8..c02a9d3e 100644 --- a/src/abi/liquid-staked-eth-2.0.ts +++ b/src/abi/lido.ts @@ -1,6 +1,6 @@ import * as ethers from 'ethers' import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './liquid-staked-eth-2.0.abi' +import {ABI_JSON} from './lido.abi' export const abi = new ethers.Interface(ABI_JSON); diff --git a/src/abi/curve-lp-token.abi.ts b/src/abi/vyper-contract.abi.ts similarity index 100% rename from src/abi/curve-lp-token.abi.ts rename to src/abi/vyper-contract.abi.ts diff --git a/src/abi/curve-lp-token.ts b/src/abi/vyper-contract.ts similarity index 99% rename from src/abi/curve-lp-token.ts rename to src/abi/vyper-contract.ts index 4d67eacb..85a82b7c 100644 --- a/src/abi/curve-lp-token.ts +++ b/src/abi/vyper-contract.ts @@ -1,6 +1,6 @@ import * as ethers from 'ethers' import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './curve-lp-token.abi' +import {ABI_JSON} from './vyper-contract.abi' export const abi = new ethers.Interface(ABI_JSON); diff --git a/src/processors/curve-lp/curve-lp.ts b/src/processors/curve-lp/curve-lp.ts index a4553f69..cc432ba0 100644 --- a/src/processors/curve-lp/curve-lp.ts +++ b/src/processors/curve-lp/curve-lp.ts @@ -2,8 +2,8 @@ import { EvmBatchProcessor } from '@subsquid/evm-processor' import { pad } from 'viem' import * as baseRewardPool from '../../abi/base-reward-pool' -import * as curveLpToken from '../../abi/curve-lp-token' import * as erc20 from '../../abi/erc20' +import * as vyperContract from '../../abi/vyper-contract' import { CurveLP } from '../../model' import { Context } from '../../processor' import { @@ -28,10 +28,10 @@ export const setup = (processor: EvmBatchProcessor) => { processor.addLog({ address: [OETH_CURVE_LP_ADDRESS], topic0: [ - curveLpToken.events.AddLiquidity.topic, - curveLpToken.events.RemoveLiquidity.topic, - curveLpToken.events.RemoveLiquidityImbalance.topic, - curveLpToken.events.RemoveLiquidityOne.topic, + vyperContract.events.AddLiquidity.topic, + vyperContract.events.RemoveLiquidity.topic, + vyperContract.events.RemoveLiquidityImbalance.topic, + vyperContract.events.RemoveLiquidityOne.topic, // curve_lp_token.events.TokenExchange.topic, // Not sure if including this helps get up-to-date eth balances. ], }) @@ -155,23 +155,23 @@ const processLiquidityEvents = async ( block: Context['blocks']['0'], log: Context['blocks']['0']['logs']['0'], ) => { - if (log.topics[0] === curveLpToken.events.AddLiquidity.topic) { - const { token_supply } = curveLpToken.events.AddLiquidity.decode(log) + if (log.topics[0] === vyperContract.events.AddLiquidity.topic) { + const { token_supply } = vyperContract.events.AddLiquidity.decode(log) const { curveLP } = await getLatestCurveLP(ctx, result, block) curveLP.totalSupply = token_supply } else if ( - log.topics[0] === curveLpToken.events.RemoveLiquidityImbalance.topic + log.topics[0] === vyperContract.events.RemoveLiquidityImbalance.topic ) { const { token_supply } = - curveLpToken.events.RemoveLiquidityImbalance.decode(log) + vyperContract.events.RemoveLiquidityImbalance.decode(log) const { curveLP } = await getLatestCurveLP(ctx, result, block) curveLP.totalSupply = token_supply - } else if (log.topics[0] === curveLpToken.events.RemoveLiquidityOne.topic) { - const { token_supply } = curveLpToken.events.RemoveLiquidityOne.decode(log) + } else if (log.topics[0] === vyperContract.events.RemoveLiquidityOne.topic) { + const { token_supply } = vyperContract.events.RemoveLiquidityOne.decode(log) const { curveLP } = await getLatestCurveLP(ctx, result, block) curveLP.totalSupply = token_supply - } else if (log.topics[0] === curveLpToken.events.RemoveLiquidity.topic) { - const { token_supply } = curveLpToken.events.RemoveLiquidity.decode(log) + } else if (log.topics[0] === vyperContract.events.RemoveLiquidity.topic) { + const { token_supply } = vyperContract.events.RemoveLiquidity.decode(log) const { curveLP } = await getLatestCurveLP(ctx, result, block) curveLP.totalSupply = token_supply } diff --git a/src/processors/vault/vault.ts b/src/processors/vault/vault.ts index d888f116..a22a4848 100644 --- a/src/processors/vault/vault.ts +++ b/src/processors/vault/vault.ts @@ -2,7 +2,7 @@ import { EvmBatchProcessor } from '@subsquid/evm-processor' import { pad } from 'viem' import * as erc20 from '../../abi/erc20' -import * as stEth from '../../abi/liquid-staked-eth-2.0' +import * as lido from '../../abi/lido' import { Vault } from '../../model' import { Context } from '../../processor' import { @@ -34,7 +34,7 @@ export const setup = (processor: EvmBatchProcessor) => { }) processor.addLog({ address: [STETH_ADDRESS], - topic0: [stEth.events.TokenRebased.topic], + topic0: [lido.events.TokenRebased.topic], }) } @@ -61,11 +61,11 @@ const processStEthRebase = async ( ) => { if ( log.address === STETH_ADDRESS && - log.topics[0] === stEth.events.TokenRebased.topic + log.topics[0] === lido.events.TokenRebased.topic ) { ctx.log.info('vault: updating stETH balance') const { vault } = await getLatestVault(ctx, result, block) - const contract = new stEth.Contract(ctx, block.header, STETH_ADDRESS) + const contract = new lido.Contract(ctx, block.header, STETH_ADDRESS) vault.stETH = await contract.balanceOf(OETH_VAULT_ADDRESS) } } diff --git a/src/utils/addresses.ts b/src/utils/addresses.ts index 95f5cf24..4b3cbeb9 100644 --- a/src/utils/addresses.ts +++ b/src/utils/addresses.ts @@ -34,3 +34,6 @@ export const OETH_MORPHO_AAVE_ADDRESS = '0xc1fc9e5ec3058921ea5025d703cbe31764756319' export const OETH_DRIPPER_ADDRESS = '0xc0f42f73b8f01849a2dd99753524d4ba14317eb3' + +export const OETH_STRATEGY_BALANCER_ADDRESS = + '0x49109629ac1deb03f2e9b2fe2ac4a623e0e7dfdc' diff --git a/tsconfig.json b/tsconfig.json index e59d8d66..784a5474 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,8 @@ "experimentalDecorators": true, "emitDecoratorMetadata": true, "skipLibCheck": true, - "resolveJsonModule": true + "resolveJsonModule": true, + "forceConsistentCasingInFileNames": true }, "include": [ "src" From 3af6ae30bd0e27a3c62b2571f4245669804812ff Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Wed, 4 Oct 2023 19:28:14 -0700 Subject: [PATCH 2/6] feat: track balancer meta pool strategy (aura) --- ....json => balancer-meta-pool-strategy.json} | 328 ++++++- ...84606457-Data.js => 1696471715316-Data.js} | 10 +- schema.graphql | 10 + src/abi/balancer-meta-pool-strategy.abi.ts | 824 ++++++++++++++++++ src/abi/balancer-meta-pool-strategy.ts | 248 ++++++ src/main.ts | 11 +- .../balancerMetaPoolStrategy.model.ts | 29 + src/model/generated/index.ts | 1 + .../strategies/balancer-meta-pool.ts | 94 ++ src/processors/utils.ts | 22 + src/utils/addresses.ts | 3 +- 11 files changed, 1571 insertions(+), 9 deletions(-) rename abi/{initializable-abstract-strategy.json => balancer-meta-pool-strategy.json} (60%) rename db/migrations/{1696284606457-Data.js => 1696471715316-Data.js} (91%) create mode 100644 src/abi/balancer-meta-pool-strategy.abi.ts create mode 100644 src/abi/balancer-meta-pool-strategy.ts create mode 100644 src/model/generated/balancerMetaPoolStrategy.model.ts create mode 100644 src/processors/strategies/balancer-meta-pool.ts diff --git a/abi/initializable-abstract-strategy.json b/abi/balancer-meta-pool-strategy.json similarity index 60% rename from abi/initializable-abstract-strategy.json rename to abi/balancer-meta-pool-strategy.json index ce372861..f36f56e8 100644 --- a/abi/initializable-abstract-strategy.json +++ b/abi/balancer-meta-pool-strategy.json @@ -1,4 +1,74 @@ [ + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "platformAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "vaultAddress", + "type": "address" + } + ], + "internalType": "struct InitializableAbstractStrategy.BaseStrategyConfig", + "name": "_stratConfig", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "rEthAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "stEthAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "wstEthAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "frxEthAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "sfrxEthAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "balancerVaultAddress", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "balancerPoolId", + "type": "bytes32" + } + ], + "internalType": "struct BaseBalancerStrategy.BaseBalancerConfig", + "name": "_balancerConfig", + "type": "tuple" + }, + { + "internalType": "address", + "name": "_auraRewardPoolAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, { "anonymous": false, "inputs": [ @@ -62,6 +132,44 @@ "name": "HarvesterAddressesUpdated", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_prevMaxDeviationPercentage", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_newMaxDeviationPercentage", + "type": "uint256" + } + ], + "name": "MaxDepositDeviationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_prevMaxDeviationPercentage", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_newMaxDeviationPercentage", + "type": "uint256" + } + ], + "name": "MaxWithdrawalDeviationUpdated", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -207,6 +315,45 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "auraRewardPoolAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "balancerPoolId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "balancerVault", + "outputs": [ + { + "internalType": "contract IBalancerVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -219,7 +366,20 @@ "outputs": [ { "internalType": "uint256", - "name": "balance", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "checkBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "value", "type": "uint256" } ], @@ -244,12 +404,12 @@ "inputs": [ { "internalType": "address", - "name": "_asset", + "name": "", "type": "address" }, { "internalType": "uint256", - "name": "_amount", + "name": "", "type": "uint256" } ], @@ -258,6 +418,24 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "depositAll", @@ -265,6 +443,19 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "frxETH", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "getRewardTokenAddresses", @@ -340,6 +531,32 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "maxDepositDeviation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxWithdrawalDeviation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "platformAddress", @@ -353,6 +570,19 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "rETH", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -405,6 +635,32 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_maxDepositDeviation", + "type": "uint256" + } + ], + "name": "setMaxDepositDeviation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_maxWithdrawalDeviation", + "type": "uint256" + } + ], + "name": "setMaxWithdrawalDeviation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -436,6 +692,32 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "sfrxETH", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stETH", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -508,12 +790,12 @@ }, { "internalType": "address", - "name": "_asset", + "name": "_strategyAsset", "type": "address" }, { "internalType": "uint256", - "name": "_amount", + "name": "_strategyAmount", "type": "uint256" } ], @@ -522,11 +804,47 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "address[]", + "name": "_strategyAssets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_strategyAmounts", + "type": "uint256[]" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "withdrawAll", "outputs": [], "stateMutability": "nonpayable", "type": "function" + }, + { + "inputs": [], + "name": "wstETH", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" } ] \ No newline at end of file diff --git a/db/migrations/1696284606457-Data.js b/db/migrations/1696471715316-Data.js similarity index 91% rename from db/migrations/1696284606457-Data.js rename to db/migrations/1696471715316-Data.js index b7f35b73..3b070038 100644 --- a/db/migrations/1696284606457-Data.js +++ b/db/migrations/1696471715316-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1696284606457 { - name = 'Data1696284606457' +module.exports = class Data1696471715316 { + name = 'Data1696471715316' async up(db) { await db.query(`CREATE TABLE "oeth" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, CONSTRAINT "PK_de1d885501070dbd1ab6f8577ba" PRIMARY KEY ("id"))`) @@ -39,6 +39,9 @@ module.exports = class Data1696284606457 { await db.query(`CREATE TABLE "dripper" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_74fd102c8d1c60f4b1650a61ffc" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_88c58f8948c3294c2a9e2791dc" ON "dripper" ("timestamp") `) await db.query(`CREATE INDEX "IDX_06822c0a260797711acc9023d5" ON "dripper" ("block_number") `) + await db.query(`CREATE TABLE "balancer_meta_pool_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total" numeric NOT NULL, "r_eth" numeric NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_45e940df650a615eee3b7d93551" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_7e32ebb0d5d950103ce8f14cf9" ON "balancer_meta_pool_strategy" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_0bc3af65ef5d204a326388b7ad" ON "balancer_meta_pool_strategy" ("block_number") `) await db.query(`ALTER TABLE "history" ADD CONSTRAINT "FK_59a55adcc59ddb69c297da693e5" FOREIGN KEY ("address_id") REFERENCES "address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "rebase" ADD CONSTRAINT "FK_02d02f9022ef86e60f1a84b9dc2" FOREIGN KEY ("apy_id") REFERENCES "apy"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "rebase_option" ADD CONSTRAINT "FK_66c04aee6855c74debae4add8fe" FOREIGN KEY ("address_id") REFERENCES "address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) @@ -82,6 +85,9 @@ module.exports = class Data1696284606457 { await db.query(`DROP TABLE "dripper"`) await db.query(`DROP INDEX "public"."IDX_88c58f8948c3294c2a9e2791dc"`) await db.query(`DROP INDEX "public"."IDX_06822c0a260797711acc9023d5"`) + await db.query(`DROP TABLE "balancer_meta_pool_strategy"`) + await db.query(`DROP INDEX "public"."IDX_7e32ebb0d5d950103ce8f14cf9"`) + await db.query(`DROP INDEX "public"."IDX_0bc3af65ef5d204a326388b7ad"`) await db.query(`ALTER TABLE "history" DROP CONSTRAINT "FK_59a55adcc59ddb69c297da693e5"`) await db.query(`ALTER TABLE "rebase" DROP CONSTRAINT "FK_02d02f9022ef86e60f1a84b9dc2"`) await db.query(`ALTER TABLE "rebase_option" DROP CONSTRAINT "FK_66c04aee6855c74debae4add8fe"`) diff --git a/schema.graphql b/schema.graphql index 443e60d8..0b4e4079 100644 --- a/schema.graphql +++ b/schema.graphql @@ -125,3 +125,13 @@ type Dripper @entity { blockNumber: Int! @index weth: BigInt! } + +# OETHBalancerMetaPoolStrategy: 0x49109629ac1deb03f2e9b2fe2ac4a623e0e7dfdc +type BalancerMetaPoolStrategy @entity { + id: ID! + timestamp: DateTime! @index + blockNumber: Int! @index + total: BigInt! + rETH: BigInt! + weth: BigInt! +} \ No newline at end of file diff --git a/src/abi/balancer-meta-pool-strategy.abi.ts b/src/abi/balancer-meta-pool-strategy.abi.ts new file mode 100644 index 00000000..0ba31284 --- /dev/null +++ b/src/abi/balancer-meta-pool-strategy.abi.ts @@ -0,0 +1,824 @@ +export const ABI_JSON = [ + { + "type": "constructor", + "stateMutability": "undefined", + "payable": false, + "inputs": [ + { + "type": "tuple", + "name": "_stratConfig", + "components": [ + { + "type": "address", + "name": "platformAddress" + }, + { + "type": "address", + "name": "vaultAddress" + } + ] + }, + { + "type": "tuple", + "name": "_balancerConfig", + "components": [ + { + "type": "address", + "name": "rEthAddress" + }, + { + "type": "address", + "name": "stEthAddress" + }, + { + "type": "address", + "name": "wstEthAddress" + }, + { + "type": "address", + "name": "frxEthAddress" + }, + { + "type": "address", + "name": "sfrxEthAddress" + }, + { + "type": "address", + "name": "balancerVaultAddress" + }, + { + "type": "bytes32", + "name": "balancerPoolId" + } + ] + }, + { + "type": "address", + "name": "_auraRewardPoolAddress" + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Deposit", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": true + }, + { + "type": "address", + "name": "_pToken", + "indexed": false + }, + { + "type": "uint256", + "name": "_amount", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "GovernorshipTransferred", + "inputs": [ + { + "type": "address", + "name": "previousGovernor", + "indexed": true + }, + { + "type": "address", + "name": "newGovernor", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "HarvesterAddressesUpdated", + "inputs": [ + { + "type": "address", + "name": "_oldHarvesterAddress", + "indexed": false + }, + { + "type": "address", + "name": "_newHarvesterAddress", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "MaxDepositDeviationUpdated", + "inputs": [ + { + "type": "uint256", + "name": "_prevMaxDeviationPercentage", + "indexed": false + }, + { + "type": "uint256", + "name": "_newMaxDeviationPercentage", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "MaxWithdrawalDeviationUpdated", + "inputs": [ + { + "type": "uint256", + "name": "_prevMaxDeviationPercentage", + "indexed": false + }, + { + "type": "uint256", + "name": "_newMaxDeviationPercentage", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PTokenAdded", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": true + }, + { + "type": "address", + "name": "_pToken", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PTokenRemoved", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": true + }, + { + "type": "address", + "name": "_pToken", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PendingGovernorshipTransfer", + "inputs": [ + { + "type": "address", + "name": "previousGovernor", + "indexed": true + }, + { + "type": "address", + "name": "newGovernor", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "RewardTokenAddressesUpdated", + "inputs": [ + { + "type": "address[]", + "name": "_oldAddresses" + }, + { + "type": "address[]", + "name": "_newAddresses" + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "RewardTokenCollected", + "inputs": [ + { + "type": "address", + "name": "recipient", + "indexed": false + }, + { + "type": "address", + "name": "rewardToken", + "indexed": false + }, + { + "type": "uint256", + "name": "amount", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Withdrawal", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": true + }, + { + "type": "address", + "name": "_pToken", + "indexed": false + }, + { + "type": "uint256", + "name": "_amount", + "indexed": false + } + ] + }, + { + "type": "function", + "name": "assetToPToken", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + } + ], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "auraRewardPoolAddress", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "balancerPoolId", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bytes32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "balancerVault", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "checkBalance", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "amount" + } + ] + }, + { + "type": "function", + "name": "checkBalance", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "value" + } + ] + }, + { + "type": "function", + "name": "claimGovernance", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "collectRewardTokens", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "deposit", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + }, + { + "type": "uint256", + "name": "" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "deposit", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address[]", + "name": "" + }, + { + "type": "uint256[]", + "name": "" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "depositAll", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "frxETH", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getRewardTokenAddresses", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address[]", + "name": "" + } + ] + }, + { + "type": "function", + "name": "governor", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "harvesterAddress", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "initialize", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address[]", + "name": "_rewardTokenAddresses" + }, + { + "type": "address[]", + "name": "_assets" + }, + { + "type": "address[]", + "name": "_pTokens" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "isGovernor", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "maxDepositDeviation", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "maxWithdrawalDeviation", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "platformAddress", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "rETH", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "removePToken", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_assetIndex" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "rewardTokenAddresses", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "" + } + ], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "safeApproveAllTokens", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "setHarvesterAddress", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_harvesterAddress" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setMaxDepositDeviation", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_maxDepositDeviation" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setMaxWithdrawalDeviation", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_maxWithdrawalDeviation" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setPTokenAddress", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + }, + { + "type": "address", + "name": "_pToken" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setRewardTokenAddresses", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address[]", + "name": "_rewardTokenAddresses" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "sfrxETH", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "stETH", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "supportsAsset", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "transferGovernance", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_newGovernor" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "transferToken", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + }, + { + "type": "uint256", + "name": "_amount" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "vaultAddress", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "withdraw", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_recipient" + }, + { + "type": "address", + "name": "_strategyAsset" + }, + { + "type": "uint256", + "name": "_strategyAmount" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "withdraw", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_recipient" + }, + { + "type": "address[]", + "name": "_strategyAssets" + }, + { + "type": "uint256[]", + "name": "_strategyAmounts" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "withdrawAll", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "wstETH", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + } +] diff --git a/src/abi/balancer-meta-pool-strategy.ts b/src/abi/balancer-meta-pool-strategy.ts new file mode 100644 index 00000000..05449970 --- /dev/null +++ b/src/abi/balancer-meta-pool-strategy.ts @@ -0,0 +1,248 @@ +import * as ethers from 'ethers' +import {LogEvent, Func, ContractBase} from './abi.support' +import {ABI_JSON} from './balancer-meta-pool-strategy.abi' + +export const abi = new ethers.Interface(ABI_JSON); + +export const events = { + Deposit: new LogEvent<([_asset: string, _pToken: string, _amount: bigint] & {_asset: string, _pToken: string, _amount: bigint})>( + abi, '0x5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62' + ), + GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( + abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' + ), + HarvesterAddressesUpdated: new LogEvent<([_oldHarvesterAddress: string, _newHarvesterAddress: string] & {_oldHarvesterAddress: string, _newHarvesterAddress: string})>( + abi, '0xe48386b84419f4d36e0f96c10cc3510b6fb1a33795620c5098b22472bbe90796' + ), + MaxDepositDeviationUpdated: new LogEvent<([_prevMaxDeviationPercentage: bigint, _newMaxDeviationPercentage: bigint] & {_prevMaxDeviationPercentage: bigint, _newMaxDeviationPercentage: bigint})>( + abi, '0x42ef8699937e03e56ce59a64b430e1a18719693244c594c7884f9cb7c1c98e5c' + ), + MaxWithdrawalDeviationUpdated: new LogEvent<([_prevMaxDeviationPercentage: bigint, _newMaxDeviationPercentage: bigint] & {_prevMaxDeviationPercentage: bigint, _newMaxDeviationPercentage: bigint})>( + abi, '0xdea5bd7251b6797372e2785ac437c2b046149b71216727e0d33ab3140b11d6f7' + ), + PTokenAdded: new LogEvent<([_asset: string, _pToken: string] & {_asset: string, _pToken: string})>( + abi, '0xef6485b84315f9b1483beffa32aae9a0596890395e3d7521f1c5fbb51790e765' + ), + PTokenRemoved: new LogEvent<([_asset: string, _pToken: string] & {_asset: string, _pToken: string})>( + abi, '0x16b7600acff27e39a8a96056b3d533045298de927507f5c1d97e4accde60488c' + ), + PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( + abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' + ), + RewardTokenAddressesUpdated: new LogEvent<([_oldAddresses: Array, _newAddresses: Array] & {_oldAddresses: Array, _newAddresses: Array})>( + abi, '0x04c0b9649497d316554306e53678d5f5f5dbc3a06f97dec13ff4cfe98b986bbc' + ), + RewardTokenCollected: new LogEvent<([recipient: string, rewardToken: string, amount: bigint] & {recipient: string, rewardToken: string, amount: bigint})>( + abi, '0xf6c07a063ed4e63808eb8da7112d46dbcd38de2b40a73dbcc9353c5a94c72353' + ), + Withdrawal: new LogEvent<([_asset: string, _pToken: string, _amount: bigint] & {_asset: string, _pToken: string, _amount: bigint})>( + abi, '0x2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b6398' + ), +} + +export const functions = { + assetToPToken: new Func<[_: string], {}, string>( + abi, '0x0fc3b4c4' + ), + auraRewardPoolAddress: new Func<[], {}, string>( + abi, '0x3132a21d' + ), + balancerPoolId: new Func<[], {}, string>( + abi, '0xdbbb64b9' + ), + balancerVault: new Func<[], {}, string>( + abi, '0x158274a5' + ), + 'checkBalance(address)': new Func<[_asset: string], {_asset: string}, bigint>( + abi, '0x5f515226' + ), + 'checkBalance()': new Func<[], {}, bigint>( + abi, '0xc71daccb' + ), + claimGovernance: new Func<[], {}, []>( + abi, '0x5d36b190' + ), + collectRewardTokens: new Func<[], {}, []>( + abi, '0x5a063f63' + ), + 'deposit(address,uint256)': new Func<[_: string, _: bigint], {}, []>( + abi, '0x47e7ef24' + ), + 'deposit(address[],uint256[])': new Func<[_: Array, _: Array], {}, []>( + abi, '0xefc908a1' + ), + depositAll: new Func<[], {}, []>( + abi, '0xde5f6268' + ), + frxETH: new Func<[], {}, string>( + abi, '0x565d3e6e' + ), + getRewardTokenAddresses: new Func<[], {}, Array>( + abi, '0xf6ca71b0' + ), + governor: new Func<[], {}, string>( + abi, '0x0c340a24' + ), + harvesterAddress: new Func<[], {}, string>( + abi, '0x67c7066c' + ), + initialize: new Func<[_rewardTokenAddresses: Array, _assets: Array, _pTokens: Array], {_rewardTokenAddresses: Array, _assets: Array, _pTokens: Array}, []>( + abi, '0x435356d1' + ), + isGovernor: new Func<[], {}, boolean>( + abi, '0xc7af3352' + ), + maxDepositDeviation: new Func<[], {}, bigint>( + abi, '0x3f6f7a14' + ), + maxWithdrawalDeviation: new Func<[], {}, bigint>( + abi, '0x14f0747e' + ), + platformAddress: new Func<[], {}, string>( + abi, '0xdbe55e56' + ), + rETH: new Func<[], {}, string>( + abi, '0xca8aa0e4' + ), + removePToken: new Func<[_assetIndex: bigint], {_assetIndex: bigint}, []>( + abi, '0x9136616a' + ), + rewardTokenAddresses: new Func<[_: bigint], {}, string>( + abi, '0x7b2d9b2c' + ), + safeApproveAllTokens: new Func<[], {}, []>( + abi, '0xad1728cb' + ), + setHarvesterAddress: new Func<[_harvesterAddress: string], {_harvesterAddress: string}, []>( + abi, '0xc2e1e3f4' + ), + setMaxDepositDeviation: new Func<[_maxDepositDeviation: bigint], {_maxDepositDeviation: bigint}, []>( + abi, '0x683c1ef9' + ), + setMaxWithdrawalDeviation: new Func<[_maxWithdrawalDeviation: bigint], {_maxWithdrawalDeviation: bigint}, []>( + abi, '0x79e66fcc' + ), + setPTokenAddress: new Func<[_asset: string, _pToken: string], {_asset: string, _pToken: string}, []>( + abi, '0x0ed57b3a' + ), + setRewardTokenAddresses: new Func<[_rewardTokenAddresses: Array], {_rewardTokenAddresses: Array}, []>( + abi, '0x96d538bb' + ), + sfrxETH: new Func<[], {}, string>( + abi, '0xc9ac8c8e' + ), + stETH: new Func<[], {}, string>( + abi, '0xc1fe3e48' + ), + supportsAsset: new Func<[_asset: string], {_asset: string}, boolean>( + abi, '0xaa388af6' + ), + transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( + abi, '0xd38bfff4' + ), + transferToken: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( + abi, '0x1072cbea' + ), + vaultAddress: new Func<[], {}, string>( + abi, '0x430bf08a' + ), + 'withdraw(address,address,uint256)': new Func<[_recipient: string, _strategyAsset: string, _strategyAmount: bigint], {_recipient: string, _strategyAsset: string, _strategyAmount: bigint}, []>( + abi, '0xd9caed12' + ), + 'withdraw(address,address[],uint256[])': new Func<[_recipient: string, _strategyAssets: Array, _strategyAmounts: Array], {_recipient: string, _strategyAssets: Array, _strategyAmounts: Array}, []>( + abi, '0xedbd7668' + ), + withdrawAll: new Func<[], {}, []>( + abi, '0x853828b6' + ), + wstETH: new Func<[], {}, string>( + abi, '0x4aa07e64' + ), +} + +export class Contract extends ContractBase { + + assetToPToken(arg0: string): Promise { + return this.eth_call(functions.assetToPToken, [arg0]) + } + + auraRewardPoolAddress(): Promise { + return this.eth_call(functions.auraRewardPoolAddress, []) + } + + balancerPoolId(): Promise { + return this.eth_call(functions.balancerPoolId, []) + } + + balancerVault(): Promise { + return this.eth_call(functions.balancerVault, []) + } + + 'checkBalance(address)'(_asset: string): Promise { + return this.eth_call(functions['checkBalance(address)'], [_asset]) + } + + 'checkBalance()'(): Promise { + return this.eth_call(functions['checkBalance()'], []) + } + + frxETH(): Promise { + return this.eth_call(functions.frxETH, []) + } + + getRewardTokenAddresses(): Promise> { + return this.eth_call(functions.getRewardTokenAddresses, []) + } + + governor(): Promise { + return this.eth_call(functions.governor, []) + } + + harvesterAddress(): Promise { + return this.eth_call(functions.harvesterAddress, []) + } + + isGovernor(): Promise { + return this.eth_call(functions.isGovernor, []) + } + + maxDepositDeviation(): Promise { + return this.eth_call(functions.maxDepositDeviation, []) + } + + maxWithdrawalDeviation(): Promise { + return this.eth_call(functions.maxWithdrawalDeviation, []) + } + + platformAddress(): Promise { + return this.eth_call(functions.platformAddress, []) + } + + rETH(): Promise { + return this.eth_call(functions.rETH, []) + } + + rewardTokenAddresses(arg0: bigint): Promise { + return this.eth_call(functions.rewardTokenAddresses, [arg0]) + } + + sfrxETH(): Promise { + return this.eth_call(functions.sfrxETH, []) + } + + stETH(): Promise { + return this.eth_call(functions.stETH, []) + } + + supportsAsset(_asset: string): Promise { + return this.eth_call(functions.supportsAsset, [_asset]) + } + + vaultAddress(): Promise { + return this.eth_call(functions.vaultAddress, []) + } + + wstETH(): Promise { + return this.eth_call(functions.wstETH, []) + } +} diff --git a/src/main.ts b/src/main.ts index bf711675..d2461a40 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,11 +4,20 @@ import * as dripper from './processors/dripper' import * as fraxStaking from './processors/frax-staking' import * as morphoAave from './processors/morpho-aave' import * as oeth from './processors/oeth' +import * as balancerMetaPoolStrategy from './processors/strategies/balancer-meta-pool' import * as vault from './processors/vault' run({ // The idea is that these processors have zero dependencies on one another and can be processed asynchronously. - processors: [oeth, vault, fraxStaking, morphoAave, dripper, curveLp], + processors: [ + oeth, + vault, + fraxStaking, + morphoAave, + dripper, + curveLp, + balancerMetaPoolStrategy, + ], // For processors which depend on results from other processors, post processors run after all processors have finished. postProcessors: [], }) diff --git a/src/model/generated/balancerMetaPoolStrategy.model.ts b/src/model/generated/balancerMetaPoolStrategy.model.ts new file mode 100644 index 00000000..0d6d3ada --- /dev/null +++ b/src/model/generated/balancerMetaPoolStrategy.model.ts @@ -0,0 +1,29 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" +import * as marshal from "./marshal" + +@Entity_() +export class BalancerMetaPoolStrategy { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @Column_("timestamp with time zone", {nullable: false}) + timestamp!: Date + + @Index_() + @Column_("int4", {nullable: false}) + blockNumber!: number + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + total!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + rETH!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + weth!: bigint +} diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index eda24cf2..c9d4c957 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -11,3 +11,4 @@ export * from "./curveLp.model" export * from "./fraxStaking.model" export * from "./morphoAave.model" export * from "./dripper.model" +export * from "./balancerMetaPoolStrategy.model" diff --git a/src/processors/strategies/balancer-meta-pool.ts b/src/processors/strategies/balancer-meta-pool.ts new file mode 100644 index 00000000..dba0d15e --- /dev/null +++ b/src/processors/strategies/balancer-meta-pool.ts @@ -0,0 +1,94 @@ +import { EvmBatchProcessor } from '@subsquid/evm-processor' + +import * as balancerMetaPoolStrategy from '../../abi/balancer-meta-pool-strategy' +import { BalancerMetaPoolStrategy } from '../../model' +import { Context } from '../../processor' +import { + OETH_STRATEGY_BALANCER_ADDRESS, + RETH_ADDRESS, + WETH_ADDRESS, +} from '../../utils/addresses' +import { getOrCreate } from '../utils' + +export const from = 18156219 // https://etherscan.io/tx/0x41c4c0e86ef95e0bfaac7bd94f30f7c30505278f5d7d70c4e99deb4d79b14f58 + +export const setup = (processor: EvmBatchProcessor) => { + processor.addLog({ + address: [OETH_STRATEGY_BALANCER_ADDRESS], + topic0: [ + balancerMetaPoolStrategy.events.Deposit.topic, + balancerMetaPoolStrategy.events.Withdrawal.topic, + ], + }) +} + +interface ProcessResult { + strategies: BalancerMetaPoolStrategy[] +} + +export const process = async (ctx: Context) => { + const result: ProcessResult = { + strategies: [], + } + + for (const block of ctx.blocks) { + for (const log of block.logs) { + if (log.address === OETH_STRATEGY_BALANCER_ADDRESS) { + if ( + log.topics[0] === balancerMetaPoolStrategy.events.Deposit.topic || + log.topics[0] === balancerMetaPoolStrategy.events.Withdrawal.topic + ) { + await updateValues(ctx, block, log, result) + } + } + } + } + await ctx.store.insert(result.strategies) +} + +export const updateValues = async ( + ctx: Context, + block: Context['blocks']['0'], + log: Context['blocks']['0']['logs']['0'], + result: ProcessResult, +) => { + const timestampId = new Date(block.header.timestamp).toISOString() + const strategy = new balancerMetaPoolStrategy.Contract( + ctx, + block.header, + OETH_STRATEGY_BALANCER_ADDRESS, + ) + const [record, total, rETH, weth] = await Promise.all([ + getOrCreateBalancerMetaPool(ctx, block, log, result, timestampId), + strategy['checkBalance()'](), + strategy['checkBalance(address)'](RETH_ADDRESS), + strategy['checkBalance(address)'](WETH_ADDRESS), + ]) + record.total = total + record.rETH = rETH + record.weth = weth +} + +export const getOrCreateBalancerMetaPool = ( + ctx: Context, + block: Context['blocks']['0'], + log: Context['blocks']['0']['logs']['0'], + result: ProcessResult, + id: string, +) => { + return getOrCreate( + ctx, + BalancerMetaPoolStrategy, + result.strategies, + id, + (latest) => + new BalancerMetaPoolStrategy({ + id, + blockNumber: block.header.height, + timestamp: new Date(block.header.timestamp), + total: latest?.total ?? 0n, + rETH: latest?.rETH ?? 0n, + weth: latest?.weth ?? 0n, + }), + ) +} diff --git a/src/processors/utils.ts b/src/processors/utils.ts index fe80d0a4..5567cbed 100644 --- a/src/processors/utils.ts +++ b/src/processors/utils.ts @@ -52,3 +52,25 @@ export const getLatestEntity = async ( })) return { current, latest } } + +export const getOrCreate = async ( + ctx: Context, + entity: EntityClass, + memory: T[], + id: string, + createNew: (latest: T | undefined) => T, +) => { + const current = memory.slice(memory.length - 1).find((v) => v.id === id) + if (current) return current + const latest = + memory[memory.length - 1] ?? + (await ctx.store.findOne(entity as EntityClass, { + where: { id: LessThanOrEqual(id) }, + order: { id: 'desc' }, + })) + + const value = createNew(latest) + memory.push(value) + + return value +} diff --git a/src/utils/addresses.ts b/src/utils/addresses.ts index 4b3cbeb9..6567c1dd 100644 --- a/src/utils/addresses.ts +++ b/src/utils/addresses.ts @@ -7,8 +7,10 @@ export const OETH_VAULT_ADDRESS = '0x39254033945aa2e4809cc2977e7087bee48bd7ab' export const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' export const STETH_ADDRESS = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84' +export const WSTETH_ADDRESS = '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0' export const RETH_ADDRESS = '0xae78736cd615f374d3085123a210448e74fc6393' export const FRXETH_ADDRESS = '0x5e8422345238f34275888049021821e8e08caa1f' +export const SFRXETH_ADDRESS = '0xac3e018457b222d93114458476f3e3416abbe38f' export const VAULT_ERC20_ADDRESSES = [ WETH_ADDRESS, @@ -28,7 +30,6 @@ export const OETH_CURVE_LP_ADDRESS = export const OETH_FRAX_STAKING_ADDRESS = '0x3ff8654d633d4ea0fae24c52aec73b4a20d0d0e5' -export const SFRXETH_ADDRESS = '0xac3e018457b222d93114458476f3e3416abbe38f' export const OETH_MORPHO_AAVE_ADDRESS = '0xc1fc9e5ec3058921ea5025d703cbe31764756319' From 557da0f186c5153322e30a894a5b0e92e97ced9e Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 5 Oct 2023 08:38:42 -0700 Subject: [PATCH 3/6] feat: track balancer meta rename vyper-contract.json back to curve-lp-token.json --- ...yper-contract.json => curve-lp-token.json} | 0 ...-contract.abi.ts => curve-lp-token.abi.ts} | 0 .../{vyper-contract.ts => curve-lp-token.ts} | 2 +- .../initializable-abstract-strategy.abi.ts | 513 ------------------ src/abi/initializable-abstract-strategy.ts | 153 ------ src/processors/curve-lp/curve-lp.ts | 26 +- 6 files changed, 14 insertions(+), 680 deletions(-) rename abi/{vyper-contract.json => curve-lp-token.json} (100%) rename src/abi/{vyper-contract.abi.ts => curve-lp-token.abi.ts} (100%) rename src/abi/{vyper-contract.ts => curve-lp-token.ts} (99%) delete mode 100644 src/abi/initializable-abstract-strategy.abi.ts delete mode 100644 src/abi/initializable-abstract-strategy.ts diff --git a/abi/vyper-contract.json b/abi/curve-lp-token.json similarity index 100% rename from abi/vyper-contract.json rename to abi/curve-lp-token.json diff --git a/src/abi/vyper-contract.abi.ts b/src/abi/curve-lp-token.abi.ts similarity index 100% rename from src/abi/vyper-contract.abi.ts rename to src/abi/curve-lp-token.abi.ts diff --git a/src/abi/vyper-contract.ts b/src/abi/curve-lp-token.ts similarity index 99% rename from src/abi/vyper-contract.ts rename to src/abi/curve-lp-token.ts index 85a82b7c..4d67eacb 100644 --- a/src/abi/vyper-contract.ts +++ b/src/abi/curve-lp-token.ts @@ -1,6 +1,6 @@ import * as ethers from 'ethers' import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './vyper-contract.abi' +import {ABI_JSON} from './curve-lp-token.abi' export const abi = new ethers.Interface(ABI_JSON); diff --git a/src/abi/initializable-abstract-strategy.abi.ts b/src/abi/initializable-abstract-strategy.abi.ts deleted file mode 100644 index 48e5aa06..00000000 --- a/src/abi/initializable-abstract-strategy.abi.ts +++ /dev/null @@ -1,513 +0,0 @@ -export const ABI_JSON = [ - { - "type": "event", - "anonymous": false, - "name": "Deposit", - "inputs": [ - { - "type": "address", - "name": "_asset", - "indexed": true - }, - { - "type": "address", - "name": "_pToken", - "indexed": false - }, - { - "type": "uint256", - "name": "_amount", - "indexed": false - } - ] - }, - { - "type": "event", - "anonymous": false, - "name": "GovernorshipTransferred", - "inputs": [ - { - "type": "address", - "name": "previousGovernor", - "indexed": true - }, - { - "type": "address", - "name": "newGovernor", - "indexed": true - } - ] - }, - { - "type": "event", - "anonymous": false, - "name": "HarvesterAddressesUpdated", - "inputs": [ - { - "type": "address", - "name": "_oldHarvesterAddress", - "indexed": false - }, - { - "type": "address", - "name": "_newHarvesterAddress", - "indexed": false - } - ] - }, - { - "type": "event", - "anonymous": false, - "name": "PTokenAdded", - "inputs": [ - { - "type": "address", - "name": "_asset", - "indexed": true - }, - { - "type": "address", - "name": "_pToken", - "indexed": false - } - ] - }, - { - "type": "event", - "anonymous": false, - "name": "PTokenRemoved", - "inputs": [ - { - "type": "address", - "name": "_asset", - "indexed": true - }, - { - "type": "address", - "name": "_pToken", - "indexed": false - } - ] - }, - { - "type": "event", - "anonymous": false, - "name": "PendingGovernorshipTransfer", - "inputs": [ - { - "type": "address", - "name": "previousGovernor", - "indexed": true - }, - { - "type": "address", - "name": "newGovernor", - "indexed": true - } - ] - }, - { - "type": "event", - "anonymous": false, - "name": "RewardTokenAddressesUpdated", - "inputs": [ - { - "type": "address[]", - "name": "_oldAddresses" - }, - { - "type": "address[]", - "name": "_newAddresses" - } - ] - }, - { - "type": "event", - "anonymous": false, - "name": "RewardTokenCollected", - "inputs": [ - { - "type": "address", - "name": "recipient", - "indexed": false - }, - { - "type": "address", - "name": "rewardToken", - "indexed": false - }, - { - "type": "uint256", - "name": "amount", - "indexed": false - } - ] - }, - { - "type": "event", - "anonymous": false, - "name": "Withdrawal", - "inputs": [ - { - "type": "address", - "name": "_asset", - "indexed": true - }, - { - "type": "address", - "name": "_pToken", - "indexed": false - }, - { - "type": "uint256", - "name": "_amount", - "indexed": false - } - ] - }, - { - "type": "function", - "name": "assetToPToken", - "constant": true, - "stateMutability": "view", - "payable": false, - "inputs": [ - { - "type": "address", - "name": "" - } - ], - "outputs": [ - { - "type": "address", - "name": "" - } - ] - }, - { - "type": "function", - "name": "checkBalance", - "constant": true, - "stateMutability": "view", - "payable": false, - "inputs": [ - { - "type": "address", - "name": "_asset" - } - ], - "outputs": [ - { - "type": "uint256", - "name": "balance" - } - ] - }, - { - "type": "function", - "name": "claimGovernance", - "constant": false, - "payable": false, - "inputs": [], - "outputs": [] - }, - { - "type": "function", - "name": "collectRewardTokens", - "constant": false, - "payable": false, - "inputs": [], - "outputs": [] - }, - { - "type": "function", - "name": "deposit", - "constant": false, - "payable": false, - "inputs": [ - { - "type": "address", - "name": "_asset" - }, - { - "type": "uint256", - "name": "_amount" - } - ], - "outputs": [] - }, - { - "type": "function", - "name": "depositAll", - "constant": false, - "payable": false, - "inputs": [], - "outputs": [] - }, - { - "type": "function", - "name": "getRewardTokenAddresses", - "constant": true, - "stateMutability": "view", - "payable": false, - "inputs": [], - "outputs": [ - { - "type": "address[]", - "name": "" - } - ] - }, - { - "type": "function", - "name": "governor", - "constant": true, - "stateMutability": "view", - "payable": false, - "inputs": [], - "outputs": [ - { - "type": "address", - "name": "" - } - ] - }, - { - "type": "function", - "name": "harvesterAddress", - "constant": true, - "stateMutability": "view", - "payable": false, - "inputs": [], - "outputs": [ - { - "type": "address", - "name": "" - } - ] - }, - { - "type": "function", - "name": "initialize", - "constant": false, - "payable": false, - "inputs": [ - { - "type": "address[]", - "name": "_rewardTokenAddresses" - }, - { - "type": "address[]", - "name": "_assets" - }, - { - "type": "address[]", - "name": "_pTokens" - } - ], - "outputs": [] - }, - { - "type": "function", - "name": "isGovernor", - "constant": true, - "stateMutability": "view", - "payable": false, - "inputs": [], - "outputs": [ - { - "type": "bool", - "name": "" - } - ] - }, - { - "type": "function", - "name": "platformAddress", - "constant": true, - "stateMutability": "view", - "payable": false, - "inputs": [], - "outputs": [ - { - "type": "address", - "name": "" - } - ] - }, - { - "type": "function", - "name": "removePToken", - "constant": false, - "payable": false, - "inputs": [ - { - "type": "uint256", - "name": "_assetIndex" - } - ], - "outputs": [] - }, - { - "type": "function", - "name": "rewardTokenAddresses", - "constant": true, - "stateMutability": "view", - "payable": false, - "inputs": [ - { - "type": "uint256", - "name": "" - } - ], - "outputs": [ - { - "type": "address", - "name": "" - } - ] - }, - { - "type": "function", - "name": "safeApproveAllTokens", - "constant": false, - "payable": false, - "inputs": [], - "outputs": [] - }, - { - "type": "function", - "name": "setHarvesterAddress", - "constant": false, - "payable": false, - "inputs": [ - { - "type": "address", - "name": "_harvesterAddress" - } - ], - "outputs": [] - }, - { - "type": "function", - "name": "setPTokenAddress", - "constant": false, - "payable": false, - "inputs": [ - { - "type": "address", - "name": "_asset" - }, - { - "type": "address", - "name": "_pToken" - } - ], - "outputs": [] - }, - { - "type": "function", - "name": "setRewardTokenAddresses", - "constant": false, - "payable": false, - "inputs": [ - { - "type": "address[]", - "name": "_rewardTokenAddresses" - } - ], - "outputs": [] - }, - { - "type": "function", - "name": "supportsAsset", - "constant": true, - "stateMutability": "view", - "payable": false, - "inputs": [ - { - "type": "address", - "name": "_asset" - } - ], - "outputs": [ - { - "type": "bool", - "name": "" - } - ] - }, - { - "type": "function", - "name": "transferGovernance", - "constant": false, - "payable": false, - "inputs": [ - { - "type": "address", - "name": "_newGovernor" - } - ], - "outputs": [] - }, - { - "type": "function", - "name": "transferToken", - "constant": false, - "payable": false, - "inputs": [ - { - "type": "address", - "name": "_asset" - }, - { - "type": "uint256", - "name": "_amount" - } - ], - "outputs": [] - }, - { - "type": "function", - "name": "vaultAddress", - "constant": true, - "stateMutability": "view", - "payable": false, - "inputs": [], - "outputs": [ - { - "type": "address", - "name": "" - } - ] - }, - { - "type": "function", - "name": "withdraw", - "constant": false, - "payable": false, - "inputs": [ - { - "type": "address", - "name": "_recipient" - }, - { - "type": "address", - "name": "_asset" - }, - { - "type": "uint256", - "name": "_amount" - } - ], - "outputs": [] - }, - { - "type": "function", - "name": "withdrawAll", - "constant": false, - "payable": false, - "inputs": [], - "outputs": [] - } -] diff --git a/src/abi/initializable-abstract-strategy.ts b/src/abi/initializable-abstract-strategy.ts deleted file mode 100644 index 12cfdcf0..00000000 --- a/src/abi/initializable-abstract-strategy.ts +++ /dev/null @@ -1,153 +0,0 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './initializable-abstract-strategy.abi' - -export const abi = new ethers.Interface(ABI_JSON); - -export const events = { - Deposit: new LogEvent<([_asset: string, _pToken: string, _amount: bigint] & {_asset: string, _pToken: string, _amount: bigint})>( - abi, '0x5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62' - ), - GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' - ), - HarvesterAddressesUpdated: new LogEvent<([_oldHarvesterAddress: string, _newHarvesterAddress: string] & {_oldHarvesterAddress: string, _newHarvesterAddress: string})>( - abi, '0xe48386b84419f4d36e0f96c10cc3510b6fb1a33795620c5098b22472bbe90796' - ), - PTokenAdded: new LogEvent<([_asset: string, _pToken: string] & {_asset: string, _pToken: string})>( - abi, '0xef6485b84315f9b1483beffa32aae9a0596890395e3d7521f1c5fbb51790e765' - ), - PTokenRemoved: new LogEvent<([_asset: string, _pToken: string] & {_asset: string, _pToken: string})>( - abi, '0x16b7600acff27e39a8a96056b3d533045298de927507f5c1d97e4accde60488c' - ), - PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' - ), - RewardTokenAddressesUpdated: new LogEvent<([_oldAddresses: Array, _newAddresses: Array] & {_oldAddresses: Array, _newAddresses: Array})>( - abi, '0x04c0b9649497d316554306e53678d5f5f5dbc3a06f97dec13ff4cfe98b986bbc' - ), - RewardTokenCollected: new LogEvent<([recipient: string, rewardToken: string, amount: bigint] & {recipient: string, rewardToken: string, amount: bigint})>( - abi, '0xf6c07a063ed4e63808eb8da7112d46dbcd38de2b40a73dbcc9353c5a94c72353' - ), - Withdrawal: new LogEvent<([_asset: string, _pToken: string, _amount: bigint] & {_asset: string, _pToken: string, _amount: bigint})>( - abi, '0x2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b6398' - ), -} - -export const functions = { - assetToPToken: new Func<[_: string], {}, string>( - abi, '0x0fc3b4c4' - ), - checkBalance: new Func<[_asset: string], {_asset: string}, bigint>( - abi, '0x5f515226' - ), - claimGovernance: new Func<[], {}, []>( - abi, '0x5d36b190' - ), - collectRewardTokens: new Func<[], {}, []>( - abi, '0x5a063f63' - ), - deposit: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( - abi, '0x47e7ef24' - ), - depositAll: new Func<[], {}, []>( - abi, '0xde5f6268' - ), - getRewardTokenAddresses: new Func<[], {}, Array>( - abi, '0xf6ca71b0' - ), - governor: new Func<[], {}, string>( - abi, '0x0c340a24' - ), - harvesterAddress: new Func<[], {}, string>( - abi, '0x67c7066c' - ), - initialize: new Func<[_rewardTokenAddresses: Array, _assets: Array, _pTokens: Array], {_rewardTokenAddresses: Array, _assets: Array, _pTokens: Array}, []>( - abi, '0x435356d1' - ), - isGovernor: new Func<[], {}, boolean>( - abi, '0xc7af3352' - ), - platformAddress: new Func<[], {}, string>( - abi, '0xdbe55e56' - ), - removePToken: new Func<[_assetIndex: bigint], {_assetIndex: bigint}, []>( - abi, '0x9136616a' - ), - rewardTokenAddresses: new Func<[_: bigint], {}, string>( - abi, '0x7b2d9b2c' - ), - safeApproveAllTokens: new Func<[], {}, []>( - abi, '0xad1728cb' - ), - setHarvesterAddress: new Func<[_harvesterAddress: string], {_harvesterAddress: string}, []>( - abi, '0xc2e1e3f4' - ), - setPTokenAddress: new Func<[_asset: string, _pToken: string], {_asset: string, _pToken: string}, []>( - abi, '0x0ed57b3a' - ), - setRewardTokenAddresses: new Func<[_rewardTokenAddresses: Array], {_rewardTokenAddresses: Array}, []>( - abi, '0x96d538bb' - ), - supportsAsset: new Func<[_asset: string], {_asset: string}, boolean>( - abi, '0xaa388af6' - ), - transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( - abi, '0xd38bfff4' - ), - transferToken: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( - abi, '0x1072cbea' - ), - vaultAddress: new Func<[], {}, string>( - abi, '0x430bf08a' - ), - withdraw: new Func<[_recipient: string, _asset: string, _amount: bigint], {_recipient: string, _asset: string, _amount: bigint}, []>( - abi, '0xd9caed12' - ), - withdrawAll: new Func<[], {}, []>( - abi, '0x853828b6' - ), -} - -export class Contract extends ContractBase { - - assetToPToken(arg0: string): Promise { - return this.eth_call(functions.assetToPToken, [arg0]) - } - - checkBalance(_asset: string): Promise { - return this.eth_call(functions.checkBalance, [_asset]) - } - - getRewardTokenAddresses(): Promise> { - return this.eth_call(functions.getRewardTokenAddresses, []) - } - - governor(): Promise { - return this.eth_call(functions.governor, []) - } - - harvesterAddress(): Promise { - return this.eth_call(functions.harvesterAddress, []) - } - - isGovernor(): Promise { - return this.eth_call(functions.isGovernor, []) - } - - platformAddress(): Promise { - return this.eth_call(functions.platformAddress, []) - } - - rewardTokenAddresses(arg0: bigint): Promise { - return this.eth_call(functions.rewardTokenAddresses, [arg0]) - } - - supportsAsset(_asset: string): Promise { - return this.eth_call(functions.supportsAsset, [_asset]) - } - - vaultAddress(): Promise { - return this.eth_call(functions.vaultAddress, []) - } -} diff --git a/src/processors/curve-lp/curve-lp.ts b/src/processors/curve-lp/curve-lp.ts index cc432ba0..a4553f69 100644 --- a/src/processors/curve-lp/curve-lp.ts +++ b/src/processors/curve-lp/curve-lp.ts @@ -2,8 +2,8 @@ import { EvmBatchProcessor } from '@subsquid/evm-processor' import { pad } from 'viem' import * as baseRewardPool from '../../abi/base-reward-pool' +import * as curveLpToken from '../../abi/curve-lp-token' import * as erc20 from '../../abi/erc20' -import * as vyperContract from '../../abi/vyper-contract' import { CurveLP } from '../../model' import { Context } from '../../processor' import { @@ -28,10 +28,10 @@ export const setup = (processor: EvmBatchProcessor) => { processor.addLog({ address: [OETH_CURVE_LP_ADDRESS], topic0: [ - vyperContract.events.AddLiquidity.topic, - vyperContract.events.RemoveLiquidity.topic, - vyperContract.events.RemoveLiquidityImbalance.topic, - vyperContract.events.RemoveLiquidityOne.topic, + curveLpToken.events.AddLiquidity.topic, + curveLpToken.events.RemoveLiquidity.topic, + curveLpToken.events.RemoveLiquidityImbalance.topic, + curveLpToken.events.RemoveLiquidityOne.topic, // curve_lp_token.events.TokenExchange.topic, // Not sure if including this helps get up-to-date eth balances. ], }) @@ -155,23 +155,23 @@ const processLiquidityEvents = async ( block: Context['blocks']['0'], log: Context['blocks']['0']['logs']['0'], ) => { - if (log.topics[0] === vyperContract.events.AddLiquidity.topic) { - const { token_supply } = vyperContract.events.AddLiquidity.decode(log) + if (log.topics[0] === curveLpToken.events.AddLiquidity.topic) { + const { token_supply } = curveLpToken.events.AddLiquidity.decode(log) const { curveLP } = await getLatestCurveLP(ctx, result, block) curveLP.totalSupply = token_supply } else if ( - log.topics[0] === vyperContract.events.RemoveLiquidityImbalance.topic + log.topics[0] === curveLpToken.events.RemoveLiquidityImbalance.topic ) { const { token_supply } = - vyperContract.events.RemoveLiquidityImbalance.decode(log) + curveLpToken.events.RemoveLiquidityImbalance.decode(log) const { curveLP } = await getLatestCurveLP(ctx, result, block) curveLP.totalSupply = token_supply - } else if (log.topics[0] === vyperContract.events.RemoveLiquidityOne.topic) { - const { token_supply } = vyperContract.events.RemoveLiquidityOne.decode(log) + } else if (log.topics[0] === curveLpToken.events.RemoveLiquidityOne.topic) { + const { token_supply } = curveLpToken.events.RemoveLiquidityOne.decode(log) const { curveLP } = await getLatestCurveLP(ctx, result, block) curveLP.totalSupply = token_supply - } else if (log.topics[0] === vyperContract.events.RemoveLiquidity.topic) { - const { token_supply } = vyperContract.events.RemoveLiquidity.decode(log) + } else if (log.topics[0] === curveLpToken.events.RemoveLiquidity.topic) { + const { token_supply } = curveLpToken.events.RemoveLiquidity.decode(log) const { curveLP } = await getLatestCurveLP(ctx, result, block) curveLP.totalSupply = token_supply } From a512d70ad659722ace5e491dd551d16b1c832f5c Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 5 Oct 2023 17:33:17 -0700 Subject: [PATCH 4/6] feat: track balancer meta additional update triggers, does happen to get us the same #s as shown on the other analytics repo --- abi/balancer-vault.json | 1179 ++++++++++++++ abi/base-reward-pool-4626.json | 1236 ++++++++++++++ abi/meta-stable-pool.json | 1437 +++++++++++++++++ schema.graphql | 2 +- src/processor.ts | 13 +- .../strategies/balancer-meta-pool.ts | 142 +- 6 files changed, 3958 insertions(+), 51 deletions(-) create mode 100644 abi/balancer-vault.json create mode 100644 abi/base-reward-pool-4626.json create mode 100644 abi/meta-stable-pool.json diff --git a/abi/balancer-vault.json b/abi/balancer-vault.json new file mode 100644 index 00000000..ccaba518 --- /dev/null +++ b/abi/balancer-vault.json @@ -0,0 +1,1179 @@ +[ + { + "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" + } +] \ No newline at end of file diff --git a/abi/base-reward-pool-4626.json b/abi/base-reward-pool-4626.json new file mode 100644 index 00000000..26c842c8 --- /dev/null +++ b/abi/base-reward-pool-4626.json @@ -0,0 +1,1236 @@ +[ + { + "inputs": [ + { + "internalType": "uint256", + "name": "pid_", + "type": "uint256" + }, + { + "internalType": "address", + "name": "stakingToken_", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken_", + "type": "address" + }, + { + "internalType": "address", + "name": "operator_", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "lptoken_", + "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": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "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": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Withdraw", + "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": "_reward", + "type": "address" + } + ], + "name": "addExtraReward", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "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": [], + "name": "asset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "clearExtraRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "convertToAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "convertToShares", + "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": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "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": "extraRewards", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "extraRewardsLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getReward", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "bool", + "name": "_claimExtras", + "type": "bool" + } + ], + "name": "getReward", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "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": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "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": [], + "name": "pid", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "processIdleRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_rewards", + "type": "uint256" + } + ], + "name": "queueNewRewards", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "queuedRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "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": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "stake", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stakeAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_for", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "stakeFor", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stakingToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "userRewardPerTokenPaid", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "claim", + "type": "bool" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "claim", + "type": "bool" + } + ], + "name": "withdrawAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "claim", + "type": "bool" + } + ], + "name": "withdrawAllAndUnwrap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "claim", + "type": "bool" + } + ], + "name": "withdrawAndUnwrap", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/meta-stable-pool.json b/abi/meta-stable-pool.json new file mode 100644 index 00000000..1ae16a10 --- /dev/null +++ b/abi/meta-stable-pool.json @@ -0,0 +1,1437 @@ +[ + { + "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": "tokens", + "type": "address[]" + }, + { + "internalType": "contract IRateProvider[]", + "name": "rateProviders", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "priceRateCacheDuration", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "amplificationParameter", + "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 MetaStablePool.NewPoolParams", + "name": "params", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "startValue", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "endValue", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + } + ], + "name": "AmpUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "currentValue", + "type": "uint256" + } + ], + "name": "AmpUpdateStopped", + "type": "event" + }, + { + "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": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "PriceRateCacheUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IRateProvider", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "cacheDuration", + "type": "uint256" + } + ], + "name": "PriceRateProviderSet", + "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": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "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": "getAmplificationParameter", + "outputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isUpdating", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "precision", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { + "internalType": "contract IAuthorizer", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLargestSafeQueryWindow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getLastInvariant", + "outputs": [ + { + "internalType": "uint256", + "name": "lastInvariant", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastInvariantAmp", + "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": "getOracleMiscData", + "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" + } + ], + "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": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "getPriceRateCache", + "outputs": [ + { + "internalType": "uint256", + "name": "rate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expires", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRateProviders", + "outputs": [ + { + "internalType": "contract IRateProvider[]", + "name": "providers", + "type": "address[]" + } + ], + "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": "getScalingFactors", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "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": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "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": "amountsOut", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "dueProtocolFeeAmounts", + "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": "balances", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "indexIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "indexOut", + "type": "uint256" + } + ], + "name": "onSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "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": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "bytes", + "name": "poolConfig", + "type": "bytes" + } + ], + "name": "setAssetManagerPoolConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "setPaused", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + } + ], + "name": "setPriceRateCacheDuration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "name": "setSwapFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "rawEndValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + } + ], + "name": "startAmplificationParameterUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stopAmplificationParameterUpdate", + "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" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "updatePriceRateCache", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/schema.graphql b/schema.graphql index 0b4e4079..b5cb0cf1 100644 --- a/schema.graphql +++ b/schema.graphql @@ -134,4 +134,4 @@ type BalancerMetaPoolStrategy @entity { total: BigInt! rETH: BigInt! weth: BigInt! -} \ No newline at end of file +} diff --git a/src/processor.ts b/src/processor.ts index 7933db7e..361a92bb 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -81,22 +81,27 @@ export const run = ({ async (ctx) => { resetProcessorState() let start: number - const time = (name: string) => () => - ctx.log.info(`${name} ${Date.now() - start}ms`) + const time = (name: string) => () => { + const message = `${name} ${Date.now() - start}ms` + return () => ctx.log.info(message) + } + ctx.log.info(`=== processing from ${ctx.blocks[0].header.height}`) start = Date.now() - await Promise.all( + const times = await Promise.all( processors.map((p, index) => p.process(ctx).then(time(p.name ?? `processor-${index}`)), ), ) + times.forEach((t) => t()) start = Date.now() - await Promise.all( + const postTimes = await Promise.all( postProcessors.map((p, index) => p.process(ctx).then(time(p.name ?? `postProcessor-${index}`)), ), ) + postTimes.forEach((t) => t()) }, ) } diff --git a/src/processors/strategies/balancer-meta-pool.ts b/src/processors/strategies/balancer-meta-pool.ts index dba0d15e..28998d42 100644 --- a/src/processors/strategies/balancer-meta-pool.ts +++ b/src/processors/strategies/balancer-meta-pool.ts @@ -1,27 +1,81 @@ import { EvmBatchProcessor } from '@subsquid/evm-processor' import * as balancerMetaPoolStrategy from '../../abi/balancer-meta-pool-strategy' +import * as baseRewardPool4626 from '../../abi/base-reward-pool-4626' +import * as metaStablePool from '../../abi/meta-stable-pool' import { BalancerMetaPoolStrategy } from '../../model' import { Context } from '../../processor' -import { - OETH_STRATEGY_BALANCER_ADDRESS, - RETH_ADDRESS, - WETH_ADDRESS, -} from '../../utils/addresses' -import { getOrCreate } from '../utils' +import { RETH_ADDRESS, WETH_ADDRESS } from '../../utils/addresses' +import { getLatestEntity } from '../utils' export const from = 18156219 // https://etherscan.io/tx/0x41c4c0e86ef95e0bfaac7bd94f30f7c30505278f5d7d70c4e99deb4d79b14f58 +const addresses = { + strategy: '0x49109629ac1deb03f2e9b2fe2ac4a623e0e7dfdc', + lpToken: '0x1e19cf2d73a72ef1332c882f20534b6519be0276', + auraRewardsPool: '0xdd1fe5ad401d4777ce89959b7fa587e569bf125d', + balancerVault: '0xba12222222228d8ba445958a75a0704d566bf2c8', +} +const poolId = + '0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112' + export const setup = (processor: EvmBatchProcessor) => { processor.addLog({ - address: [OETH_STRATEGY_BALANCER_ADDRESS], + address: [addresses.strategy], topic0: [ balancerMetaPoolStrategy.events.Deposit.topic, balancerMetaPoolStrategy.events.Withdrawal.topic, + balancerMetaPoolStrategy.events.RewardTokenCollected.topic, + ], + }) + processor.addLog({ + address: [addresses.lpToken], + topic0: [ + metaStablePool.events.Transfer.topic, + metaStablePool.events.PriceRateCacheUpdated.topic, + metaStablePool.events.PriceRateProviderSet.topic, + metaStablePool.events.OracleEnabledChanged.topic, + metaStablePool.events.SwapFeePercentageChanged.topic, + ], + }) + processor.addLog({ + address: [addresses.auraRewardsPool], + topic0: [ + baseRewardPool4626.events.Transfer.topic, + baseRewardPool4626.events.Staked.topic, + baseRewardPool4626.events.Deposit.topic, + baseRewardPool4626.events.Withdrawn.topic, + baseRewardPool4626.events.Withdraw.topic, + baseRewardPool4626.events.RewardAdded.topic, + baseRewardPool4626.events.RewardPaid.topic, ], }) } +const addressesToListenTo = new Set([ + addresses.strategy, + addresses.lpToken, + addresses.auraRewardsPool, + addresses.balancerVault, +]) +const topicsToListenTo = new Set([ + balancerMetaPoolStrategy.events.Deposit.topic, + balancerMetaPoolStrategy.events.Withdrawal.topic, + balancerMetaPoolStrategy.events.RewardTokenCollected.topic, + metaStablePool.events.Transfer.topic, + metaStablePool.events.PriceRateCacheUpdated.topic, + metaStablePool.events.PriceRateProviderSet.topic, + metaStablePool.events.OracleEnabledChanged.topic, + metaStablePool.events.SwapFeePercentageChanged.topic, + baseRewardPool4626.events.Transfer.topic, + baseRewardPool4626.events.Staked.topic, + baseRewardPool4626.events.Deposit.topic, + baseRewardPool4626.events.Withdrawn.topic, + baseRewardPool4626.events.Withdraw.topic, + baseRewardPool4626.events.RewardAdded.topic, + baseRewardPool4626.events.RewardPaid.topic, +]) + interface ProcessResult { strategies: BalancerMetaPoolStrategy[] } @@ -32,15 +86,14 @@ export const process = async (ctx: Context) => { } for (const block of ctx.blocks) { - for (const log of block.logs) { - if (log.address === OETH_STRATEGY_BALANCER_ADDRESS) { - if ( - log.topics[0] === balancerMetaPoolStrategy.events.Deposit.topic || - log.topics[0] === balancerMetaPoolStrategy.events.Withdrawal.topic - ) { - await updateValues(ctx, block, log, result) - } - } + if (block.header.height < from) continue + const shouldUpdate = !!block.logs.find( + (log) => + addressesToListenTo.has(log.address) && + topicsToListenTo.has(log.topics[0]), + ) + if (shouldUpdate) { + await updateValues(ctx, block, result) } } await ctx.store.insert(result.strategies) @@ -49,46 +102,43 @@ export const process = async (ctx: Context) => { export const updateValues = async ( ctx: Context, block: Context['blocks']['0'], - log: Context['blocks']['0']['logs']['0'], result: ProcessResult, ) => { const timestampId = new Date(block.header.timestamp).toISOString() const strategy = new balancerMetaPoolStrategy.Contract( ctx, block.header, - OETH_STRATEGY_BALANCER_ADDRESS, + addresses.strategy, ) - const [record, total, rETH, weth] = await Promise.all([ - getOrCreateBalancerMetaPool(ctx, block, log, result, timestampId), + const [{ current, latest }, total, rETH, weth] = await Promise.all([ + getLatestEntity( + ctx, + BalancerMetaPoolStrategy, + result.strategies, + timestampId, + ), strategy['checkBalance()'](), strategy['checkBalance(address)'](RETH_ADDRESS), strategy['checkBalance(address)'](WETH_ADDRESS), ]) - record.total = total - record.rETH = rETH - record.weth = weth -} -export const getOrCreateBalancerMetaPool = ( - ctx: Context, - block: Context['blocks']['0'], - log: Context['blocks']['0']['logs']['0'], - result: ProcessResult, - id: string, -) => { - return getOrCreate( - ctx, - BalancerMetaPoolStrategy, - result.strategies, - id, - (latest) => - new BalancerMetaPoolStrategy({ - id, - blockNumber: block.header.height, - timestamp: new Date(block.header.timestamp), - total: latest?.total ?? 0n, - rETH: latest?.rETH ?? 0n, - weth: latest?.weth ?? 0n, - }), - ) + if (!current) { + if ( + !latest || + latest.total !== total || + latest.rETH !== rETH || + latest.weth !== weth + ) { + result.strategies.push( + new BalancerMetaPoolStrategy({ + id: timestampId, + blockNumber: block.header.height, + timestamp: new Date(block.header.timestamp), + total: total, + rETH: rETH, + weth: weth, + }), + ) + } + } } From 46451af722a6498771d6240137f9863ecf564a29 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Fri, 6 Oct 2023 10:37:43 -0700 Subject: [PATCH 5/6] feat: track balancer meta add origin lens contract which we'll use to get aura balances after it's deploy block --- abi/origin-lens.json | 410 +++++ src/abi/balancer-vault.abi.ts | 1055 +++++++++++++ src/abi/balancer-vault.ts | 176 +++ src/abi/base-reward-pool-4626.abi.ts | 1205 +++++++++++++++ src/abi/base-reward-pool-4626.ts | 371 +++++ src/abi/meta-stable-pool.abi.ts | 1327 +++++++++++++++++ src/abi/meta-stable-pool.ts | 297 ++++ src/abi/origin-lens.abi.ts | 408 +++++ src/abi/origin-lens.ts | 149 ++ .../strategies/balancer-meta-pool.ts | 37 +- 10 files changed, 5418 insertions(+), 17 deletions(-) create mode 100644 abi/origin-lens.json create mode 100644 src/abi/balancer-vault.abi.ts create mode 100644 src/abi/balancer-vault.ts create mode 100644 src/abi/base-reward-pool-4626.abi.ts create mode 100644 src/abi/base-reward-pool-4626.ts create mode 100644 src/abi/meta-stable-pool.abi.ts create mode 100644 src/abi/meta-stable-pool.ts create mode 100644 src/abi/origin-lens.abi.ts create mode 100644 src/abi/origin-lens.ts diff --git a/abi/origin-lens.json b/abi/origin-lens.json new file mode 100644 index 00000000..4e360855 --- /dev/null +++ b/abi/origin-lens.json @@ -0,0 +1,410 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_oToken", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousGovernor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernor", + "type": "address" + } + ], + "name": "GovernorshipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousGovernor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernor", + "type": "address" + } + ], + "name": "PendingGovernorshipTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "StrategistUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "strategyAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "enum OriginLens.StrategyKinds", + "name": "kind", + "type": "uint8" + } + ], + "name": "StrategyTypeChanged", + "type": "event" + }, + { + "inputs": [], + "name": "ETH_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "assetCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "assets", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cacheStrategies", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "claimGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "curvePoolCoinCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "strategyAddr", + "type": "address" + }, + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getStrategyAssetBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "strategyAddr", + "type": "address" + } + ], + "name": "getStrategyBalances", + "outputs": [ + { + "internalType": "address[]", + "name": "supportedAssets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "assetBalances", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_strategistAddr", + "type": "address" + }, + { + "internalType": "address[]", + "name": "_strategies", + "type": "address[]" + }, + { + "internalType": "uint8[]", + "name": "strategyKinds", + "type": "uint8[]" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isGovernor", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oToken", + "outputs": [ + { + "internalType": "contract IOUSD", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracleRouter", + "outputs": [ + { + "internalType": "contract IOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "setStrategistAddr", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "strategy", + "type": "address" + }, + { + "internalType": "enum OriginLens.StrategyKinds", + "name": "kind", + "type": "uint8" + } + ], + "name": "setStrategyKind", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "strategies", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "strategistAddr", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "strategyConfig", + "outputs": [ + { + "internalType": "bool", + "name": "supported", + "type": "bool" + }, + { + "internalType": "enum OriginLens.StrategyKinds", + "name": "kind", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newGovernor", + "type": "address" + } + ], + "name": "transferGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/src/abi/balancer-vault.abi.ts b/src/abi/balancer-vault.abi.ts new file mode 100644 index 00000000..ce9d8094 --- /dev/null +++ b/src/abi/balancer-vault.abi.ts @@ -0,0 +1,1055 @@ +export const ABI_JSON = [ + { + "type": "constructor", + "stateMutability": "undefined", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "authorizer" + }, + { + "type": "address", + "name": "weth" + }, + { + "type": "uint256", + "name": "pauseWindowDuration" + }, + { + "type": "uint256", + "name": "bufferPeriodDuration" + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "AuthorizerChanged", + "inputs": [ + { + "type": "address", + "name": "newAuthorizer", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "ExternalBalanceTransfer", + "inputs": [ + { + "type": "address", + "name": "token", + "indexed": true + }, + { + "type": "address", + "name": "sender", + "indexed": true + }, + { + "type": "address", + "name": "recipient", + "indexed": false + }, + { + "type": "uint256", + "name": "amount", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "FlashLoan", + "inputs": [ + { + "type": "address", + "name": "recipient", + "indexed": true + }, + { + "type": "address", + "name": "token", + "indexed": true + }, + { + "type": "uint256", + "name": "amount", + "indexed": false + }, + { + "type": "uint256", + "name": "feeAmount", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "InternalBalanceChanged", + "inputs": [ + { + "type": "address", + "name": "user", + "indexed": true + }, + { + "type": "address", + "name": "token", + "indexed": true + }, + { + "type": "int256", + "name": "delta", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PausedStateChanged", + "inputs": [ + { + "type": "bool", + "name": "paused", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PoolBalanceChanged", + "inputs": [ + { + "type": "bytes32", + "name": "poolId", + "indexed": true + }, + { + "type": "address", + "name": "liquidityProvider", + "indexed": true + }, + { + "type": "address[]", + "name": "tokens" + }, + { + "type": "int256[]", + "name": "deltas" + }, + { + "type": "uint256[]", + "name": "protocolFeeAmounts" + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PoolBalanceManaged", + "inputs": [ + { + "type": "bytes32", + "name": "poolId", + "indexed": true + }, + { + "type": "address", + "name": "assetManager", + "indexed": true + }, + { + "type": "address", + "name": "token", + "indexed": true + }, + { + "type": "int256", + "name": "cashDelta", + "indexed": false + }, + { + "type": "int256", + "name": "managedDelta", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PoolRegistered", + "inputs": [ + { + "type": "bytes32", + "name": "poolId", + "indexed": true + }, + { + "type": "address", + "name": "poolAddress", + "indexed": true + }, + { + "type": "uint8", + "name": "specialization", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "RelayerApprovalChanged", + "inputs": [ + { + "type": "address", + "name": "relayer", + "indexed": true + }, + { + "type": "address", + "name": "sender", + "indexed": true + }, + { + "type": "bool", + "name": "approved", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Swap", + "inputs": [ + { + "type": "bytes32", + "name": "poolId", + "indexed": true + }, + { + "type": "address", + "name": "tokenIn", + "indexed": true + }, + { + "type": "address", + "name": "tokenOut", + "indexed": true + }, + { + "type": "uint256", + "name": "amountIn", + "indexed": false + }, + { + "type": "uint256", + "name": "amountOut", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "TokensDeregistered", + "inputs": [ + { + "type": "bytes32", + "name": "poolId", + "indexed": true + }, + { + "type": "address[]", + "name": "tokens" + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "TokensRegistered", + "inputs": [ + { + "type": "bytes32", + "name": "poolId", + "indexed": true + }, + { + "type": "address[]", + "name": "tokens" + }, + { + "type": "address[]", + "name": "assetManagers" + } + ] + }, + { + "type": "function", + "name": "WETH", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "batchSwap", + "constant": false, + "stateMutability": "payable", + "payable": true, + "inputs": [ + { + "type": "uint8", + "name": "kind" + }, + { + "type": "tuple[]", + "name": "swaps", + "components": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "uint256", + "name": "assetInIndex" + }, + { + "type": "uint256", + "name": "assetOutIndex" + }, + { + "type": "uint256", + "name": "amount" + }, + { + "type": "bytes", + "name": "userData" + } + ] + }, + { + "type": "address[]", + "name": "assets" + }, + { + "type": "tuple", + "name": "funds", + "components": [ + { + "type": "address", + "name": "sender" + }, + { + "type": "bool", + "name": "fromInternalBalance" + }, + { + "type": "address", + "name": "recipient" + }, + { + "type": "bool", + "name": "toInternalBalance" + } + ] + }, + { + "type": "int256[]", + "name": "limits" + }, + { + "type": "uint256", + "name": "deadline" + } + ], + "outputs": [ + { + "type": "int256[]", + "name": "assetDeltas" + } + ] + }, + { + "type": "function", + "name": "deregisterTokens", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "address[]", + "name": "tokens" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "exitPool", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "address", + "name": "sender" + }, + { + "type": "address", + "name": "recipient" + }, + { + "type": "tuple", + "name": "request", + "components": [ + { + "type": "address[]", + "name": "assets" + }, + { + "type": "uint256[]", + "name": "minAmountsOut" + }, + { + "type": "bytes", + "name": "userData" + }, + { + "type": "bool", + "name": "toInternalBalance" + } + ] + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "flashLoan", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "recipient" + }, + { + "type": "address[]", + "name": "tokens" + }, + { + "type": "uint256[]", + "name": "amounts" + }, + { + "type": "bytes", + "name": "userData" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "getActionId", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "bytes4", + "name": "selector" + } + ], + "outputs": [ + { + "type": "bytes32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getAuthorizer", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getDomainSeparator", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bytes32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getInternalBalance", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "user" + }, + { + "type": "address[]", + "name": "tokens" + } + ], + "outputs": [ + { + "type": "uint256[]", + "name": "balances" + } + ] + }, + { + "type": "function", + "name": "getNextNonce", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "user" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getPausedState", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "paused" + }, + { + "type": "uint256", + "name": "pauseWindowEndTime" + }, + { + "type": "uint256", + "name": "bufferPeriodEndTime" + } + ] + }, + { + "type": "function", + "name": "getPool", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + } + ], + "outputs": [ + { + "type": "address", + "name": "" + }, + { + "type": "uint8", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getPoolTokenInfo", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "address", + "name": "token" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "cash" + }, + { + "type": "uint256", + "name": "managed" + }, + { + "type": "uint256", + "name": "lastChangeBlock" + }, + { + "type": "address", + "name": "assetManager" + } + ] + }, + { + "type": "function", + "name": "getPoolTokens", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + } + ], + "outputs": [ + { + "type": "address[]", + "name": "tokens" + }, + { + "type": "uint256[]", + "name": "balances" + }, + { + "type": "uint256", + "name": "lastChangeBlock" + } + ] + }, + { + "type": "function", + "name": "getProtocolFeesCollector", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "hasApprovedRelayer", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "user" + }, + { + "type": "address", + "name": "relayer" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "joinPool", + "constant": false, + "stateMutability": "payable", + "payable": true, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "address", + "name": "sender" + }, + { + "type": "address", + "name": "recipient" + }, + { + "type": "tuple", + "name": "request", + "components": [ + { + "type": "address[]", + "name": "assets" + }, + { + "type": "uint256[]", + "name": "maxAmountsIn" + }, + { + "type": "bytes", + "name": "userData" + }, + { + "type": "bool", + "name": "fromInternalBalance" + } + ] + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "managePoolBalance", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "tuple[]", + "name": "ops", + "components": [ + { + "type": "uint8", + "name": "kind" + }, + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "address", + "name": "token" + }, + { + "type": "uint256", + "name": "amount" + } + ] + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "manageUserBalance", + "constant": false, + "stateMutability": "payable", + "payable": true, + "inputs": [ + { + "type": "tuple[]", + "name": "ops", + "components": [ + { + "type": "uint8", + "name": "kind" + }, + { + "type": "address", + "name": "asset" + }, + { + "type": "uint256", + "name": "amount" + }, + { + "type": "address", + "name": "sender" + }, + { + "type": "address", + "name": "recipient" + } + ] + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "queryBatchSwap", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint8", + "name": "kind" + }, + { + "type": "tuple[]", + "name": "swaps", + "components": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "uint256", + "name": "assetInIndex" + }, + { + "type": "uint256", + "name": "assetOutIndex" + }, + { + "type": "uint256", + "name": "amount" + }, + { + "type": "bytes", + "name": "userData" + } + ] + }, + { + "type": "address[]", + "name": "assets" + }, + { + "type": "tuple", + "name": "funds", + "components": [ + { + "type": "address", + "name": "sender" + }, + { + "type": "bool", + "name": "fromInternalBalance" + }, + { + "type": "address", + "name": "recipient" + }, + { + "type": "bool", + "name": "toInternalBalance" + } + ] + } + ], + "outputs": [ + { + "type": "int256[]", + "name": "" + } + ] + }, + { + "type": "function", + "name": "registerPool", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint8", + "name": "specialization" + } + ], + "outputs": [ + { + "type": "bytes32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "registerTokens", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "address[]", + "name": "tokens" + }, + { + "type": "address[]", + "name": "assetManagers" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setAuthorizer", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "newAuthorizer" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setPaused", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bool", + "name": "paused" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setRelayerApproval", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "sender" + }, + { + "type": "address", + "name": "relayer" + }, + { + "type": "bool", + "name": "approved" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "swap", + "constant": false, + "stateMutability": "payable", + "payable": true, + "inputs": [ + { + "type": "tuple", + "name": "singleSwap", + "components": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "uint8", + "name": "kind" + }, + { + "type": "address", + "name": "assetIn" + }, + { + "type": "address", + "name": "assetOut" + }, + { + "type": "uint256", + "name": "amount" + }, + { + "type": "bytes", + "name": "userData" + } + ] + }, + { + "type": "tuple", + "name": "funds", + "components": [ + { + "type": "address", + "name": "sender" + }, + { + "type": "bool", + "name": "fromInternalBalance" + }, + { + "type": "address", + "name": "recipient" + }, + { + "type": "bool", + "name": "toInternalBalance" + } + ] + }, + { + "type": "uint256", + "name": "limit" + }, + { + "type": "uint256", + "name": "deadline" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "amountCalculated" + } + ] + }, + { + "type": "receive", + "stateMutability": "payable" + } +] diff --git a/src/abi/balancer-vault.ts b/src/abi/balancer-vault.ts new file mode 100644 index 00000000..ca69514f --- /dev/null +++ b/src/abi/balancer-vault.ts @@ -0,0 +1,176 @@ +import * as ethers from 'ethers' +import {LogEvent, Func, ContractBase} from './abi.support' +import {ABI_JSON} from './balancer-vault.abi' + +export const abi = new ethers.Interface(ABI_JSON); + +export const events = { + AuthorizerChanged: new LogEvent<([newAuthorizer: string] & {newAuthorizer: string})>( + abi, '0x94b979b6831a51293e2641426f97747feed46f17779fed9cd18d1ecefcfe92ef' + ), + ExternalBalanceTransfer: new LogEvent<([token: string, sender: string, recipient: string, amount: bigint] & {token: string, sender: string, recipient: string, amount: bigint})>( + abi, '0x540a1a3f28340caec336c81d8d7b3df139ee5cdc1839a4f283d7ebb7eaae2d5c' + ), + FlashLoan: new LogEvent<([recipient: string, token: string, amount: bigint, feeAmount: bigint] & {recipient: string, token: string, amount: bigint, feeAmount: bigint})>( + abi, '0x0d7d75e01ab95780d3cd1c8ec0dd6c2ce19e3a20427eec8bf53283b6fb8e95f0' + ), + InternalBalanceChanged: new LogEvent<([user: string, token: string, delta: bigint] & {user: string, token: string, delta: bigint})>( + abi, '0x18e1ea4139e68413d7d08aa752e71568e36b2c5bf940893314c2c5b01eaa0c42' + ), + PausedStateChanged: new LogEvent<([paused: boolean] & {paused: boolean})>( + abi, '0x9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64' + ), + PoolBalanceChanged: new LogEvent<([poolId: string, liquidityProvider: string, tokens: Array, deltas: Array, protocolFeeAmounts: Array] & {poolId: string, liquidityProvider: string, tokens: Array, deltas: Array, protocolFeeAmounts: Array})>( + abi, '0xe5ce249087ce04f05a957192435400fd97868dba0e6a4b4c049abf8af80dae78' + ), + PoolBalanceManaged: new LogEvent<([poolId: string, assetManager: string, token: string, cashDelta: bigint, managedDelta: bigint] & {poolId: string, assetManager: string, token: string, cashDelta: bigint, managedDelta: bigint})>( + abi, '0x6edcaf6241105b4c94c2efdbf3a6b12458eb3d07be3a0e81d24b13c44045fe7a' + ), + PoolRegistered: new LogEvent<([poolId: string, poolAddress: string, specialization: number] & {poolId: string, poolAddress: string, specialization: number})>( + abi, '0x3c13bc30b8e878c53fd2a36b679409c073afd75950be43d8858768e956fbc20e' + ), + RelayerApprovalChanged: new LogEvent<([relayer: string, sender: string, approved: boolean] & {relayer: string, sender: string, approved: boolean})>( + abi, '0x46961fdb4502b646d5095fba7600486a8ac05041d55cdf0f16ed677180b5cad8' + ), + Swap: new LogEvent<([poolId: string, tokenIn: string, tokenOut: string, amountIn: bigint, amountOut: bigint] & {poolId: string, tokenIn: string, tokenOut: string, amountIn: bigint, amountOut: bigint})>( + abi, '0x2170c741c41531aec20e7c107c24eecfdd15e69c9bb0a8dd37b1840b9e0b207b' + ), + TokensDeregistered: new LogEvent<([poolId: string, tokens: Array] & {poolId: string, tokens: Array})>( + abi, '0x7dcdc6d02ef40c7c1a7046a011b058bd7f988fa14e20a66344f9d4e60657d610' + ), + TokensRegistered: new LogEvent<([poolId: string, tokens: Array, assetManagers: Array] & {poolId: string, tokens: Array, assetManagers: Array})>( + abi, '0xf5847d3f2197b16cdcd2098ec95d0905cd1abdaf415f07bb7cef2bba8ac5dec4' + ), +} + +export const functions = { + WETH: new Func<[], {}, string>( + abi, '0xad5c4648' + ), + batchSwap: new Func<[kind: number, swaps: Array<([poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string] & {poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string})>, assets: Array, funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean}), limits: Array, deadline: bigint], {kind: number, swaps: Array<([poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string] & {poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string})>, assets: Array, funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean}), limits: Array, deadline: bigint}, Array>( + abi, '0x945bcec9' + ), + deregisterTokens: new Func<[poolId: string, tokens: Array], {poolId: string, tokens: Array}, []>( + abi, '0x7d3aeb96' + ), + exitPool: new Func<[poolId: string, sender: string, recipient: string, request: ([assets: Array, minAmountsOut: Array, userData: string, toInternalBalance: boolean] & {assets: Array, minAmountsOut: Array, userData: string, toInternalBalance: boolean})], {poolId: string, sender: string, recipient: string, request: ([assets: Array, minAmountsOut: Array, userData: string, toInternalBalance: boolean] & {assets: Array, minAmountsOut: Array, userData: string, toInternalBalance: boolean})}, []>( + abi, '0x8bdb3913' + ), + flashLoan: new Func<[recipient: string, tokens: Array, amounts: Array, userData: string], {recipient: string, tokens: Array, amounts: Array, userData: string}, []>( + abi, '0x5c38449e' + ), + getActionId: new Func<[selector: string], {selector: string}, string>( + abi, '0x851c1bb3' + ), + getAuthorizer: new Func<[], {}, string>( + abi, '0xaaabadc5' + ), + getDomainSeparator: new Func<[], {}, string>( + abi, '0xed24911d' + ), + getInternalBalance: new Func<[user: string, tokens: Array], {user: string, tokens: Array}, Array>( + abi, '0x0f5a6efa' + ), + getNextNonce: new Func<[user: string], {user: string}, bigint>( + abi, '0x90193b7c' + ), + getPausedState: new Func<[], {}, ([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})>( + abi, '0x1c0de051' + ), + getPool: new Func<[poolId: string], {poolId: string}, [_: string, _: number]>( + abi, '0xf6c00927' + ), + getPoolTokenInfo: new Func<[poolId: string, token: string], {poolId: string, token: string}, ([cash: bigint, managed: bigint, lastChangeBlock: bigint, assetManager: string] & {cash: bigint, managed: bigint, lastChangeBlock: bigint, assetManager: string})>( + abi, '0xb05f8e48' + ), + getPoolTokens: new Func<[poolId: string], {poolId: string}, ([tokens: Array, balances: Array, lastChangeBlock: bigint] & {tokens: Array, balances: Array, lastChangeBlock: bigint})>( + abi, '0xf94d4668' + ), + getProtocolFeesCollector: new Func<[], {}, string>( + abi, '0xd2946c2b' + ), + hasApprovedRelayer: new Func<[user: string, relayer: string], {user: string, relayer: string}, boolean>( + abi, '0xfec90d72' + ), + joinPool: new Func<[poolId: string, sender: string, recipient: string, request: ([assets: Array, maxAmountsIn: Array, userData: string, fromInternalBalance: boolean] & {assets: Array, maxAmountsIn: Array, userData: string, fromInternalBalance: boolean})], {poolId: string, sender: string, recipient: string, request: ([assets: Array, maxAmountsIn: Array, userData: string, fromInternalBalance: boolean] & {assets: Array, maxAmountsIn: Array, userData: string, fromInternalBalance: boolean})}, []>( + abi, '0xb95cac28' + ), + managePoolBalance: new Func<[ops: Array<([kind: number, poolId: string, token: string, amount: bigint] & {kind: number, poolId: string, token: string, amount: bigint})>], {ops: Array<([kind: number, poolId: string, token: string, amount: bigint] & {kind: number, poolId: string, token: string, amount: bigint})>}, []>( + abi, '0xe6c46092' + ), + manageUserBalance: new Func<[ops: Array<([kind: number, asset: string, amount: bigint, sender: string, recipient: string] & {kind: number, asset: string, amount: bigint, sender: string, recipient: string})>], {ops: Array<([kind: number, asset: string, amount: bigint, sender: string, recipient: string] & {kind: number, asset: string, amount: bigint, sender: string, recipient: string})>}, []>( + abi, '0x0e8e3e84' + ), + queryBatchSwap: new Func<[kind: number, swaps: Array<([poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string] & {poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string})>, assets: Array, funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean})], {kind: number, swaps: Array<([poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string] & {poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string})>, assets: Array, funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean})}, Array>( + abi, '0xf84d066e' + ), + registerPool: new Func<[specialization: number], {specialization: number}, string>( + abi, '0x09b2760f' + ), + registerTokens: new Func<[poolId: string, tokens: Array, assetManagers: Array], {poolId: string, tokens: Array, assetManagers: Array}, []>( + abi, '0x66a9c7d2' + ), + setAuthorizer: new Func<[newAuthorizer: string], {newAuthorizer: string}, []>( + abi, '0x058a628f' + ), + setPaused: new Func<[paused: boolean], {paused: boolean}, []>( + abi, '0x16c38b3c' + ), + setRelayerApproval: new Func<[sender: string, relayer: string, approved: boolean], {sender: string, relayer: string, approved: boolean}, []>( + abi, '0xfa6e671d' + ), + swap: new Func<[singleSwap: ([poolId: string, kind: number, assetIn: string, assetOut: string, amount: bigint, userData: string] & {poolId: string, kind: number, assetIn: string, assetOut: string, amount: bigint, userData: string}), funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean}), limit: bigint, deadline: bigint], {singleSwap: ([poolId: string, kind: number, assetIn: string, assetOut: string, amount: bigint, userData: string] & {poolId: string, kind: number, assetIn: string, assetOut: string, amount: bigint, userData: string}), funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean}), limit: bigint, deadline: bigint}, bigint>( + abi, '0x52bbbe29' + ), +} + +export class Contract extends ContractBase { + + WETH(): Promise { + return this.eth_call(functions.WETH, []) + } + + getActionId(selector: string): Promise { + return this.eth_call(functions.getActionId, [selector]) + } + + getAuthorizer(): Promise { + return this.eth_call(functions.getAuthorizer, []) + } + + getDomainSeparator(): Promise { + return this.eth_call(functions.getDomainSeparator, []) + } + + getInternalBalance(user: string, tokens: Array): Promise> { + return this.eth_call(functions.getInternalBalance, [user, tokens]) + } + + getNextNonce(user: string): Promise { + return this.eth_call(functions.getNextNonce, [user]) + } + + getPausedState(): Promise<([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})> { + return this.eth_call(functions.getPausedState, []) + } + + getPool(poolId: string): Promise<[_: string, _: number]> { + return this.eth_call(functions.getPool, [poolId]) + } + + getPoolTokenInfo(poolId: string, token: string): Promise<([cash: bigint, managed: bigint, lastChangeBlock: bigint, assetManager: string] & {cash: bigint, managed: bigint, lastChangeBlock: bigint, assetManager: string})> { + return this.eth_call(functions.getPoolTokenInfo, [poolId, token]) + } + + getPoolTokens(poolId: string): Promise<([tokens: Array, balances: Array, lastChangeBlock: bigint] & {tokens: Array, balances: Array, lastChangeBlock: bigint})> { + return this.eth_call(functions.getPoolTokens, [poolId]) + } + + getProtocolFeesCollector(): Promise { + return this.eth_call(functions.getProtocolFeesCollector, []) + } + + hasApprovedRelayer(user: string, relayer: string): Promise { + return this.eth_call(functions.hasApprovedRelayer, [user, relayer]) + } +} diff --git a/src/abi/base-reward-pool-4626.abi.ts b/src/abi/base-reward-pool-4626.abi.ts new file mode 100644 index 00000000..e3a0693f --- /dev/null +++ b/src/abi/base-reward-pool-4626.abi.ts @@ -0,0 +1,1205 @@ +export const ABI_JSON = [ + { + "type": "constructor", + "stateMutability": "undefined", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "pid_" + }, + { + "type": "address", + "name": "stakingToken_" + }, + { + "type": "address", + "name": "rewardToken_" + }, + { + "type": "address", + "name": "operator_" + }, + { + "type": "address", + "name": "rewardManager_" + }, + { + "type": "address", + "name": "lptoken_" + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Approval", + "inputs": [ + { + "type": "address", + "name": "owner", + "indexed": true + }, + { + "type": "address", + "name": "spender", + "indexed": true + }, + { + "type": "uint256", + "name": "value", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Deposit", + "inputs": [ + { + "type": "address", + "name": "caller", + "indexed": true + }, + { + "type": "address", + "name": "owner", + "indexed": true + }, + { + "type": "uint256", + "name": "assets", + "indexed": false + }, + { + "type": "uint256", + "name": "shares", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "RewardAdded", + "inputs": [ + { + "type": "uint256", + "name": "reward", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "RewardPaid", + "inputs": [ + { + "type": "address", + "name": "user", + "indexed": true + }, + { + "type": "uint256", + "name": "reward", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Staked", + "inputs": [ + { + "type": "address", + "name": "user", + "indexed": true + }, + { + "type": "uint256", + "name": "amount", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Transfer", + "inputs": [ + { + "type": "address", + "name": "from", + "indexed": true + }, + { + "type": "address", + "name": "to", + "indexed": true + }, + { + "type": "uint256", + "name": "value", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Withdraw", + "inputs": [ + { + "type": "address", + "name": "caller", + "indexed": true + }, + { + "type": "address", + "name": "receiver", + "indexed": true + }, + { + "type": "address", + "name": "owner", + "indexed": true + }, + { + "type": "uint256", + "name": "assets", + "indexed": false + }, + { + "type": "uint256", + "name": "shares", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Withdrawn", + "inputs": [ + { + "type": "address", + "name": "user", + "indexed": true + }, + { + "type": "uint256", + "name": "amount", + "indexed": false + } + ] + }, + { + "type": "function", + "name": "addExtraReward", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_reward" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "allowance", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "owner" + }, + { + "type": "address", + "name": "spender" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "approve", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "spender" + }, + { + "type": "uint256", + "name": "amount" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "asset", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "balanceOf", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "clearExtraRewards", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "convertToAssets", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "shares" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "convertToShares", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "assets" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "currentRewards", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "decimals", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint8", + "name": "" + } + ] + }, + { + "type": "function", + "name": "deposit", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "assets" + }, + { + "type": "address", + "name": "receiver" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "duration", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "earned", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "extraRewards", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "" + } + ], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "extraRewardsLength", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getReward", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getReward", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_account" + }, + { + "type": "bool", + "name": "_claimExtras" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "historicalRewards", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "lastTimeRewardApplicable", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "lastUpdateTime", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "maxDeposit", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "maxMint", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "owner" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "maxRedeem", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "owner" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "maxWithdraw", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "owner" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "mint", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "shares" + }, + { + "type": "address", + "name": "receiver" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "name", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "string", + "name": "" + } + ] + }, + { + "type": "function", + "name": "newRewardRatio", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "operator", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "periodFinish", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "pid", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "previewDeposit", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "assets" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "previewMint", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "shares" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "previewRedeem", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "shares" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "previewWithdraw", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "assets" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "shares" + } + ] + }, + { + "type": "function", + "name": "processIdleRewards", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "queueNewRewards", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_rewards" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "queuedRewards", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "redeem", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "shares" + }, + { + "type": "address", + "name": "receiver" + }, + { + "type": "address", + "name": "owner" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "rewardManager", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "rewardPerToken", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "rewardPerTokenStored", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "rewardRate", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "rewardToken", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "rewards", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "stake", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_amount" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "stakeAll", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "stakeFor", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_for" + }, + { + "type": "uint256", + "name": "_amount" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "stakingToken", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "symbol", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "string", + "name": "" + } + ] + }, + { + "type": "function", + "name": "totalAssets", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "totalSupply", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "transfer", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + }, + { + "type": "uint256", + "name": "" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "transferFrom", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + }, + { + "type": "address", + "name": "" + }, + { + "type": "uint256", + "name": "" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "userRewardPerTokenPaid", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "withdraw", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "amount" + }, + { + "type": "bool", + "name": "claim" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "withdraw", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "assets" + }, + { + "type": "address", + "name": "receiver" + }, + { + "type": "address", + "name": "owner" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "withdrawAll", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bool", + "name": "claim" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "withdrawAllAndUnwrap", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bool", + "name": "claim" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "withdrawAndUnwrap", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "amount" + }, + { + "type": "bool", + "name": "claim" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + } +] diff --git a/src/abi/base-reward-pool-4626.ts b/src/abi/base-reward-pool-4626.ts new file mode 100644 index 00000000..7b8e5821 --- /dev/null +++ b/src/abi/base-reward-pool-4626.ts @@ -0,0 +1,371 @@ +import * as ethers from 'ethers' +import {LogEvent, Func, ContractBase} from './abi.support' +import {ABI_JSON} from './base-reward-pool-4626.abi' + +export const abi = new ethers.Interface(ABI_JSON); + +export const events = { + Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( + abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' + ), + Deposit: new LogEvent<([caller: string, owner: string, assets: bigint, shares: bigint] & {caller: string, owner: string, assets: bigint, shares: bigint})>( + abi, '0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7' + ), + RewardAdded: new LogEvent<([reward: bigint] & {reward: bigint})>( + abi, '0xde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d' + ), + RewardPaid: new LogEvent<([user: string, reward: bigint] & {user: string, reward: bigint})>( + abi, '0xe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486' + ), + Staked: new LogEvent<([user: string, amount: bigint] & {user: string, amount: bigint})>( + abi, '0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d' + ), + Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( + abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' + ), + Withdraw: new LogEvent<([caller: string, receiver: string, owner: string, assets: bigint, shares: bigint] & {caller: string, receiver: string, owner: string, assets: bigint, shares: bigint})>( + abi, '0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db' + ), + Withdrawn: new LogEvent<([user: string, amount: bigint] & {user: string, amount: bigint})>( + abi, '0x7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5' + ), +} + +export const functions = { + addExtraReward: new Func<[_reward: string], {_reward: string}, boolean>( + abi, '0x5e43c47b' + ), + allowance: new Func<[owner: string, spender: string], {owner: string, spender: string}, bigint>( + abi, '0xdd62ed3e' + ), + approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( + abi, '0x095ea7b3' + ), + asset: new Func<[], {}, string>( + abi, '0x38d52e0f' + ), + balanceOf: new Func<[account: string], {account: string}, bigint>( + abi, '0x70a08231' + ), + clearExtraRewards: new Func<[], {}, []>( + abi, '0x0569d388' + ), + convertToAssets: new Func<[shares: bigint], {shares: bigint}, bigint>( + abi, '0x07a2d13a' + ), + convertToShares: new Func<[assets: bigint], {assets: bigint}, bigint>( + abi, '0xc6e6f592' + ), + currentRewards: new Func<[], {}, bigint>( + abi, '0x901a7d53' + ), + decimals: new Func<[], {}, number>( + abi, '0x313ce567' + ), + deposit: new Func<[assets: bigint, receiver: string], {assets: bigint, receiver: string}, bigint>( + abi, '0x6e553f65' + ), + duration: new Func<[], {}, bigint>( + abi, '0x0fb5a6b4' + ), + earned: new Func<[account: string], {account: string}, bigint>( + abi, '0x008cc262' + ), + extraRewards: new Func<[_: bigint], {}, string>( + abi, '0x40c35446' + ), + extraRewardsLength: new Func<[], {}, bigint>( + abi, '0xd55a23f4' + ), + 'getReward()': new Func<[], {}, boolean>( + abi, '0x3d18b912' + ), + 'getReward(address,bool)': new Func<[_account: string, _claimExtras: boolean], {_account: string, _claimExtras: boolean}, boolean>( + abi, '0x7050ccd9' + ), + historicalRewards: new Func<[], {}, bigint>( + abi, '0x262d3d6d' + ), + lastTimeRewardApplicable: new Func<[], {}, bigint>( + abi, '0x80faa57d' + ), + lastUpdateTime: new Func<[], {}, bigint>( + abi, '0xc8f33c91' + ), + maxDeposit: new Func<[_: string], {}, bigint>( + abi, '0x402d267d' + ), + maxMint: new Func<[owner: string], {owner: string}, bigint>( + abi, '0xc63d75b6' + ), + maxRedeem: new Func<[owner: string], {owner: string}, bigint>( + abi, '0xd905777e' + ), + maxWithdraw: new Func<[owner: string], {owner: string}, bigint>( + abi, '0xce96cb77' + ), + mint: new Func<[shares: bigint, receiver: string], {shares: bigint, receiver: string}, bigint>( + abi, '0x94bf804d' + ), + name: new Func<[], {}, string>( + abi, '0x06fdde03' + ), + newRewardRatio: new Func<[], {}, bigint>( + abi, '0x6c8bcee8' + ), + operator: new Func<[], {}, string>( + abi, '0x570ca735' + ), + periodFinish: new Func<[], {}, bigint>( + abi, '0xebe2b12b' + ), + pid: new Func<[], {}, bigint>( + abi, '0xf1068454' + ), + previewDeposit: new Func<[assets: bigint], {assets: bigint}, bigint>( + abi, '0xef8b30f7' + ), + previewMint: new Func<[shares: bigint], {shares: bigint}, bigint>( + abi, '0xb3d7f6b9' + ), + previewRedeem: new Func<[shares: bigint], {shares: bigint}, bigint>( + abi, '0x4cdad506' + ), + previewWithdraw: new Func<[assets: bigint], {assets: bigint}, bigint>( + abi, '0x0a28a477' + ), + processIdleRewards: new Func<[], {}, []>( + abi, '0x3e8b83e3' + ), + queueNewRewards: new Func<[_rewards: bigint], {_rewards: bigint}, boolean>( + abi, '0x590a41f5' + ), + queuedRewards: new Func<[], {}, bigint>( + abi, '0x63d38c3b' + ), + redeem: new Func<[shares: bigint, receiver: string, owner: string], {shares: bigint, receiver: string, owner: string}, bigint>( + abi, '0xba087652' + ), + rewardManager: new Func<[], {}, string>( + abi, '0x0f4ef8a6' + ), + rewardPerToken: new Func<[], {}, bigint>( + abi, '0xcd3daf9d' + ), + rewardPerTokenStored: new Func<[], {}, bigint>( + abi, '0xdf136d65' + ), + rewardRate: new Func<[], {}, bigint>( + abi, '0x7b0a47ee' + ), + rewardToken: new Func<[], {}, string>( + abi, '0xf7c618c1' + ), + rewards: new Func<[_: string], {}, bigint>( + abi, '0x0700037d' + ), + stake: new Func<[_amount: bigint], {_amount: bigint}, boolean>( + abi, '0xa694fc3a' + ), + stakeAll: new Func<[], {}, boolean>( + abi, '0x8dcb4061' + ), + stakeFor: new Func<[_for: string, _amount: bigint], {_for: string, _amount: bigint}, boolean>( + abi, '0x2ee40908' + ), + stakingToken: new Func<[], {}, string>( + abi, '0x72f702f3' + ), + symbol: new Func<[], {}, string>( + abi, '0x95d89b41' + ), + totalAssets: new Func<[], {}, bigint>( + abi, '0x01e1d114' + ), + totalSupply: new Func<[], {}, bigint>( + abi, '0x18160ddd' + ), + transfer: new Func<[_: string, _: bigint], {}, boolean>( + abi, '0xa9059cbb' + ), + transferFrom: new Func<[_: string, _: string, _: bigint], {}, boolean>( + abi, '0x23b872dd' + ), + userRewardPerTokenPaid: new Func<[_: string], {}, bigint>( + abi, '0x8b876347' + ), + 'withdraw(uint256,bool)': new Func<[amount: bigint, claim: boolean], {amount: bigint, claim: boolean}, boolean>( + abi, '0x38d07436' + ), + 'withdraw(uint256,address,address)': new Func<[assets: bigint, receiver: string, owner: string], {assets: bigint, receiver: string, owner: string}, bigint>( + abi, '0xb460af94' + ), + withdrawAll: new Func<[claim: boolean], {claim: boolean}, []>( + abi, '0x1c1c6fe5' + ), + withdrawAllAndUnwrap: new Func<[claim: boolean], {claim: boolean}, []>( + abi, '0x49f039a2' + ), + withdrawAndUnwrap: new Func<[amount: bigint, claim: boolean], {amount: bigint, claim: boolean}, boolean>( + abi, '0xc32e7202' + ), +} + +export class Contract extends ContractBase { + + allowance(owner: string, spender: string): Promise { + return this.eth_call(functions.allowance, [owner, spender]) + } + + asset(): Promise { + return this.eth_call(functions.asset, []) + } + + balanceOf(account: string): Promise { + return this.eth_call(functions.balanceOf, [account]) + } + + convertToAssets(shares: bigint): Promise { + return this.eth_call(functions.convertToAssets, [shares]) + } + + convertToShares(assets: bigint): Promise { + return this.eth_call(functions.convertToShares, [assets]) + } + + currentRewards(): Promise { + return this.eth_call(functions.currentRewards, []) + } + + decimals(): Promise { + return this.eth_call(functions.decimals, []) + } + + duration(): Promise { + return this.eth_call(functions.duration, []) + } + + earned(account: string): Promise { + return this.eth_call(functions.earned, [account]) + } + + extraRewards(arg0: bigint): Promise { + return this.eth_call(functions.extraRewards, [arg0]) + } + + extraRewardsLength(): Promise { + return this.eth_call(functions.extraRewardsLength, []) + } + + historicalRewards(): Promise { + return this.eth_call(functions.historicalRewards, []) + } + + lastTimeRewardApplicable(): Promise { + return this.eth_call(functions.lastTimeRewardApplicable, []) + } + + lastUpdateTime(): Promise { + return this.eth_call(functions.lastUpdateTime, []) + } + + maxDeposit(arg0: string): Promise { + return this.eth_call(functions.maxDeposit, [arg0]) + } + + maxMint(owner: string): Promise { + return this.eth_call(functions.maxMint, [owner]) + } + + maxRedeem(owner: string): Promise { + return this.eth_call(functions.maxRedeem, [owner]) + } + + maxWithdraw(owner: string): Promise { + return this.eth_call(functions.maxWithdraw, [owner]) + } + + name(): Promise { + return this.eth_call(functions.name, []) + } + + newRewardRatio(): Promise { + return this.eth_call(functions.newRewardRatio, []) + } + + operator(): Promise { + return this.eth_call(functions.operator, []) + } + + periodFinish(): Promise { + return this.eth_call(functions.periodFinish, []) + } + + pid(): Promise { + return this.eth_call(functions.pid, []) + } + + previewDeposit(assets: bigint): Promise { + return this.eth_call(functions.previewDeposit, [assets]) + } + + previewMint(shares: bigint): Promise { + return this.eth_call(functions.previewMint, [shares]) + } + + previewRedeem(shares: bigint): Promise { + return this.eth_call(functions.previewRedeem, [shares]) + } + + previewWithdraw(assets: bigint): Promise { + return this.eth_call(functions.previewWithdraw, [assets]) + } + + queuedRewards(): Promise { + return this.eth_call(functions.queuedRewards, []) + } + + rewardManager(): Promise { + return this.eth_call(functions.rewardManager, []) + } + + rewardPerToken(): Promise { + return this.eth_call(functions.rewardPerToken, []) + } + + rewardPerTokenStored(): Promise { + return this.eth_call(functions.rewardPerTokenStored, []) + } + + rewardRate(): Promise { + return this.eth_call(functions.rewardRate, []) + } + + rewardToken(): Promise { + return this.eth_call(functions.rewardToken, []) + } + + rewards(arg0: string): Promise { + return this.eth_call(functions.rewards, [arg0]) + } + + stakingToken(): Promise { + return this.eth_call(functions.stakingToken, []) + } + + symbol(): Promise { + return this.eth_call(functions.symbol, []) + } + + totalAssets(): Promise { + return this.eth_call(functions.totalAssets, []) + } + + totalSupply(): Promise { + return this.eth_call(functions.totalSupply, []) + } + + userRewardPerTokenPaid(arg0: string): Promise { + return this.eth_call(functions.userRewardPerTokenPaid, [arg0]) + } +} diff --git a/src/abi/meta-stable-pool.abi.ts b/src/abi/meta-stable-pool.abi.ts new file mode 100644 index 00000000..617297b0 --- /dev/null +++ b/src/abi/meta-stable-pool.abi.ts @@ -0,0 +1,1327 @@ +export const ABI_JSON = [ + { + "type": "constructor", + "stateMutability": "undefined", + "payable": false, + "inputs": [ + { + "type": "tuple", + "name": "params", + "components": [ + { + "type": "address", + "name": "vault" + }, + { + "type": "string", + "name": "name" + }, + { + "type": "string", + "name": "symbol" + }, + { + "type": "address[]", + "name": "tokens" + }, + { + "type": "address[]", + "name": "rateProviders" + }, + { + "type": "uint256[]", + "name": "priceRateCacheDuration" + }, + { + "type": "uint256", + "name": "amplificationParameter" + }, + { + "type": "uint256", + "name": "swapFeePercentage" + }, + { + "type": "uint256", + "name": "pauseWindowDuration" + }, + { + "type": "uint256", + "name": "bufferPeriodDuration" + }, + { + "type": "bool", + "name": "oracleEnabled" + }, + { + "type": "address", + "name": "owner" + } + ] + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "AmpUpdateStarted", + "inputs": [ + { + "type": "uint256", + "name": "startValue", + "indexed": false + }, + { + "type": "uint256", + "name": "endValue", + "indexed": false + }, + { + "type": "uint256", + "name": "startTime", + "indexed": false + }, + { + "type": "uint256", + "name": "endTime", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "AmpUpdateStopped", + "inputs": [ + { + "type": "uint256", + "name": "currentValue", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Approval", + "inputs": [ + { + "type": "address", + "name": "owner", + "indexed": true + }, + { + "type": "address", + "name": "spender", + "indexed": true + }, + { + "type": "uint256", + "name": "value", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "OracleEnabledChanged", + "inputs": [ + { + "type": "bool", + "name": "enabled", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PausedStateChanged", + "inputs": [ + { + "type": "bool", + "name": "paused", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PriceRateCacheUpdated", + "inputs": [ + { + "type": "address", + "name": "token", + "indexed": true + }, + { + "type": "uint256", + "name": "rate", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PriceRateProviderSet", + "inputs": [ + { + "type": "address", + "name": "token", + "indexed": true + }, + { + "type": "address", + "name": "provider", + "indexed": true + }, + { + "type": "uint256", + "name": "cacheDuration", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "SwapFeePercentageChanged", + "inputs": [ + { + "type": "uint256", + "name": "swapFeePercentage", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Transfer", + "inputs": [ + { + "type": "address", + "name": "from", + "indexed": true + }, + { + "type": "address", + "name": "to", + "indexed": true + }, + { + "type": "uint256", + "name": "value", + "indexed": false + } + ] + }, + { + "type": "function", + "name": "DOMAIN_SEPARATOR", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bytes32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "allowance", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "owner" + }, + { + "type": "address", + "name": "spender" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "approve", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "spender" + }, + { + "type": "uint256", + "name": "amount" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "balanceOf", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "decimals", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint8", + "name": "" + } + ] + }, + { + "type": "function", + "name": "decreaseAllowance", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "spender" + }, + { + "type": "uint256", + "name": "amount" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "enableOracle", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "getActionId", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "bytes4", + "name": "selector" + } + ], + "outputs": [ + { + "type": "bytes32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getAmplificationParameter", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "value" + }, + { + "type": "bool", + "name": "isUpdating" + }, + { + "type": "uint256", + "name": "precision" + } + ] + }, + { + "type": "function", + "name": "getAuthorizer", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getLargestSafeQueryWindow", + "constant": true, + "stateMutability": "pure", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getLastInvariant", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "lastInvariant" + }, + { + "type": "uint256", + "name": "lastInvariantAmp" + } + ] + }, + { + "type": "function", + "name": "getLatest", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint8", + "name": "variable" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getOracleMiscData", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "int256", + "name": "logInvariant" + }, + { + "type": "int256", + "name": "logTotalSupply" + }, + { + "type": "uint256", + "name": "oracleSampleCreationTimestamp" + }, + { + "type": "uint256", + "name": "oracleIndex" + }, + { + "type": "bool", + "name": "oracleEnabled" + } + ] + }, + { + "type": "function", + "name": "getOwner", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getPastAccumulators", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "tuple[]", + "name": "queries", + "components": [ + { + "type": "uint8", + "name": "variable" + }, + { + "type": "uint256", + "name": "ago" + } + ] + } + ], + "outputs": [ + { + "type": "int256[]", + "name": "results" + } + ] + }, + { + "type": "function", + "name": "getPausedState", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "paused" + }, + { + "type": "uint256", + "name": "pauseWindowEndTime" + }, + { + "type": "uint256", + "name": "bufferPeriodEndTime" + } + ] + }, + { + "type": "function", + "name": "getPoolId", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bytes32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getPriceRateCache", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "token" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "rate" + }, + { + "type": "uint256", + "name": "duration" + }, + { + "type": "uint256", + "name": "expires" + } + ] + }, + { + "type": "function", + "name": "getRate", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getRateProviders", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address[]", + "name": "providers" + } + ] + }, + { + "type": "function", + "name": "getSample", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "index" + } + ], + "outputs": [ + { + "type": "int256", + "name": "logPairPrice" + }, + { + "type": "int256", + "name": "accLogPairPrice" + }, + { + "type": "int256", + "name": "logBptPrice" + }, + { + "type": "int256", + "name": "accLogBptPrice" + }, + { + "type": "int256", + "name": "logInvariant" + }, + { + "type": "int256", + "name": "accLogInvariant" + }, + { + "type": "uint256", + "name": "timestamp" + } + ] + }, + { + "type": "function", + "name": "getScalingFactors", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256[]", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getSwapFeePercentage", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getTimeWeightedAverage", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "tuple[]", + "name": "queries", + "components": [ + { + "type": "uint8", + "name": "variable" + }, + { + "type": "uint256", + "name": "secs" + }, + { + "type": "uint256", + "name": "ago" + } + ] + } + ], + "outputs": [ + { + "type": "uint256[]", + "name": "results" + } + ] + }, + { + "type": "function", + "name": "getTotalSamples", + "constant": true, + "stateMutability": "pure", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getVault", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "increaseAllowance", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "spender" + }, + { + "type": "uint256", + "name": "addedValue" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "name", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "string", + "name": "" + } + ] + }, + { + "type": "function", + "name": "nonces", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "owner" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "onExitPool", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "address", + "name": "sender" + }, + { + "type": "address", + "name": "recipient" + }, + { + "type": "uint256[]", + "name": "balances" + }, + { + "type": "uint256", + "name": "lastChangeBlock" + }, + { + "type": "uint256", + "name": "protocolSwapFeePercentage" + }, + { + "type": "bytes", + "name": "userData" + } + ], + "outputs": [ + { + "type": "uint256[]", + "name": "amountsOut" + }, + { + "type": "uint256[]", + "name": "dueProtocolFeeAmounts" + } + ] + }, + { + "type": "function", + "name": "onJoinPool", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "address", + "name": "sender" + }, + { + "type": "address", + "name": "recipient" + }, + { + "type": "uint256[]", + "name": "balances" + }, + { + "type": "uint256", + "name": "lastChangeBlock" + }, + { + "type": "uint256", + "name": "protocolSwapFeePercentage" + }, + { + "type": "bytes", + "name": "userData" + } + ], + "outputs": [ + { + "type": "uint256[]", + "name": "amountsIn" + }, + { + "type": "uint256[]", + "name": "dueProtocolFeeAmounts" + } + ] + }, + { + "type": "function", + "name": "onSwap", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "tuple", + "name": "request", + "components": [ + { + "type": "uint8", + "name": "kind" + }, + { + "type": "address", + "name": "tokenIn" + }, + { + "type": "address", + "name": "tokenOut" + }, + { + "type": "uint256", + "name": "amount" + }, + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "uint256", + "name": "lastChangeBlock" + }, + { + "type": "address", + "name": "from" + }, + { + "type": "address", + "name": "to" + }, + { + "type": "bytes", + "name": "userData" + } + ] + }, + { + "type": "uint256[]", + "name": "balances" + }, + { + "type": "uint256", + "name": "indexIn" + }, + { + "type": "uint256", + "name": "indexOut" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "onSwap", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "tuple", + "name": "request", + "components": [ + { + "type": "uint8", + "name": "kind" + }, + { + "type": "address", + "name": "tokenIn" + }, + { + "type": "address", + "name": "tokenOut" + }, + { + "type": "uint256", + "name": "amount" + }, + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "uint256", + "name": "lastChangeBlock" + }, + { + "type": "address", + "name": "from" + }, + { + "type": "address", + "name": "to" + }, + { + "type": "bytes", + "name": "userData" + } + ] + }, + { + "type": "uint256", + "name": "balanceTokenIn" + }, + { + "type": "uint256", + "name": "balanceTokenOut" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "permit", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "owner" + }, + { + "type": "address", + "name": "spender" + }, + { + "type": "uint256", + "name": "value" + }, + { + "type": "uint256", + "name": "deadline" + }, + { + "type": "uint8", + "name": "v" + }, + { + "type": "bytes32", + "name": "r" + }, + { + "type": "bytes32", + "name": "s" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "queryExit", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "address", + "name": "sender" + }, + { + "type": "address", + "name": "recipient" + }, + { + "type": "uint256[]", + "name": "balances" + }, + { + "type": "uint256", + "name": "lastChangeBlock" + }, + { + "type": "uint256", + "name": "protocolSwapFeePercentage" + }, + { + "type": "bytes", + "name": "userData" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "bptIn" + }, + { + "type": "uint256[]", + "name": "amountsOut" + } + ] + }, + { + "type": "function", + "name": "queryJoin", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bytes32", + "name": "poolId" + }, + { + "type": "address", + "name": "sender" + }, + { + "type": "address", + "name": "recipient" + }, + { + "type": "uint256[]", + "name": "balances" + }, + { + "type": "uint256", + "name": "lastChangeBlock" + }, + { + "type": "uint256", + "name": "protocolSwapFeePercentage" + }, + { + "type": "bytes", + "name": "userData" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "bptOut" + }, + { + "type": "uint256[]", + "name": "amountsIn" + } + ] + }, + { + "type": "function", + "name": "setAssetManagerPoolConfig", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "token" + }, + { + "type": "bytes", + "name": "poolConfig" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setPaused", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "bool", + "name": "paused" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setPriceRateCacheDuration", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "token" + }, + { + "type": "uint256", + "name": "duration" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setSwapFeePercentage", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "swapFeePercentage" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "startAmplificationParameterUpdate", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "rawEndValue" + }, + { + "type": "uint256", + "name": "endTime" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "stopAmplificationParameterUpdate", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "symbol", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "string", + "name": "" + } + ] + }, + { + "type": "function", + "name": "totalSupply", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "transfer", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "recipient" + }, + { + "type": "uint256", + "name": "amount" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "transferFrom", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "sender" + }, + { + "type": "address", + "name": "recipient" + }, + { + "type": "uint256", + "name": "amount" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "updatePriceRateCache", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "token" + } + ], + "outputs": [] + } +] diff --git a/src/abi/meta-stable-pool.ts b/src/abi/meta-stable-pool.ts new file mode 100644 index 00000000..7a5c1edf --- /dev/null +++ b/src/abi/meta-stable-pool.ts @@ -0,0 +1,297 @@ +import * as ethers from 'ethers' +import {LogEvent, Func, ContractBase} from './abi.support' +import {ABI_JSON} from './meta-stable-pool.abi' + +export const abi = new ethers.Interface(ABI_JSON); + +export const events = { + AmpUpdateStarted: new LogEvent<([startValue: bigint, endValue: bigint, startTime: bigint, endTime: bigint] & {startValue: bigint, endValue: bigint, startTime: bigint, endTime: bigint})>( + abi, '0x1835882ee7a34ac194f717a35e09bb1d24c82a3b9d854ab6c9749525b714cdf2' + ), + AmpUpdateStopped: new LogEvent<([currentValue: bigint] & {currentValue: bigint})>( + abi, '0xa0d01593e47e69d07e0ccd87bece09411e07dd1ed40ca8f2e7af2976542a0233' + ), + Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( + abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' + ), + OracleEnabledChanged: new LogEvent<([enabled: boolean] & {enabled: boolean})>( + abi, '0x3e350b41e86a8e10f804ade6d35340d620be35569cc75ac943e8bb14ab80ead1' + ), + PausedStateChanged: new LogEvent<([paused: boolean] & {paused: boolean})>( + abi, '0x9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64' + ), + PriceRateCacheUpdated: new LogEvent<([token: string, rate: bigint] & {token: string, rate: bigint})>( + abi, '0xc1a224b14823b63c7711127f125fbf592434682f38881ebb61408747a303affc' + ), + PriceRateProviderSet: new LogEvent<([token: string, provider: string, cacheDuration: bigint] & {token: string, provider: string, cacheDuration: bigint})>( + abi, '0xca6c2c5b6b44b5f3f0c08f0e28e5b6deda1cb38c3fe1113e8031d926c1e8c6d0' + ), + SwapFeePercentageChanged: new LogEvent<([swapFeePercentage: bigint] & {swapFeePercentage: bigint})>( + abi, '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' + ), + Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( + abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' + ), +} + +export const functions = { + DOMAIN_SEPARATOR: new Func<[], {}, string>( + abi, '0x3644e515' + ), + allowance: new Func<[owner: string, spender: string], {owner: string, spender: string}, bigint>( + abi, '0xdd62ed3e' + ), + approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( + abi, '0x095ea7b3' + ), + balanceOf: new Func<[account: string], {account: string}, bigint>( + abi, '0x70a08231' + ), + decimals: new Func<[], {}, number>( + abi, '0x313ce567' + ), + decreaseAllowance: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( + abi, '0xa457c2d7' + ), + enableOracle: new Func<[], {}, []>( + abi, '0x292c914a' + ), + getActionId: new Func<[selector: string], {selector: string}, string>( + abi, '0x851c1bb3' + ), + getAmplificationParameter: new Func<[], {}, ([value: bigint, isUpdating: boolean, precision: bigint] & {value: bigint, isUpdating: boolean, precision: bigint})>( + abi, '0x6daccffa' + ), + getAuthorizer: new Func<[], {}, string>( + abi, '0xaaabadc5' + ), + getLargestSafeQueryWindow: new Func<[], {}, bigint>( + abi, '0xffd088eb' + ), + getLastInvariant: new Func<[], {}, ([lastInvariant: bigint, lastInvariantAmp: bigint] & {lastInvariant: bigint, lastInvariantAmp: bigint})>( + abi, '0x9b02cdde' + ), + getLatest: new Func<[variable: number], {variable: number}, bigint>( + abi, '0xb10be739' + ), + getOracleMiscData: new Func<[], {}, ([logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean] & {logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean})>( + abi, '0x1ed4eddc' + ), + getOwner: new Func<[], {}, string>( + abi, '0x893d20e8' + ), + getPastAccumulators: new Func<[queries: Array<([variable: number, ago: bigint] & {variable: number, ago: bigint})>], {queries: Array<([variable: number, ago: bigint] & {variable: number, ago: bigint})>}, Array>( + abi, '0x6b843239' + ), + getPausedState: new Func<[], {}, ([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})>( + abi, '0x1c0de051' + ), + getPoolId: new Func<[], {}, string>( + abi, '0x38fff2d0' + ), + getPriceRateCache: new Func<[token: string], {token: string}, ([rate: bigint, duration: bigint, expires: bigint] & {rate: bigint, duration: bigint, expires: bigint})>( + abi, '0xb867ee5a' + ), + getRate: new Func<[], {}, bigint>( + abi, '0x679aefce' + ), + getRateProviders: new Func<[], {}, Array>( + abi, '0x238a2d59' + ), + getSample: new Func<[index: bigint], {index: bigint}, ([logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint] & {logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint})>( + abi, '0x60d1507c' + ), + getScalingFactors: new Func<[], {}, Array>( + abi, '0x1dd746ea' + ), + getSwapFeePercentage: new Func<[], {}, bigint>( + abi, '0x55c67628' + ), + getTimeWeightedAverage: new Func<[queries: Array<([variable: number, secs: bigint, ago: bigint] & {variable: number, secs: bigint, ago: bigint})>], {queries: Array<([variable: number, secs: bigint, ago: bigint] & {variable: number, secs: bigint, ago: bigint})>}, Array>( + abi, '0x1dccd830' + ), + getTotalSamples: new Func<[], {}, bigint>( + abi, '0xb48b5b40' + ), + getVault: new Func<[], {}, string>( + abi, '0x8d928af8' + ), + increaseAllowance: new Func<[spender: string, addedValue: bigint], {spender: string, addedValue: bigint}, boolean>( + abi, '0x39509351' + ), + name: new Func<[], {}, string>( + abi, '0x06fdde03' + ), + nonces: new Func<[owner: string], {owner: string}, bigint>( + abi, '0x7ecebe00' + ), + onExitPool: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([amountsOut: Array, dueProtocolFeeAmounts: Array] & {amountsOut: Array, dueProtocolFeeAmounts: Array})>( + abi, '0x74f3b009' + ), + onJoinPool: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([amountsIn: Array, dueProtocolFeeAmounts: Array] & {amountsIn: Array, dueProtocolFeeAmounts: Array})>( + abi, '0xd5c096c4' + ), + 'onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256[],uint256,uint256)': new Func<[request: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balances: Array, indexIn: bigint, indexOut: bigint], {request: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balances: Array, indexIn: bigint, indexOut: bigint}, bigint>( + abi, '0x01ec954a' + ), + 'onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256,uint256)': new Func<[request: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balanceTokenIn: bigint, balanceTokenOut: bigint], {request: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balanceTokenIn: bigint, balanceTokenOut: bigint}, bigint>( + abi, '0x9d2c110c' + ), + permit: new Func<[owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string], {owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string}, []>( + abi, '0xd505accf' + ), + queryExit: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([bptIn: bigint, amountsOut: Array] & {bptIn: bigint, amountsOut: Array})>( + abi, '0x6028bfd4' + ), + queryJoin: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([bptOut: bigint, amountsIn: Array] & {bptOut: bigint, amountsIn: Array})>( + abi, '0x87ec6817' + ), + setAssetManagerPoolConfig: new Func<[token: string, poolConfig: string], {token: string, poolConfig: string}, []>( + abi, '0x50dd6ed9' + ), + setPaused: new Func<[paused: boolean], {paused: boolean}, []>( + abi, '0x16c38b3c' + ), + setPriceRateCacheDuration: new Func<[token: string, duration: bigint], {token: string, duration: bigint}, []>( + abi, '0xb7710251' + ), + setSwapFeePercentage: new Func<[swapFeePercentage: bigint], {swapFeePercentage: bigint}, []>( + abi, '0x38e9922e' + ), + startAmplificationParameterUpdate: new Func<[rawEndValue: bigint, endTime: bigint], {rawEndValue: bigint, endTime: bigint}, []>( + abi, '0x2f1a0bc9' + ), + stopAmplificationParameterUpdate: new Func<[], {}, []>( + abi, '0xeb0f24d6' + ), + symbol: new Func<[], {}, string>( + abi, '0x95d89b41' + ), + totalSupply: new Func<[], {}, bigint>( + abi, '0x18160ddd' + ), + transfer: new Func<[recipient: string, amount: bigint], {recipient: string, amount: bigint}, boolean>( + abi, '0xa9059cbb' + ), + transferFrom: new Func<[sender: string, recipient: string, amount: bigint], {sender: string, recipient: string, amount: bigint}, boolean>( + abi, '0x23b872dd' + ), + updatePriceRateCache: new Func<[token: string], {token: string}, []>( + abi, '0xa0daaed0' + ), +} + +export class Contract extends ContractBase { + + DOMAIN_SEPARATOR(): Promise { + return this.eth_call(functions.DOMAIN_SEPARATOR, []) + } + + allowance(owner: string, spender: string): Promise { + return this.eth_call(functions.allowance, [owner, spender]) + } + + balanceOf(account: string): Promise { + return this.eth_call(functions.balanceOf, [account]) + } + + decimals(): Promise { + return this.eth_call(functions.decimals, []) + } + + getActionId(selector: string): Promise { + return this.eth_call(functions.getActionId, [selector]) + } + + getAmplificationParameter(): Promise<([value: bigint, isUpdating: boolean, precision: bigint] & {value: bigint, isUpdating: boolean, precision: bigint})> { + return this.eth_call(functions.getAmplificationParameter, []) + } + + getAuthorizer(): Promise { + return this.eth_call(functions.getAuthorizer, []) + } + + getLargestSafeQueryWindow(): Promise { + return this.eth_call(functions.getLargestSafeQueryWindow, []) + } + + getLastInvariant(): Promise<([lastInvariant: bigint, lastInvariantAmp: bigint] & {lastInvariant: bigint, lastInvariantAmp: bigint})> { + return this.eth_call(functions.getLastInvariant, []) + } + + getLatest(variable: number): Promise { + return this.eth_call(functions.getLatest, [variable]) + } + + getOracleMiscData(): Promise<([logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean] & {logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean})> { + return this.eth_call(functions.getOracleMiscData, []) + } + + getOwner(): Promise { + return this.eth_call(functions.getOwner, []) + } + + getPastAccumulators(queries: Array<([variable: number, ago: bigint] & {variable: number, ago: bigint})>): Promise> { + return this.eth_call(functions.getPastAccumulators, [queries]) + } + + getPausedState(): Promise<([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})> { + return this.eth_call(functions.getPausedState, []) + } + + getPoolId(): Promise { + return this.eth_call(functions.getPoolId, []) + } + + getPriceRateCache(token: string): Promise<([rate: bigint, duration: bigint, expires: bigint] & {rate: bigint, duration: bigint, expires: bigint})> { + return this.eth_call(functions.getPriceRateCache, [token]) + } + + getRate(): Promise { + return this.eth_call(functions.getRate, []) + } + + getRateProviders(): Promise> { + return this.eth_call(functions.getRateProviders, []) + } + + getSample(index: bigint): Promise<([logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint] & {logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint})> { + return this.eth_call(functions.getSample, [index]) + } + + getScalingFactors(): Promise> { + return this.eth_call(functions.getScalingFactors, []) + } + + getSwapFeePercentage(): Promise { + return this.eth_call(functions.getSwapFeePercentage, []) + } + + getTimeWeightedAverage(queries: Array<([variable: number, secs: bigint, ago: bigint] & {variable: number, secs: bigint, ago: bigint})>): Promise> { + return this.eth_call(functions.getTimeWeightedAverage, [queries]) + } + + getTotalSamples(): Promise { + return this.eth_call(functions.getTotalSamples, []) + } + + getVault(): Promise { + return this.eth_call(functions.getVault, []) + } + + name(): Promise { + return this.eth_call(functions.name, []) + } + + nonces(owner: string): Promise { + return this.eth_call(functions.nonces, [owner]) + } + + symbol(): Promise { + return this.eth_call(functions.symbol, []) + } + + totalSupply(): Promise { + return this.eth_call(functions.totalSupply, []) + } +} diff --git a/src/abi/origin-lens.abi.ts b/src/abi/origin-lens.abi.ts new file mode 100644 index 00000000..8cadbf26 --- /dev/null +++ b/src/abi/origin-lens.abi.ts @@ -0,0 +1,408 @@ +export const ABI_JSON = [ + { + "type": "constructor", + "stateMutability": "undefined", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_oToken" + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "GovernorshipTransferred", + "inputs": [ + { + "type": "address", + "name": "previousGovernor", + "indexed": true + }, + { + "type": "address", + "name": "newGovernor", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PendingGovernorshipTransfer", + "inputs": [ + { + "type": "address", + "name": "previousGovernor", + "indexed": true + }, + { + "type": "address", + "name": "newGovernor", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "StrategistUpdated", + "inputs": [ + { + "type": "address", + "name": "_address", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "StrategyTypeChanged", + "inputs": [ + { + "type": "address", + "name": "strategyAddr", + "indexed": true + }, + { + "type": "uint8", + "name": "kind", + "indexed": false + } + ] + }, + { + "type": "function", + "name": "ETH_ADDR", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "WETH_ADDR", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "assetCount", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "assets", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "" + } + ], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "cacheStrategies", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "claimGovernance", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "curvePoolCoinCount", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getStrategyAssetBalance", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "strategyAddr" + }, + { + "type": "address", + "name": "asset" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "balance" + } + ] + }, + { + "type": "function", + "name": "getStrategyBalances", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "strategyAddr" + } + ], + "outputs": [ + { + "type": "address[]", + "name": "supportedAssets" + }, + { + "type": "uint256[]", + "name": "assetBalances" + } + ] + }, + { + "type": "function", + "name": "governor", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "initialize", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_strategistAddr" + }, + { + "type": "address[]", + "name": "_strategies" + }, + { + "type": "uint8[]", + "name": "strategyKinds" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "isGovernor", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "oToken", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "oracleRouter", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "setStrategistAddr", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_address" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setStrategyKind", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "strategy" + }, + { + "type": "uint8", + "name": "kind" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "strategies", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "" + } + ], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "strategistAddr", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "strategyConfig", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + } + ], + "outputs": [ + { + "type": "bool", + "name": "supported" + }, + { + "type": "uint8", + "name": "kind" + } + ] + }, + { + "type": "function", + "name": "transferGovernance", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_newGovernor" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "vault", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + } +] diff --git a/src/abi/origin-lens.ts b/src/abi/origin-lens.ts new file mode 100644 index 00000000..55cbcda4 --- /dev/null +++ b/src/abi/origin-lens.ts @@ -0,0 +1,149 @@ +import * as ethers from 'ethers' +import {LogEvent, Func, ContractBase} from './abi.support' +import {ABI_JSON} from './origin-lens.abi' + +export const abi = new ethers.Interface(ABI_JSON); + +export const events = { + GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( + abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' + ), + PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( + abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' + ), + StrategistUpdated: new LogEvent<([_address: string] & {_address: string})>( + abi, '0x869e0abd13cc3a975de7b93be3df1cb2255c802b1cead85963cc79d99f131bee' + ), + StrategyTypeChanged: new LogEvent<([strategyAddr: string, kind: number] & {strategyAddr: string, kind: number})>( + abi, '0x7fab7e3127613cf3a72eafc4bfcb3e179d35d1c69e1d0217c1dd029dc23690bd' + ), +} + +export const functions = { + ETH_ADDR: new Func<[], {}, string>( + abi, '0x7753f47b' + ), + WETH_ADDR: new Func<[], {}, string>( + abi, '0x82dfc5f7' + ), + assetCount: new Func<[], {}, bigint>( + abi, '0xeafe7a74' + ), + assets: new Func<[_: bigint], {}, string>( + abi, '0xcf35bdd0' + ), + cacheStrategies: new Func<[], {}, []>( + abi, '0x44f98829' + ), + claimGovernance: new Func<[], {}, []>( + abi, '0x5d36b190' + ), + curvePoolCoinCount: new Func<[_: string], {}, bigint>( + abi, '0xdd6640c3' + ), + getStrategyAssetBalance: new Func<[strategyAddr: string, asset: string], {strategyAddr: string, asset: string}, bigint>( + abi, '0x3a1d532b' + ), + getStrategyBalances: new Func<[strategyAddr: string], {strategyAddr: string}, ([supportedAssets: Array, assetBalances: Array] & {supportedAssets: Array, assetBalances: Array})>( + abi, '0xe50bf68f' + ), + governor: new Func<[], {}, string>( + abi, '0x0c340a24' + ), + initialize: new Func<[_strategistAddr: string, _strategies: Array, strategyKinds: Array], {_strategistAddr: string, _strategies: Array, strategyKinds: Array}, []>( + abi, '0xe336f8c5' + ), + isGovernor: new Func<[], {}, boolean>( + abi, '0xc7af3352' + ), + oToken: new Func<[], {}, string>( + abi, '0x1a32aad6' + ), + oracleRouter: new Func<[], {}, string>( + abi, '0x55a29e91' + ), + setStrategistAddr: new Func<[_address: string], {_address: string}, []>( + abi, '0x773540b3' + ), + setStrategyKind: new Func<[strategy: string, kind: number], {strategy: string, kind: number}, []>( + abi, '0xaefc61e0' + ), + strategies: new Func<[_: bigint], {}, string>( + abi, '0xd574ea3d' + ), + strategistAddr: new Func<[], {}, string>( + abi, '0x570d8e1d' + ), + strategyConfig: new Func<[_: string], {}, ([supported: boolean, kind: number] & {supported: boolean, kind: number})>( + abi, '0x91450e63' + ), + transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( + abi, '0xd38bfff4' + ), + vault: new Func<[], {}, string>( + abi, '0xfbfa77cf' + ), +} + +export class Contract extends ContractBase { + + ETH_ADDR(): Promise { + return this.eth_call(functions.ETH_ADDR, []) + } + + WETH_ADDR(): Promise { + return this.eth_call(functions.WETH_ADDR, []) + } + + assetCount(): Promise { + return this.eth_call(functions.assetCount, []) + } + + assets(arg0: bigint): Promise { + return this.eth_call(functions.assets, [arg0]) + } + + curvePoolCoinCount(arg0: string): Promise { + return this.eth_call(functions.curvePoolCoinCount, [arg0]) + } + + getStrategyAssetBalance(strategyAddr: string, asset: string): Promise { + return this.eth_call(functions.getStrategyAssetBalance, [strategyAddr, asset]) + } + + getStrategyBalances(strategyAddr: string): Promise<([supportedAssets: Array, assetBalances: Array] & {supportedAssets: Array, assetBalances: Array})> { + return this.eth_call(functions.getStrategyBalances, [strategyAddr]) + } + + governor(): Promise { + return this.eth_call(functions.governor, []) + } + + isGovernor(): Promise { + return this.eth_call(functions.isGovernor, []) + } + + oToken(): Promise { + return this.eth_call(functions.oToken, []) + } + + oracleRouter(): Promise { + return this.eth_call(functions.oracleRouter, []) + } + + strategies(arg0: bigint): Promise { + return this.eth_call(functions.strategies, [arg0]) + } + + strategistAddr(): Promise { + return this.eth_call(functions.strategistAddr, []) + } + + strategyConfig(arg0: string): Promise<([supported: boolean, kind: number] & {supported: boolean, kind: number})> { + return this.eth_call(functions.strategyConfig, [arg0]) + } + + vault(): Promise { + return this.eth_call(functions.vault, []) + } +} diff --git a/src/processors/strategies/balancer-meta-pool.ts b/src/processors/strategies/balancer-meta-pool.ts index 28998d42..db227f85 100644 --- a/src/processors/strategies/balancer-meta-pool.ts +++ b/src/processors/strategies/balancer-meta-pool.ts @@ -3,14 +3,18 @@ import { EvmBatchProcessor } from '@subsquid/evm-processor' import * as balancerMetaPoolStrategy from '../../abi/balancer-meta-pool-strategy' import * as baseRewardPool4626 from '../../abi/base-reward-pool-4626' import * as metaStablePool from '../../abi/meta-stable-pool' +import * as originLens from '../../abi/origin-lens' import { BalancerMetaPoolStrategy } from '../../model' import { Context } from '../../processor' import { RETH_ADDRESS, WETH_ADDRESS } from '../../utils/addresses' import { getLatestEntity } from '../utils' -export const from = 18156219 // https://etherscan.io/tx/0x41c4c0e86ef95e0bfaac7bd94f30f7c30505278f5d7d70c4e99deb4d79b14f58 +const strategyDeployBlock = 18156219 +const originLensProxyDeployBlock = 18292379 +export const from = strategyDeployBlock // https://etherscan.io/tx/0x41c4c0e86ef95e0bfaac7bd94f30f7c30505278f5d7d70c4e99deb4d79b14f58 const addresses = { + originLens: '0x6590e684c23dbea7fc61598f601a36e9bbd0c7d9', strategy: '0x49109629ac1deb03f2e9b2fe2ac4a623e0e7dfdc', lpToken: '0x1e19cf2d73a72ef1332c882f20534b6519be0276', auraRewardsPool: '0xdd1fe5ad401d4777ce89959b7fa587e569bf125d', @@ -25,7 +29,6 @@ export const setup = (processor: EvmBatchProcessor) => { topic0: [ balancerMetaPoolStrategy.events.Deposit.topic, balancerMetaPoolStrategy.events.Withdrawal.topic, - balancerMetaPoolStrategy.events.RewardTokenCollected.topic, ], }) processor.addLog({ @@ -33,9 +36,6 @@ export const setup = (processor: EvmBatchProcessor) => { topic0: [ metaStablePool.events.Transfer.topic, metaStablePool.events.PriceRateCacheUpdated.topic, - metaStablePool.events.PriceRateProviderSet.topic, - metaStablePool.events.OracleEnabledChanged.topic, - metaStablePool.events.SwapFeePercentageChanged.topic, ], }) processor.addLog({ @@ -46,8 +46,6 @@ export const setup = (processor: EvmBatchProcessor) => { baseRewardPool4626.events.Deposit.topic, baseRewardPool4626.events.Withdrawn.topic, baseRewardPool4626.events.Withdraw.topic, - baseRewardPool4626.events.RewardAdded.topic, - baseRewardPool4626.events.RewardPaid.topic, ], }) } @@ -61,19 +59,13 @@ const addressesToListenTo = new Set([ const topicsToListenTo = new Set([ balancerMetaPoolStrategy.events.Deposit.topic, balancerMetaPoolStrategy.events.Withdrawal.topic, - balancerMetaPoolStrategy.events.RewardTokenCollected.topic, metaStablePool.events.Transfer.topic, metaStablePool.events.PriceRateCacheUpdated.topic, - metaStablePool.events.PriceRateProviderSet.topic, - metaStablePool.events.OracleEnabledChanged.topic, - metaStablePool.events.SwapFeePercentageChanged.topic, baseRewardPool4626.events.Transfer.topic, baseRewardPool4626.events.Staked.topic, baseRewardPool4626.events.Deposit.topic, baseRewardPool4626.events.Withdrawn.topic, baseRewardPool4626.events.Withdraw.topic, - baseRewardPool4626.events.RewardAdded.topic, - baseRewardPool4626.events.RewardPaid.topic, ]) interface ProcessResult { @@ -110,16 +102,27 @@ export const updateValues = async ( block.header, addresses.strategy, ) - const [{ current, latest }, total, rETH, weth] = await Promise.all([ + const lens = new originLens.Contract(ctx, block.header, addresses.originLens) + const [{ current, latest }, { total, rETH, weth }] = await Promise.all([ getLatestEntity( ctx, BalancerMetaPoolStrategy, result.strategies, timestampId, ), - strategy['checkBalance()'](), - strategy['checkBalance(address)'](RETH_ADDRESS), - strategy['checkBalance(address)'](WETH_ADDRESS), + block.header.height < originLensProxyDeployBlock + ? Promise.all([ + strategy['checkBalance()'](), + strategy['checkBalance(address)'](RETH_ADDRESS), + strategy['checkBalance(address)'](WETH_ADDRESS), + ]).then(([total, rETH, weth]) => ({ total, rETH, weth })) + : lens + .getStrategyBalances(addresses.strategy) + .then(({ assetBalances: [rETH, weth] }) => ({ + total: rETH + weth, + rETH, + weth, + })), ]) if (!current) { From 8ef6bc2f37d8a150f3dcce33fc0b0297a8eedf34 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Fri, 6 Oct 2023 10:39:17 -0700 Subject: [PATCH 6/6] feat: track balancer meta unintended change --- tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 784a5474..e59d8d66 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,8 +11,7 @@ "experimentalDecorators": true, "emitDecoratorMetadata": true, "skipLibCheck": true, - "resolveJsonModule": true, - "forceConsistentCasingInFileNames": true + "resolveJsonModule": true }, "include": [ "src"