From 979b5b57e52b9d3222240512d88790bcf1fec19a Mon Sep 17 00:00:00 2001 From: Dhruv Chauhan Date: Thu, 5 Sep 2024 11:19:53 +0530 Subject: [PATCH] add subgraph --- deployment/deployment.json | 34 + subgraphs/gogopool/.gitignore | 4 + subgraphs/gogopool/README.md | 17 + subgraphs/gogopool/abis/GoGoPool/GGAVAX.json | 1040 +++++++++++++++ .../abis/GoGoPool/MinipoolManager.json | 1128 +++++++++++++++++ .../gogopool/abis/Prices/AaveOracle.json | 159 +++ .../abis/Prices/Calculations/Curve.json | 143 +++ .../abis/Prices/Calculations/SushiSwap.json | 137 ++ subgraphs/gogopool/abis/Prices/ChainLink.json | 530 ++++++++ .../abis/Prices/ChainlinkDataFeed.json | 509 ++++++++ .../gogopool/abis/Prices/Curve/Pool.json | 916 +++++++++++++ .../gogopool/abis/Prices/Curve/Registry.json | 337 +++++ subgraphs/gogopool/abis/Prices/EGETH.json | 349 +++++ subgraphs/gogopool/abis/Prices/ERC20.json | 828 ++++++++++++ .../gogopool/abis/Prices/EigenpieMLRT.json | 349 +++++ subgraphs/gogopool/abis/Prices/SFRAX.json | 730 +++++++++++ .../gogopool/abis/Prices/Uniswap/Factory.json | 125 ++ .../gogopool/abis/Prices/Uniswap/Pair.json | 461 +++++++ .../gogopool/abis/Prices/Uniswap/Router.json | 398 ++++++ subgraphs/gogopool/abis/Prices/WBETH.json | 1072 ++++++++++++++++ subgraphs/gogopool/abis/Prices/YearnLens.json | 174 +++ subgraphs/gogopool/abis/Tokens/ERC20.json | 222 ++++ .../gogopool/abis/Tokens/ERC20NameBytes.json | 17 + .../abis/Tokens/ERC20SymbolBytes.json | 17 + .../configurations/configurations.ts | 20 + .../configurations/configurations/deploy.ts | 3 + .../configurations/interface.ts | 10 + .../configurations/configure.mustache | 6 + subgraphs/gogopool/package.json | 15 + .../gogopool-avalanche/configurations.json | 44 + .../gogopool-avalanche/configurations.ts | 29 + .../config/templates/gogopool.template.yaml | 167 +++ subgraphs/gogopool/schema.graphql | 352 +++++ subgraphs/gogopool/src/common/constants.ts | 6 + subgraphs/gogopool/src/mappings/handlers.ts | 329 +++++ subgraphs/gogopool/src/prices/README.md | 295 +++++ .../prices/calculations/CalculationsCurve.ts | 47 + .../calculations/CalculationsSushiswap.ts | 47 + .../gogopool/src/prices/common/constants.ts | 43 + subgraphs/gogopool/src/prices/common/types.ts | 147 +++ subgraphs/gogopool/src/prices/common/utils.ts | 202 +++ .../gogopool/src/prices/config/arbitrum.ts | 146 +++ .../gogopool/src/prices/config/aurora.ts | 133 ++ .../gogopool/src/prices/config/avalanche.ts | 140 ++ subgraphs/gogopool/src/prices/config/base.ts | 130 ++ subgraphs/gogopool/src/prices/config/blast.ts | 131 ++ subgraphs/gogopool/src/prices/config/bsc.ts | 130 ++ subgraphs/gogopool/src/prices/config/celo.ts | 132 ++ .../gogopool/src/prices/config/cronos.ts | 131 ++ .../gogopool/src/prices/config/fantom.ts | 145 +++ subgraphs/gogopool/src/prices/config/fuse.ts | 132 ++ .../gogopool/src/prices/config/gnosis.ts | 134 ++ .../gogopool/src/prices/config/harmony.ts | 136 ++ subgraphs/gogopool/src/prices/config/linea.ts | 129 ++ .../gogopool/src/prices/config/mainnet.ts | 371 ++++++ subgraphs/gogopool/src/prices/config/mode.ts | 129 ++ .../gogopool/src/prices/config/moonbeam.ts | 133 ++ .../gogopool/src/prices/config/optimism.ts | 145 +++ .../gogopool/src/prices/config/polygon.ts | 139 ++ .../src/prices/config/polygon_zkevm.ts | 129 ++ .../gogopool/src/prices/config/scroll.ts | 129 ++ .../gogopool/src/prices/config/template.ts | 142 +++ .../gogopool/src/prices/config/zksync_era.ts | 130 ++ subgraphs/gogopool/src/prices/index.ts | 151 +++ .../gogopool/src/prices/oracles/AaveOracle.ts | 44 + .../src/prices/oracles/ChainLinkFeed.ts | 53 + .../src/prices/oracles/YearnLensOracle.ts | 44 + .../src/prices/routers/CurveRouter.ts | 368 ++++++ .../src/prices/routers/UniswapForksRouter.ts | 292 +++++ subgraphs/gogopool/src/sdk/README.md | 25 + .../gogopool/src/sdk/protocols/config.ts | 45 + .../src/sdk/protocols/generic/account.ts | 93 ++ .../src/sdk/protocols/generic/index.ts | 72 ++ .../src/sdk/protocols/generic/pool.ts | 317 +++++ .../src/sdk/protocols/generic/poolSnapshot.ts | 93 ++ .../src/sdk/protocols/generic/protocol.ts | 257 ++++ .../sdk/protocols/generic/protocolSnapshot.ts | 165 +++ .../src/sdk/protocols/generic/tokens.ts | 58 + subgraphs/gogopool/src/sdk/util/arrays.ts | 103 ++ subgraphs/gogopool/src/sdk/util/constants.ts | 229 ++++ subgraphs/gogopool/src/sdk/util/events.ts | 70 + subgraphs/gogopool/src/sdk/util/numbers.ts | 61 + subgraphs/gogopool/src/sdk/util/rewards.ts | 295 +++++ subgraphs/gogopool/tsconfig.json | 4 + 84 files changed, 17493 insertions(+) create mode 100644 subgraphs/gogopool/.gitignore create mode 100644 subgraphs/gogopool/README.md create mode 100644 subgraphs/gogopool/abis/GoGoPool/GGAVAX.json create mode 100644 subgraphs/gogopool/abis/GoGoPool/MinipoolManager.json create mode 100644 subgraphs/gogopool/abis/Prices/AaveOracle.json create mode 100644 subgraphs/gogopool/abis/Prices/Calculations/Curve.json create mode 100644 subgraphs/gogopool/abis/Prices/Calculations/SushiSwap.json create mode 100644 subgraphs/gogopool/abis/Prices/ChainLink.json create mode 100644 subgraphs/gogopool/abis/Prices/ChainlinkDataFeed.json create mode 100644 subgraphs/gogopool/abis/Prices/Curve/Pool.json create mode 100644 subgraphs/gogopool/abis/Prices/Curve/Registry.json create mode 100644 subgraphs/gogopool/abis/Prices/EGETH.json create mode 100644 subgraphs/gogopool/abis/Prices/ERC20.json create mode 100644 subgraphs/gogopool/abis/Prices/EigenpieMLRT.json create mode 100644 subgraphs/gogopool/abis/Prices/SFRAX.json create mode 100644 subgraphs/gogopool/abis/Prices/Uniswap/Factory.json create mode 100644 subgraphs/gogopool/abis/Prices/Uniswap/Pair.json create mode 100644 subgraphs/gogopool/abis/Prices/Uniswap/Router.json create mode 100644 subgraphs/gogopool/abis/Prices/WBETH.json create mode 100644 subgraphs/gogopool/abis/Prices/YearnLens.json create mode 100644 subgraphs/gogopool/abis/Tokens/ERC20.json create mode 100644 subgraphs/gogopool/abis/Tokens/ERC20NameBytes.json create mode 100644 subgraphs/gogopool/abis/Tokens/ERC20SymbolBytes.json create mode 100644 subgraphs/gogopool/configurations/configurations/configurations.ts create mode 100644 subgraphs/gogopool/configurations/configurations/deploy.ts create mode 100644 subgraphs/gogopool/configurations/configurations/interface.ts create mode 100644 subgraphs/gogopool/configurations/configure.mustache create mode 100644 subgraphs/gogopool/package.json create mode 100644 subgraphs/gogopool/protocols/gogopool/config/deployments/gogopool-avalanche/configurations.json create mode 100644 subgraphs/gogopool/protocols/gogopool/config/deployments/gogopool-avalanche/configurations.ts create mode 100644 subgraphs/gogopool/protocols/gogopool/config/templates/gogopool.template.yaml create mode 100644 subgraphs/gogopool/schema.graphql create mode 100644 subgraphs/gogopool/src/common/constants.ts create mode 100644 subgraphs/gogopool/src/mappings/handlers.ts create mode 100644 subgraphs/gogopool/src/prices/README.md create mode 100644 subgraphs/gogopool/src/prices/calculations/CalculationsCurve.ts create mode 100644 subgraphs/gogopool/src/prices/calculations/CalculationsSushiswap.ts create mode 100644 subgraphs/gogopool/src/prices/common/constants.ts create mode 100644 subgraphs/gogopool/src/prices/common/types.ts create mode 100644 subgraphs/gogopool/src/prices/common/utils.ts create mode 100644 subgraphs/gogopool/src/prices/config/arbitrum.ts create mode 100644 subgraphs/gogopool/src/prices/config/aurora.ts create mode 100644 subgraphs/gogopool/src/prices/config/avalanche.ts create mode 100644 subgraphs/gogopool/src/prices/config/base.ts create mode 100644 subgraphs/gogopool/src/prices/config/blast.ts create mode 100644 subgraphs/gogopool/src/prices/config/bsc.ts create mode 100644 subgraphs/gogopool/src/prices/config/celo.ts create mode 100644 subgraphs/gogopool/src/prices/config/cronos.ts create mode 100644 subgraphs/gogopool/src/prices/config/fantom.ts create mode 100644 subgraphs/gogopool/src/prices/config/fuse.ts create mode 100644 subgraphs/gogopool/src/prices/config/gnosis.ts create mode 100644 subgraphs/gogopool/src/prices/config/harmony.ts create mode 100644 subgraphs/gogopool/src/prices/config/linea.ts create mode 100644 subgraphs/gogopool/src/prices/config/mainnet.ts create mode 100644 subgraphs/gogopool/src/prices/config/mode.ts create mode 100644 subgraphs/gogopool/src/prices/config/moonbeam.ts create mode 100644 subgraphs/gogopool/src/prices/config/optimism.ts create mode 100644 subgraphs/gogopool/src/prices/config/polygon.ts create mode 100644 subgraphs/gogopool/src/prices/config/polygon_zkevm.ts create mode 100644 subgraphs/gogopool/src/prices/config/scroll.ts create mode 100644 subgraphs/gogopool/src/prices/config/template.ts create mode 100644 subgraphs/gogopool/src/prices/config/zksync_era.ts create mode 100644 subgraphs/gogopool/src/prices/index.ts create mode 100644 subgraphs/gogopool/src/prices/oracles/AaveOracle.ts create mode 100644 subgraphs/gogopool/src/prices/oracles/ChainLinkFeed.ts create mode 100644 subgraphs/gogopool/src/prices/oracles/YearnLensOracle.ts create mode 100644 subgraphs/gogopool/src/prices/routers/CurveRouter.ts create mode 100644 subgraphs/gogopool/src/prices/routers/UniswapForksRouter.ts create mode 100644 subgraphs/gogopool/src/sdk/README.md create mode 100644 subgraphs/gogopool/src/sdk/protocols/config.ts create mode 100644 subgraphs/gogopool/src/sdk/protocols/generic/account.ts create mode 100644 subgraphs/gogopool/src/sdk/protocols/generic/index.ts create mode 100644 subgraphs/gogopool/src/sdk/protocols/generic/pool.ts create mode 100644 subgraphs/gogopool/src/sdk/protocols/generic/poolSnapshot.ts create mode 100644 subgraphs/gogopool/src/sdk/protocols/generic/protocol.ts create mode 100644 subgraphs/gogopool/src/sdk/protocols/generic/protocolSnapshot.ts create mode 100644 subgraphs/gogopool/src/sdk/protocols/generic/tokens.ts create mode 100644 subgraphs/gogopool/src/sdk/util/arrays.ts create mode 100644 subgraphs/gogopool/src/sdk/util/constants.ts create mode 100644 subgraphs/gogopool/src/sdk/util/events.ts create mode 100644 subgraphs/gogopool/src/sdk/util/numbers.ts create mode 100644 subgraphs/gogopool/src/sdk/util/rewards.ts create mode 100644 subgraphs/gogopool/tsconfig.json diff --git a/deployment/deployment.json b/deployment/deployment.json index a3be8f0173..978d03d63e 100644 --- a/deployment/deployment.json +++ b/deployment/deployment.json @@ -12322,5 +12322,39 @@ } } } + }, + "gogopool": { + "schema": "generic", + "base": "gogopool", + "protocol": "gogopool", + "project": "gogopool", + "deployments": { + "gogopool-avalanche": { + "network": "avalanche", + "status": "prod", + "versions": { + "schema": "3.0.0", + "subgraph": "1.0.0", + "methodology": "1.0.0" + }, + "files": { + "template": "gogopool.template.yaml" + }, + "options": { + "prepare:yaml": true, + "prepare:constants": true + }, + "services": { + "hosted-service": { + "slug": "gogopool-avalanche", + "query-id": "gogopool-avalanche" + }, + "decentralized-network": { + "slug": "gogopool-avalanche", + "query-id": "todo" + } + } + } + } } } diff --git a/subgraphs/gogopool/.gitignore b/subgraphs/gogopool/.gitignore new file mode 100644 index 0000000000..09140957fa --- /dev/null +++ b/subgraphs/gogopool/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +configure.ts +docs/ +package-lock.json diff --git a/subgraphs/gogopool/README.md b/subgraphs/gogopool/README.md new file mode 100644 index 0000000000..e077b10c7a --- /dev/null +++ b/subgraphs/gogopool/README.md @@ -0,0 +1,17 @@ +# GoGoPool Subgraph + +## Methodology v1.0.0 + +## Metrics + +### Usage and Transactions + +### TVL + +### Revenue + +## Useful Links + +- Landing Page: +- Docs: +- Contracts: diff --git a/subgraphs/gogopool/abis/GoGoPool/GGAVAX.json b/subgraphs/gogopool/abis/GoGoPool/GGAVAX.json new file mode 100644 index 0000000000..63bae8d7e7 --- /dev/null +++ b/subgraphs/gogopool/abis/GoGoPool/GGAVAX.json @@ -0,0 +1,1040 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "ContractNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "ContractPaused", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidOrOutdatedContract", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidStakingDeposit", + "type": "error" + }, + { + "inputs": [], + "name": "MustBeGuardian", + "type": "error" + }, + { + "inputs": [], + "name": "MustBeGuardianOrValidContract", + "type": "error" + }, + { + "inputs": [], + "name": "MustBeMultisig", + "type": "error" + }, + { + "inputs": [], + "name": "SyncError", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAssets", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroShares", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "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": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "baseAmt", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardsAmt", + "type": "uint256" + } + ], + "name": "DepositedFromStaking", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "cycleEnd", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardsAmt", + "type": "uint256" + } + ], + "name": "NewRewardsCycle", + "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": "amount", + "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": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "WithdrawnForStaking", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "amountAvailableForStaking", + "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": "contract ERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "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": "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": "shares", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "depositAVAX", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "baseAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardAmt", + "type": "uint256" + } + ], + "name": "depositFromStaking", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract Storage", + "name": "storageAddress", + "type": "address" + }, + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialDeposit", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "lastRewardsAmt", + "outputs": [ + { + "internalType": "uint192", + "name": "", + "type": "uint192" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastSync", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "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": "assets", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "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": "", + "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": "assets", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "redeemAVAX", + "outputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardsCycleEnd", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardsCycleLength", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stakingTotalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "syncRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalReleasedAssets", + "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": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "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": "shares", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "withdrawAVAX", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "withdrawForStaking", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] diff --git a/subgraphs/gogopool/abis/GoGoPool/MinipoolManager.json b/subgraphs/gogopool/abis/GoGoPool/MinipoolManager.json new file mode 100644 index 0000000000..87409178b2 --- /dev/null +++ b/subgraphs/gogopool/abis/GoGoPool/MinipoolManager.json @@ -0,0 +1,1128 @@ +[ + { + "inputs": [ + { + "internalType": "contract Storage", + "name": "storageAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "CancellationTooEarly", + "type": "error" + }, + { + "inputs": [], + "name": "ContractNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "ContractPaused", + "type": "error" + }, + { + "inputs": [], + "name": "DelegationFeeOutOfBounds", + "type": "error" + }, + { + "inputs": [], + "name": "DurationOutOfBounds", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientAVAXForMinipoolCreation", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientGGPCollateralization", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAVAXAssignmentRequest", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAmount", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidEndTime", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidMultisigAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidNodeID", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidOrOutdatedContract", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidStartTime", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidStateTransition", + "type": "error" + }, + { + "inputs": [], + "name": "MinipoolDurationExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "MinipoolNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "MustBeGuardian", + "type": "error" + }, + { + "inputs": [], + "name": "MustBeGuardianOrValidContract", + "type": "error" + }, + { + "inputs": [], + "name": "MustBeMultisig", + "type": "error" + }, + { + "inputs": [], + "name": "NegativeCycleDuration", + "type": "error" + }, + { + "inputs": [], + "name": "OnlyOwner", + "type": "error" + }, + { + "inputs": [], + "name": "OnlyRole", + "type": "error" + }, + { + "inputs": [], + "name": "WithdrawAmountTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "WithdrawForDelegationDisabled", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "blsPubkeyAndSig", + "type": "bytes" + } + ], + "name": "BLSKeysAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardsAmount", + "type": "uint256" + } + ], + "name": "DepositFromDelegation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "ggp", + "type": "uint256" + } + ], + "name": "GGPSlashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "hardwareProvider", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "duration", + "type": "uint256" + } + ], + "name": "MinipoolLaunched", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "indexed": true, + "internalType": "enum MinipoolStatus", + "name": "status", + "type": "uint8" + } + ], + "name": "MinipoolStatusChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "WithdrawForDelegation", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "avaxRewardAmt", + "type": "uint256" + } + ], + "name": "calculateGGPSlashAmt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + } + ], + "name": "canClaimAndInitiateStaking", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + } + ], + "name": "cancelMinipool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "errorCode", + "type": "bytes32" + } + ], + "name": "cancelMinipoolByMultisig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + } + ], + "name": "claimAndInitiateStaking", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "delegationFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxAssignmentRequest", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "blsPubkeyAndSig", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "hardwareProvider", + "type": "bytes32" + } + ], + "name": "createMinipool", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "delegationFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxAssignmentRequest", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "blsPubkeyAndSig", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "hardwareProvider", + "type": "bytes32" + } + ], + "name": "createMinipoolOnBehalfOf", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "rewards", + "type": "uint256" + }, + { + "internalType": "address", + "name": "nodeID", + "type": "address" + } + ], + "name": "depositFromDelegation", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxAmt", + "type": "uint256" + } + ], + "name": "getExpectedAVAXRewardsAmt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + } + ], + "name": "getIndexOf", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "index", + "type": "int256" + } + ], + "name": "getMinipool", + "outputs": [ + { + "components": [ + { + "internalType": "int256", + "name": "index", + "type": "int256" + }, + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "uint256", + "name": "status", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "delegationFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "multisigAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "avaxNodeOpAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxNodeOpInitialAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxLiquidStakerAmt", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "blsPubkeyAndSig", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "txID", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "creationTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialStartTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxTotalRewardAmt", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "errorCode", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "ggpSlashAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxNodeOpRewardAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxLiquidStakerRewardAmt", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "hardwareProvider", + "type": "bytes32" + } + ], + "internalType": "struct MinipoolManager.Minipool", + "name": "mp", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + } + ], + "name": "getMinipoolByNodeID", + "outputs": [ + { + "components": [ + { + "internalType": "int256", + "name": "index", + "type": "int256" + }, + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "uint256", + "name": "status", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "delegationFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "multisigAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "avaxNodeOpAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxNodeOpInitialAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxLiquidStakerAmt", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "blsPubkeyAndSig", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "txID", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "creationTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialStartTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxTotalRewardAmt", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "errorCode", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "ggpSlashAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxNodeOpRewardAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxLiquidStakerRewardAmt", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "hardwareProvider", + "type": "bytes32" + } + ], + "internalType": "struct MinipoolManager.Minipool", + "name": "mp", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMinipoolCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum MinipoolStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "offset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "getMinipools", + "outputs": [ + { + "components": [ + { + "internalType": "int256", + "name": "index", + "type": "int256" + }, + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "uint256", + "name": "status", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "delegationFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "multisigAddr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "avaxNodeOpAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxNodeOpInitialAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxLiquidStakerAmt", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "blsPubkeyAndSig", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "txID", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "creationTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialStartTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxTotalRewardAmt", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "errorCode", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "ggpSlashAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxNodeOpRewardAmt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxLiquidStakerRewardAmt", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "hardwareProvider", + "type": "bytes32" + } + ], + "internalType": "struct MinipoolManager.Minipool[]", + "name": "minipools", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalAVAXLiquidStakerAmt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minStakingDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "receiveWithdrawalAVAX", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxTotalRewardAmt", + "type": "uint256" + } + ], + "name": "recordStakingEnd", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "avaxTotalRewardAmt", + "type": "uint256" + } + ], + "name": "recordStakingEndThenMaybeCycle", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "errorCode", + "type": "bytes32" + } + ], + "name": "recordStakingError", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "txID", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + } + ], + "name": "recordStakingStart", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + } + ], + "name": "requireValidMinipool", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "bytes", + "name": "blsPubkeyAndSig", + "type": "bytes" + } + ], + "name": "setBLSKeys", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "nodeID", + "type": "address" + } + ], + "name": "withdrawForDelegation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + } + ], + "name": "withdrawMinipoolFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nodeID", + "type": "address" + }, + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "hardwareProvider", + "type": "bytes32" + } + ], + "name": "withdrawRewardsAndRelaunchMinipool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/AaveOracle.json b/subgraphs/gogopool/abis/Prices/AaveOracle.json new file mode 100644 index 0000000000..3149642bb9 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/AaveOracle.json @@ -0,0 +1,159 @@ +[ + { + "inputs": [ + { + "internalType": "contract IPoolAddressesProvider", + "name": "provider", + "type": "address" + }, + { "internalType": "address[]", "name": "assets", "type": "address[]" }, + { "internalType": "address[]", "name": "sources", "type": "address[]" }, + { + "internalType": "address", + "name": "fallbackOracle", + "type": "address" + }, + { "internalType": "address", "name": "baseCurrency", "type": "address" }, + { + "internalType": "uint256", + "name": "baseCurrencyUnit", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "source", + "type": "address" + } + ], + "name": "AssetSourceUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "baseCurrency", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "baseCurrencyUnit", + "type": "uint256" + } + ], + "name": "BaseCurrencySet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "fallbackOracle", + "type": "address" + } + ], + "name": "FallbackOracleUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "ADDRESSES_PROVIDER", + "outputs": [ + { + "internalType": "contract IPoolAddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BASE_CURRENCY", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BASE_CURRENCY_UNIT", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "asset", "type": "address" } + ], + "name": "getAssetPrice", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address[]", "name": "assets", "type": "address[]" } + ], + "name": "getAssetsPrices", + "outputs": [ + { "internalType": "uint256[]", "name": "", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFallbackOracle", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "asset", "type": "address" } + ], + "name": "getSourceOfAsset", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address[]", "name": "assets", "type": "address[]" }, + { "internalType": "address[]", "name": "sources", "type": "address[]" } + ], + "name": "setAssetSources", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "fallbackOracle", "type": "address" } + ], + "name": "setFallbackOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/Calculations/Curve.json b/subgraphs/gogopool/abis/Prices/Calculations/Curve.json new file mode 100644 index 0000000000..b1f6da3de4 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/Calculations/Curve.json @@ -0,0 +1,143 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_curveAddressProviderAddress", + "type": "address" + }, + { "internalType": "address", "name": "_oracleAddress", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "curveAddressProviderAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "curveMetapoolFactoryAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "curveRegistryAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "curveLpTokenAddress", + "type": "address" + } + ], + "name": "getBasePrice", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "curveLpTokenAddress", + "type": "address" + } + ], + "name": "getCurvePriceUsdc", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "getPool", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "assetAddress", "type": "address" } + ], + "name": "getPriceUsdc", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "poolAddress", "type": "address" } + ], + "name": "getUnderlyingCoinFromPool", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "curveLpTokenAddress", + "type": "address" + } + ], + "name": "getVirtualPrice", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "isBasicToken", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "isCurveLpToken", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracleAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ownerAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "slot", "type": "bytes32" }, + { "internalType": "bytes32", "name": "value", "type": "bytes32" } + ], + "name": "updateSlot", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/Calculations/SushiSwap.json b/subgraphs/gogopool/abis/Prices/Calculations/SushiSwap.json new file mode 100644 index 0000000000..8b9718ae78 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/Calculations/SushiSwap.json @@ -0,0 +1,137 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_primaryRouterAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_primaryFactoryAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_secondaryRouterAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_secondaryFactoryAddress", + "type": "address" + }, + { "internalType": "address", "name": "_usdcAddress", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "getLpTokenPriceUsdc", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "getLpTokenTotalLiquidityUsdc", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token0Address", "type": "address" }, + { "internalType": "address", "name": "token1Address", "type": "address" } + ], + "name": "getPriceFromRouter", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "getPriceFromRouterUsdc", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "getPriceUsdc", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "getRouterForLpToken", + "outputs": [ + { "internalType": "contract PriceRouter", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "isLpToken", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "primaryFactoryAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "primaryRouterAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "secondaryFactoryAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "secondaryRouterAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "usdcAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "wethAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/ChainLink.json b/subgraphs/gogopool/abis/Prices/ChainLink.json new file mode 100644 index 0000000000..55882931c3 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/ChainLink.json @@ -0,0 +1,530 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "accessController", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "AccessControllerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "denomination", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "latestAggregator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "previousAggregator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "nextPhaseId", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "FeedConfirmed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "denomination", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "proposedAggregator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "currentAggregator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "FeedProposed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "OwnershipTransferRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "address", "name": "aggregator", "type": "address" } + ], + "name": "confirmFeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "description", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAccessController", + "outputs": [ + { + "internalType": "contract AccessControllerInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "uint256", "name": "roundId", "type": "uint256" } + ], + "name": "getAnswer", + "outputs": [ + { "internalType": "int256", "name": "answer", "type": "int256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "getCurrentPhaseId", + "outputs": [ + { "internalType": "uint16", "name": "currentPhaseId", "type": "uint16" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "getFeed", + "outputs": [ + { + "internalType": "contract AggregatorV2V3Interface", + "name": "aggregator", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "uint80", "name": "roundId", "type": "uint80" } + ], + "name": "getNextRoundId", + "outputs": [ + { "internalType": "uint80", "name": "nextRoundId", "type": "uint80" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "uint16", "name": "phaseId", "type": "uint16" } + ], + "name": "getPhase", + "outputs": [ + { + "components": [ + { "internalType": "uint16", "name": "phaseId", "type": "uint16" }, + { + "internalType": "uint80", + "name": "startingAggregatorRoundId", + "type": "uint80" + }, + { + "internalType": "uint80", + "name": "endingAggregatorRoundId", + "type": "uint80" + } + ], + "internalType": "struct FeedRegistryInterface.Phase", + "name": "phase", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "uint16", "name": "phaseId", "type": "uint16" } + ], + "name": "getPhaseFeed", + "outputs": [ + { + "internalType": "contract AggregatorV2V3Interface", + "name": "aggregator", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "uint16", "name": "phaseId", "type": "uint16" } + ], + "name": "getPhaseRange", + "outputs": [ + { "internalType": "uint80", "name": "startingRoundId", "type": "uint80" }, + { "internalType": "uint80", "name": "endingRoundId", "type": "uint80" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "uint80", "name": "roundId", "type": "uint80" } + ], + "name": "getPreviousRoundId", + "outputs": [ + { "internalType": "uint80", "name": "previousRoundId", "type": "uint80" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "getProposedFeed", + "outputs": [ + { + "internalType": "contract AggregatorV2V3Interface", + "name": "proposedAggregator", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "uint80", "name": "_roundId", "type": "uint80" } + ], + "name": "getRoundData", + "outputs": [ + { "internalType": "uint80", "name": "roundId", "type": "uint80" }, + { "internalType": "int256", "name": "answer", "type": "int256" }, + { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, + { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, + { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "uint80", "name": "roundId", "type": "uint80" } + ], + "name": "getRoundFeed", + "outputs": [ + { + "internalType": "contract AggregatorV2V3Interface", + "name": "aggregator", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "uint256", "name": "roundId", "type": "uint256" } + ], + "name": "getTimestamp", + "outputs": [ + { "internalType": "uint256", "name": "timestamp", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "aggregator", "type": "address" } + ], + "name": "isFeedEnabled", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "latestAnswer", + "outputs": [ + { "internalType": "int256", "name": "answer", "type": "int256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "latestRound", + "outputs": [ + { "internalType": "uint256", "name": "roundId", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "latestRoundData", + "outputs": [ + { "internalType": "uint80", "name": "roundId", "type": "uint80" }, + { "internalType": "int256", "name": "answer", "type": "int256" }, + { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, + { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, + { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "latestTimestamp", + "outputs": [ + { "internalType": "uint256", "name": "timestamp", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "address", "name": "aggregator", "type": "address" } + ], + "name": "proposeFeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" }, + { "internalType": "uint80", "name": "roundId", "type": "uint80" } + ], + "name": "proposedGetRoundData", + "outputs": [ + { "internalType": "uint80", "name": "id", "type": "uint80" }, + { "internalType": "int256", "name": "answer", "type": "int256" }, + { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, + { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, + { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "proposedLatestRoundData", + "outputs": [ + { "internalType": "uint80", "name": "id", "type": "uint80" }, + { "internalType": "int256", "name": "answer", "type": "int256" }, + { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, + { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, + { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract AccessControllerInterface", + "name": "_accessController", + "type": "address" + } + ], + "name": "setAccessController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "typeAndVersion", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "base", "type": "address" }, + { "internalType": "address", "name": "quote", "type": "address" } + ], + "name": "version", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/ChainlinkDataFeed.json b/subgraphs/gogopool/abis/Prices/ChainlinkDataFeed.json new file mode 100644 index 0000000000..bca8a84144 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/ChainlinkDataFeed.json @@ -0,0 +1,509 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_aggregator", + "type": "address" + }, + { + "internalType": "address", + "name": "_accessController", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "int256", + "name": "current", + "type": "int256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "roundId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + } + ], + "name": "AnswerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "roundId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "startedBy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + } + ], + "name": "NewRound", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "OwnershipTransferRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessController", + "outputs": [ + { + "internalType": "contract AccessControllerInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "aggregator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_aggregator", + "type": "address" + } + ], + "name": "confirmAggregator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "description", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_roundId", + "type": "uint256" + } + ], + "name": "getAnswer", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint80", + "name": "_roundId", + "type": "uint80" + } + ], + "name": "getRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_roundId", + "type": "uint256" + } + ], + "name": "getTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestAnswer", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestRound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "name": "phaseAggregators", + "outputs": [ + { + "internalType": "contract AggregatorV2V3Interface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "phaseId", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_aggregator", + "type": "address" + } + ], + "name": "proposeAggregator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "proposedAggregator", + "outputs": [ + { + "internalType": "contract AggregatorV2V3Interface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint80", + "name": "_roundId", + "type": "uint80" + } + ], + "name": "proposedGetRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proposedLatestRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_accessController", + "type": "address" + } + ], + "name": "setController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/Curve/Pool.json b/subgraphs/gogopool/abis/Prices/Curve/Pool.json new file mode 100644 index 0000000000..d4843cae7d --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/Curve/Pool.json @@ -0,0 +1,916 @@ +[ + { + "name": "TokenExchange", + "inputs": [ + { "type": "address", "name": "buyer", "indexed": true }, + { "type": "int128", "name": "sold_id", "indexed": false }, + { "type": "uint256", "name": "tokens_sold", "indexed": false }, + { "type": "int128", "name": "bought_id", "indexed": false }, + { "type": "uint256", "name": "tokens_bought", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "TokenExchange", + "inputs": [ + { "name": "buyer", "type": "address", "indexed": true }, + { "name": "sold_id", "type": "uint256", "indexed": false }, + { "name": "tokens_sold", "type": "uint256", "indexed": false }, + { "name": "bought_id", "type": "uint256", "indexed": false }, + { "name": "tokens_bought", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "TokenExchangeUnderlying", + "inputs": [ + { "name": "buyer", "type": "address", "indexed": true }, + { "name": "sold_id", "type": "int128", "indexed": false }, + { "name": "tokens_sold", "type": "uint256", "indexed": false }, + { "name": "bought_id", "type": "int128", "indexed": false }, + { "name": "tokens_bought", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "AddLiquidity", + "inputs": [ + { "name": "provider", "type": "address", "indexed": true }, + { "name": "token_amounts", "type": "uint256[2]", "indexed": false }, + { "name": "fee", "type": "uint256", "indexed": false }, + { "name": "token_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "AddLiquidity", + "inputs": [ + { "name": "provider", "type": "address", "indexed": true }, + { "name": "token_amounts", "type": "uint256[3]", "indexed": false }, + { "name": "fee", "type": "uint256", "indexed": false }, + { "name": "token_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "AddLiquidity", + "inputs": [ + { "name": "provider", "type": "address", "indexed": true }, + { "name": "token_amounts", "type": "uint256[2]", "indexed": false }, + { "name": "fees", "type": "uint256[2]", "indexed": false }, + { "name": "invariant", "type": "uint256", "indexed": false }, + { "name": "token_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "AddLiquidity", + "inputs": [ + { "type": "address", "name": "provider", "indexed": true }, + { "type": "uint256[3]", "name": "token_amounts", "indexed": false }, + { "type": "uint256[3]", "name": "fees", "indexed": false }, + { "type": "uint256", "name": "invariant", "indexed": false }, + { "type": "uint256", "name": "token_supply", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "AddLiquidity", + "inputs": [ + { "type": "address", "name": "provider", "indexed": true }, + { "type": "uint256[4]", "name": "token_amounts", "indexed": false }, + { "type": "uint256[4]", "name": "fees", "indexed": false }, + { "type": "uint256", "name": "invariant", "indexed": false }, + { "type": "uint256", "name": "token_supply", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RemoveLiquidity", + "inputs": [ + { "name": "provider", "type": "address", "indexed": true }, + { "name": "token_amounts", "type": "uint256[2]", "indexed": false }, + { "name": "token_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RemoveLiquidity", + "inputs": [ + { "name": "provider", "type": "address", "indexed": true }, + { "name": "token_amounts", "type": "uint256[3]", "indexed": false }, + { "name": "token_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RemoveLiquidity", + "inputs": [ + { "name": "provider", "type": "address", "indexed": true }, + { "name": "token_amounts", "type": "uint256[2]", "indexed": false }, + { "name": "fees", "type": "uint256[2]", "indexed": false }, + { "name": "token_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RemoveLiquidity", + "inputs": [ + { "type": "address", "name": "provider", "indexed": true }, + { "type": "uint256[3]", "name": "token_amounts", "indexed": false }, + { "type": "uint256[3]", "name": "fees", "indexed": false }, + { "type": "uint256", "name": "token_supply", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RemoveLiquidity", + "inputs": [ + { "type": "address", "name": "provider", "indexed": true }, + { "type": "uint256[4]", "name": "token_amounts", "indexed": false }, + { "type": "uint256[4]", "name": "fees", "indexed": false }, + { "type": "uint256", "name": "token_supply", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RemoveLiquidityOne", + "inputs": [ + { "type": "address", "name": "provider", "indexed": true }, + { "type": "uint256", "name": "token_amount", "indexed": false }, + { "type": "uint256", "name": "coin_amount", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RemoveLiquidityOne", + "inputs": [ + { "name": "provider", "type": "address", "indexed": true }, + { "name": "token_amount", "type": "uint256", "indexed": false }, + { "name": "coin_amount", "type": "uint256", "indexed": false }, + { "name": "token_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RemoveLiquidityImbalance", + "inputs": [ + { "type": "address", "name": "provider", "indexed": true }, + { "type": "uint256[2]", "name": "token_amounts", "indexed": false }, + { "type": "uint256[2]", "name": "fees", "indexed": false }, + { "type": "uint256", "name": "invariant", "indexed": false }, + { "type": "uint256", "name": "token_supply", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RemoveLiquidityImbalance", + "inputs": [ + { "type": "address", "name": "provider", "indexed": true }, + { "type": "uint256[3]", "name": "token_amounts", "indexed": false }, + { "type": "uint256[3]", "name": "fees", "indexed": false }, + { "type": "uint256", "name": "invariant", "indexed": false }, + { "type": "uint256", "name": "token_supply", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RemoveLiquidityImbalance", + "inputs": [ + { "type": "address", "name": "provider", "indexed": true }, + { "type": "uint256[4]", "name": "token_amounts", "indexed": false }, + { "type": "uint256[4]", "name": "fees", "indexed": false }, + { "type": "uint256", "name": "invariant", "indexed": false }, + { "type": "uint256", "name": "token_supply", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewFee", + "inputs": [ + { "type": "uint256", "name": "fee", "indexed": false }, + { "type": "uint256", "name": "admin_fee", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewFee", + "inputs": [ + { "type": "uint256", "name": "fee", "indexed": false }, + { "type": "uint256", "name": "admin_fee", "indexed": false }, + { "type": "uint256", "name": "offpeg_fee_multiplier", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + + { + "name": "CommitNewAdmin", + "inputs": [ + { "name": "deadline", "type": "uint256", "indexed": true }, + { "name": "admin", "type": "address", "indexed": true } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewAdmin", + "inputs": [{ "name": "admin", "type": "address", "indexed": true }], + "anonymous": false, + "type": "event" + }, + { + "name": "CommitNewParameters", + "inputs": [ + { "name": "deadline", "type": "uint256", "indexed": true }, + { "name": "admin_fee", "type": "uint256", "indexed": false }, + { "name": "mid_fee", "type": "uint256", "indexed": false }, + { "name": "out_fee", "type": "uint256", "indexed": false }, + { "name": "fee_gamma", "type": "uint256", "indexed": false }, + { "name": "allowed_extra_profit", "type": "uint256", "indexed": false }, + { "name": "adjustment_step", "type": "uint256", "indexed": false }, + { "name": "ma_half_time", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewParameters", + "inputs": [ + { "name": "admin_fee", "type": "uint256", "indexed": false }, + { "name": "mid_fee", "type": "uint256", "indexed": false }, + { "name": "out_fee", "type": "uint256", "indexed": false }, + { "name": "fee_gamma", "type": "uint256", "indexed": false }, + { "name": "allowed_extra_profit", "type": "uint256", "indexed": false }, + { "name": "adjustment_step", "type": "uint256", "indexed": false }, + { "name": "ma_half_time", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "RampAgamma", + "inputs": [ + { "name": "initial_A", "type": "uint256", "indexed": false }, + { "name": "future_A", "type": "uint256", "indexed": false }, + { "name": "initial_gamma", "type": "uint256", "indexed": false }, + { "name": "future_gamma", "type": "uint256", "indexed": false }, + { "name": "initial_time", "type": "uint256", "indexed": false }, + { "name": "future_time", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StopRampA", + "inputs": [ + { "name": "current_A", "type": "uint256", "indexed": false }, + { "name": "current_gamma", "type": "uint256", "indexed": false }, + { "name": "time", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "ClaimAdminFee", + "inputs": [ + { "name": "admin", "type": "address", "indexed": true }, + { "name": "tokens", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "stateMutability": "nonpayable", + "type": "constructor", + "inputs": [ + { "name": "owner", "type": "address" }, + { "name": "admin_fee_receiver", "type": "address" }, + { "name": "A", "type": "uint256" }, + { "name": "gamma", "type": "uint256" }, + { "name": "mid_fee", "type": "uint256" }, + { "name": "out_fee", "type": "uint256" }, + { "name": "allowed_extra_profit", "type": "uint256" }, + { "name": "fee_gamma", "type": "uint256" }, + { "name": "adjustment_step", "type": "uint256" }, + { "name": "admin_fee", "type": "uint256" }, + { "name": "ma_half_time", "type": "uint256" }, + { "name": "initial_price", "type": "uint256" } + ], + "outputs": [] + }, + { "stateMutability": "payable", "type": "fallback" }, + { + "stateMutability": "view", + "type": "function", + "name": "token", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 516 + }, + { + "stateMutability": "view", + "type": "function", + "name": "coins", + "inputs": [{ "name": "i", "type": "uint256" }], + "outputs": [{ "name": "", "type": "address" }], + "gas": 648 + }, + { + "stateMutability": "view", + "type": "function", + "name": "A", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 685 + }, + { + "stateMutability": "view", + "type": "function", + "name": "gamma", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 11789 + }, + { + "stateMutability": "view", + "type": "function", + "name": "fee", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 17633 + }, + { + "stateMutability": "view", + "type": "function", + "name": "get_virtual_price", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 364797 + }, + { + "stateMutability": "payable", + "type": "function", + "name": "exchange", + "inputs": [ + { "name": "i", "type": "uint256" }, + { "name": "j", "type": "uint256" }, + { "name": "dx", "type": "uint256" }, + { "name": "min_dy", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 16775598 + }, + { + "stateMutability": "payable", + "type": "function", + "name": "exchange", + "inputs": [ + { "name": "i", "type": "uint256" }, + { "name": "j", "type": "uint256" }, + { "name": "dx", "type": "uint256" }, + { "name": "min_dy", "type": "uint256" }, + { "name": "use_eth", "type": "bool" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 16775598 + }, + { + "stateMutability": "payable", + "type": "function", + "name": "exchange_underlying", + "inputs": [ + { "name": "i", "type": "uint256" }, + { "name": "j", "type": "uint256" }, + { "name": "dx", "type": "uint256" }, + { "name": "min_dy", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 16775396 + }, + { + "stateMutability": "view", + "type": "function", + "name": "get_dy", + "inputs": [ + { "name": "i", "type": "uint256" }, + { "name": "j", "type": "uint256" }, + { "name": "dx", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4577515 + }, + { + "stateMutability": "payable", + "type": "function", + "name": "add_liquidity", + "inputs": [ + { "name": "amounts", "type": "uint256[2]" }, + { "name": "min_mint_amount", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 17694821 + }, + { + "stateMutability": "payable", + "type": "function", + "name": "add_liquidity", + "inputs": [ + { "name": "amounts", "type": "uint256[2]" }, + { "name": "min_mint_amount", "type": "uint256" }, + { "name": "use_eth", "type": "bool" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 17694821 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "remove_liquidity", + "inputs": [ + { "name": "_amount", "type": "uint256" }, + { "name": "min_amounts", "type": "uint256[2]" } + ], + "outputs": [], + "gas": 263729 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "remove_liquidity", + "inputs": [ + { "name": "_amount", "type": "uint256" }, + { "name": "min_amounts", "type": "uint256[2]" }, + { "name": "use_eth", "type": "bool" } + ], + "outputs": [], + "gas": 263729 + }, + { + "stateMutability": "view", + "type": "function", + "name": "calc_token_amount", + "inputs": [{ "name": "amounts", "type": "uint256[2]" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 5200947 + }, + { + "stateMutability": "view", + "type": "function", + "name": "calc_withdraw_one_coin", + "inputs": [ + { "name": "token_amount", "type": "uint256" }, + { "name": "i", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 12584 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "remove_liquidity_one_coin", + "inputs": [ + { "name": "token_amount", "type": "uint256" }, + { "name": "i", "type": "uint256" }, + { "name": "min_amount", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 16702178 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "remove_liquidity_one_coin", + "inputs": [ + { "name": "token_amount", "type": "uint256" }, + { "name": "i", "type": "uint256" }, + { "name": "min_amount", "type": "uint256" }, + { "name": "use_eth", "type": "bool" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 16702178 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_admin_fees", + "inputs": [], + "outputs": [], + "gas": 3250985 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "ramp_A_gamma", + "inputs": [ + { "name": "future_A", "type": "uint256" }, + { "name": "future_gamma", "type": "uint256" }, + { "name": "future_time", "type": "uint256" } + ], + "outputs": [], + "gas": 161698 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "stop_ramp_A_gamma", + "inputs": [], + "outputs": [], + "gas": 156743 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "commit_new_parameters", + "inputs": [ + { "name": "_new_mid_fee", "type": "uint256" }, + { "name": "_new_out_fee", "type": "uint256" }, + { "name": "_new_admin_fee", "type": "uint256" }, + { "name": "_new_fee_gamma", "type": "uint256" }, + { "name": "_new_allowed_extra_profit", "type": "uint256" }, + { "name": "_new_adjustment_step", "type": "uint256" }, + { "name": "_new_ma_half_time", "type": "uint256" } + ], + "outputs": [], + "gas": 305084 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "apply_new_parameters", + "inputs": [], + "outputs": [], + "gas": 3543175 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "revert_new_parameters", + "inputs": [], + "outputs": [], + "gas": 23142 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "commit_transfer_ownership", + "inputs": [{ "name": "_owner", "type": "address" }], + "outputs": [], + "gas": 78827 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "apply_transfer_ownership", + "inputs": [], + "outputs": [], + "gas": 67042 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "revert_transfer_ownership", + "inputs": [], + "outputs": [], + "gas": 23232 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "kill_me", + "inputs": [], + "outputs": [], + "gas": 40455 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "unkill_me", + "inputs": [], + "outputs": [], + "gas": 23292 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "set_admin_fee_receiver", + "inputs": [{ "name": "_admin_fee_receiver", "type": "address" }], + "outputs": [], + "gas": 38482 + }, + { + "stateMutability": "view", + "type": "function", + "name": "lp_price", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 217046 + }, + { + "stateMutability": "view", + "type": "function", + "name": "price_scale", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3426 + }, + { + "stateMutability": "view", + "type": "function", + "name": "price_oracle", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3456 + }, + { + "stateMutability": "view", + "type": "function", + "name": "price_oracle", + "inputs": [{ "name": "", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3456 + }, + { + "stateMutability": "view", + "type": "function", + "name": "last_prices", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3486 + }, + { + "stateMutability": "view", + "type": "function", + "name": "last_prices_timestamp", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3516 + }, + { + "stateMutability": "view", + "type": "function", + "name": "initial_A_gamma", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3546 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_A_gamma", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3576 + }, + { + "stateMutability": "view", + "type": "function", + "name": "initial_A_gamma_time", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3606 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_A_gamma_time", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3636 + }, + { + "stateMutability": "view", + "type": "function", + "name": "allowed_extra_profit", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3666 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_allowed_extra_profit", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3696 + }, + { + "stateMutability": "view", + "type": "function", + "name": "fee_gamma", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3726 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_fee_gamma", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3756 + }, + { + "stateMutability": "view", + "type": "function", + "name": "adjustment_step", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3786 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_adjustment_step", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3816 + }, + { + "stateMutability": "view", + "type": "function", + "name": "ma_half_time", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3846 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_ma_half_time", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3876 + }, + { + "stateMutability": "view", + "type": "function", + "name": "mid_fee", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3906 + }, + { + "stateMutability": "view", + "type": "function", + "name": "out_fee", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3936 + }, + { + "stateMutability": "view", + "type": "function", + "name": "admin_fee", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3966 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_mid_fee", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3996 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_out_fee", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4026 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_admin_fee", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4056 + }, + { + "stateMutability": "view", + "type": "function", + "name": "balances", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4131 + }, + { + "stateMutability": "view", + "type": "function", + "name": "D", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4116 + }, + { + "stateMutability": "view", + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 4146 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_owner", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 4176 + }, + { + "stateMutability": "view", + "type": "function", + "name": "xcp_profit", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4206 + }, + { + "stateMutability": "view", + "type": "function", + "name": "xcp_profit_a", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4236 + }, + { + "stateMutability": "view", + "type": "function", + "name": "virtual_price", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4266 + }, + { + "stateMutability": "view", + "type": "function", + "name": "is_killed", + "inputs": [], + "outputs": [{ "name": "", "type": "bool" }], + "gas": 4296 + }, + { + "stateMutability": "view", + "type": "function", + "name": "kill_deadline", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4326 + }, + { + "stateMutability": "view", + "type": "function", + "name": "transfer_ownership_deadline", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4356 + }, + { + "stateMutability": "view", + "type": "function", + "name": "admin_actions_deadline", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4386 + }, + { + "stateMutability": "view", + "type": "function", + "name": "admin_fee_receiver", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 4416 + }, + { + "name": "lp_token", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2291 + } +] diff --git a/subgraphs/gogopool/abis/Prices/Curve/Registry.json b/subgraphs/gogopool/abis/Prices/Curve/Registry.json new file mode 100644 index 0000000000..9747624cc9 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/Curve/Registry.json @@ -0,0 +1,337 @@ +[ + { + "name": "PoolAdded", + "inputs": [ + { "type": "address", "name": "pool", "indexed": true }, + { "type": "bytes", "name": "rate_method_id", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "PoolRemoved", + "inputs": [{ "type": "address", "name": "pool", "indexed": true }], + "anonymous": false, + "type": "event" + }, + { + "outputs": [], + "inputs": [ + { "type": "address", "name": "_address_provider" }, + { "type": "address", "name": "_gauge_controller" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "name": "find_pool_for_coins", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [ + { "type": "address", "name": "_from" }, + { "type": "address", "name": "_to" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "name": "find_pool_for_coins", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [ + { "type": "address", "name": "_from" }, + { "type": "address", "name": "_to" }, + { "type": "uint256", "name": "i" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "name": "get_n_coins", + "outputs": [{ "type": "uint256[2]", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 1704 + }, + { + "name": "get_coins", + "outputs": [{ "type": "address[8]", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 12285 + }, + { + "name": "get_underlying_coins", + "outputs": [{ "type": "address[8]", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 12347 + }, + { + "name": "get_decimals", + "outputs": [{ "type": "uint256[8]", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 8199 + }, + { + "name": "get_underlying_decimals", + "outputs": [{ "type": "uint256[8]", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 8261 + }, + { + "name": "get_rates", + "outputs": [{ "type": "uint256[8]", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 34780 + }, + { + "name": "get_gauges", + "outputs": [ + { "type": "address[10]", "name": "" }, + { "type": "int128[10]", "name": "" } + ], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 20310 + }, + { + "name": "get_balances", + "outputs": [{ "type": "uint256[8]", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 16818 + }, + { + "name": "get_underlying_balances", + "outputs": [{ "type": "uint256[8]", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 158953 + }, + { + "name": "get_virtual_price_from_lp_token", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "_token" }], + "stateMutability": "view", + "type": "function", + "gas": 2080 + }, + { + "name": "get_A", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 1198 + }, + { + "name": "get_parameters", + "outputs": [ + { "type": "uint256", "name": "A" }, + { "type": "uint256", "name": "future_A" }, + { "type": "uint256", "name": "fee" }, + { "type": "uint256", "name": "admin_fee" }, + { "type": "uint256", "name": "future_fee" }, + { "type": "uint256", "name": "future_admin_fee" }, + { "type": "address", "name": "future_owner" }, + { "type": "uint256", "name": "initial_A" }, + { "type": "uint256", "name": "initial_A_time" }, + { "type": "uint256", "name": "future_A_time" } + ], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 6458 + }, + { + "name": "get_fees", + "outputs": [{ "type": "uint256[2]", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 1603 + }, + { + "name": "get_admin_balances", + "outputs": [{ "type": "uint256[8]", "name": "" }], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "view", + "type": "function", + "gas": 36719 + }, + { + "name": "get_coin_indices", + "outputs": [ + { "type": "int128", "name": "" }, + { "type": "int128", "name": "" }, + { "type": "bool", "name": "" } + ], + "inputs": [ + { "type": "address", "name": "_pool" }, + { "type": "address", "name": "_from" }, + { "type": "address", "name": "_to" } + ], + "stateMutability": "view", + "type": "function", + "gas": 27456 + }, + { + "name": "estimate_gas_used", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "address", "name": "_pool" }, + { "type": "address", "name": "_from" }, + { "type": "address", "name": "_to" } + ], + "stateMutability": "view", + "type": "function", + "gas": 32329 + }, + { + "name": "add_pool", + "outputs": [], + "inputs": [ + { "type": "address", "name": "_pool" }, + { "type": "uint256", "name": "_n_coins" }, + { "type": "address", "name": "_lp_token" }, + { "type": "bytes32", "name": "_rate_method_id" }, + { "type": "uint256", "name": "_decimals" }, + { "type": "uint256", "name": "_underlying_decimals" }, + { "type": "bool", "name": "_has_initial_A" }, + { "type": "bool", "name": "_is_v1" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 10196577 + }, + { + "name": "add_pool_without_underlying", + "outputs": [], + "inputs": [ + { "type": "address", "name": "_pool" }, + { "type": "uint256", "name": "_n_coins" }, + { "type": "address", "name": "_lp_token" }, + { "type": "bytes32", "name": "_rate_method_id" }, + { "type": "uint256", "name": "_decimals" }, + { "type": "uint256", "name": "_use_rates" }, + { "type": "bool", "name": "_has_initial_A" }, + { "type": "bool", "name": "_is_v1" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 5590664 + }, + { + "name": "add_metapool", + "outputs": [], + "inputs": [ + { "type": "address", "name": "_pool" }, + { "type": "uint256", "name": "_n_coins" }, + { "type": "address", "name": "_lp_token" }, + { "type": "uint256", "name": "_decimals" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 10226976 + }, + { + "name": "remove_pool", + "outputs": [], + "inputs": [{ "type": "address", "name": "_pool" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 779646579509 + }, + { + "name": "set_coin_gas_estimates", + "outputs": [], + "inputs": [ + { "type": "address[10]", "name": "_addr" }, + { "type": "uint256[10]", "name": "_amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 357165 + }, + { + "name": "set_gas_estimate_contract", + "outputs": [], + "inputs": [ + { "type": "address", "name": "_pool" }, + { "type": "address", "name": "_estimator" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37747 + }, + { + "name": "set_liquidity_gauges", + "outputs": [], + "inputs": [ + { "type": "address", "name": "_pool" }, + { "type": "address[10]", "name": "_liquidity_gauges" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 365793 + }, + { + "name": "address_provider", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2111 + }, + { + "name": "gauge_controller", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2141 + }, + { + "name": "pool_list", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [{ "type": "uint256", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 2280 + }, + { + "name": "pool_count", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2201 + }, + { + "name": "get_pool_from_lp_token", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [{ "type": "address", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 2446 + }, + { + "name": "get_lp_token", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [{ "type": "address", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 2476 + } +] diff --git a/subgraphs/gogopool/abis/Prices/EGETH.json b/subgraphs/gogopool/abis/Prices/EGETH.json new file mode 100644 index 0000000000..03463c03a9 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/EGETH.json @@ -0,0 +1,349 @@ +[ + { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, + { "inputs": [], "name": "CallerNotEigenpieConfigAdmin", "type": "error" }, + { "inputs": [], "name": "CallerNotEigenpieConfigBurner", "type": "error" }, + { "inputs": [], "name": "CallerNotEigenpieConfigManager", "type": "error" }, + { "inputs": [], "name": "CallerNotEigenpieConfigMinter", "type": "error" }, + { + "inputs": [], + "name": "CallerNotEigenpieConfigPriceProvider", + "type": "error" + }, + { "inputs": [], "name": "ZeroAddressNotAllowed", "type": "error" }, + { + "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": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newExchangeRate", + "type": "uint256" + } + ], + "name": "LSTExchangeRateUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "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": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "eigenpieConfig", + "type": "address" + } + ], + "name": "UpdatedEigenpieConfig", + "type": "event" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "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": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "eigenpieConfig", + "outputs": [ + { + "internalType": "contract IEigenpieConfig", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "exchangeRateToLST", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "exchangeRateToNative", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "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": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { + "internalType": "address", + "name": "eigenpieConfigAddr", + "type": "address" + }, + { "internalType": "string", "name": "name", "type": "string" }, + { "internalType": "string", "name": "symbol", "type": "string" } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "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": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "underlyingAsset", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "eigenpieConfigAddr", + "type": "address" + } + ], + "name": "updateEigenpieConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_newRate", "type": "uint256" } + ], + "name": "updateExchangeRateToLST", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/ERC20.json b/subgraphs/gogopool/abis/Prices/ERC20.json new file mode 100644 index 0000000000..5c47f76a53 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/ERC20.json @@ -0,0 +1,828 @@ +[ + { + "name": "Transfer", + "inputs": [ + { "type": "address", "name": "sender", "indexed": true }, + { "type": "address", "name": "receiver", "indexed": true }, + { "type": "uint256", "name": "value", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "Approval", + "inputs": [ + { "type": "address", "name": "owner", "indexed": true }, + { "type": "address", "name": "spender", "indexed": true }, + { "type": "uint256", "name": "value", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyAdded", + "inputs": [ + { "type": "address", "name": "strategy", "indexed": true }, + { "type": "uint256", "name": "debtRatio", "indexed": false }, + { "type": "uint256", "name": "rateLimit", "indexed": false }, + { "type": "uint256", "name": "performanceFee", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyReported", + "inputs": [ + { "type": "address", "name": "strategy", "indexed": true }, + { "type": "uint256", "name": "gain", "indexed": false }, + { "type": "uint256", "name": "loss", "indexed": false }, + { "type": "uint256", "name": "totalGain", "indexed": false }, + { "type": "uint256", "name": "totalLoss", "indexed": false }, + { "type": "uint256", "name": "totalDebt", "indexed": false }, + { "type": "uint256", "name": "debtAdded", "indexed": false }, + { "type": "uint256", "name": "debtRatio", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateGovernance", + "inputs": [{ "type": "address", "name": "governance", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateManagement", + "inputs": [{ "type": "address", "name": "management", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateGuestList", + "inputs": [{ "type": "address", "name": "guestList", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateRewards", + "inputs": [{ "type": "address", "name": "rewards", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateDepositLimit", + "inputs": [{ "type": "uint256", "name": "depositLimit", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdatePerformanceFee", + "inputs": [ + { "type": "uint256", "name": "performanceFee", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateManagementFee", + "inputs": [ + { "type": "uint256", "name": "managementFee", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateGuardian", + "inputs": [{ "type": "address", "name": "guardian", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "EmergencyShutdown", + "inputs": [{ "type": "bool", "name": "active", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateWithdrawalQueue", + "inputs": [{ "type": "address[20]", "name": "queue", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyUpdateDebtRatio", + "inputs": [ + { "type": "address", "name": "strategy", "indexed": true }, + { "type": "uint256", "name": "debtRatio", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyUpdateRateLimit", + "inputs": [ + { "type": "address", "name": "strategy", "indexed": true }, + { "type": "uint256", "name": "rateLimit", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyUpdatePerformanceFee", + "inputs": [ + { "type": "address", "name": "strategy", "indexed": true }, + { "type": "uint256", "name": "performanceFee", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyMigrated", + "inputs": [ + { "type": "address", "name": "oldVersion", "indexed": true }, + { "type": "address", "name": "newVersion", "indexed": true } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyRevoked", + "inputs": [{ "type": "address", "name": "strategy", "indexed": true }], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyRemovedFromQueue", + "inputs": [{ "type": "address", "name": "strategy", "indexed": true }], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyAddedToQueue", + "inputs": [{ "type": "address", "name": "strategy", "indexed": true }], + "anonymous": false, + "type": "event" + }, + { + "name": "initialize", + "outputs": [], + "inputs": [ + { "type": "address", "name": "token" }, + { "type": "address", "name": "governance" }, + { "type": "address", "name": "rewards" }, + { "type": "string", "name": "nameOverride" }, + { "type": "string", "name": "symbolOverride" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "initialize", + "outputs": [], + "inputs": [ + { "type": "address", "name": "token" }, + { "type": "address", "name": "governance" }, + { "type": "address", "name": "rewards" }, + { "type": "string", "name": "nameOverride" }, + { "type": "string", "name": "symbolOverride" }, + { "type": "address", "name": "guardian" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "apiVersion", + "outputs": [{ "type": "string", "name": "" }], + "inputs": [], + "stateMutability": "pure", + "type": "function", + "gas": 4519 + }, + { + "name": "setName", + "outputs": [], + "inputs": [{ "type": "string", "name": "name" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 107017 + }, + { + "name": "setSymbol", + "outputs": [], + "inputs": [{ "type": "string", "name": "symbol" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 71867 + }, + { + "name": "setGovernance", + "outputs": [], + "inputs": [{ "type": "address", "name": "governance" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 36338 + }, + { + "name": "acceptGovernance", + "outputs": [], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37610 + }, + { + "name": "setManagement", + "outputs": [], + "inputs": [{ "type": "address", "name": "management" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37748 + }, + { + "name": "setGuestList", + "outputs": [], + "inputs": [{ "type": "address", "name": "guestList" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37778 + }, + { + "name": "setRewards", + "outputs": [], + "inputs": [{ "type": "address", "name": "rewards" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37808 + }, + { + "name": "setDepositLimit", + "outputs": [], + "inputs": [{ "type": "uint256", "name": "limit" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37738 + }, + { + "name": "setPerformanceFee", + "outputs": [], + "inputs": [{ "type": "uint256", "name": "fee" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37872 + }, + { + "name": "setManagementFee", + "outputs": [], + "inputs": [{ "type": "uint256", "name": "fee" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37902 + }, + { + "name": "setGuardian", + "outputs": [], + "inputs": [{ "type": "address", "name": "guardian" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 39146 + }, + { + "name": "setEmergencyShutdown", + "outputs": [], + "inputs": [{ "type": "bool", "name": "active" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 39217 + }, + { + "name": "setWithdrawalQueue", + "outputs": [], + "inputs": [{ "type": "address[20]", "name": "queue" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 763893 + }, + { + "name": "transfer", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "receiver" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 76733 + }, + { + "name": "transferFrom", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "sender" }, + { "type": "address", "name": "receiver" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 116496 + }, + { + "name": "approve", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "spender" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 38244 + }, + { + "name": "increaseAllowance", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "spender" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 40285 + }, + { + "name": "decreaseAllowance", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "spender" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 40309 + }, + { + "name": "permit", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "owner" }, + { "type": "address", "name": "spender" }, + { "type": "uint256", "name": "amount" }, + { "type": "uint256", "name": "expiry" }, + { "type": "bytes", "name": "signature" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 81237 + }, + { + "name": "totalAssets", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 4123 + }, + { + "name": "deposit", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "deposit", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "uint256", "name": "_amount" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "deposit", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "uint256", "name": "_amount" }, + { "type": "address", "name": "recipient" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "maxAvailableShares", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 364171 + }, + { + "name": "withdraw", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "withdraw", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "uint256", "name": "maxShares" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "withdraw", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "uint256", "name": "maxShares" }, + { "type": "address", "name": "recipient" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "withdraw", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "uint256", "name": "maxShares" }, + { "type": "address", "name": "recipient" }, + { "type": "uint256", "name": "maxLoss" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "pricePerShare", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 12412 + }, + { + "name": "addStrategy", + "outputs": [], + "inputs": [ + { "type": "address", "name": "strategy" }, + { "type": "uint256", "name": "debtRatio" }, + { "type": "uint256", "name": "rateLimit" }, + { "type": "uint256", "name": "performanceFee" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 1450351 + }, + { + "name": "updateStrategyDebtRatio", + "outputs": [], + "inputs": [ + { "type": "address", "name": "strategy" }, + { "type": "uint256", "name": "debtRatio" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 115316 + }, + { + "name": "updateStrategyRateLimit", + "outputs": [], + "inputs": [ + { "type": "address", "name": "strategy" }, + { "type": "uint256", "name": "rateLimit" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 41467 + }, + { + "name": "updateStrategyPerformanceFee", + "outputs": [], + "inputs": [ + { "type": "address", "name": "strategy" }, + { "type": "uint256", "name": "performanceFee" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 41344 + }, + { + "name": "migrateStrategy", + "outputs": [], + "inputs": [ + { "type": "address", "name": "oldVersion" }, + { "type": "address", "name": "newVersion" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 1105801 + }, + { + "name": "revokeStrategy", + "outputs": [], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "revokeStrategy", + "outputs": [], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "addStrategyToQueue", + "outputs": [], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 1196920 + }, + { + "name": "removeStrategyFromQueue", + "outputs": [], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 23091666 + }, + { + "name": "debtOutstanding", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "name": "debtOutstanding", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "view", + "type": "function" + }, + { + "name": "creditAvailable", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "name": "creditAvailable", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "view", + "type": "function" + }, + { + "name": "availableDepositLimit", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 9808 + }, + { + "name": "expectedReturn", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "name": "expectedReturn", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "view", + "type": "function" + }, + { + "name": "report", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "uint256", "name": "gain" }, + { "type": "uint256", "name": "loss" }, + { "type": "uint256", "name": "_debtPayment" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 937520 + }, + { + "name": "sweep", + "outputs": [], + "inputs": [{ "type": "address", "name": "token" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "sweep", + "outputs": [], + "inputs": [ + { "type": "address", "name": "token" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "name", + "outputs": [{ "type": "string", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 9053 + }, + { + "name": "symbol", + "outputs": [{ "type": "string", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 8106 + }, + { + "name": "decimals", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2711 + }, + { + "name": "balanceOf", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 2956 + }, + { + "name": "allowance", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "address", "name": "arg0" }, + { "type": "address", "name": "arg1" } + ], + "stateMutability": "view", + "type": "function", + "gas": 3201 + }, + { + "name": "totalSupply", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2801 + }, + { + "name": "token", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2831 + }, + { + "name": "governance", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2861 + }, + { + "name": "management", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2891 + }, + { + "name": "guardian", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2921 + }, + { + "name": "guestList", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2951 + }, + { + "name": "strategies", + "outputs": [ + { "type": "uint256", "name": "performanceFee" }, + { "type": "uint256", "name": "activation" }, + { "type": "uint256", "name": "debtRatio" }, + { "type": "uint256", "name": "rateLimit" }, + { "type": "uint256", "name": "lastReport" }, + { "type": "uint256", "name": "totalDebt" }, + { "type": "uint256", "name": "totalGain" }, + { "type": "uint256", "name": "totalLoss" } + ], + "inputs": [{ "type": "address", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 10322 + }, + { + "name": "withdrawalQueue", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [{ "type": "uint256", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 3120 + }, + { + "name": "emergencyShutdown", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3041 + }, + { + "name": "depositLimit", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3071 + }, + { + "name": "debtRatio", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3101 + }, + { + "name": "totalDebt", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3131 + }, + { + "name": "lastReport", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3161 + }, + { + "name": "activation", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3191 + }, + { + "name": "rewards", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3221 + }, + { + "name": "managementFee", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3251 + }, + { + "name": "performanceFee", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3281 + }, + { + "name": "nonces", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 3526 + }, + { + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "type": "bytes32", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3341 + } +] diff --git a/subgraphs/gogopool/abis/Prices/EigenpieMLRT.json b/subgraphs/gogopool/abis/Prices/EigenpieMLRT.json new file mode 100644 index 0000000000..03463c03a9 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/EigenpieMLRT.json @@ -0,0 +1,349 @@ +[ + { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, + { "inputs": [], "name": "CallerNotEigenpieConfigAdmin", "type": "error" }, + { "inputs": [], "name": "CallerNotEigenpieConfigBurner", "type": "error" }, + { "inputs": [], "name": "CallerNotEigenpieConfigManager", "type": "error" }, + { "inputs": [], "name": "CallerNotEigenpieConfigMinter", "type": "error" }, + { + "inputs": [], + "name": "CallerNotEigenpieConfigPriceProvider", + "type": "error" + }, + { "inputs": [], "name": "ZeroAddressNotAllowed", "type": "error" }, + { + "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": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newExchangeRate", + "type": "uint256" + } + ], + "name": "LSTExchangeRateUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "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": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "eigenpieConfig", + "type": "address" + } + ], + "name": "UpdatedEigenpieConfig", + "type": "event" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "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": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "eigenpieConfig", + "outputs": [ + { + "internalType": "contract IEigenpieConfig", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "exchangeRateToLST", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "exchangeRateToNative", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "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": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { + "internalType": "address", + "name": "eigenpieConfigAddr", + "type": "address" + }, + { "internalType": "string", "name": "name", "type": "string" }, + { "internalType": "string", "name": "symbol", "type": "string" } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "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": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "underlyingAsset", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "eigenpieConfigAddr", + "type": "address" + } + ], + "name": "updateEigenpieConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_newRate", "type": "uint256" } + ], + "name": "updateExchangeRateToLST", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/SFRAX.json b/subgraphs/gogopool/abis/Prices/SFRAX.json new file mode 100644 index 0000000000..b7e97dd119 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/SFRAX.json @@ -0,0 +1,730 @@ +[ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_underlying", + "type": "address" + }, + { "internalType": "string", "name": "_name", "type": "string" }, + { "internalType": "string", "name": "_symbol", "type": "string" }, + { + "internalType": "uint32", + "name": "_rewardsCycleLength", + "type": "uint32" + }, + { + "internalType": "uint256", + "name": "_maxDistributionPerSecondPerAsset", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_timelockAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pendingTimelockAddress", + "type": "address" + }, + { "internalType": "address", "name": "actualAddress", "type": "address" } + ], + "name": "AddressIsNotPendingTimelock", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "timelockAddress", + "type": "address" + }, + { "internalType": "address", "name": "actualAddress", "type": "address" } + ], + "name": "AddressIsNotTimelock", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "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": "rewardsToDistribute", + "type": "uint256" + } + ], + "name": "DistributeRewards", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMax", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newMax", + "type": "uint256" + } + ], + "name": "SetMaxDistributionPerSecondPerAsset", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint40", + "name": "cycleEnd", + "type": "uint40" + }, + { + "indexed": false, + "internalType": "uint40", + "name": "lastSync", + "type": "uint40" + }, + { + "indexed": false, + "internalType": "uint216", + "name": "rewardCycleAmount", + "type": "uint216" + } + ], + "name": "SyncRewards", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousTimelock", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newTimelock", + "type": "address" + } + ], + "name": "TimelockTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousTimelock", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newTimelock", + "type": "address" + } + ], + "name": "TimelockTransferred", + "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": "amount", + "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" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PRECISION", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "REWARDS_CYCLE_LENGTH", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UNDERLYING_PRECISION", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptTransferTimelock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "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": "contract ERC20", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "uint40", "name": "cycleEnd", "type": "uint40" }, + { "internalType": "uint40", "name": "lastSync", "type": "uint40" }, + { + "internalType": "uint216", + "name": "rewardCycleAmount", + "type": "uint216" + } + ], + "internalType": "struct LinearRewardsErc4626.RewardsCycleData", + "name": "_rewardsCycleData", + "type": "tuple" + }, + { "internalType": "uint256", "name": "_deltaTime", "type": "uint256" } + ], + "name": "calculateRewardsToDistribute", + "outputs": [ + { + "internalType": "uint256", + "name": "_rewardToDistribute", + "type": "uint256" + } + ], + "stateMutability": "view", + "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": "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": "_shares", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_assets", "type": "uint256" }, + { "internalType": "address", "name": "_receiver", "type": "address" }, + { "internalType": "uint256", "name": "_deadline", "type": "uint256" }, + { "internalType": "bool", "name": "_approveMax", "type": "bool" }, + { "internalType": "uint8", "name": "_v", "type": "uint8" }, + { "internalType": "bytes32", "name": "_r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "_s", "type": "bytes32" } + ], + "name": "depositWithSignature", + "outputs": [ + { "internalType": "uint256", "name": "_shares", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "lastRewardsDistribution", + "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": [], + "name": "maxDistributionPerSecondPerAsset", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "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": "_assets", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "nonces", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingTimelockAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "assets", "type": "uint256" } + ], + "name": "previewDeposit", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "previewDistributeRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "_rewardToDistribute", + "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": [], + "name": "previewSyncRewards", + "outputs": [ + { + "components": [ + { "internalType": "uint40", "name": "cycleEnd", "type": "uint40" }, + { "internalType": "uint40", "name": "lastSync", "type": "uint40" }, + { + "internalType": "uint216", + "name": "rewardCycleAmount", + "type": "uint216" + } + ], + "internalType": "struct LinearRewardsErc4626.RewardsCycleData", + "name": "_newRewardsCycleData", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "assets", "type": "uint256" } + ], + "name": "previewWithdraw", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pricePerShare", + "outputs": [ + { "internalType": "uint256", "name": "_pricePerShare", "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": "_assets", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceTimelock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardsCycleData", + "outputs": [ + { "internalType": "uint40", "name": "cycleEnd", "type": "uint40" }, + { "internalType": "uint40", "name": "lastSync", "type": "uint40" }, + { + "internalType": "uint216", + "name": "rewardCycleAmount", + "type": "uint216" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_maxDistributionPerSecondPerAsset", + "type": "uint256" + } + ], + "name": "setMaxDistributionPerSecondPerAsset", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "storedTotalAssets", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "syncRewardsAndDistribution", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "timelockAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { "internalType": "uint256", "name": "_totalAssets", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_newTimelock", "type": "address" } + ], + "name": "transferTimelock", + "outputs": [], + "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": "_shares", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/Uniswap/Factory.json b/subgraphs/gogopool/abis/Prices/Uniswap/Factory.json new file mode 100644 index 0000000000..1b14599d5d --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/Uniswap/Factory.json @@ -0,0 +1,125 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_feeToSetter", "type": "address" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "pair", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "PairCreated", + "type": "event" + }, + { + "constant": true, + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "allPairs", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "allPairsLength", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "tokenA", "type": "address" }, + { "internalType": "address", "name": "tokenB", "type": "address" } + ], + "name": "createPair", + "outputs": [ + { "internalType": "address", "name": "pair", "type": "address" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "feeTo", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "feeToSetter", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "getPair", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_feeTo", "type": "address" } + ], + "name": "setFeeTo", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_feeToSetter", "type": "address" } + ], + "name": "setFeeToSetter", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/Uniswap/Pair.json b/subgraphs/gogopool/abis/Prices/Uniswap/Pair.json new file mode 100644 index 0000000000..e5efebf418 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/Uniswap/Pair.json @@ -0,0 +1,461 @@ +[ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0In", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1In", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0Out", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1Out", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "Swap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint112", + "name": "reserve0", + "type": "uint112" + }, + { + "indexed": false, + "internalType": "uint112", + "name": "reserve1", + "type": "uint112" + } + ], + "name": "Sync", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MINIMUM_LIQUIDITY", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], + "name": "burn", + "outputs": [ + { "internalType": "uint256", "name": "amount0", "type": "uint256" }, + { "internalType": "uint256", "name": "amount1", "type": "uint256" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "factory", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getReserves", + "outputs": [ + { "internalType": "uint112", "name": "_reserve0", "type": "uint112" }, + { "internalType": "uint112", "name": "_reserve1", "type": "uint112" }, + { + "internalType": "uint32", + "name": "_blockTimestampLast", + "type": "uint32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_token0", "type": "address" }, + { "internalType": "address", "name": "_token1", "type": "address" } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "kLast", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], + "name": "mint", + "outputs": [ + { "internalType": "uint256", "name": "liquidity", "type": "uint256" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "nonces", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "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": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "price0CumulativeLast", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "price1CumulativeLast", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], + "name": "skim", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "amount0Out", "type": "uint256" }, + { "internalType": "uint256", "name": "amount1Out", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "bytes", "name": "data", "type": "bytes" } + ], + "name": "swap", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "sync", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "token0", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "token1", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Prices/Uniswap/Router.json b/subgraphs/gogopool/abis/Prices/Uniswap/Router.json new file mode 100644 index 0000000000..efc7f31728 --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/Uniswap/Router.json @@ -0,0 +1,398 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_factory", "type": "address" }, + { "internalType": "address", "name": "_WETH", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "WETH", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenA", "type": "address" }, + { "internalType": "address", "name": "tokenB", "type": "address" }, + { + "internalType": "uint256", + "name": "amountADesired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountBDesired", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, + { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "addLiquidity", + "outputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "amountB", "type": "uint256" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { + "internalType": "uint256", + "name": "amountTokenDesired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "addLiquidityETH", + "outputs": [ + { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, + { "internalType": "uint256", "name": "amountETH", "type": "uint256" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveIn", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveOut", "type": "uint256" } + ], + "name": "getAmountIn", + "outputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveIn", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveOut", "type": "uint256" } + ], + "name": "getAmountOut", + "outputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" } + ], + "name": "getAmountsIn", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" } + ], + "name": "getAmountsOut", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveA", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveB", "type": "uint256" } + ], + "name": "quote", + "outputs": [ + { "internalType": "uint256", "name": "amountB", "type": "uint256" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenA", "type": "address" }, + { "internalType": "address", "name": "tokenB", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, + { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "removeLiquidity", + "outputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "amountB", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "removeLiquidityETH", + "outputs": [ + { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "removeLiquidityETHSupportingFeeOnTransferTokens", + "outputs": [ + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "bool", "name": "approveMax", "type": "bool" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "removeLiquidityETHWithPermit", + "outputs": [ + { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "bool", "name": "approveMax", "type": "bool" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "removeLiquidityETHWithPermitSupportingFeeOnTransferTokens", + "outputs": [ + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenA", "type": "address" }, + { "internalType": "address", "name": "tokenB", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, + { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "bool", "name": "approveMax", "type": "bool" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "removeLiquidityWithPermit", + "outputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "amountB", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapETHForExactTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactETHForTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactETHForTokensSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForETH", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForETHSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForTokensSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "uint256", "name": "amountInMax", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapTokensForExactETH", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "uint256", "name": "amountInMax", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapTokensForExactTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } +] diff --git a/subgraphs/gogopool/abis/Prices/WBETH.json b/subgraphs/gogopool/abis/Prices/WBETH.json new file mode 100644 index 0000000000..888bb50f5c --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/WBETH.json @@ -0,0 +1,1072 @@ +[ + { + "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": "authorizer", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "nonce", + "type": "bytes32" + } + ], + "name": "AuthorizationCanceled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "authorizer", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "nonce", + "type": "bytes32" + } + ], + "name": "AuthorizationUsed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "Blacklisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newBlacklister", + "type": "address" + } + ], + "name": "BlacklisterChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "burner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "ethAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wBETHAmount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "referral", + "type": "address" + } + ], + "name": "DepositEth", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousReceiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newReceiver", + "type": "address" + } + ], + "name": "EthReceiverUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newExchangeRate", + "type": "uint256" + } + ], + "name": "ExchangeRateUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newMasterMinter", + "type": "address" + } + ], + "name": "MasterMinterChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minterAllowedAmount", + "type": "uint256" + } + ], + "name": "MinterConfigured", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldMinter", + "type": "address" + } + ], + "name": "MinterRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "ethReceiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "ethAmount", + "type": "uint256" + } + ], + "name": "MovedToStakingAddress", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "unwrapAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "ethAmount", + "type": "uint256" + } + ], + "name": "MovedToUnwrapAddress", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOperator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOperator", + "type": "address" + } + ], + "name": "OperatorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newOracle", + "type": "address" + } + ], + "name": "OracleUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { "anonymous": false, "inputs": [], "name": "Pause", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "PauserChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wbethAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "ethAmount", + "type": "uint256" + } + ], + "name": "RequestWithdrawEth", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newRescuer", + "type": "address" + } + ], + "name": "RescuerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "supplier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "ethAmount", + "type": "uint256" + } + ], + "name": "SuppliedEth", + "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": "_account", + "type": "address" + } + ], + "name": "UnBlacklisted", + "type": "event" + }, + { "anonymous": false, "inputs": [], "name": "Unpause", "type": "event" }, + { + "inputs": [], + "name": "CANCEL_AUTHORIZATION_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RECEIVE_WITH_AUTHORIZATION_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_WITH_AUTHORIZATION_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_EXCHANGE_RATE_UNIT", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_UNWRAP_ETH_ADDRESS", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "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": "value", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "authorizer", "type": "address" }, + { "internalType": "bytes32", "name": "nonce", "type": "bytes32" } + ], + "name": "authorizationState", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" } + ], + "name": "blacklist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blacklister", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "authorizer", "type": "address" }, + { "internalType": "bytes32", "name": "nonce", "type": "bytes32" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "cancelAuthorization", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "minter", "type": "address" }, + { + "internalType": "uint256", + "name": "minterAllowedAmount", + "type": "uint256" + } + ], + "name": "configureMinter", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "currency", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "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": "decrement", "type": "uint256" } + ], + "name": "decreaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "referral", "type": "address" } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "ethReceiver", + "outputs": [ + { "internalType": "address", "name": "_ethReceiver", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "exchangeRate", + "outputs": [ + { "internalType": "uint256", "name": "_exchangeRate", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "increment", "type": "uint256" } + ], + "name": "increaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "string", "name": "tokenName", "type": "string" }, + { "internalType": "string", "name": "tokenSymbol", "type": "string" }, + { "internalType": "string", "name": "tokenCurrency", "type": "string" }, + { "internalType": "uint8", "name": "tokenDecimals", "type": "uint8" }, + { + "internalType": "address", + "name": "newMasterMinter", + "type": "address" + }, + { "internalType": "address", "name": "newPauser", "type": "address" }, + { + "internalType": "address", + "name": "newBlacklister", + "type": "address" + }, + { "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "string", "name": "newName", "type": "string" } + ], + "name": "initializeV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "lostAndFound", "type": "address" } + ], + "name": "initializeV2_1", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" } + ], + "name": "isBlacklisted", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "isMinter", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "masterMinter", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "mint", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "mint", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "minter", "type": "address" } + ], + "name": "minterAllowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "moveToStakingAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "moveToUnwrapAddress", + "outputs": [], + "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": [], + "name": "operator", + "outputs": [ + { "internalType": "address", "name": "_operator", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { "internalType": "address", "name": "_oracle", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauser", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "validAfter", "type": "uint256" }, + { "internalType": "uint256", "name": "validBefore", "type": "uint256" }, + { "internalType": "bytes32", "name": "nonce", "type": "bytes32" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "receiveWithAuthorization", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "minter", "type": "address" } + ], + "name": "removeMinter", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "wbethAmount", "type": "uint256" } + ], + "name": "requestWithdrawEth", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "tokenContract", + "type": "address" + }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "rescueERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rescuer", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "supplyEth", + "outputs": [], + "stateMutability": "payable", + "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": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "validAfter", "type": "uint256" }, + { "internalType": "uint256", "name": "validBefore", "type": "uint256" }, + { "internalType": "bytes32", "name": "nonce", "type": "bytes32" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "transferWithAuthorization", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" } + ], + "name": "unBlacklist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newBlacklister", + "type": "address" + } + ], + "name": "updateBlacklister", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newEthReceiver", "type": "address" } + ], + "name": "updateEthReceiver", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newExchangeRate", + "type": "uint256" + } + ], + "name": "updateExchangeRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newMasterMinter", + "type": "address" + } + ], + "name": "updateMasterMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newOperator", "type": "address" } + ], + "name": "updateOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newOracle", "type": "address" } + ], + "name": "updateOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_newPauser", "type": "address" } + ], + "name": "updatePauser", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newRescuer", "type": "address" } + ], + "name": "updateRescuer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } +] diff --git a/subgraphs/gogopool/abis/Prices/YearnLens.json b/subgraphs/gogopool/abis/Prices/YearnLens.json new file mode 100644 index 0000000000..60a45cc87c --- /dev/null +++ b/subgraphs/gogopool/abis/Prices/YearnLens.json @@ -0,0 +1,174 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_managementListAddress", + "type": "address" + }, + { "internalType": "address", "name": "_usdcAddress", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "tokenAliasAddress", + "type": "address" + } + ], + "name": "TokenAliasAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "tokenAddress", + "type": "address" + } + ], + "name": "TokenAliasRemoved", + "type": "event" + }, + { "stateMutability": "nonpayable", "type": "fallback" }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" }, + { + "internalType": "address", + "name": "tokenAliasAddress", + "type": "address" + } + ], + "name": "addTokenAlias", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenAliasAddress", + "type": "address" + } + ], + "internalType": "struct Oracle.TokenAlias[]", + "name": "_tokenAliases", + "type": "tuple[]" + } + ], + "name": "addTokenAliases", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "calculations", + "outputs": [ + { "internalType": "address[]", "name": "", "type": "address[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "getNormalizedValueUsdc", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "uint256", "name": "priceUsdc", "type": "uint256" } + ], + "name": "getNormalizedValueUsdc", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "getPriceUsdcRecommended", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "managementList", + "outputs": [ + { + "internalType": "contract ManagementList", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" } + ], + "name": "removeTokenAlias", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "calculationAddresses", + "type": "address[]" + } + ], + "name": "setCalculations", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "tokenAliases", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "usdcAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Tokens/ERC20.json b/subgraphs/gogopool/abis/Tokens/ERC20.json new file mode 100644 index 0000000000..405d6b3648 --- /dev/null +++ b/subgraphs/gogopool/abis/Tokens/ERC20.json @@ -0,0 +1,222 @@ +[ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "balance", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + }, + { + "name": "_spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + } +] diff --git a/subgraphs/gogopool/abis/Tokens/ERC20NameBytes.json b/subgraphs/gogopool/abis/Tokens/ERC20NameBytes.json new file mode 100644 index 0000000000..2d3c877a8c --- /dev/null +++ b/subgraphs/gogopool/abis/Tokens/ERC20NameBytes.json @@ -0,0 +1,17 @@ +[ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/gogopool/abis/Tokens/ERC20SymbolBytes.json b/subgraphs/gogopool/abis/Tokens/ERC20SymbolBytes.json new file mode 100644 index 0000000000..a76d616366 --- /dev/null +++ b/subgraphs/gogopool/abis/Tokens/ERC20SymbolBytes.json @@ -0,0 +1,17 @@ +[ + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/gogopool/configurations/configurations/configurations.ts b/subgraphs/gogopool/configurations/configurations/configurations.ts new file mode 100644 index 0000000000..c631da9aa4 --- /dev/null +++ b/subgraphs/gogopool/configurations/configurations/configurations.ts @@ -0,0 +1,20 @@ +import { log } from "@graphprotocol/graph-ts"; + +import { Configurations } from "./interface"; +import { Deploy } from "./deploy"; +import { GoGoPoolAvaxConfigurations } from "../../protocols/gogopool/config/deployments/gogopool-avalanche/configurations"; + +export function getNetworkConfigurations(deploy: i32): Configurations { + switch (deploy) { + case Deploy.GOGOPOOL_AVALANCHE: { + return new GoGoPoolAvaxConfigurations(); + } + default: { + log.critical( + "No configurations found for deployment protocol/network", + [] + ); + return new GoGoPoolAvaxConfigurations(); + } + } +} diff --git a/subgraphs/gogopool/configurations/configurations/deploy.ts b/subgraphs/gogopool/configurations/configurations/deploy.ts new file mode 100644 index 0000000000..b5ce09b3f0 --- /dev/null +++ b/subgraphs/gogopool/configurations/configurations/deploy.ts @@ -0,0 +1,3 @@ +export namespace Deploy { + export const GOGOPOOL_AVALANCHE = 0; +} diff --git a/subgraphs/gogopool/configurations/configurations/interface.ts b/subgraphs/gogopool/configurations/configurations/interface.ts new file mode 100644 index 0000000000..9617d359cf --- /dev/null +++ b/subgraphs/gogopool/configurations/configurations/interface.ts @@ -0,0 +1,10 @@ +import { Address } from "@graphprotocol/graph-ts"; + +export interface Configurations { + getNetwork(): string; + getProtocolId(): string; + getProtocolName(): string; + getProtocolSlug(): string; + getLSTAddress(): Address; + getWAVAXAddress(): Address; +} diff --git a/subgraphs/gogopool/configurations/configure.mustache b/subgraphs/gogopool/configurations/configure.mustache new file mode 100644 index 0000000000..971ba89573 --- /dev/null +++ b/subgraphs/gogopool/configurations/configure.mustache @@ -0,0 +1,6 @@ +import { getNetworkConfigurations } from "./configurations/configurations"; +import { Deploy } from "./configurations/deploy"; + +let deployment = Deploy.{{ deployment }}; + +export const NetworkConfigs = getNetworkConfigurations(deployment); diff --git a/subgraphs/gogopool/package.json b/subgraphs/gogopool/package.json new file mode 100644 index 0000000000..f6025f9d70 --- /dev/null +++ b/subgraphs/gogopool/package.json @@ -0,0 +1,15 @@ +{ + "name": "gogopool", + "license": "MIT", + "scripts": { + "format": "npx prettier --write .", + "prepare:constants": "mustache protocols/${npm_config_protocol}/config/deployments/${npm_config_id}/configurations.json configurations/configure.mustache > configurations/configure.ts" + }, + "dependencies": { + "@graphprotocol/graph-cli": "^0.80.1", + "@graphprotocol/graph-ts": "^0.35.1" + }, + "devDependencies": { + "prettier": "^3.2.5" + } +} diff --git a/subgraphs/gogopool/protocols/gogopool/config/deployments/gogopool-avalanche/configurations.json b/subgraphs/gogopool/protocols/gogopool/config/deployments/gogopool-avalanche/configurations.json new file mode 100644 index 0000000000..4a50102c71 --- /dev/null +++ b/subgraphs/gogopool/protocols/gogopool/config/deployments/gogopool-avalanche/configurations.json @@ -0,0 +1,44 @@ +{ + "deployment": "GOGOPOOL_AVALANCHE", + "network": "avalanche", + "file": "./src/mappings/handlers.ts", + "ggAVAX": { + "address": "0xa25eaf2906fa1a3a13edac9b9657108af7b703e3", + "startBlock": "28365002" + }, + "minipoolManagers": [ + { + "name": "MinipoolManager1", + "abi": "MinipoolManager", + "address": "0x9e6579161c6f53722541edbd5ac96779c5b280e9", + "startBlock": "34805434" + }, + { + "name": "MinipoolManager2", + "abi": "MinipoolManager", + "address": "0xe51262211948c338c50640f1d5bdba4f4d208dea", + "startBlock": "37284561" + }, + { + "name": "MinipoolManager3", + "abi": "MinipoolManager", + "address": "0xb84fa022c7fe1ce3a1f94c49f2f13236c3d1ed08", + "startBlock": "37284659" + }, + { + "name": "MinipoolManager4", + "abi": "MinipoolManager", + "address": "0x17395ad76b236fabeac3634b78ff8f6970222199", + "startBlock": "42855225" + }, + { + "name": "MinipoolManager5", + "abi": "MinipoolManager", + "address": "0xc300bc9b4b690ba7a182126299a0618ece268ee7", + "startBlock": "48965588" + } + ], + "graftEnabled": false, + "subgraphId": "", + "graftStartBlock": 0 +} diff --git a/subgraphs/gogopool/protocols/gogopool/config/deployments/gogopool-avalanche/configurations.ts b/subgraphs/gogopool/protocols/gogopool/config/deployments/gogopool-avalanche/configurations.ts new file mode 100644 index 0000000000..e3ec4c6a98 --- /dev/null +++ b/subgraphs/gogopool/protocols/gogopool/config/deployments/gogopool-avalanche/configurations.ts @@ -0,0 +1,29 @@ +import { Address } from "@graphprotocol/graph-ts"; + +import { Configurations } from "../../../../../configurations/configurations/interface"; +import { + PROTOCOL_NAME, + PROTOCOL_SLUG, +} from "../../../../../src/common/constants"; +import { Network } from "../../../../../src/sdk/util/constants"; + +export class GoGoPoolAvaxConfigurations implements Configurations { + getNetwork(): string { + return Network.AVALANCHE; + } + getProtocolId(): string { + return "0xa25eaf2906fa1a3a13edac9b9657108af7b703e3"; + } + getProtocolName(): string { + return PROTOCOL_NAME; + } + getProtocolSlug(): string { + return PROTOCOL_SLUG; + } + getLSTAddress(): Address { + return Address.fromString("0xa25eaf2906fa1a3a13edac9b9657108af7b703e3"); + } + getWAVAXAddress(): Address { + return Address.fromString("0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7"); + } +} diff --git a/subgraphs/gogopool/protocols/gogopool/config/templates/gogopool.template.yaml b/subgraphs/gogopool/protocols/gogopool/config/templates/gogopool.template.yaml new file mode 100644 index 0000000000..023e3f2944 --- /dev/null +++ b/subgraphs/gogopool/protocols/gogopool/config/templates/gogopool.template.yaml @@ -0,0 +1,167 @@ +specVersion: 0.0.8 +schema: + file: ./schema.graphql +{{#graftEnabled}} +features: + - grafting +graft: + base: {{ subgraphId }} # Subgraph ID of base subgraph + block: {{ graftStartBlock }} # Block number +{{/graftEnabled}} +dataSources: + - kind: ethereum + name: GGAVAX + network: {{ network }} + source: + address: "{{ ggAVAX.address }}" + abi: GGAVAX + startBlock: {{ ggAVAX.startBlock }} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Token + - Pool + - PoolDailySnapshot + - PoolHourlySnapshot + - Protocol + - FinancialsDailySnapshot + - UsageMetricsDailySnapshot + - UsageMetricsHourlySnapshot + abis: + - name: GGAVAX + file: ./abis/GoGoPool/GGAVAX.json + - name: MinipoolManager + file: ./abis/GoGoPool/MinipoolManager.json + - name: ChainlinkDataFeed + file: ./abis/Prices/ChainlinkDataFeed.json + + - name: ERC20 + file: ./abis/Tokens/ERC20.json + - name: ERC20SymbolBytes + file: ./abis/Tokens/ERC20SymbolBytes.json + - name: ERC20NameBytes + file: ./abis/Tokens/ERC20NameBytes.json + + ########################################### + ############## Price Oracle ############### + ########################################### + # ERC20 + - name: _ERC20 + file: ./abis/Prices/ERC20.json + # Curve Contracts + - name: CurvePool + file: ./abis/Prices/Curve/Pool.json + - name: CurveRegistry + file: ./abis/Prices/Curve/Registry.json + - name: CalculationsCurve + file: ./abis/Prices/Calculations/Curve.json + # YearnLens Contracts + - name: YearnLensContract + file: ./abis/Prices/YearnLens.json + # Aave Oracle Contract + - name: AaveOracleContract + file: ./abis/Prices/AaveOracle.json + # SushiSwap Contracts + - name: CalculationsSushiSwap + file: ./abis/Prices/Calculations/SushiSwap.json + # ChainLink Contracts + - name: ChainLinkContract + file: ./abis/Prices/ChainLink.json + # Uniswap Contracts + - name: UniswapRouter + file: ./abis/Prices/Uniswap/Router.json + - name: UniswapFactory + file: ./abis/Prices/Uniswap/Factory.json + - name: UniswapPair + file: ./abis/Prices/Uniswap/Pair.json + eventHandlers: + - event: Deposit(indexed address,indexed address,uint256,uint256) + handler: handleDeposit + - event: DepositedFromStaking(indexed address,uint256,uint256) + handler: handleDepositedFromStaking + - event: Withdraw(indexed address,indexed address,indexed address,uint256,uint256) + handler: handleWithdraw + - event: WithdrawnForStaking(indexed address,uint256) + handler: handleWithdrawnForStaking + - event: NewRewardsCycle(indexed uint256,uint256) + handler: handleNewRewardsCycle + file: {{{ file }}} + {{#minipoolManagers}} + - kind: ethereum + name: {{ name }} + network: {{ network }} + source: + address: "{{ address }}" + abi: {{ abi }} + startBlock: {{ startBlock }} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Token + - Pool + - PoolDailySnapshot + - PoolHourlySnapshot + - Protocol + - FinancialsDailySnapshot + - UsageMetricsDailySnapshot + - UsageMetricsHourlySnapshot + abis: + - name: GGAVAX + file: ./abis/GoGoPool/GGAVAX.json + - name: MinipoolManager + file: ./abis/GoGoPool/MinipoolManager.json + - name: ChainlinkDataFeed + file: ./abis/Prices/ChainlinkDataFeed.json + + - name: ERC20 + file: ./abis/Tokens/ERC20.json + - name: ERC20SymbolBytes + file: ./abis/Tokens/ERC20SymbolBytes.json + - name: ERC20NameBytes + file: ./abis/Tokens/ERC20NameBytes.json + + ########################################### + ############## Price Oracle ############### + ########################################### + # ERC20 + - name: _ERC20 + file: ./abis/Prices/ERC20.json + # Curve Contracts + - name: CurvePool + file: ./abis/Prices/Curve/Pool.json + - name: CurveRegistry + file: ./abis/Prices/Curve/Registry.json + - name: CalculationsCurve + file: ./abis/Prices/Calculations/Curve.json + # YearnLens Contracts + - name: YearnLensContract + file: ./abis/Prices/YearnLens.json + # Aave Oracle Contract + - name: AaveOracleContract + file: ./abis/Prices/AaveOracle.json + # SushiSwap Contracts + - name: CalculationsSushiSwap + file: ./abis/Prices/Calculations/SushiSwap.json + # ChainLink Contracts + - name: ChainLinkContract + file: ./abis/Prices/ChainLink.json + # Uniswap Contracts + - name: UniswapRouter + file: ./abis/Prices/Uniswap/Router.json + - name: UniswapFactory + file: ./abis/Prices/Uniswap/Factory.json + - name: UniswapPair + file: ./abis/Prices/Uniswap/Pair.json + eventHandlers: + - event: DepositFromDelegation(indexed address,uint256,uint256) + handler: handleDepositFromDelegation + - event: WithdrawForDelegation(indexed address,uint256) + handler: handleWithdrawForDelegation + - event: MinipoolStatusChanged(indexed address,indexed uint8) + handler: handleMinipoolStatusChanged + file: {{{ file }}} + {{/minipoolManagers}} \ No newline at end of file diff --git a/subgraphs/gogopool/schema.graphql b/subgraphs/gogopool/schema.graphql new file mode 100644 index 0000000000..9e73664985 --- /dev/null +++ b/subgraphs/gogopool/schema.graphql @@ -0,0 +1,352 @@ +# Subgraph Schema: Generic +# Version: 3.0.0 +# See https://github.com/messari/subgraphs/blob/master/docs/SCHEMA.md for details + +enum Network { + ARBITRUM_ONE + ARWEAVE_MAINNET + AURORA + AVALANCHE + BOBA + BSC # aka BNB Chain + CELO + COSMOS + CRONOS + MAINNET # Ethereum Mainnet + FANTOM + FUSE + HARMONY + JUNO + MOONBEAM + MOONRIVER + NEAR_MAINNET + OPTIMISM + OSMOSIS + MATIC # aka Polygon + GNOSIS +} + +enum ProtocolType { + EXCHANGE + LENDING + YIELD + BRIDGE + GENERIC + # Will add more +} + +enum TokenType { + MULTIPLE + UNKNOWN + ERC20 + ERC721 + ERC1155 + BEP20 + BEP721 + BEP1155 + # Will add more +} + +type Token @entity @regularPolling { + " Smart contract address of the token " + id: Bytes! + + " Name of the token, mirrored from the smart contract " + name: String! + + " Symbol of the token, mirrored from the smart contract " + symbol: String! + + " The number of decimal places this token uses, default to 18 " + decimals: Int! + + " Optional field to track the price of a token, mostly for caching purposes " + lastPriceUSD: BigDecimal + + " Optional field to track the block number of the last token price " + lastPriceBlockNumber: BigInt +} + +############################# +##### Protocol Metadata ##### +############################# + +type Protocol @entity @regularPolling { + " Smart contract address of the protocol's main contract (Factory, Registry, etc) " + id: Bytes! + + " Name of the protocol, including version. e.g. Uniswap v3 " + name: String! + + " Slug of protocol, including version. e.g. uniswap-v3 " + slug: String! + + " Version of the subgraph schema, in SemVer format (e.g. 1.0.0) " + schemaVersion: String! + + " Version of the subgraph implementation, in SemVer format (e.g. 1.0.0) " + subgraphVersion: String! + + " Version of the methodology used to compute metrics, loosely based on SemVer format (e.g. 1.0.0) " + methodologyVersion: String! + + " The blockchain network this subgraph is indexing on " + network: Network! + + " The type of protocol (e.g. DEX, Lending, Yield, etc) " + type: ProtocolType! + + ##### Quantitative Data ##### + + " Current TVL (Total Value Locked) of the entire protocol " + totalValueLockedUSD: BigDecimal! + + " Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 0.25% of the swap fee in Sushiswap). Depositors on Lending Protocols. NFT sellers on OpenSea. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " Gross revenue for the protocol (revenue claimed by protocol). Examples: AMM protocol fee (Sushi’s 0.05%). OpenSea 10% sell fee. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. " + cumulativeTotalRevenueUSD: BigDecimal! + + " Total number of transactions. Transactions include events triggered by outside users (ie, deposit, withdraw, etc.)" + cumulativeTransactionCount: Int! + + " Number of cumulative unique users " + cumulativeUniqueUsers: Int! + + " Total number of pools " + totalPoolCount: Int! + + " Day ID of the most recent daily snapshot " + lastSnapshotDayID: Int! + + " Timestamp of the last time this entity was updated " + lastUpdateTimestamp: BigInt! + + ##### Snapshots ##### + + " Daily usage metrics for this protocol " + dailyUsageMetrics: [UsageMetricsDailySnapshot!]! + @derivedFrom(field: "protocol") + + " Daily financial metrics for this protocol " + financialMetrics: [FinancialsDailySnapshot!]! @derivedFrom(field: "protocol") + + ##### Pools ##### + + " All pools that belong to this protocol " + pools: [Pool!]! @derivedFrom(field: "protocol") +} + +############################### +##### Protocol Timeseries ##### +############################### + +type UsageMetricsDailySnapshot @entity @dailySnapshot { + " ID is # of days since Unix epoch time " + id: Bytes! + + " Number of days since Unix epoch time " + day: Int! + + " Protocol this snapshot is associated with " + protocol: Protocol! + + " Number of unique daily active users " + dailyActiveUsers: Int! + + " Number of cumulative unique users " + cumulativeUniqueUsers: Int! + + " Total number of transactions occurred in a day. Transactions include all entities that implement the Event interface. " + dailyTransactionCount: Int! + + " Total number of transactions. Transactions include events triggered by outside users (ie, deposit, withdraw, etc.)" + cumulativeTransactionCount: Int! + + " Total number of pools " + totalPoolCount: Int! + + " Timestamp of when this snapshot was taken/last modified (May be taken after interval has passed) " + timestamp: BigInt! + + " Block number of when this snapshot was taken/last modified (May be taken after interval has passed) " + blockNumber: BigInt! +} + +type FinancialsDailySnapshot @entity @dailySnapshot { + " ID is # of days since Unix epoch time " + id: Bytes! + + " Number of days since Unix epoch time " + day: Int! + + " Protocol this snapshot is associated with " + protocol: Protocol! + + " Current TVL (Total Value Locked) of the entire protocol " + totalValueLockedUSD: BigDecimal! + + " Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 0.25% of the swap fee in Sushiswap). Depositors on Lending Protocols. NFT sellers on OpenSea. " + dailySupplySideRevenueUSD: BigDecimal! + + " Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 0.25% of the swap fee in Sushiswap). Depositors on Lending Protocols. NFT sellers on OpenSea. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " Gross revenue for the protocol (revenue claimed by protocol). Examples: AMM protocol fee (Sushi’s 0.05%). OpenSea 10% sell fee. " + dailyProtocolSideRevenueUSD: BigDecimal! + + " Gross revenue for the protocol (revenue claimed by protocol). Examples: AMM protocol fee (Sushi’s 0.05%). OpenSea 10% sell fee. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. " + dailyTotalRevenueUSD: BigDecimal! + + " All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. " + cumulativeTotalRevenueUSD: BigDecimal! + + " Timestamp of when this snapshot was taken/last modified (May be taken after interval has passed) " + timestamp: BigInt! + + " Block number of when this snapshot was taken/last modified (May be taken after interval has passed) " + blockNumber: BigInt! +} + +########################### +##### Pool-Level Data ##### +########################### + +type Pool @entity @regularPolling { + " Smart contract address of the pool " + id: Bytes! + + " The protocol this pool belongs to " + protocol: Protocol! + + " Name of the pool (e.g. Curve.fi DAI/USDC/USDT) " + name: String + + " Symbol of liquidity pool (e.g. 3CRV) " + symbol: String + + # Generally protocols accept one or multiple tokens and mint tokens to the depositor to track ownership + # Some protocols don't mint any tokens to track ownership, in that case outputToken is null. + + " Token that is minted to track ownership of position in protocol " + outputToken: Token + + " Tokens that need to be deposited to take a position in protocol. e.g. WETH and USDC to deposit into the WETH-USDC pool. Array to account for multi-asset pools like Curve and Balancer " + inputTokens: [Token!]! + + " Creation timestamp " + createdTimestamp: BigInt! + + " Creation block number " + createdBlockNumber: BigInt! + + ##### Quantitative Data ##### + + " Current TVL (Total Value Locked) of this pool in USD " + totalValueLockedUSD: BigDecimal! + + " All revenue generated by the pool, accrued to the supply side. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " All revenue generated by the pool, accrued to the protocol. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " All revenue generated by the pool. " + cumulativeTotalRevenueUSD: BigDecimal! + + _inputTokenDeposited: [BigInt!] + _inputTokenBorrowed: [BigInt!] + + " Amount of input tokens in the pool. The ordering should be the same as the pool's `inputTokens` field. " + inputTokenBalances: [BigInt!]! + + " The USD value of input tokens in this pool. Should be the same order as the pool's `inputTokens` field. " + inputTokenBalancesUSD: [BigDecimal!]! + + " Total supply of output token. Note that certain DEXes don't have an output token (e.g. Bancor) " + outputTokenSupply: BigInt + + " Day ID of the most recent daily snapshot " + lastSnapshotDayID: Int! + + " Timestamp of the last time this entity was updated " + lastUpdateTimestamp: BigInt! +} + +type PoolDailySnapshot @entity @dailySnapshot { + " { Smart contract address of the pool }-{ # of days since Unix epoch time } " + id: Bytes! + + " Number of days since Unix epoch time " + day: Int! + + " The protocol this snapshot belongs to " + protocol: Protocol! + + " The pool this snapshot belongs to " + pool: Pool! + + ##### Quantitative Data ##### + + " Current TVL (Total Value Locked) of this pool " + totalValueLockedUSD: BigDecimal! + + " All revenue generated by the pool, accrued to the supply side. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " Daily revenue generated by the pool, accrued to the supply side. " + dailySupplySideRevenueUSD: BigDecimal! + + " All revenue generated by the pool, accrued to the protocol. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " Daily revenue generated by the pool, accrued to the protocol. " + dailyProtocolSideRevenueUSD: BigDecimal! + + " All revenue generated by the pool. " + cumulativeTotalRevenueUSD: BigDecimal! + + " Daily revenue generated by the pool. " + dailyTotalRevenueUSD: BigDecimal! + + " Amount of input tokens in the pool. The ordering should be the same as the pool's `inputTokens` field. " + inputTokenBalances: [BigInt!]! + + " The USD value of input tokens in this pool. Should be the same order as the pool's `inputTokens` field. " + inputTokenBalancesUSD: [BigDecimal!]! + + " Total supply of output token. Note that certain DEXes don't have an output token (e.g. Bancor) " + outputTokenSupply: BigInt + + " Timestamp of when this snapshot was taken/last modified (May be taken after interval has passed) " + timestamp: BigInt! + + " Block number of when this snapshot was taken/last modified (May be taken after interval has passed) " + blockNumber: BigInt! +} + +# An account is a unique Ethereum address +# Helps to accumulate total unique users +type Account @entity @regularPolling { + " Address of the account " + id: ID! +} + +# Helper entity for calculating daily active users +type ActiveAccount @entity { + " { daily }-{ Address of the account }-{ Days since Unix epoch } " + id: ID! +} + +type _ActivityHelper @entity { + " { daily }-{ Days since Unix epoch} " + id: Bytes! + + dailyActiveUsers: Int! +} diff --git a/subgraphs/gogopool/src/common/constants.ts b/subgraphs/gogopool/src/common/constants.ts new file mode 100644 index 0000000000..c50e69e989 --- /dev/null +++ b/subgraphs/gogopool/src/common/constants.ts @@ -0,0 +1,6 @@ +////////////////////////////// +///// Protocol Constants ///// +////////////////////////////// + +export const PROTOCOL_NAME = "GoGoPool"; +export const PROTOCOL_SLUG = "gogopool"; diff --git a/subgraphs/gogopool/src/mappings/handlers.ts b/subgraphs/gogopool/src/mappings/handlers.ts new file mode 100644 index 0000000000..47380f45de --- /dev/null +++ b/subgraphs/gogopool/src/mappings/handlers.ts @@ -0,0 +1,329 @@ +import { + Address, + BigDecimal, + BigInt, + Bytes, + dataSource, +} from "@graphprotocol/graph-ts"; + +import { Versions } from "../versions"; +import { NetworkConfigs } from "../../configurations/configure"; +import { getUsdPrice, getUsdPricePerToken } from "../prices"; + +import { SDK } from "../sdk/protocols/generic"; +import { ProtocolConfig, TokenPricer } from "../sdk/protocols/config"; +import { TokenInitializer, TokenParams } from "../sdk/protocols/generic/tokens"; +import { bigIntToBigDecimal } from "../sdk/util/numbers"; +import { + BIGDECIMAL_ZERO, + BIGINT_ZERO, + ETH_ADDRESS, + INT_ZERO, + Network, +} from "../sdk/util/constants"; + +import { + Deposit, + DepositedFromStaking, + Withdraw, + WithdrawnForStaking, + NewRewardsCycle, + GGAVAX, +} from "../../generated/GGAVAX/GGAVAX"; +import { + DepositFromDelegation, + WithdrawForDelegation, + MinipoolStatusChanged, + MinipoolManager, +} from "../../generated/GGAVAX/MinipoolManager"; +import { _ERC20 } from "../../generated/GGAVAX/_ERC20"; +import { ChainlinkDataFeed } from "../../generated/GGAVAX/ChainlinkDataFeed"; +import { Token } from "../../generated/schema"; +import { CustomPriceType } from "../prices/common/types"; + +const conf = new ProtocolConfig( + NetworkConfigs.getProtocolId(), + NetworkConfigs.getProtocolName(), + NetworkConfigs.getProtocolSlug(), + Versions +); + +class Pricer implements TokenPricer { + getTokenPrice(token: Token): BigDecimal { + const pricedTokenAddr = Address.fromBytes(token.id); + let returnedPrice = BIGDECIMAL_ZERO; + + const network = dataSource.network().toUpperCase().replace("-", "_"); + if (network == Network.AVALANCHE) { + if (pricedTokenAddr == NetworkConfigs.getWAVAXAddress()) { + const chainlinkDataFeedContract = ChainlinkDataFeed.bind( + Address.fromString("0x0a77230d17318075983913bc2145db16c7366156") // AVAX / USD feed + ); + + const result = chainlinkDataFeedContract.latestAnswer(); + const decimals = chainlinkDataFeedContract.decimals(); + const usdPricePerToken = CustomPriceType.initialize( + result.toBigDecimal(), + decimals as i32, + "ChainlinkFeed" + ); + returnedPrice = usdPricePerToken.usdPrice; + } else { + returnedPrice = getUsdPricePerToken(pricedTokenAddr).usdPrice; + } + } + return returnedPrice; + } + + getAmountValueUSD(token: Token, amount: BigInt): BigDecimal { + const pricedTokenAddr = Address.fromBytes(token.id); + const _amount = bigIntToBigDecimal(amount, token.decimals); + let returnedPrice = BIGDECIMAL_ZERO; + + const network = dataSource.network().toUpperCase().replace("-", "_"); + if (network == Network.AVALANCHE) { + if (pricedTokenAddr == NetworkConfigs.getWAVAXAddress()) { + const chainlinkDataFeedContract = ChainlinkDataFeed.bind( + Address.fromString("0x0a77230d17318075983913bc2145db16c7366156") // AVAX / USD feed + ); + + const result = chainlinkDataFeedContract.latestAnswer(); + const decimals = chainlinkDataFeedContract.decimals(); + const usdPricePerToken = CustomPriceType.initialize( + result.toBigDecimal(), + decimals as i32, + "ChainlinkFeed" + ); + returnedPrice = usdPricePerToken.usdPrice.times(_amount); + } else { + returnedPrice = getUsdPrice(pricedTokenAddr, _amount); + } + } + return returnedPrice; + } +} + +class TokenInit implements TokenInitializer { + getTokenParams(address: Address): TokenParams { + let name = "unknown"; + let symbol = "UNKNOWN"; + let decimals = INT_ZERO as i32; + + if (address == Address.fromString(ETH_ADDRESS)) { + name = "eth"; + symbol = "ETH"; + decimals = 18 as i32; + } else { + const erc20 = _ERC20.bind(address); + name = erc20.name(); + symbol = erc20.symbol(); + decimals = erc20.decimals().toI32(); + } + return new TokenParams(name, symbol, decimals); + } +} + +export function handleDeposit(event: Deposit): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(NetworkConfigs.getWAVAXAddress()); + const outputToken = sdk.Tokens.getOrCreateToken( + NetworkConfigs.getLSTAddress() + ); + + const pool = sdk.Pools.loadPool(Bytes.fromI32(1)); + if (!pool.isInitialized) { + pool.initialize("Stakers Pool", "ggAVAX", [token.id], outputToken); + } + + const ggAVAX = GGAVAX.bind(NetworkConfigs.getLSTAddress()); + const staked = ggAVAX.totalAssets(); + pool.setInputTokenBalances([staked], true); + const supply = ggAVAX.totalSupply(); + pool.setOutputTokenSupply(supply); + + const user = event.transaction.from; + const account = sdk.Accounts.loadAccount(user); + account.trackActivity(); +} + +export function handleDepositedFromStaking(event: DepositedFromStaking): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(NetworkConfigs.getWAVAXAddress()); + const outputToken = sdk.Tokens.getOrCreateToken( + NetworkConfigs.getLSTAddress() + ); + + const pool = sdk.Pools.loadPool(Bytes.fromI32(1)); + if (!pool.isInitialized) { + pool.initialize("Stakers Pool", "ggAVAX", [token.id], outputToken); + } + + const ggAVAX = GGAVAX.bind(NetworkConfigs.getLSTAddress()); + const staked = ggAVAX.totalAssets(); + pool.setInputTokenBalances([staked], true); + const supply = ggAVAX.totalSupply(); + pool.setOutputTokenSupply(supply); + + const user = event.transaction.from; + const account = sdk.Accounts.loadAccount(user); + account.trackActivity(); +} + +export function handleWithdraw(event: Withdraw): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(NetworkConfigs.getWAVAXAddress()); + const outputToken = sdk.Tokens.getOrCreateToken( + NetworkConfigs.getLSTAddress() + ); + + const pool = sdk.Pools.loadPool(Bytes.fromI32(1)); + if (!pool.isInitialized) { + pool.initialize("Stakers Pool", "ggAVAX", [token.id], outputToken); + } + + const ggAVAX = GGAVAX.bind(NetworkConfigs.getLSTAddress()); + const staked = ggAVAX.totalAssets(); + pool.setInputTokenBalances([staked], true); + const supply = ggAVAX.totalSupply(); + pool.setOutputTokenSupply(supply); + + const user = event.transaction.from; + const account = sdk.Accounts.loadAccount(user); + account.trackActivity(); +} + +export function handleWithdrawnForStaking(event: WithdrawnForStaking): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(NetworkConfigs.getWAVAXAddress()); + const outputToken = sdk.Tokens.getOrCreateToken( + NetworkConfigs.getLSTAddress() + ); + + const pool = sdk.Pools.loadPool(Bytes.fromI32(1)); + if (!pool.isInitialized) { + pool.initialize("Stakers Pool", "ggAVAX", [token.id], outputToken); + } + + const ggAVAX = GGAVAX.bind(NetworkConfigs.getLSTAddress()); + const staked = ggAVAX.totalAssets(); + pool.setInputTokenBalances([staked], true); + const supply = ggAVAX.totalSupply(); + pool.setOutputTokenSupply(supply); + + const user = event.transaction.from; + const account = sdk.Accounts.loadAccount(user); + account.trackActivity(); +} + +export function handleNewRewardsCycle(event: NewRewardsCycle): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(NetworkConfigs.getWAVAXAddress()); + const outputToken = sdk.Tokens.getOrCreateToken( + NetworkConfigs.getLSTAddress() + ); + + const pool = sdk.Pools.loadPool(Bytes.fromI32(1)); + if (!pool.isInitialized) { + pool.initialize("Stakers Pool", "ggAVAX", [token.id], outputToken); + } + + const rewards = event.params.rewardsAmt; + + pool.addRevenueNative(token, rewards, BIGINT_ZERO); +} + +export function handleDepositFromDelegation( + event: DepositFromDelegation +): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(NetworkConfigs.getWAVAXAddress()); + + const pool = sdk.Pools.loadPool(Bytes.fromI32(2)); + if (!pool.isInitialized) { + pool.initialize("Operators Pool", "ggAVAX", [token.id], null); + } + + const mm = MinipoolManager.bind(event.address); + const staked = mm.getTotalAVAXLiquidStakerAmt(); + pool.setInputTokenBalances([staked], true); + + const user = event.transaction.from; + const account = sdk.Accounts.loadAccount(user); + account.trackActivity(); +} + +export function handleWithdrawForDelegation( + event: WithdrawForDelegation +): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(NetworkConfigs.getWAVAXAddress()); + + const pool = sdk.Pools.loadPool(Bytes.fromI32(2)); + if (!pool.isInitialized) { + pool.initialize("Operators Pool", "ggAVAX", [token.id], null); + } + + const mm = MinipoolManager.bind(event.address); + const staked = mm.getTotalAVAXLiquidStakerAmt(); + pool.setInputTokenBalances([staked], true); + + const user = event.transaction.from; + const account = sdk.Accounts.loadAccount(user); + account.trackActivity(); +} + +export function handleMinipoolStatusChanged( + event: MinipoolStatusChanged +): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(NetworkConfigs.getWAVAXAddress()); + + const pool = sdk.Pools.loadPool(Bytes.fromI32(2)); + if (!pool.isInitialized) { + pool.initialize("Operators Pool", "ggAVAX", [token.id], null); + } + + const mm = MinipoolManager.bind(event.address); + const staked = mm.getTotalAVAXLiquidStakerAmt(); + pool.setInputTokenBalances([staked], true); +} diff --git a/subgraphs/gogopool/src/prices/README.md b/subgraphs/gogopool/src/prices/README.md new file mode 100644 index 0000000000..a21d78286a --- /dev/null +++ b/subgraphs/gogopool/src/prices/README.md @@ -0,0 +1,295 @@ +# Price Oracle + +## Configuration + +In `subgraph.yaml`, add the following code snippet inside the `abis` section of the `datasources` which is going to fetch prices of token using the `Price Oracle`. +
+**NOTE**: Include the following code snippet in each of the datasources, that is dependent on the `Price Oracle` and update imports in each file inside oracle folder. + +``` +########################################### +############## Price Oracle ############### +########################################### +# ERC20 +- name: _ERC20 + file: ./abis/Prices/ERC20.json +# Curve Contracts +- name: CurvePool + file: ./abis/Prices/Curve/Pool.json +- name: CurveRegistry + file: ./abis/Prices/Curve/Registry.json +- name: CalculationsCurve + file: ./abis/Prices/Calculations/Curve.json +# YearnLens Contracts +- name: YearnLensContract + file: ./abis/Prices/YearnLens.json +# Aave Oracle Contract +- name: AaveOracleContract + file: ./abis/Prices/AaveOracle.json +# SushiSwap Contracts +- name: CalculationsSushiSwap + file: ./abis/Prices/Calculations/SushiSwap.json +# ChainLink Contracts +- name: ChainLinkContract + file: ./abis/Prices/ChainLink.json +# Uniswap Contracts +- name: UniswapRouter + file: ./abis/Prices/Uniswap/Router.json +- name: UniswapFactory + file: ./abis/Prices/Uniswap/Factory.json +- name: UniswapPair + file: ./abis/Prices/Uniswap/Pair.json +``` + +## Usage + +Following are some ways through which you can get the prices of tokens: + +``` +import { BigDecimal } from "@graphprotocol/graph-ts"; +import { getUsdPrice, getUsdPricePerToken, getLiquidityBoundPrice } from "../Oracle"; + +// Method 1 +// Using function getUsdPrice(tokenAddr: Address, amount: BigDecimal): BigDecimal + +let tokenPrice = getUsdPrice(tokenAddr, amount); +``` + +> Note: Preferred as it internally calls `getLiquidityBoundPrice(...)` and returns token price bounded by it's pool's liquidity. +>
+> To get the price per token, you can still use `getUsdPrice(...)` as: +>

> `let tokenPrice = getUsdPrice(tokenAddr, BIGDECIMAL_ONE);` + +``` +// Method 2 +// Using function getUsdPricePerToken(tokenAddr: Address): CustomPriceType + +let tokenPrice: BigDecimal; +let fetchPrice = getUsdPricePerToken(tokenAddr); + +// fetchPrice.reverted: Bool +// fetchPrice.usdPrice: BigDecimal +// fetchPrice.decimals: number +// fetchPrice.oracleType: string +// fetchPrice.liquidity: BigDecimal + +if (!fetchPrice.reverted) { + if ( + fetchPrice.oracleType == constants.OracleType.UNISWAP_FORKS_ROUTER || + fetchPrice.oracleType == constants.OracleType.CURVE_ROUTER + ) { + fetchPrice = getLiquidityBoundPrice(tokenAddr, fetchPrice, amount) + } + tokenPrice = fetchPrice.usdPrice * amount +} +``` + +## Optimizations + +- Configure default `number of oracles` to fetch price from and their `order of preference` in OracleType's constructor, depending on which oracles _generally_ works best for you. +- Although querying multiple oracles for the same token's price mean more contract calls, this overhead can be beared for smaller subgraphs, and for specific tokens/block ranges for larger ones in favour of spotting and ignoring outlier values by avoiding complete reliance on a single source of truth and trusting the closer majority values, especially for low/distributed liquidity tokens, or during volatile markets. +

+ The result is an average price on the k-closest reported values. +
+ where, `k = ceil(reportedPrices.length/2)` +- For any observed pricing discrepancies, you may define an override on the default oracle configuration in network's config file which works better for the mispriced token(s). +
+ An example override is defined under `ORACLE CONFIG OVERRIDES` section in `config/template.ts` +

+ Any new overrides shall be maintained in both the subgraph as well as the reference pricelib directory, so the same inconsistencies do not have to be handled separately. + +## Folder Structure + +``` +Prices +├── calculations +│ ├── CalculationsCurve.ts +│ └── CalculationsSushiSwap.ts +├── common +│ ├── types.ts +│ ├── constants.ts +│ └── utils.ts +├── config +│ ├── arbitrum.ts +│ ├── aurora.ts +│ ├── avalanche.ts +│ ├── bsc.ts +│ ├── celo.ts +│ ├── cronos.ts +│ ├── fantom.ts +│ ├── fuse.ts +│ ├── gnosis.ts +│ ├── harmony.ts +│ ├── mainnet.ts +│ ├── moonbeam.ts +│ ├── optimism.ts +│ ├── polygon.ts +│ └── template.ts +├── oracles +│ ├── AaveOracle.ts +│ ├── ChainLinkFeed.ts +│ └── YearnLensOracle.ts +├── routers +│ ├── CurveRouter.ts +│ └── UniswapForksRouter.ts +│── README.md +└── index.ts +``` + +## Development Status + +🔨 = In progress. +🛠 = Feature complete. Additional testing required. +`MultiCall` = If the method uses more than two `JSON RPC Call`. + +### Arbitrum + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| YearnLens | `0x043518ab266485dc085a1db095b8d9c2fc78e9b9` | `2396321` | ❎ | +| AaveOracle | `0xb56c2F0B653B2e0b10C9b928C8580Ac5Df02C7C7` | `7740843` | ❎ | +| Curve | `0x3268c3bda100ef0ff3c2d044f23eab62c80d78d2` | `11707234` | ❎ | +| SushiSwap | `0x5ea7e501c9a23f4a76dc7d33a11d995b13a1dd25` | `2396120` | ❎ | +| CurveRouters | | | | +| | `0x445FE580eF8d70FF569aB36e80c647af338db351` | `1362056` | ✅ | +| | `0x0E9fBb167DF83EdE3240D6a5fa5d40c6C6851e15` | `4530115` | ✅ | +| UniswapForks | | | | +| | `0x1b02da8cb0d097eb8d57a175b88c7d8b47997506` | `73` | ✅ | + +### Aurora + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| CurveRouters | | | | +| | `0x5B5CFE992AdAC0C9D48E05854B2d91C73a003858` | `62440525` | ✅ | +| UniswapForks | | | | +| | `0x2CB45Edb4517d5947aFdE3BEAbF95A582506858B` | | ✅ | + +### Avalanche + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| AaveOracle | `0xEBd36016B3eD09D4693Ed4251c67Bd858c3c7C9C` | `11970477` | ❎ | +| CurveRouters | | | | +| | `0x8474DdbE98F5aA3179B3B3F5942D724aFcdec9f6` | `5254206` | ✅ | +| | `0x90f421832199e93d01b64DaF378b183809EB0988` | `9384663` | ✅ | +| UniswapForks | | | | +| | `0x60aE616a2155Ee3d9A68541Ba4544862310933d4` | `2486393` | ✅ | +| | `0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106` | `56879` | ✅ | +| | `0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506` | `506236` | ✅ | + +### BSC + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| UniswapForks | | | | +| | `0x10ED43C718714eb63d5aA57B78B54704E256024E` | `6810080` | ✅ | +| | `0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F` | `586899` | ✅ | + +### Celo + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| UniswapForks | | | | +| | `0xe3d8bd6aed4f159bc8000a9cd47cffdb95f96121` | `5272598` | ✅ | +| | `0x1b02da8cb0d097eb8d57a175b88c7d8b47997506` | `7254057` | ✅ | + +### Cronos + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| UniswapForks | | | | +| | `0x145863eb42cf62847a6ca784e6416c1682b1b2ae` | `5247` | ✅ | + +### Fantom + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| YearnLens | `0x57aa88a0810dfe3f9b71a9b179dd8bf5f956c46a` | `17091856` | ❎ | +| Curve | `0x0b53e9df372e72d8fdcdbedfbb56059957a37128` | `27067399` | ❎ | +| SushiSwap | `0x44536de2220987d098d1d29d3aafc7f7348e9ee4` | `3809480` | ❎ | +| CurveRouters | | | | +| | `0x0f854EA9F38ceA4B1c2FC79047E9D0134419D5d6` | `5655918` | ✅ | +| | `0x4fb93D7d320E8A263F22f62C2059dFC2A8bCbC4c` | `27552509` | ✅ | +| UniswapForks | | | | +| | `0xbe4fc72f8293f9d3512d58b969c98c3f676cb957` | `3796241` | ✅ | +| | `0x16327E3FbDaCA3bcF7E38F5Af2599D2DDc33aE52` | `4250168` | ✅ | +| | `0x1b02da8cb0d097eb8d57a175b88c7d8b47997506` | `2457904` | ✅ | + +### Fuse + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| UniswapForks | | | | +| | `0xe3f85aad0c8dd7337427b9df5d0fb741d65eeeb5` | `15645719` | ✅ | +| | `0x1b02da8cb0d097eb8d57a175b88c7d8b47997506` | `12936314` | ✅ | + +### Gnosis + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| CurveRouters | | | | +| | `0x55E91365697EB8032F98290601847296eC847210` | `20754886` | ✅ | +| | `0x8A4694401bE8F8FCCbC542a3219aF1591f87CE17` | `23334728` | ✅ | +| UniswapForks | | | | +| | `0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506` | `14735910` | ✅ | + +### Harmony + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| AaveOracle | `0x3c90887ede8d65ccb2777a5d577beab2548280ad` | `23930344` | ❎ | +| CurveRouters | | | | +| | `0x0a53FaDa2d943057C47A301D25a4D9b3B8e01e8E` | `18003250` | ✅ | +| UniswapForks | | | | +| | `0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506` | `11256069` | ✅ | + +### Mainnet + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| YearnLens | `0x83d95e0d5f402511db06817aff3f9ea88224b030` | `12242339` | ❎ | +| ChainLink | `0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf` | `12864088` | ❎ | +| Curve | `0x25BF7b72815476Dd515044F9650Bf79bAd0Df655` | `12370088` | ❎ | +| SushiSwap | `0x8263e161A855B644f582d9C164C66aABEe53f927` | `12692284` | ❎ | +| CurveRouters | | | | +| | `0x7D86446dDb609eD0F5f8684AcF30380a356b2B4c` | `11154794` | ✅ | +| | `0x8F942C20D02bEfc377D41445793068908E2250D0` | `13986752` | ✅ | +| UniswapForks | | | | +| | `0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F` | `10794261` | ✅ | +| | `0x7a250d5630b4cf539739df2c5dacb4c659f2488d` | `10207858` | ✅ | + +### Moonbeam + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| CurveRouters | | | | +| | `0xC2b1DF84112619D190193E48148000e3990Bf627` | `1452049` | ✅ | +| UniswapForks | | | | +| | `0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506` | `503734` | ✅ | + +### Optimism + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| YearnLens | `0xb082d9f4734c535d9d80536f7e87a6f4f471bf65` | `18109291` | ❎ | +| AaveOracle | `0xD81eb3728a631871a7eBBaD631b5f424909f0c77` | `4365625` | ❎ | +| Curve | `0x0ffe8434eae67c9838b12c3cd11ac4005daa7227` | `18368996` | ❎ | +| SushiSwap | `0x5fd3815dcb668200a662114fbc9af13ac0a55b4d` | `18216910` | ❎ | +| CurveRouters | | | | +| | `0xC5cfaDA84E902aD92DD40194f0883ad49639b023` | `2373837` | ✅ | +| | `0x7DA64233Fefb352f8F501B357c018158ED8aA455` | `3729171` | ✅ | +| UniswapForks | | | | +| | `0x9c12939390052919aF3155f41Bf4160Fd3666A6f` | `19702709` | ✅ | + +### Polygon + +| **Method** | **Address** | **StartBlock** | **MultiCall** | +| ------------ | :------------------------------------------: | :------------: | :-----------: | +| AaveOracle | `0xb023e699F5a33916Ea823A16485e259257cA8Bd1` | `25825996` | ❎ | +| CurveRouters | | | | +| | `0x094d12e5b541784701FD8d65F11fc0598FBC6332` | `13991825` | ✅ | +| | `0x47bB542B9dE58b970bA50c9dae444DDB4c16751a` | `23556360` | ✅ | +| UniswapForks | | | | +| | `0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff` | `4931900` | ✅ | +| | `0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506` | `11333235` | ✅ | diff --git a/subgraphs/gogopool/src/prices/calculations/CalculationsCurve.ts b/subgraphs/gogopool/src/prices/calculations/CalculationsCurve.ts new file mode 100644 index 0000000000..69a94a9c4f --- /dev/null +++ b/subgraphs/gogopool/src/prices/calculations/CalculationsCurve.ts @@ -0,0 +1,47 @@ +import * as utils from "../common/utils"; +import * as constants from "../common/constants"; +import { CustomPriceType, OracleContract } from "../common/types"; +import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { CalculationsCurve as CalculationsCurveContract } from "../../../generated/GGAVAX/CalculationsCurve"; + +export function getCalculationsCurveContract( + contract: OracleContract, + block: ethereum.Block | null = null +): CalculationsCurveContract | null { + if ( + (block && contract.startBlock.gt(block.number)) || + utils.isNullAddress(contract.address) + ) + return null; + + return CalculationsCurveContract.bind(contract.address); +} + +export function getTokenPriceUSDC( + tokenAddr: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const config = utils.getConfig(); + + if (!config || config.curveCalculationsBlacklist().includes(tokenAddr)) + return new CustomPriceType(); + + const calculationCurveContract = getCalculationsCurveContract( + config.curveCalculations(), + block + ); + if (!calculationCurveContract) return new CustomPriceType(); + + const tokenPrice: BigDecimal = utils + .readValue( + calculationCurveContract.try_getCurvePriceUsdc(tokenAddr), + constants.BIGINT_ZERO + ) + .toBigDecimal(); + + return CustomPriceType.initialize( + tokenPrice, + constants.DEFAULT_USDC_DECIMALS, + constants.OracleType.CURVE_CALCULATIONS + ); +} diff --git a/subgraphs/gogopool/src/prices/calculations/CalculationsSushiswap.ts b/subgraphs/gogopool/src/prices/calculations/CalculationsSushiswap.ts new file mode 100644 index 0000000000..55cdfa1fe9 --- /dev/null +++ b/subgraphs/gogopool/src/prices/calculations/CalculationsSushiswap.ts @@ -0,0 +1,47 @@ +import * as utils from "../common/utils"; +import * as constants from "../common/constants"; +import { CustomPriceType, OracleContract } from "../common/types"; +import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { CalculationsSushiSwap as CalculationsSushiContract } from "../../../generated/GGAVAX/CalculationsSushiSwap"; + +export function getSushiSwapContract( + contract: OracleContract, + block: ethereum.Block | null = null +): CalculationsSushiContract | null { + if ( + (block && contract.startBlock.gt(block.number)) || + utils.isNullAddress(contract.address) + ) + return null; + + return CalculationsSushiContract.bind(contract.address); +} + +export function getTokenPriceUSDC( + tokenAddr: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const config = utils.getConfig(); + + if (!config || config.sushiCalculationsBlacklist().includes(tokenAddr)) + return new CustomPriceType(); + + const calculationSushiContract = getSushiSwapContract( + config.sushiCalculations(), + block + ); + if (!calculationSushiContract) return new CustomPriceType(); + + const tokenPrice: BigDecimal = utils + .readValue( + calculationSushiContract.try_getPriceUsdc(tokenAddr), + constants.BIGINT_ZERO + ) + .toBigDecimal(); + + return CustomPriceType.initialize( + tokenPrice, + constants.DEFAULT_USDC_DECIMALS, + constants.OracleType.SUSHI_CALCULATIONS + ); +} diff --git a/subgraphs/gogopool/src/prices/common/constants.ts b/subgraphs/gogopool/src/prices/common/constants.ts new file mode 100644 index 0000000000..0a0f16d46b --- /dev/null +++ b/subgraphs/gogopool/src/prices/common/constants.ts @@ -0,0 +1,43 @@ +import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////////////// COMMON //////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export namespace NULL { + export const TYPE_STRING = "0x0000000000000000000000000000000000000000"; + export const TYPE_ADDRESS = Address.fromString(TYPE_STRING); +} + +export namespace OracleType { + export const AAVE_ORACLE = "AaveOracle"; + export const CURVE_ROUTER = "CurveRouter"; + export const CHAINLINK_FEED = "ChainlinkFeed"; + export const YEARN_LENS_ORACLE = "YearnLensOracle"; + export const CURVE_CALCULATIONS = "CurveCalculations"; + export const UNISWAP_FORKS_ROUTER = "UniswapForksRouter"; + export const SUSHI_CALCULATIONS = "SushiswapCalculations"; +} + +export const CHAIN_LINK_USD_ADDRESS = Address.fromString( + "0x0000000000000000000000000000000000000348" +); + +export const PRICE_LIB_VERSION = "1.3.4"; + +export const INT_ZERO = 0 as i32; +export const INT_ONE = 1 as i32; +export const INT_TWO = 2 as i32; +export const INT_NEGATIVE_ONE = -1 as i32; + +export const BIGINT_ZERO = BigInt.fromI32(0); +export const BIGINT_ONE = BigInt.fromI32(1); +export const BIGINT_TEN = BigInt.fromI32(10); +export const BIGINT_TEN_THOUSAND = BigInt.fromI32(10000); + +export const BIGDECIMAL_ZERO = new BigDecimal(BIGINT_ZERO); +export const BIGDECIMAL_USD_PRICE = BigDecimal.fromString("1000000"); + +export const AAVE_ORACLE_DECIMALS = 8; +export const DEFAULT_USDC_DECIMALS = 6; +export const DEFAULT_DECIMALS = BigInt.fromI32(18); diff --git a/subgraphs/gogopool/src/prices/common/types.ts b/subgraphs/gogopool/src/prices/common/types.ts new file mode 100644 index 0000000000..bf2dfe1a41 --- /dev/null +++ b/subgraphs/gogopool/src/prices/common/types.ts @@ -0,0 +1,147 @@ +import * as constants from "./constants"; +import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts"; + +export class Wrapped { + inner: T; + + constructor(inner: T) { + this.inner = inner; + } +} + +export class OracleContract { + private _contractAddress: string; + private _contractStartBlock: i32; + + constructor( + contractAddress: string = constants.NULL.TYPE_STRING, + startBlock: i32 = -1 + ) { + this._contractAddress = contractAddress; + this._contractStartBlock = startBlock; + } + + get address(): Address { + return Address.fromString(this._contractAddress); + } + + get startBlock(): BigInt { + return BigInt.fromI32(this._contractStartBlock); + } +} + +export class CustomPriceType { + // `null` indicates a reverted call. + private _usdPrice: Wrapped; + private _decimals: Wrapped; + private _oracleType: string; + private _liquidity: Wrapped; + + constructor() { + this._usdPrice = new Wrapped(constants.BIGDECIMAL_ZERO); + this._decimals = new Wrapped(constants.BIGINT_ZERO.toI32() as u8); + this._oracleType = ""; + this._liquidity = new Wrapped(constants.BIGDECIMAL_ZERO); + } + + static initialize( + _usdPrice: BigDecimal, + _decimals: i32 = 0, + _oracleType: string = "", + _liquidity: BigDecimal | null = null + ): CustomPriceType { + const result = new CustomPriceType(); + result._usdPrice = new Wrapped(_usdPrice); + result._decimals = new Wrapped(_decimals as u8); + result._oracleType = _oracleType; + if (_liquidity) result._liquidity = new Wrapped(_liquidity); + + return result; + } + + get reverted(): bool { + return this._usdPrice.inner == constants.BIGDECIMAL_ZERO; + } + + get usdPrice(): BigDecimal { + return changetype>(this._usdPrice).inner.div( + constants.BIGINT_TEN.pow(this.decimals as u8).toBigDecimal() + ); + } + + get decimals(): i32 { + return changetype>(this._decimals).inner; + } + + get oracleType(): string { + return this._oracleType; + } + + get liquidity(): BigDecimal { + return this._liquidity.inner; + } + + setLiquidity(liquidity: BigDecimal): void { + this._liquidity = new Wrapped(liquidity); + } +} + +export interface OracleConfig { + oracleCount(): number; + oracleOrder(): string[]; +} + +export class OracleType { + oracleCount: number; + oracleOrder: string[]; + + constructor() { + this.oracleCount = constants.INT_ONE; + this.oracleOrder = [ + constants.OracleType.YEARN_LENS_ORACLE, + constants.OracleType.CHAINLINK_FEED, + constants.OracleType.CURVE_CALCULATIONS, + constants.OracleType.SUSHI_CALCULATIONS, + constants.OracleType.CURVE_ROUTER, + constants.OracleType.UNISWAP_FORKS_ROUTER, + ]; + } + + setOracleConfig(override: OracleConfig): void { + this.oracleCount = override.oracleCount(); + this.oracleOrder = override.oracleOrder(); + } +} + +export interface Configurations { + network(): string; + + yearnLens(): OracleContract; + chainLink(): OracleContract; + yearnLensBlacklist(): Address[]; + + aaveOracle(): OracleContract; + aaveOracleBlacklist(): Address[]; + + curveCalculations(): OracleContract; + curveCalculationsBlacklist(): Address[]; + + sushiCalculations(): OracleContract; + sushiCalculationsBlacklist(): Address[]; + + uniswapForks(): OracleContract[]; + curveRegistry(): OracleContract[]; + + hardcodedStables(): Address[]; + + ethAddress(): Address; + wethAddress(): Address; + usdcAddress(): Address; + + usdcTokenDecimals(): BigInt; + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null; +} diff --git a/subgraphs/gogopool/src/prices/common/utils.ts b/subgraphs/gogopool/src/prices/common/utils.ts new file mode 100644 index 0000000000..df2088b50c --- /dev/null +++ b/subgraphs/gogopool/src/prices/common/utils.ts @@ -0,0 +1,202 @@ +import * as BSC from "../config/bsc"; +import * as BASE from "../config/base"; +import * as MODE from "../config/mode"; +import * as CELO from "../config/celo"; +import * as FUSE from "../config/fuse"; +import * as XDAI from "../config/gnosis"; +import * as BLAST from "../config/blast"; +import * as LINEA from "../config/linea"; +import * as CRONOS from "../config/cronos"; +import * as AURORA from "../config/aurora"; +import * as FANTOM from "../config/fantom"; +import * as SCROLL from "../config/scroll"; +import * as POLYGON from "../config/polygon"; +import * as MAINNET from "../config/mainnet"; +import * as HARMONY from "../config/harmony"; +import * as MOONBEAM from "../config/moonbeam"; +import * as OPTIMISM from "../config/optimism"; +import * as AVALANCHE from "../config/avalanche"; +import * as ARBITRUM_ONE from "../config/arbitrum"; +import * as ZKSYNC_ERA from "../config/zksync_era"; +import * as POLYGON_ZKEVM from "../config/polygon_zkevm"; + +import { Configurations, CustomPriceType } from "./types"; +import * as constants from "./constants"; +import * as TEMPLATE from "../config/template"; +import { _ERC20 } from "../../../generated/GGAVAX/_ERC20"; +import { + Address, + BigInt, + BigDecimal, + dataSource, + ethereum, +} from "@graphprotocol/graph-ts"; + +export function isNullAddress(tokenAddr: Address): boolean { + return tokenAddr.equals(constants.NULL.TYPE_ADDRESS); +} + +export function bigIntToBigDecimal( + quantity: BigInt, + decimals: i32 = constants.DEFAULT_DECIMALS.toI32() +): BigDecimal { + return quantity.divDecimal( + constants.BIGINT_TEN.pow(decimals as u8).toBigDecimal() + ); +} + +export function readValue( + callResult: ethereum.CallResult, + defaultValue: T +): T { + return callResult.reverted ? defaultValue : callResult.value; +} + +export function getTokenName(tokenAddr: Address): string { + const tokenContract = _ERC20.bind(tokenAddr); + const name = readValue(tokenContract.try_name(), ""); + + return name; +} + +export function getTokenDecimals(tokenAddr: Address): BigInt { + const tokenContract = _ERC20.bind(tokenAddr); + + const decimals = readValue( + tokenContract.try_decimals(), + constants.DEFAULT_DECIMALS + ); + + return decimals; +} + +export function getTokenSupply(tokenAddr: Address): BigInt { + const tokenContract = _ERC20.bind(tokenAddr); + + const totalSupply = readValue( + tokenContract.try_totalSupply(), + constants.BIGINT_ONE + ); + + return totalSupply; +} + +export function getConfig(): Configurations { + const network = dataSource.network(); + + if (network == XDAI.NETWORK_STRING) { + return new XDAI.config(); + } else if (network == AURORA.NETWORK_STRING) { + return new AURORA.config(); + } else if (network == BSC.NETWORK_STRING) { + return new BSC.config(); + } else if (network == FANTOM.NETWORK_STRING) { + return new FANTOM.config(); + } else if (network == POLYGON.NETWORK_STRING) { + return new POLYGON.config(); + } else if (network == MAINNET.NETWORK_STRING) { + return new MAINNET.config(); + } else if (network == HARMONY.NETWORK_STRING) { + return new HARMONY.config(); + } else if (network == MOONBEAM.NETWORK_STRING) { + return new MOONBEAM.config(); + } else if (network == OPTIMISM.NETWORK_STRING) { + return new OPTIMISM.config(); + } else if (network == AVALANCHE.NETWORK_STRING) { + return new AVALANCHE.config(); + } else if (network == ARBITRUM_ONE.NETWORK_STRING) { + return new ARBITRUM_ONE.config(); + } else if (network == CRONOS.NETWORK_STRING) { + return new CRONOS.config(); + } else if (network == CELO.NETWORK_STRING) { + return new CELO.config(); + } else if (network == FUSE.NETWORK_STRING) { + return new FUSE.config(); + } else if (network == BLAST.NETWORK_STRING) { + return new BLAST.config(); + } else if (network == BASE.NETWORK_STRING) { + return new BASE.config(); + } else if (network == MODE.NETWORK_STRING) { + return new MODE.config(); + } else if (network == POLYGON_ZKEVM.NETWORK_STRING) { + return new POLYGON_ZKEVM.config(); + } else if (network == SCROLL.NETWORK_STRING) { + return new SCROLL.config(); + } else if (network == ZKSYNC_ERA.NETWORK_STRING) { + return new ZKSYNC_ERA.config(); + } else if (network == LINEA.NETWORK_STRING) { + return new LINEA.config(); + } + + return new TEMPLATE.config(); +} + +function sortByPrices(prices: CustomPriceType[]): CustomPriceType[] { + const pricesSorted = prices.sort(function (a, b) { + const x = a.usdPrice; + const y = b.usdPrice; + + if (x < y) return -1; + if (x > y) return 1; + return 0; + }); + + return pricesSorted; +} + +function pairwiseDiffOfPrices(prices: CustomPriceType[]): BigDecimal[] { + const diff: BigDecimal[] = []; + for (let i = 1; i < prices.length; i++) { + const x = prices[i].usdPrice; + const y = prices[i - 1].usdPrice; + + diff.push(x.minus(y)); + } + + return diff; +} + +export function kClosestPrices( + k: i32, + prices: CustomPriceType[] +): CustomPriceType[] { + // sort by USD prices + const pricesSorted = sortByPrices(prices); + + // pairwise difference in USD prices + const pairwiseDiff = pairwiseDiffOfPrices(pricesSorted); + + // k minimum difference values and their original indexes + const pairwiseDiffCopy = pairwiseDiff.map((x: BigDecimal) => x); + const pairwiseDiffSortedSlice = pairwiseDiffCopy.sort().slice(0, k); + const minDiffAtIdx: i32[] = []; + for (let i = 0; i < pairwiseDiffSortedSlice.length; i++) { + const idx = pairwiseDiff.indexOf(pairwiseDiffSortedSlice[i]); + minDiffAtIdx.push(idx as i32); + } + + // k closest USD price values + const kClosestPrices: CustomPriceType[] = []; + for (let i = 0; i < minDiffAtIdx.length; i++) { + if (!kClosestPrices.includes(pricesSorted[minDiffAtIdx[i]])) { + kClosestPrices.push(pricesSorted[minDiffAtIdx[i]]); + } + if (!kClosestPrices.includes(pricesSorted[minDiffAtIdx[i] + 1])) { + kClosestPrices.push(pricesSorted[minDiffAtIdx[i] + 1]); + } + } + + return kClosestPrices; +} + +export function averagePrice(prices: CustomPriceType[]): CustomPriceType { + let summationUSDPrice = constants.BIGDECIMAL_ZERO; + for (let i = 0; i < prices.length; i++) { + summationUSDPrice = summationUSDPrice.plus(prices[i].usdPrice); + } + + return CustomPriceType.initialize( + summationUSDPrice.div(new BigDecimal(BigInt.fromI32(prices.length as i32))), + constants.DEFAULT_USDC_DECIMALS + ); +} diff --git a/subgraphs/gogopool/src/prices/config/arbitrum.ts b/subgraphs/gogopool/src/prices/config/arbitrum.ts new file mode 100644 index 0000000000..bf39a7b81b --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/arbitrum.ts @@ -0,0 +1,146 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "arbitrum-one"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract( + "0x043518ab266485dc085a1db095b8d9c2fc78e9b9", + 2396321 +); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract( + "0xb56c2f0b653b2e0b10c9b928c8580ac5df02c7c7", + 7740843 +); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract( + "0x5ea7e501c9a23f4a76dc7d33a11d995b13a1dd25", + 2396120 +); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract( + "0x3268c3bda100ef0ff3c2d044f23eab62c80d78d2", + 11707234 +); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0x445fe580ef8d70ff569ab36e80c647af338db351", 1362056), + new OracleContract("0x0e9fbb167df83ede3240d6a5fa5d40c6c6851e15", 4530115), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x1b02da8cb0d097eb8d57a175b88c7d8b47997506", 73), // SushiSwap +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" +); +export const WETH_ADDRESS = Address.fromString( + "0x82af49447d8a07e3bd95bd0d56f35241523fbab1" +); +export const USDC_ADDRESS = Address.fromString( + "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/aurora.ts b/subgraphs/gogopool/src/prices/config/aurora.ts new file mode 100644 index 0000000000..d3b303b815 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/aurora.ts @@ -0,0 +1,133 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "aurora"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0x5b5cfe992adac0c9d48e05854b2d91c73a003858", 62440526), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x2cb45edb4517d5947afde3beabf95a582506858b", 49607893), // TriSolaris +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0x8bec47865ade3b172a928df8f990bc7f2a3b9f79" // Aurora +); +export const WETH_ADDRESS = Address.fromString( + "0xc9bdeed33cd01541e1eed10f90519d2c06fe3feb" // WETH +); +export const USDC_ADDRESS = Address.fromString( + "0xb12bfca5a55806aaf64e99521918a4bf0fc40802" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/avalanche.ts b/subgraphs/gogopool/src/prices/config/avalanche.ts new file mode 100644 index 0000000000..f40fbbf1aa --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/avalanche.ts @@ -0,0 +1,140 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "avalanche"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract( + "0xebd36016b3ed09d4693ed4251c67bd858c3c7c9c", + 11970477 +); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0x8474ddbe98f5aa3179b3b3f5942d724afcdec9f6", 5254206), + new OracleContract("0x90f421832199e93d01b64daf378b183809eb0988", 9384663), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x60ae616a2155ee3d9a68541ba4544862310933d4", 2486393), // TraderJOE + new OracleContract("0xe54ca86531e17ef3616d22ca28b0d458b6c89106", 56879), // Pangolin + new OracleContract("0x1b02da8cb0d097eb8d57a175b88c7d8b47997506", 506236), // Sushiswap +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab" +); +export const WETH_ADDRESS = Address.fromString( + "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7" +); +export const USDC_ADDRESS = Address.fromString( + "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/base.ts b/subgraphs/gogopool/src/prices/config/base.ts new file mode 100644 index 0000000000..3a5d77e710 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/base.ts @@ -0,0 +1,130 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "base"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x8cfe327cec66d1c090dd72bd0ff11d690c33a2eb", 2910568), + new OracleContract("0x6bded42c6da8fbf0d2ba55b2fa120c5e0c8d7891", 2631217), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS; +export const WETH_ADDRESS = Address.fromString( + "0x4200000000000000000000000000000000000006" +); +export const USDC_ADDRESS = Address.fromString( + "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/blast.ts b/subgraphs/gogopool/src/prices/config/blast.ts new file mode 100644 index 0000000000..8b788d0697 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/blast.ts @@ -0,0 +1,131 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "blast-mainnet"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x98994a9a7a2570367554589189dc9772241650f6", 157110), // Thruster v2 Router1 + new OracleContract("0x44889b52b71e60de6ed7de82e2939fcc52fb2b4e", 157501), // Thruster v2 Router2 + new OracleContract("0x54cf3d259a06601b5bc45f61a16443ed5404dd64", 285726), // Sushiswap v2 Router02 +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(18); + +export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS; +export const WETH_ADDRESS = Address.fromString( + "0x4300000000000000000000000000000000000004" +); +export const USDC_ADDRESS = Address.fromString( + "0x4300000000000000000000000000000000000003" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/bsc.ts b/subgraphs/gogopool/src/prices/config/bsc.ts new file mode 100644 index 0000000000..0d00234608 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/bsc.ts @@ -0,0 +1,130 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "bsc"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x10ed43c718714eb63d5aa57b78b54704e256024e", 6810080), // PancakeSwap v2 + new OracleContract("0x05ff2b0db69458a0750badebc4f9e13add608c7f", 586899), // PancakeSwap v1 +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(18); + +export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS; +export const WETH_ADDRESS = Address.fromString( + "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c" +); +export const USDC_ADDRESS = Address.fromString( + "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/celo.ts b/subgraphs/gogopool/src/prices/config/celo.ts new file mode 100644 index 0000000000..1e961cb575 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/celo.ts @@ -0,0 +1,132 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "celo"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0xe3d8bd6aed4f159bc8000a9cd47cffdb95f96121", 5272598), // Ubeswap + new OracleContract("0x1b02da8cb0d097eb8d57a175b88c7d8b47997506", 7254057), // Sushiswap +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0x122013fd7df1c6f636a5bb8f03108e876548b455" +); +export const WETH_ADDRESS = Address.fromString( + "0x471ece3750da237f93b8e339c536989b8978a438" // Celo native asset (CELO) +); +export const USDC_ADDRESS = Address.fromString( + "0x37f750b7cc259a2f741af45294f6a16572cf5cad" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/cronos.ts b/subgraphs/gogopool/src/prices/config/cronos.ts new file mode 100644 index 0000000000..5149b29d2a --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/cronos.ts @@ -0,0 +1,131 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "cronos"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x145863eb42cf62847a6ca784e6416c1682b1b2ae", 5247), // VVS Finance +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0xe44fd7fcb2b1581822d0c862b68222998a0c299a" +); +export const WETH_ADDRESS = Address.fromString( + "0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23" // Wrapped CRO (WCRO) +); +export const USDC_ADDRESS = Address.fromString( + "0xc21223249ca28397b4b6541dffaecc539bff0c59" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/fantom.ts b/subgraphs/gogopool/src/prices/config/fantom.ts new file mode 100644 index 0000000000..22920117cc --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/fantom.ts @@ -0,0 +1,145 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "fantom"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract( + "0x57aa88a0810dfe3f9b71a9b179dd8bf5f956c46a", + 17091856 +); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract( + "0x44536de2220987d098d1d29d3aafc7f7348e9ee4", + 3809480 +); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract( + "0x0b53e9df372e72d8fdcdbedfbb56059957a37128", + 27067399 +); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0x0f854ea9f38cea4b1c2fc79047e9d0134419d5d6", 5655918), + new OracleContract("0x4fb93d7d320e8a263f22f62c2059dfc2a8bcbc4c", 27552509), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0xbe4fc72f8293f9d3512d58b969c98c3f676cb957", 3796241), // Uniswap v2 + new OracleContract("0x16327e3fbdaca3bcf7e38f5af2599d2ddc33ae52", 4250168), // Spiritswap + new OracleContract("0x1b02da8cb0d097eb8d57a175b88c7d8b47997506", 2457904), // Sushiswap +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0x658b0c7613e890ee50b8c4bc6a3f41ef411208ad" +); +export const WETH_ADDRESS = Address.fromString( + "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83" +); +export const USDC_ADDRESS = Address.fromString( + "0x04068da6c83afcfa0e13ba15a6696662335d5b75" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/fuse.ts b/subgraphs/gogopool/src/prices/config/fuse.ts new file mode 100644 index 0000000000..87078fc497 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/fuse.ts @@ -0,0 +1,132 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "fuse"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0xe3f85aad0c8dd7337427b9df5d0fb741d65eeeb5", 15645719), // Voltage Finance + new OracleContract("0x1b02da8cb0d097eb8d57a175b88c7d8b47997506", 12936314), // Sushiswap +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0xa722c13135930332eb3d749b2f0906559d2c5b99" +); +export const WETH_ADDRESS = Address.fromString( + "0x0be9e53fd7edac9f859882afdda116645287c629" // Wrapped Fuse (WFUSE) +); +export const USDC_ADDRESS = Address.fromString( + "0x620fd5fa44be6af63715ef4e65ddfa0387ad13f5" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/gnosis.ts b/subgraphs/gogopool/src/prices/config/gnosis.ts new file mode 100644 index 0000000000..4d1ab5baaa --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/gnosis.ts @@ -0,0 +1,134 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING: string = "xdai"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0x55e91365697eb8032f98290601847296ec847210", 20754886), + new OracleContract("0x8a4694401be8f8fccbc542a3219af1591f87ce17", 23334728), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x1b02da8cb0d097eb8d57a175b88c7d8b47997506", 14735910), // SushiSwap +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1" +); +export const WETH_ADDRESS = Address.fromString( + "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d" +); +export const USDC_ADDRESS = Address.fromString( + "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/harmony.ts b/subgraphs/gogopool/src/prices/config/harmony.ts new file mode 100644 index 0000000000..6f9d265210 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/harmony.ts @@ -0,0 +1,136 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "harmony"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract( + "0xb56c2f0b653b2e0b10c9b928c8580ac5df02c7c7", + 23930344 +); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0x0a53fada2d943057c47a301d25a4d9b3b8e01e8e", 18003250), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x1b02da8cb0d097eb8d57a175b88c7d8b47997506", 11256069), // SushiSwap +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0x6983d1e6def3690c4d616b13597a09e6193ea013" +); +export const WETH_ADDRESS = Address.fromString( + "0xcf664087a5bb0237a0bad6742852ec6c8d69a27a" +); +export const USDC_ADDRESS = Address.fromString( + "0x985458e523db3d53125813ed68c274899e9dfab4" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/linea.ts b/subgraphs/gogopool/src/prices/config/linea.ts new file mode 100644 index 0000000000..49677f5ea5 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/linea.ts @@ -0,0 +1,129 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "linea"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x8cfe327cec66d1c090dd72bd0ff11d690c33a2eb", 1440), // Pancakeswap v2 Router2 +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS; +export const WETH_ADDRESS = Address.fromString( + "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f" +); +export const USDC_ADDRESS = Address.fromString( + "0x176211869ca2b568f2a7d4ee941e073a821ee1ff" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/mainnet.ts b/subgraphs/gogopool/src/prices/config/mainnet.ts new file mode 100644 index 0000000000..b050f8e598 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/mainnet.ts @@ -0,0 +1,371 @@ +/* eslint-disable @typescript-eslint/no-magic-numbers */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "mainnet"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract( + "0x83d95e0d5f402511db06817aff3f9ea88224b030", + 12242339 +); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract( + "0x47fb2585d2c56fe188d0e6ec628a38b74fceeedf", + 12864088 +); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract( + "0x8263e161a855b644f582d9c164c66aabee53f927", + 12692284 +); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract( + "0x25bf7b72815476dd515044f9650bf79bad0df655", + 12370088 +); + +// Address Provider: https://etherscan.io/address/0x0000000022d53366457f9d5e68ec105046fc4383 +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0x7d86446ddb609ed0f5f8684acf30380a356b2b4c", 11154794), + new OracleContract("0x90e00ace148ca3b23ac1bc8c240c2a7dd9c2d7f5", 12195750), // Main Registry + new OracleContract("0x8f942c20d02befc377d41445793068908e2250d0", 13986752), // CryptoSwap Registry + new OracleContract("0xf98b45fa17de75fb1ad0e7afd971b0ca00e379fc", 15732062), // Meta Registry +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f", 10794261), // SushiSwap + new OracleContract("0x7a250d5630b4cf539739df2c5dacb4c659f2488d", 10207858), // Uniswap +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = [ + Address.fromString("0x5f98805a4e8be255a32880fdec7f6728c6568ba0"), // LUSD + Address.fromString("0x8daebade922df735c38c80c7ebd708af50815faa"), // tBTC + Address.fromString("0x0316eb71485b0ab14103307bf65a021042c6d380"), // Huobi BTC + Address.fromString("0xca3d75ac011bf5ad07a98d02f18225f9bd9a6bdf"), // crvTriCrypto +]; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = [ + Address.fromString("0xca3d75ac011bf5ad07a98d02f18225f9bd9a6bdf"), // crvTriCrypto + Address.fromString("0xc4ad29ba4b3c580e6d59105fff484999997675ff"), // crv3Crypto +]; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = [ + Address.fromString("0xd632f22692fac7611d2aa1c0d552930d43caed3b"), // Curve.fi Factory USD Metapool: Frax + Address.fromString("0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3"), // Magic Internet Money + Address.fromString("0x5a6a4d54456819380173272a5e8e9b9904bdf41b"), // Curve.fi Factory USD Metapool: Magic Internet Money 3Pool + Address.fromString("0xbc6da0fe9ad5f3b0d58160288917aa56653660e9"), // Alchemix USD + Address.fromString("0x43b4fdfd4ff969587185cdb6f0bd875c5fc83f8c"), // Curve.fi Factory USD Metapool: Alchemix USD + Address.fromString("0x57ab1ec28d129707052df4df418d58a2d46d5f51"), // Synth SUSD + Address.fromString("0xc25a3a3b969415c80451098fa907ec722572917f"), // Curve.fi DAI/USDC/USDT/sUSD + Address.fromString("0x0000000000085d4780b73119b644ae5ecd22b376"), // TrueUSD + Address.fromString("0xecd5e75afb02efa118af914515d6521aabd189f1"), // Curve.fi Factory USD Metapool: TrueUSD + Address.fromString("0xfd2a8fa60abd58efe3eee34dd494cd491dc14900"), // Curve.fi aDAI/aUSDC/aUSDT + Address.fromString("0x8ee017541375f6bcd802ba119bddc94dad6911a1"), // Curve.fi Factory USD Metapool: PUSd + Address.fromString("0x5b3b5df2bf2b6543f78e053bd91c4bdd820929f1"), // Curve.fi Factory USD Metapool: USDM + Address.fromString("0x04b727c7e246ca70d496ecf52e6b6280f3c8077d"), // Curve.fi Factory USD Metapool: apeUSDFRAXBP + Address.fromString("0x3175df0976dfa876431c2e9ee6bc45b65d3473cc"), // Curve.fi FRAX/USDC + Address.fromString("0xbcb91e689114b9cc865ad7871845c95241df4105"), // Curve.fi Factory USD Metapool: PWRD Metapool + Address.fromString("0x26ea744e5b887e5205727f55dfbe8685e3b21951"), // iearn USDC + Address.fromString("0xc2cb1040220768554cf699b0d863a3cd4324ce32"), // iearn DAI + Address.fromString("0x04bc0ab673d88ae9dbc9da2380cb6b79c4bca9ae"), // iearn BUSD + Address.fromString("0xe6354ed5bc4b393a5aad09f21c46e101e692d447"), // iearn USDT + Address.fromString("0x3b3ac5386837dc563660fb6a0937dfaa5924333b"), // Curve.fi yDAI/yUSDC/yUSDT/yBUSD + Address.fromString("0xc2f5fea5197a3d92736500fd7733fcc7a3bbdf3f"), // Curve.fi Factory USD Metapool: fUSD-3pool + Address.fromString("0x0c10bf8fcb7bf5412187a595ab97a3609160b5c6"), // Decentralized USD + Address.fromString("0x028171bca77440897b824ca71d1c56cac55b68a3"), // Aave interest bearing DAI + Address.fromString("0x3ed3b47dd13ec9a98b44e6204a523e766b225811"), // Aave interest bearing USDT + Address.fromString("0xbcca60bb61934080951369a648fb03df4f96263c"), // Aave interest bearing USDC + Address.fromString("0x6c5024cd4f8a59110119c56f8933403a539555eb"), // Aave interest bearing SUSD + Address.fromString("0xd71ecff9342a5ced620049e616c5035f1db98620"), // Synth sEUR + Address.fromString("0xfc2838a17d8e8b1d5456e0a351b0708a09211147"), // FRAX/USDP + Address.fromString("0x5ca135cb8527d76e932f34b5145575f9d8cbe08e"), // FPI + Address.fromString("0xf939e0a03fb07f59a73314e73794be0e57ac1b4e"), // crvUSD +]; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////// ORACLE CONFIG OVERRIDES ///////////////////////// +/////////////////////////////////////////////////////////////////////////// + +// https://github.com/messari/subgraphs/issues/2090 +class SpellOverride implements OracleConfig { + oracleCount(): number { + return constants.INT_ONE; + } + oracleOrder(): string[] { + return [ + constants.OracleType.CHAINLINK_FEED, + constants.OracleType.CURVE_CALCULATIONS, + constants.OracleType.SUSHI_CALCULATIONS, + constants.OracleType.CURVE_ROUTER, + constants.OracleType.UNISWAP_FORKS_ROUTER, + constants.OracleType.YEARN_LENS_ORACLE, + ]; + } +} + +// https://github.com/messari/subgraphs/issues/726 +class StETHOverride implements OracleConfig { + oracleCount(): number { + return constants.INT_ONE; + } + oracleOrder(): string[] { + return [ + constants.OracleType.CHAINLINK_FEED, + constants.OracleType.CURVE_CALCULATIONS, + constants.OracleType.SUSHI_CALCULATIONS, + constants.OracleType.CURVE_ROUTER, + constants.OracleType.UNISWAP_FORKS_ROUTER, + constants.OracleType.YEARN_LENS_ORACLE, + ]; + } +} + +// https://github.com/messari/subgraphs/issues/2097 +class BaxaOverride implements OracleConfig { + oracleCount(): number { + return constants.INT_ONE; + } + oracleOrder(): string[] { + return [ + constants.OracleType.UNISWAP_FORKS_ROUTER, + constants.OracleType.YEARN_LENS_ORACLE, + constants.OracleType.CHAINLINK_FEED, + constants.OracleType.CURVE_CALCULATIONS, + constants.OracleType.CURVE_ROUTER, + constants.OracleType.SUSHI_CALCULATIONS, + ]; + } +} + +// https://github.com/messari/subgraphs/issues/2329 +class DelperOverride implements OracleConfig { + oracleCount(): number { + return constants.INT_ONE; + } + oracleOrder(): string[] { + return [ + constants.OracleType.UNISWAP_FORKS_ROUTER, + constants.OracleType.YEARN_LENS_ORACLE, + constants.OracleType.CHAINLINK_FEED, + constants.OracleType.CURVE_CALCULATIONS, + constants.OracleType.CURVE_ROUTER, + constants.OracleType.SUSHI_CALCULATIONS, + ]; + } +} + +// https://github.com/messari/subgraphs/issues/2290 +class CurveFactoryPoolOverride implements OracleConfig { + oracleCount(): number { + return constants.INT_ONE; + } + oracleOrder(): string[] { + return [ + constants.OracleType.CURVE_ROUTER, + constants.OracleType.UNISWAP_FORKS_ROUTER, + constants.OracleType.CHAINLINK_FEED, + constants.OracleType.CURVE_CALCULATIONS, + constants.OracleType.SUSHI_CALCULATIONS, + constants.OracleType.YEARN_LENS_ORACLE, + ]; + } +} + +class PreferUniswapOverride implements OracleConfig { + oracleCount(): number { + return constants.INT_ONE; + } + oracleOrder(): string[] { + return [ + constants.OracleType.UNISWAP_FORKS_ROUTER, + constants.OracleType.CURVE_CALCULATIONS, + constants.OracleType.CHAINLINK_FEED, + constants.OracleType.SUSHI_CALCULATIONS, + constants.OracleType.CURVE_ROUTER, + constants.OracleType.YEARN_LENS_ORACLE, + ]; + } +} + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" +); +export const WETH_ADDRESS = Address.fromString( + "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" +); +export const USDC_ADDRESS = Address.fromString( + "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + if (tokenAddr || block) { + if ( + tokenAddr && + [ + Address.fromString("0x090185f2135308bad17527004364ebcc2d37e5f6"), // SPELL + ].includes(tokenAddr) + ) { + return new SpellOverride(); + } + if ( + tokenAddr && + [ + Address.fromString("0xae7ab96520de3a18e5e111b5eaab095312d7fe84"), // stETH + ].includes(tokenAddr) && + block && + block.number.gt(BigInt.fromString("14019699")) && + block.number.lt(BigInt.fromString("14941265")) + ) { + return new StETHOverride(); + } + if ( + tokenAddr && + [ + Address.fromString("0x91b08f4a7c1251dfccf5440f8894f8daa10c8de5"), // BAXA + ].includes(tokenAddr) + ) { + return new BaxaOverride(); + } + if ( + tokenAddr && + [ + Address.fromString("0x077416cc6242b3a7d8e42652b8a6a2599fda4a92"), // DPR + ].includes(tokenAddr) + ) { + return new DelperOverride(); + } + if ( + tokenAddr && + [ + Address.fromString("0xed4064f376cb8d68f770fb1ff088a3d0f3ff5c4d"), // crvCRVETH + Address.fromString("0xf985005a3793dba4cce241b3c19ddcd3fe069ff4"), // ALCXFRAXBP-f + Address.fromString("0x971add32ea87f10bd192671630be3be8a11b8623"), // cvxcrv-crv-f + Address.fromString("0x137469b55d1f15651ba46a89d0588e97dd0b6562"), // BADGERWBTC-f + Address.fromString("0x4647b6d835f3b393c7a955df51eefcf0db961606"), // KP3RETH-f + Address.fromString("0x6359b6d3e327c497453d4376561ee276c6933323"), // SDTETH-f + Address.fromString("0x2889302a794da87fbf1d6db415c1492194663d13"), // crvCRVUSDTBTCWSTETH + Address.fromString("0x3a283d9c08e8b55966afb64c515f5143cf907611"), // crvCVXETH + // + Address.fromString("0x7f86bf177dd4f3494b841a37e810a34dd56c829b"), // TricryptoUSDC + Address.fromString("0xf5f5b97624542d72a9e06f04804bf81baa15e2b4"), // TricryptoUSDT + Address.fromString("0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14"), // TriCRV + Address.fromString("0xf3a43307dcafa93275993862aae628fcb50dc768"), // Factory Crypto Pool: cvxFxs/Fxs + Address.fromString("0xb79565c01b7ae53618d9b847b9443aaf4f9011e7"), // Factory Crypto Pool: LDO/ETH + Address.fromString("0x4704ab1fb693ce163f7c9d3a31b3ff4eaf797714"), // Factory Crypto Pool: FPI2Pool + Address.fromString("0xda68f66fc0f10ee61048e70106df4bdb26baf595"), // Factory Crypto Pool: JPEG/pETH + Address.fromString("0x5be6c45e2d074faa20700c49ada3e88a1cc0025d"), // Factory Crypto Pool: Curve GEAR/ETH + Address.fromString("0x8109a51542294cdbb489ae5516f42ffbd92177aa"), // Factory Crypto Pool: OGV/ETH + Address.fromString("0x390f3595bca2df7d23783dfd126427cceb997bf4"), // Factory Plain Pool: crvUSD/USDT + Address.fromString("0x4dece678ceceb27446b35c672dc7d61f30bad69e"), // Factory Plain Pool: crvUSD/USDC + ].includes(tokenAddr) + ) { + return new CurveFactoryPoolOverride(); + } + if ( + tokenAddr && + [ + Address.fromString("0xdbdb4d16eda451d0503b854cf79d55697f90c8df"), // ALCX + Address.fromString("0x62b9c7356a2dc64a1969e19c23e4f579f9810aa7"), // cvxCRV + Address.fromString("0x1ceb5cb57c4d4e2b2433641b95dd330a33185a44"), // KP3R + Address.fromString("0x73968b9a57c6e53d41345fd57a6e6ae27d6cdb2f"), // SDT + Address.fromString("0xba3335588d9403515223f109edc4eb7269a9ab5d"), // GEAR + ].includes(tokenAddr) + ) { + return new PreferUniswapOverride(); + } + } + + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/mode.ts b/subgraphs/gogopool/src/prices/config/mode.ts new file mode 100644 index 0000000000..72cd4a38c7 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/mode.ts @@ -0,0 +1,129 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "mode-mainnet"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0xc1e624c810d297fd70ef53b0e08f44fabe468591", 3325344), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS; +export const WETH_ADDRESS = Address.fromString( + "0x4200000000000000000000000000000000000006" +); +export const USDC_ADDRESS = Address.fromString( + "0xd988097fb8612cc24eec14542bc03424c656005f" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/moonbeam.ts b/subgraphs/gogopool/src/prices/config/moonbeam.ts new file mode 100644 index 0000000000..33bcd9e348 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/moonbeam.ts @@ -0,0 +1,133 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "moonbeam"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0xc2b1df84112619d190193e48148000e3990bf627", 1452049), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x445fe580ef8d70ff569ab36e80c647af338db351", 503734), // SushiSwap +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0xfa9343c3897324496a05fc75abed6bac29f8a40f" +); +export const WETH_ADDRESS = Address.fromString( + "0xacc15dc74880c9944775448304b263d191c6077f" +); +export const USDC_ADDRESS = Address.fromString( + "0x818ec0a7fe18ff94269904fced6ae3dae6d6dc0b" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/optimism.ts b/subgraphs/gogopool/src/prices/config/optimism.ts new file mode 100644 index 0000000000..3bc65a7e56 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/optimism.ts @@ -0,0 +1,145 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "optimism"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract( + "0xb082d9f4734c535d9d80536f7e87a6f4f471bf65", + 18109291 +); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract( + "0xd81eb3728a631871a7ebbad631b5f424909f0c77", + 4365625 +); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract( + "0x5fd3815dcb668200a662114fbc9af13ac0a55b4d", + 18216910 +); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract( + "0x0ffe8434eae67c9838b12c3cd11ac4005daa7227", + 18368996 +); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0xc5cfada84e902ad92dd40194f0883ad49639b023", 2373837), + new OracleContract("0x445fe580ef8d70ff569ab36e80c647af338db351", 3729171), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x9c12939390052919af3155f41bf4160fd3666a6f", 19702709), // Velodrame +]; +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0x4200000000000000000000000000000000000042" +); +export const WETH_ADDRESS = Address.fromString( + "0x4200000000000000000000000000000000000006" +); +export const USDC_ADDRESS = Address.fromString( + "0x7f5c764cbc14f9669b88837ca1490cca17c31607" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/polygon.ts b/subgraphs/gogopool/src/prices/config/polygon.ts new file mode 100644 index 0000000000..782ba266d2 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/polygon.ts @@ -0,0 +1,139 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { BigInt, Address, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "matic"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract( + "0xb023e699f5a33916ea823a16485e259257ca8bd1", + 25825996 +); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0x094d12e5b541784701fd8d65f11fc0598fbc6332", 13991825), + new OracleContract("0x47bb542b9de58b970ba50c9dae444ddb4c16751a", 23556360), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff", 4931900), // QuickSwap + new OracleContract("0x1b02da8cb0d097eb8d57a175b88c7d8b47997506", 11333235), // SushiSwap +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = Address.fromString( + "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619" +); +export const WETH_ADDRESS = Address.fromString( + "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270" +); +export const USDC_ADDRESS = Address.fromString( + "0x2791bca1f2de4661ed88a30c99a7a9449aa84174" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/polygon_zkevm.ts b/subgraphs/gogopool/src/prices/config/polygon_zkevm.ts new file mode 100644 index 0000000000..1d9f176621 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/polygon_zkevm.ts @@ -0,0 +1,129 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "polygon-zkevm"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x8cfe327cec66d1c090dd72bd0ff11d690c33a2eb", 749657), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS; +export const WETH_ADDRESS = Address.fromString( + "0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9" +); +export const USDC_ADDRESS = Address.fromString( + "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/scroll.ts b/subgraphs/gogopool/src/prices/config/scroll.ts new file mode 100644 index 0000000000..143ba93810 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/scroll.ts @@ -0,0 +1,129 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "scroll"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x5aeaf2883fbf30f3d62471154eda3c0c1b05942d", 81845), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS; +export const WETH_ADDRESS = Address.fromString( + "0x5300000000000000000000000000000000000004" +); +export const USDC_ADDRESS = Address.fromString( + "0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/config/template.ts b/subgraphs/gogopool/src/prices/config/template.ts new file mode 100644 index 0000000000..e919b22c74 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/template.ts @@ -0,0 +1,142 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "default"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////// ORACLE CONFIG OVERRIDES ///////////////////////// +/////////////////////////////////////////////////////////////////////////// + +class SomeOverride implements OracleConfig { + oracleCount(): number { + return constants.INT_ONE; + } + oracleOrder(): string[] { + return [ + constants.OracleType.YEARN_LENS_ORACLE, + constants.OracleType.CHAINLINK_FEED, + constants.OracleType.CURVE_CALCULATIONS, + constants.OracleType.SUSHI_CALCULATIONS, + constants.OracleType.CURVE_ROUTER, + constants.OracleType.UNISWAP_FORKS_ROUTER, + ]; + } +} + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS; +export const WETH_ADDRESS = constants.NULL.TYPE_ADDRESS; +export const USDC_ADDRESS = constants.NULL.TYPE_ADDRESS; + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return new SomeOverride(); + } +} diff --git a/subgraphs/gogopool/src/prices/config/zksync_era.ts b/subgraphs/gogopool/src/prices/config/zksync_era.ts new file mode 100644 index 0000000000..6f1122b785 --- /dev/null +++ b/subgraphs/gogopool/src/prices/config/zksync_era.ts @@ -0,0 +1,130 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as constants from "../common/constants"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Configurations, OracleConfig, OracleContract } from "../common/types"; + +export const NETWORK_STRING = "zksync-era"; + +/////////////////////////////////////////////////////////////////////////// +///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); +export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); +export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); +export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////// CURVE CONTRACT ////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ + new OracleContract("0x5aeaf2883fbf30f3d62471154eda3c0c1b05942d", 8637850), + new OracleContract("0x18381c0f738146fb694de18d1106bde2be040fa4", 4182380), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// BLACKLISTED TOKENS //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const YEARN_LENS_BLACKLIST: Address[] = []; +export const AAVE_ORACLE_BLACKLIST: Address[] = []; +export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; +export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +//////////////////////////// HARDCODED STABLES //////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const HARDCODED_STABLES: Address[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// HELPERS ///////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); + +export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS; +export const WETH_ADDRESS = Address.fromString( + "0x5aea5775959fbc2557cc8789bc1bf90a239d9a91" +); +export const USDC_ADDRESS = Address.fromString( + "0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4" +); + +export class config implements Configurations { + network(): string { + return NETWORK_STRING; + } + + yearnLens(): OracleContract { + return YEARN_LENS_CONTRACT_ADDRESS; + } + chainLink(): OracleContract { + return CHAIN_LINK_CONTRACT_ADDRESS; + } + yearnLensBlacklist(): Address[] { + return YEARN_LENS_BLACKLIST; + } + + aaveOracle(): OracleContract { + return AAVE_ORACLE_CONTRACT_ADDRESS; + } + aaveOracleBlacklist(): Address[] { + return AAVE_ORACLE_BLACKLIST; + } + + curveCalculations(): OracleContract { + return CURVE_CALCULATIONS_ADDRESS; + } + curveCalculationsBlacklist(): Address[] { + return CURVE_CALCULATIONS_BLACKSLIST; + } + + sushiCalculations(): OracleContract { + return SUSHISWAP_CALCULATIONS_ADDRESS; + } + sushiCalculationsBlacklist(): Address[] { + return SUSHI_CALCULATIONS_BLACKSLIST; + } + + uniswapForks(): OracleContract[] { + return UNISWAP_FORKS_ROUTER_ADDRESSES; + } + curveRegistry(): OracleContract[] { + return CURVE_REGISTRY_ADDRESSES; + } + + hardcodedStables(): Address[] { + return HARDCODED_STABLES; + } + + ethAddress(): Address { + return ETH_ADDRESS; + } + wethAddress(): Address { + return WETH_ADDRESS; + } + usdcAddress(): Address { + return USDC_ADDRESS; + } + + usdcTokenDecimals(): BigInt { + return USDC_TOKEN_DECIMALS; + } + + getOracleOverride( + tokenAddr: Address | null, + block: ethereum.Block | null + ): OracleConfig | null { + return null; + } +} diff --git a/subgraphs/gogopool/src/prices/index.ts b/subgraphs/gogopool/src/prices/index.ts new file mode 100644 index 0000000000..2de22a307e --- /dev/null +++ b/subgraphs/gogopool/src/prices/index.ts @@ -0,0 +1,151 @@ +import { + log, + Address, + ethereum, + BigDecimal, + dataSource, +} from "@graphprotocol/graph-ts"; +import { CustomPriceType, OracleType } from "./common/types"; + +import * as utils from "./common/utils"; +import * as constants from "./common/constants"; +import * as AaveOracle from "./oracles/AaveOracle"; +import * as CurveRouter from "./routers/CurveRouter"; +import * as ChainLinkFeed from "./oracles/ChainLinkFeed"; +import * as YearnLensOracle from "./oracles/YearnLensOracle"; +import * as UniswapForksRouter from "./routers/UniswapForksRouter"; +import * as CurveCalculations from "./calculations/CalculationsCurve"; +import * as SushiCalculations from "./calculations/CalculationsSushiswap"; + +export function getUsdPricePerToken( + tokenAddr: Address, + block: ethereum.Block | null = null +): CustomPriceType { + if (tokenAddr.equals(constants.NULL.TYPE_ADDRESS)) { + return new CustomPriceType(); + } + + const config = utils.getConfig(); + if (config.network() == "default") { + log.warning("Failed to fetch price: network {} not implemented", [ + dataSource.network(), + ]); + + return new CustomPriceType(); + } + + if (config.hardcodedStables().includes(tokenAddr)) { + return CustomPriceType.initialize( + constants.BIGDECIMAL_USD_PRICE, + constants.DEFAULT_USDC_DECIMALS + ); + } + + const oracle = new OracleType(); + const override = config.getOracleOverride(tokenAddr, block); + if (override) { + oracle.setOracleConfig(override); + } + const oracleCount = oracle.oracleCount; + const oracleOrder = oracle.oracleOrder; + + const prices: CustomPriceType[] = []; + for (let i = 0; i < oracleOrder.length; i++) { + if (prices.length >= oracleCount) { + break; + } + + let oraclePrice = new CustomPriceType(); + + if (oracleOrder[i] == constants.OracleType.YEARN_LENS_ORACLE) { + oraclePrice = YearnLensOracle.getTokenPriceUSDC(tokenAddr, block); + } else if (oracleOrder[i] == constants.OracleType.CHAINLINK_FEED) { + oraclePrice = ChainLinkFeed.getTokenPriceUSDC(tokenAddr, block); + } else if (oracleOrder[i] == constants.OracleType.CURVE_CALCULATIONS) { + oraclePrice = CurveCalculations.getTokenPriceUSDC(tokenAddr, block); + } else if (oracleOrder[i] == constants.OracleType.SUSHI_CALCULATIONS) { + oraclePrice = SushiCalculations.getTokenPriceUSDC(tokenAddr, block); + } else if (oracleOrder[i] == constants.OracleType.AAVE_ORACLE) { + oraclePrice = AaveOracle.getTokenPriceUSDC(tokenAddr, block); + } else if (oracleOrder[i] == constants.OracleType.CURVE_ROUTER) { + oraclePrice = CurveRouter.getCurvePriceUsdc(tokenAddr, block); + } else if (oracleOrder[i] == constants.OracleType.UNISWAP_FORKS_ROUTER) { + oraclePrice = UniswapForksRouter.getTokenPriceUSDC(tokenAddr, block); + } + + if (!oraclePrice.reverted) { + prices.push(oraclePrice); + } + } + + if (prices.length == constants.INT_ZERO) { + log.warning("[Oracle] Failed to Fetch Price, tokenAddr: {}", [ + tokenAddr.toHexString(), + ]); + + return new CustomPriceType(); + } else if (prices.length == constants.INT_ONE) { + return prices[constants.INT_ZERO]; + } else if (prices.length == constants.INT_TWO) { + return utils.averagePrice(prices); + } + + const k = Math.ceil(prices.length / constants.INT_TWO) as i32; + const closestPrices = utils.kClosestPrices(k, prices); + + return utils.averagePrice(closestPrices); +} + +export function getLiquidityBoundPrice( + tokenAddress: Address, + tokenPrice: CustomPriceType, + amount: BigDecimal +): BigDecimal { + const reportedPriceUSD = tokenPrice.usdPrice.times(amount); + const liquidity = tokenPrice.liquidity; + + let liquidityBoundPriceUSD = reportedPriceUSD; + if (liquidity > constants.BIGDECIMAL_ZERO && reportedPriceUSD > liquidity) { + liquidityBoundPriceUSD = liquidity + .div( + constants.BIGINT_TEN.pow( + constants.DEFAULT_USDC_DECIMALS as u8 + ).toBigDecimal() + ) + .times(constants.BIGINT_TEN.pow(tokenPrice.decimals as u8).toBigDecimal()) + .div(amount); + + log.warning( + "[getLiquidityBoundPrice] token: {} (reported price * amount): ({} * {}) bound to available liquidity: {}; new price: {}", + [ + tokenAddress.toHexString(), + tokenPrice.usdPrice.toString(), + amount.toString(), + liquidity.toString(), + liquidityBoundPriceUSD.toString(), + ] + ); + } + + return liquidityBoundPriceUSD; +} + +export function getUsdPrice( + tokenAddr: Address, + amount: BigDecimal, + block: ethereum.Block | null = null +): BigDecimal { + const tokenPrice = getUsdPricePerToken(tokenAddr, block); + + if (!tokenPrice.reverted) { + if ( + tokenPrice.oracleType == constants.OracleType.UNISWAP_FORKS_ROUTER || + tokenPrice.oracleType == constants.OracleType.CURVE_ROUTER + ) { + return getLiquidityBoundPrice(tokenAddr, tokenPrice, amount); + } + return tokenPrice.usdPrice.times(amount); + } + + return constants.BIGDECIMAL_ZERO; +} diff --git a/subgraphs/gogopool/src/prices/oracles/AaveOracle.ts b/subgraphs/gogopool/src/prices/oracles/AaveOracle.ts new file mode 100644 index 0000000000..a3462aaee5 --- /dev/null +++ b/subgraphs/gogopool/src/prices/oracles/AaveOracle.ts @@ -0,0 +1,44 @@ +import * as utils from "../common/utils"; +import * as constants from "../common/constants"; +import { CustomPriceType, OracleContract } from "../common/types"; +import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { AaveOracleContract } from "../../../generated/GGAVAX/AaveOracleContract"; + +export function getAaveOracleContract( + contract: OracleContract, + block: ethereum.Block | null = null +): AaveOracleContract | null { + if ( + (block && contract.startBlock.gt(block.number)) || + utils.isNullAddress(contract.address) + ) + return null; + + return AaveOracleContract.bind(contract.address); +} + +export function getTokenPriceUSDC( + tokenAddr: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const config = utils.getConfig(); + + if (!config || config.aaveOracleBlacklist().includes(tokenAddr)) + return new CustomPriceType(); + + const aaveOracleContract = getAaveOracleContract(config.aaveOracle(), block); + if (!aaveOracleContract) return new CustomPriceType(); + + const tokenPrice: BigDecimal = utils + .readValue( + aaveOracleContract.try_getAssetPrice(tokenAddr), + constants.BIGINT_ZERO + ) + .toBigDecimal(); + + return CustomPriceType.initialize( + tokenPrice, + constants.AAVE_ORACLE_DECIMALS, + constants.OracleType.AAVE_ORACLE + ); +} diff --git a/subgraphs/gogopool/src/prices/oracles/ChainLinkFeed.ts b/subgraphs/gogopool/src/prices/oracles/ChainLinkFeed.ts new file mode 100644 index 0000000000..93090f90f9 --- /dev/null +++ b/subgraphs/gogopool/src/prices/oracles/ChainLinkFeed.ts @@ -0,0 +1,53 @@ +import * as utils from "../common/utils"; +import * as constants from "../common/constants"; +import { Address, ethereum } from "@graphprotocol/graph-ts"; +import { CustomPriceType, OracleContract } from "../common/types"; +import { ChainLinkContract } from "../../../generated/GGAVAX/ChainLinkContract"; + +export function getChainLinkContract( + contract: OracleContract, + block: ethereum.Block | null = null +): ChainLinkContract | null { + if ( + (block && contract.startBlock.gt(block.number)) || + utils.isNullAddress(contract.address) + ) + return null; + + return ChainLinkContract.bind(contract.address); +} + +export function getTokenPriceUSDC( + tokenAddr: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const config = utils.getConfig(); + if (!config) return new CustomPriceType(); + + const chainLinkContract = getChainLinkContract(config.chainLink(), block); + if (!chainLinkContract) return new CustomPriceType(); + + const result = chainLinkContract.try_latestRoundData( + tokenAddr, + constants.CHAIN_LINK_USD_ADDRESS + ); + + if (!result.reverted) { + const decimals = chainLinkContract.try_decimals( + tokenAddr, + constants.CHAIN_LINK_USD_ADDRESS + ); + + if (decimals.reverted) { + return new CustomPriceType(); + } + + return CustomPriceType.initialize( + result.value.value1.toBigDecimal(), + decimals.value, + constants.OracleType.CHAINLINK_FEED + ); + } + + return new CustomPriceType(); +} diff --git a/subgraphs/gogopool/src/prices/oracles/YearnLensOracle.ts b/subgraphs/gogopool/src/prices/oracles/YearnLensOracle.ts new file mode 100644 index 0000000000..ed50d6386d --- /dev/null +++ b/subgraphs/gogopool/src/prices/oracles/YearnLensOracle.ts @@ -0,0 +1,44 @@ +import * as utils from "../common/utils"; +import * as constants from "../common/constants"; +import { CustomPriceType, OracleContract } from "../common/types"; +import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { YearnLensContract } from "../../../generated/GGAVAX/YearnLensContract"; + +export function getYearnLensContract( + contract: OracleContract, + block: ethereum.Block | null = null +): YearnLensContract | null { + if ( + (block && contract.startBlock.gt(block.number)) || + utils.isNullAddress(contract.address) + ) + return null; + + return YearnLensContract.bind(contract.address); +} + +export function getTokenPriceUSDC( + tokenAddr: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const config = utils.getConfig(); + + if (!config || config.yearnLensBlacklist().includes(tokenAddr)) + return new CustomPriceType(); + + const yearnLensContract = getYearnLensContract(config.yearnLens(), block); + if (!yearnLensContract) return new CustomPriceType(); + + const tokenPrice: BigDecimal = utils + .readValue( + yearnLensContract.try_getPriceUsdcRecommended(tokenAddr), + constants.BIGINT_ZERO + ) + .toBigDecimal(); + + return CustomPriceType.initialize( + tokenPrice, + constants.DEFAULT_USDC_DECIMALS, + constants.OracleType.YEARN_LENS_ORACLE + ); +} diff --git a/subgraphs/gogopool/src/prices/routers/CurveRouter.ts b/subgraphs/gogopool/src/prices/routers/CurveRouter.ts new file mode 100644 index 0000000000..4a94f5e5d3 --- /dev/null +++ b/subgraphs/gogopool/src/prices/routers/CurveRouter.ts @@ -0,0 +1,368 @@ +/* eslint-disable @typescript-eslint/no-magic-numbers */ +import { getUsdPricePerToken } from ".."; +import * as utils from "../common/utils"; +import * as constants from "../common/constants"; +import { CustomPriceType } from "../common/types"; +import { BigInt, Address, BigDecimal, ethereum } from "@graphprotocol/graph-ts"; +import { CurvePool as CurvePoolContract } from "../../../generated/GGAVAX/CurvePool"; +import { CurveRegistry as CurveRegistryContract } from "../../../generated/GGAVAX/CurveRegistry"; + +export function isCurveLpToken( + lpAddress: Address, + block: ethereum.Block +): bool { + const poolAddress = getPoolFromLpToken(lpAddress, block); + if (poolAddress.notEqual(constants.NULL.TYPE_ADDRESS)) return true; + + return false; +} + +export function getPoolFromLpToken( + lpAddress: Address, + block: ethereum.Block | null = null +): Address { + const config = utils.getConfig(); + const curveRegistryAdresses = config.curveRegistry(); + + for (let idx = 0; idx < curveRegistryAdresses.length; idx++) { + const curveRegistry = curveRegistryAdresses[idx]; + if (block && curveRegistry.startBlock.gt(block.number)) continue; + + const curveRegistryContract = CurveRegistryContract.bind( + curveRegistry.address + ); + + const poolAddress = utils.readValue
( + curveRegistryContract.try_get_pool_from_lp_token(lpAddress), + constants.NULL.TYPE_ADDRESS + ); + + if (poolAddress.notEqual(constants.NULL.TYPE_ADDRESS)) return poolAddress; + } + + return constants.NULL.TYPE_ADDRESS; +} + +export function isLpCryptoPool( + lpAddress: Address, + block: ethereum.Block | null = null +): bool { + const poolAddress = getPoolFromLpToken(lpAddress, block); + + if (poolAddress != constants.NULL.TYPE_ADDRESS) { + return isPoolCryptoPool(poolAddress); + } + + return false; +} + +export function isPoolCryptoPool(poolAddress: Address): bool { + const poolContract = CurvePoolContract.bind(poolAddress); + + const priceOracleCall = poolContract.try_price_oracle(); + if (!priceOracleCall.reverted) return true; + + const priceOracle1Call = poolContract.try_price_oracle1( + constants.BIGINT_ZERO + ); + if (!priceOracle1Call.reverted) return true; + + return false; +} + +export function getCurvePriceUsdc( + lpAddress: Address, + block: ethereum.Block | null = null +): CustomPriceType { + if (isLpCryptoPool(lpAddress, block)) + return cryptoPoolLpPriceUsdc(lpAddress, block); + + const basePrice = getBasePrice(lpAddress, block); + const virtualPrice = getVirtualPrice(lpAddress, block).toBigDecimal(); + + const config = utils.getConfig(); + const usdcTokenDecimals = config.usdcTokenDecimals(); + + const decimalsAdjustment = + constants.DEFAULT_DECIMALS.minus(usdcTokenDecimals); + const priceUsdc = virtualPrice + .times(basePrice.usdPrice) + .times( + constants.BIGINT_TEN.pow(decimalsAdjustment.toI32() as u8).toBigDecimal() + ); + + const liquidity = getLpTokenLiquidityUsdc(lpAddress, block); + + return CustomPriceType.initialize( + priceUsdc, + decimalsAdjustment.plus(constants.DEFAULT_DECIMALS).toI32() as u8, + constants.OracleType.CURVE_ROUTER, + liquidity.usdPrice + ); +} + +export function getBasePrice( + lpAddress: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const poolAddress = getPoolFromLpToken(lpAddress, block); + + if (poolAddress.equals(constants.NULL.TYPE_ADDRESS)) + return new CustomPriceType(); + + const underlyingCoinAddress = getUnderlyingCoinFromPool(poolAddress, block); + const basePrice = getPriceUsdcRecommended(underlyingCoinAddress, block); + + return basePrice; +} + +export function getUnderlyingCoinFromPool( + poolAddress: Address, + block: ethereum.Block | null = null +): Address { + const config = utils.getConfig(); + const curveRegistryAdresses = config.curveRegistry(); + + for (let idx = 0; idx < curveRegistryAdresses.length; idx++) { + const curveRegistry = curveRegistryAdresses[idx]; + if (block && curveRegistry.startBlock.gt(block.number)) continue; + + const curveRegistryContract = CurveRegistryContract.bind( + curveRegistry.address + ); + + const coins = utils.readValue( + curveRegistryContract.try_get_underlying_coins(poolAddress), + [] + ); + + if (coins.length != 0) return getPreferredCoinFromCoins(coins); + } + + return constants.NULL.TYPE_ADDRESS; +} + +export function getPreferredCoinFromCoins(coins: Address[]): Address { + let preferredCoinAddress = constants.NULL.TYPE_ADDRESS; + for (let coinIdx = 0; coinIdx < 8; coinIdx++) { + const coinAddress = coins[coinIdx]; + + if (coinAddress.notEqual(constants.NULL.TYPE_ADDRESS)) { + preferredCoinAddress = coinAddress; + } + // Found preferred coin and we're at the end of the token array + if ( + (preferredCoinAddress.notEqual(constants.NULL.TYPE_ADDRESS) && + coinAddress.equals(constants.NULL.TYPE_ADDRESS)) || + coinIdx == 7 + ) { + break; + } + } + + return preferredCoinAddress; +} + +export function getVirtualPrice( + curveLpTokenAddress: Address, + block: ethereum.Block | null = null +): BigInt { + const config = utils.getConfig(); + const curveRegistryAdresses = config.curveRegistry(); + + for (let idx = 0; idx < curveRegistryAdresses.length; idx++) { + const curveRegistry = curveRegistryAdresses[idx]; + if (block && curveRegistry.startBlock.gt(block.number)) continue; + + const curveRegistryContract = CurveRegistryContract.bind( + curveRegistry.address + ); + + const virtualPriceCall = + curveRegistryContract.try_get_virtual_price_from_lp_token( + curveLpTokenAddress + ); + + if (!virtualPriceCall.reverted) return virtualPriceCall.value; + } + + return constants.BIGINT_ZERO; +} + +export function getPriceUsdcRecommended( + tokenAddress: Address, + block: ethereum.Block | null = null +): CustomPriceType { + return getUsdPricePerToken(tokenAddress, block); +} + +export function cryptoPoolLpPriceUsdc( + lpAddress: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const totalSupply = utils.getTokenSupply(lpAddress); + + const totalValueUsdc = cryptoPoolLpTotalValueUsdc(lpAddress, block); + const priceUsdc = totalValueUsdc + .times( + constants.BIGINT_TEN.pow( + constants.DEFAULT_DECIMALS.toI32() as u8 + ).toBigDecimal() + ) + .div(totalSupply.toBigDecimal()); + + return CustomPriceType.initialize( + priceUsdc, + 0, + constants.OracleType.CURVE_ROUTER + ); +} + +export function cryptoPoolLpTotalValueUsdc( + lpAddress: Address, + block: ethereum.Block | null = null +): BigDecimal { + const poolAddress = getPoolFromLpToken(lpAddress, block); + + const underlyingTokensAddresses = + cryptoPoolUnderlyingTokensAddressesByPoolAddress(poolAddress); + + let totalValue = constants.BIGDECIMAL_ZERO; + + for ( + let tokenIdx = 0; + tokenIdx < underlyingTokensAddresses.length; + tokenIdx++ + ) { + const tokenValueUsdc = cryptoPoolTokenAmountUsdc( + poolAddress, + underlyingTokensAddresses[tokenIdx], + BigInt.fromI32(tokenIdx), + block + ); + totalValue = totalValue.plus(tokenValueUsdc); + } + + return totalValue; +} + +export function cryptoPoolTokenAmountUsdc( + poolAddress: Address, + tokenAddress: Address, + tokenIdx: BigInt, + block: ethereum.Block | null = null +): BigDecimal { + const poolContract = CurvePoolContract.bind(poolAddress); + + const tokenBalance = utils + .readValue( + poolContract.try_balances(tokenIdx), + constants.BIGINT_ZERO + ) + .toBigDecimal(); + + const tokenDecimals = utils.getTokenDecimals(tokenAddress); + const tokenPrice = getPriceUsdcRecommended(tokenAddress, block); + const tokenValueUsdc = tokenBalance + .times(tokenPrice.usdPrice) + .div(constants.BIGINT_TEN.pow(tokenDecimals.toI32() as u8).toBigDecimal()); + + return tokenValueUsdc; +} + +export function cryptoPoolUnderlyingTokensAddressesByPoolAddress( + poolAddress: Address +): Address[] { + const poolContract = CurvePoolContract.bind(poolAddress); + + let idx = 0; + const coins: Address[] = []; + while (idx >= 0) { + const coin = utils.readValue
( + poolContract.try_coins(BigInt.fromI32(idx)), + constants.NULL.TYPE_ADDRESS + ); + + if (coin.equals(constants.NULL.TYPE_ADDRESS)) { + return coins; + } + + coins.push(coin); + idx += 1; + } + + return coins; +} + +export function getPriceUsdc( + tokenAddress: Address, + block: ethereum.Block +): CustomPriceType { + if (isCurveLpToken(tokenAddress, block)) + return getCurvePriceUsdc(tokenAddress, block); + + const poolContract = CurvePoolContract.bind(tokenAddress); + const virtualPrice = utils + .readValue( + poolContract.try_get_virtual_price(), + constants.BIGINT_ZERO + ) + .toBigDecimal(); + + const coins: Address[] = []; + for (let i = 0; i < 8; i++) { + const coin = utils.readValue
( + poolContract.try_coins(BigInt.fromI32(i)), + constants.NULL.TYPE_ADDRESS + ); + + coins.push(coin); + } + + const preferredCoin = getPreferredCoinFromCoins(coins); + const price = getPriceUsdcRecommended(preferredCoin, block); + + return CustomPriceType.initialize( + price.usdPrice.times(virtualPrice), + constants.DEFAULT_DECIMALS.toI32() as u8, + constants.OracleType.CURVE_ROUTER + ); +} + +function getLpTokenLiquidityUsdc( + lpAddress: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const poolAddress = getPoolFromLpToken(lpAddress, block); + const poolContract = CurvePoolContract.bind(poolAddress); + + let liquidity = constants.BIGDECIMAL_ZERO; + for (let i = 0; i < 8; i++) { + const coin = utils.readValue
( + poolContract.try_coins(BigInt.fromI32(i)), + constants.NULL.TYPE_ADDRESS + ); + if (coin.equals(constants.NULL.TYPE_ADDRESS) || coin.equals(lpAddress)) + continue; + + const decimals = utils.getTokenDecimals(coin); + const balance = utils.readValue( + poolContract.try_balances(BigInt.fromI32(i as i32)), + constants.BIGINT_ZERO + ); + + const price = getPriceUsdcRecommended(coin, block); + liquidity = liquidity.plus( + balance + .div(constants.BIGINT_TEN.pow(decimals.toI32() as u8)) + .toBigDecimal() + .times(price.usdPrice) + ); + } + + return CustomPriceType.initialize( + liquidity, + constants.DEFAULT_USDC_DECIMALS, + constants.OracleType.CURVE_ROUTER + ); +} diff --git a/subgraphs/gogopool/src/prices/routers/UniswapForksRouter.ts b/subgraphs/gogopool/src/prices/routers/UniswapForksRouter.ts new file mode 100644 index 0000000000..b268f3826a --- /dev/null +++ b/subgraphs/gogopool/src/prices/routers/UniswapForksRouter.ts @@ -0,0 +1,292 @@ +import * as utils from "../common/utils"; +import * as constants from "../common/constants"; +import { CustomPriceType } from "../common/types"; +import { Address, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; +import { UniswapPair as UniswapPairContract } from "../../../generated/GGAVAX/UniswapPair"; +import { UniswapRouter as UniswapRouterContract } from "../../../generated/GGAVAX/UniswapRouter"; +import { UniswapFactory as UniswapFactoryContract } from "../../../generated/GGAVAX/UniswapFactory"; + +export function isLpToken(tokenAddress: Address, ethAddress: Address): bool { + if (tokenAddress.equals(ethAddress)) return false; + + const lpToken = UniswapRouterContract.bind(tokenAddress); + const isFactoryAvailable = utils.readValue( + lpToken.try_factory(), + constants.NULL.TYPE_ADDRESS + ); + + if (isFactoryAvailable.equals(constants.NULL.TYPE_ADDRESS)) return false; + + return true; +} + +export function getTokenPriceUSDC( + tokenAddress: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const config = utils.getConfig(); + if (!config) return new CustomPriceType(); + + const ethAddress = config.ethAddress(); + const usdcAddress = config.usdcAddress(); + + if (isLpToken(tokenAddress, ethAddress)) { + return getLpTokenPriceUsdc(tokenAddress, block); + } + return getPriceFromRouterUSDC(tokenAddress, usdcAddress, block); +} + +export function getPriceFromRouterUSDC( + tokenAddress: Address, + usdcAddress: Address, + block: ethereum.Block | null = null +): CustomPriceType { + return getPriceFromRouter(tokenAddress, usdcAddress, block); +} + +export function getPriceFromRouter( + token0Address: Address, + token1Address: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const config = utils.getConfig(); + + const ethAddress = config.ethAddress(); + const wethAddress = config.wethAddress(); + + // Construct swap path + const path: Address[] = []; + let numberOfJumps: BigInt; + + // Convert ETH address to WETH + if (token0Address == ethAddress) token0Address = wethAddress; + if (token1Address == ethAddress) token1Address = wethAddress; + + const inputTokenIsWeth: bool = + token0Address.equals(wethAddress) || token1Address.equals(wethAddress); + + if (inputTokenIsWeth) { + // Path = [token0, weth] or [weth, token1] + numberOfJumps = BigInt.fromI32(1); + + path.push(token0Address); + path.push(token1Address); + } else { + // Path = [token0, weth, token1] + numberOfJumps = BigInt.fromI32(2); + + path.push(token0Address); + path.push(wethAddress); + path.push(token1Address); + } + + const token0Decimals = utils.getTokenDecimals(token0Address); + const amountIn = constants.BIGINT_TEN.pow(token0Decimals.toI32() as u8); + + const routerAddresses = config.uniswapForks(); + + let routerAddress = constants.NULL.TYPE_ADDRESS; + let amountOut = constants.BIGINT_ZERO; + for (let idx = 0; idx < routerAddresses.length; idx++) { + const router = routerAddresses[idx]; + if (block && router.startBlock.gt(block.number)) continue; + + const uniswapForkRouter = UniswapRouterContract.bind(router.address); + const amountOutArray = uniswapForkRouter.try_getAmountsOut(amountIn, path); + + if (!amountOutArray.reverted) { + routerAddress = router.address; + amountOut = amountOutArray.value[amountOutArray.value.length - 1]; + break; + } + } + + const feeBips = BigInt.fromI32(30); + + const amountOutBigDecimal = amountOut + .times(constants.BIGINT_TEN_THOUSAND) + .div(constants.BIGINT_TEN_THOUSAND.minus(feeBips.times(numberOfJumps))) + .toBigDecimal(); + + const priceFromRouter = CustomPriceType.initialize( + amountOutBigDecimal, + config.usdcTokenDecimals().toI32() as u8, + constants.OracleType.UNISWAP_FORKS_ROUTER + ); + + const routerContract = UniswapRouterContract.bind(routerAddress); + const factoryAddress = utils.readValue( + routerContract.try_factory(), + constants.NULL.TYPE_ADDRESS + ); + if (factoryAddress.equals(constants.NULL.TYPE_ADDRESS)) + return priceFromRouter; + + const factoryContract = UniswapFactoryContract.bind(factoryAddress); + const tokenPair = utils.readValue( + factoryContract.try_getPair(token0Address, wethAddress), + constants.NULL.TYPE_ADDRESS + ); + if (tokenPair.equals(constants.NULL.TYPE_ADDRESS)) return priceFromRouter; + + const liquidityUSD = getLpTokenLiquidityUsdc(tokenPair, wethAddress, block); + priceFromRouter.setLiquidity(liquidityUSD.usdPrice); + + return priceFromRouter; +} + +export function getLpTokenPriceUsdc( + tokenAddress: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const uniSwapPair = UniswapPairContract.bind(tokenAddress); + + const totalLiquidity: CustomPriceType = getLpTokenTotalLiquidityUsdc( + tokenAddress, + block + ); + const totalSupply = utils.readValue( + uniSwapPair.try_totalSupply(), + constants.BIGINT_ZERO + ); + if (totalSupply == constants.BIGINT_ZERO || totalLiquidity.reverted) { + return new CustomPriceType(); + } + + let pairDecimals: number; + const pairDecimalsCall = uniSwapPair.try_decimals(); + + if (pairDecimalsCall.reverted) { + log.warning( + "[UniswapForksRouter] Failed to fetch pair decimals, tokenAddress: {}", + [tokenAddress.toHexString()] + ); + + return new CustomPriceType(); + } else { + pairDecimals = pairDecimalsCall.value; + } + + const pricePerLpTokenUsdc = totalLiquidity.usdPrice + .times(constants.BIGINT_TEN.pow(pairDecimals as u8).toBigDecimal()) + .div(totalSupply.toBigDecimal()); + + return CustomPriceType.initialize( + pricePerLpTokenUsdc, + constants.DEFAULT_USDC_DECIMALS, + constants.OracleType.UNISWAP_FORKS_ROUTER + ); +} + +export function getLpTokenTotalLiquidityUsdc( + tokenAddress: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const uniSwapPair = UniswapPairContract.bind(tokenAddress); + + const token0Address = utils.readValue
( + uniSwapPair.try_token0(), + constants.NULL.TYPE_ADDRESS + ); + const token1Address = utils.readValue
( + uniSwapPair.try_token1(), + constants.NULL.TYPE_ADDRESS + ); + + if ( + token0Address.equals(constants.NULL.TYPE_ADDRESS) || + token1Address.equals(constants.NULL.TYPE_ADDRESS) + ) { + return new CustomPriceType(); + } + + const token0Decimals = utils.getTokenDecimals(token0Address); + const token1Decimals = utils.getTokenDecimals(token1Address); + + const reservesCall = uniSwapPair.try_getReserves(); + + if (reservesCall.reverted) return new CustomPriceType(); + + const token0Price = getTokenPriceUSDC(token0Address, block); + const token1Price = getTokenPriceUSDC(token1Address, block); + + if (token0Price.reverted || token1Price.reverted) { + return new CustomPriceType(); + } + + const reserves = reservesCall.value; + const reserve0 = reserves.value0; + const reserve1 = reserves.value1; + + if ( + reserve0.notEqual(constants.BIGINT_ZERO) || + reserve1.notEqual(constants.BIGINT_ZERO) + ) { + const liquidity0 = reserve0 + .toBigDecimal() + .div( + constants.BIGINT_TEN.pow(token0Decimals.toI32() as u8).toBigDecimal() + ) + .times(token0Price.usdPrice); + + const liquidity1 = reserve1 + .toBigDecimal() + .div( + constants.BIGINT_TEN.pow(token1Decimals.toI32() as u8).toBigDecimal() + ) + .times(token1Price.usdPrice); + + const totalLiquidity = liquidity0.plus(liquidity1); + + return CustomPriceType.initialize( + totalLiquidity, + constants.DEFAULT_USDC_DECIMALS, + constants.OracleType.UNISWAP_FORKS_ROUTER + ); + } + return new CustomPriceType(); +} + +function getLpTokenLiquidityUsdc( + lpAddress: Address, + wethAddress: Address, + block: ethereum.Block | null = null +): CustomPriceType { + const uniSwapPair = UniswapPairContract.bind(lpAddress); + + const token1Call = uniSwapPair.try_token1(); + if (token1Call.reverted) return new CustomPriceType(); + const token1Address = token1Call.value; + + const reservesCall = uniSwapPair.try_getReserves(); + if (reservesCall.reverted) return new CustomPriceType(); + const reserves = reservesCall.value; + + let wethReserves = reserves.value0; + if (token1Address == wethAddress) { + wethReserves = reserves.value1; + } + + const wethPrice = getTokenPriceUSDC(wethAddress, block); + if (wethPrice.reverted) { + return new CustomPriceType(); + } + + const wethDecimals = utils.getTokenDecimals(wethAddress); + + if (wethReserves.notEqual(constants.BIGINT_ZERO)) { + const liquidityUSDC = utils + .bigIntToBigDecimal( + wethReserves, + wethDecimals.toI32() - constants.DEFAULT_USDC_DECIMALS + ) + .times(wethPrice.usdPrice); + + return CustomPriceType.initialize( + liquidityUSDC, + constants.DEFAULT_USDC_DECIMALS, + constants.OracleType.UNISWAP_FORKS_ROUTER + ); + } + return new CustomPriceType(); +} diff --git a/subgraphs/gogopool/src/sdk/README.md b/subgraphs/gogopool/src/sdk/README.md new file mode 100644 index 0000000000..c8e3bddd41 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/README.md @@ -0,0 +1,25 @@ +## Wat dis? + +This folder contains a library which abstracts the developer from most of the _schema related_ functionality. Ideally, building a subgraph should only consist on understading a protocol and translating certain events into actions and metrics. But the particularities of how this metrics are stored and how they relate to each other inside the schema can and should be abstracted away. Things like taking snapshots of entities every X amount of time, updating TVL every time there is a deposit/withdrawal, updating fees at _swap & pool & protocol & snapshot levels_, etc ... This library aims to do that. + +When using this library, entities should not be updated directly, but always through the library unless absolutely needed. An exception to this is if you create your own auxiliary entity to aid on the handling of some events. + +## How It's Organized + +Pretty straightforward, `/protocols` and `/util`. + +Because we are currently experimenting different approaches, each protocol type has a different schema, and AssemblyScript has some limitations when dealing with interfaces, so far, each protocol type has its own implementation. They all live in their respective folders under `/protocols`, and have very little shared code. + +`/util` contains all these common functions and constants we use over and over. + +## Setting it up + +It would be ideal to have the library to get setup automatically with the messari-cli, in a similar way as we do to generate versions. We might eventually get there, but so far it consists on a manual copy process. + +Refer to each protocol type readme, since requirements might vary: + +- [Bridges](./protocols/bridge/README.md) +- [Lending](./protocols/lending/README.md) +- [Perpetual Futures](./protocols/perpfutures/README.md) +- DEX +- Yield diff --git a/subgraphs/gogopool/src/sdk/protocols/config.ts b/subgraphs/gogopool/src/sdk/protocols/config.ts new file mode 100644 index 0000000000..f75004e165 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/protocols/config.ts @@ -0,0 +1,45 @@ +import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; +import { Token } from "../../../generated/schema"; +import { Versions } from "../../../../../deployment/context/interface"; + +export interface ProtocolConfigurer { + getID(): string; + getName(): string; + getSlug(): string; + getVersions(): Versions; +} + +export class ProtocolConfig implements ProtocolConfigurer { + id: string; + name: string; + slug: string; + versions: Versions; + + constructor(id: string, name: string, slug: string, versions: Versions) { + this.id = id; + this.name = name; + this.slug = slug; + this.versions = versions; + } + + getID(): string { + return this.id; + } + + getName(): string { + return this.name; + } + + getSlug(): string { + return this.slug; + } + + getVersions(): Versions { + return this.versions; + } +} + +export interface TokenPricer { + getTokenPrice(token: Token): BigDecimal; + getAmountValueUSD(token: Token, amount: BigInt): BigDecimal; +} diff --git a/subgraphs/gogopool/src/sdk/protocols/generic/account.ts b/subgraphs/gogopool/src/sdk/protocols/generic/account.ts new file mode 100644 index 0000000000..b962ef2360 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/protocols/generic/account.ts @@ -0,0 +1,93 @@ +import { + ActiveAccount, + Account as AccountSchema, +} from "../../../../generated/schema"; +import { TokenManager } from "./tokens"; +import { ProtocolManager } from "./protocol"; +import { Address } from "@graphprotocol/graph-ts"; +import { CustomEventType, getUnixDays, getUnixHours } from "../../util/events"; + +/** + * This file contains the AccountClass, which does + * the operations on the Account entity. This includes: + * - Creating a new Account + * - Updating an existing Account + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +export class AccountManager { + protocol: ProtocolManager; + tokens: TokenManager; + + constructor(protocol: ProtocolManager, tokens: TokenManager) { + this.protocol = protocol; + this.tokens = tokens; + } + + loadAccount(address: Address): Account { + let acc = AccountSchema.load(address.toHexString()); + if (acc) { + return new Account(this.protocol, acc, this.tokens); + } + + acc = new AccountSchema(address.toHexString()); + acc.save(); + + this.protocol.addUser(); + + return new Account(this.protocol, acc, this.tokens); + } +} + +export class AccountWasActive { + hourly: boolean; + daily: boolean; +} + +export class Account { + account: AccountSchema; + event: CustomEventType; + protocol: ProtocolManager; + tokens: TokenManager; + + constructor( + protocol: ProtocolManager, + account: AccountSchema, + tokens: TokenManager + ) { + this.account = account; + this.protocol = protocol; + this.event = protocol.getCurrentEvent(); + this.tokens = tokens; + } + + trackActivity(): void { + const days = getUnixDays(this.event.block); + const hours = getUnixHours(this.event.block); + + const generalHourlyID = `${this.account.id}-hourly-${hours}`; + const generalDailyID = `${this.account.id}-daily-${days}`; + + const generalActivity: AccountWasActive = { + daily: this.isActiveByActivityID(generalDailyID), + hourly: this.isActiveByActivityID(generalHourlyID), + }; + + this.protocol.addActiveUser(generalActivity); + this.protocol.addTransaction(); + } + + private isActiveByActivityID(id: string): boolean { + const dAct = ActiveAccount.load(id); + if (!dAct) { + new ActiveAccount(id).save(); + return true; + } + return false; + } +} diff --git a/subgraphs/gogopool/src/sdk/protocols/generic/index.ts b/subgraphs/gogopool/src/sdk/protocols/generic/index.ts new file mode 100644 index 0000000000..59f201e67f --- /dev/null +++ b/subgraphs/gogopool/src/sdk/protocols/generic/index.ts @@ -0,0 +1,72 @@ +import { PoolManager } from "./pool"; +import { AccountManager } from "./account"; +import { ProtocolManager } from "./protocol"; +import { BIGINT_ZERO } from "../../util/constants"; +import { ethereum } from "@graphprotocol/graph-ts"; +import { CustomEventType } from "../../util/events"; +import { TokenManager, TokenInitializer } from "./tokens"; +import { ProtocolConfigurer, TokenPricer } from "../config"; + +/** + * This file contains the SDK class, which initializes + * all managers from event or call. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + + */ + +export class SDK { + Protocol: ProtocolManager; + Accounts: AccountManager; + Pools: PoolManager; + Tokens: TokenManager; + Pricer: TokenPricer; + + constructor( + config: ProtocolConfigurer, + pricer: TokenPricer, + tokenInitializer: TokenInitializer, + event: CustomEventType + ) { + this.Protocol = ProtocolManager.load(config, pricer, event); + this.Tokens = new TokenManager(this.Protocol, tokenInitializer); + this.Accounts = new AccountManager(this.Protocol, this.Tokens); + this.Pools = new PoolManager(this.Protocol, this.Tokens); + this.Pricer = pricer; + + this.Protocol.sdk = this; + } + + static initializeFromEvent( + config: ProtocolConfigurer, + pricer: TokenPricer, + tokenInitializer: TokenInitializer, + event: ethereum.Event + ): SDK { + const customEvent = CustomEventType.initialize( + event.block, + event.transaction, + event.logIndex, + event + ); + return new SDK(config, pricer, tokenInitializer, customEvent); + } + + static initializeFromCall( + config: ProtocolConfigurer, + pricer: TokenPricer, + tokenInitializer: TokenInitializer, + event: ethereum.Call + ): SDK { + const customEvent = CustomEventType.initialize( + event.block, + event.transaction, + BIGINT_ZERO + ); + return new SDK(config, pricer, tokenInitializer, customEvent); + } +} diff --git a/subgraphs/gogopool/src/sdk/protocols/generic/pool.ts b/subgraphs/gogopool/src/sdk/protocols/generic/pool.ts new file mode 100644 index 0000000000..0d8d48bdad --- /dev/null +++ b/subgraphs/gogopool/src/sdk/protocols/generic/pool.ts @@ -0,0 +1,317 @@ +import { TokenManager } from "./tokens"; +import { ProtocolManager } from "./protocol"; +import { PoolSnapshot } from "./poolSnapshot"; +import { BIGDECIMAL_ZERO, BIGINT_ZERO } from "../../util/constants"; +import { Pool as PoolSchema, Token } from "../../../../generated/schema"; +import { Bytes, BigDecimal, BigInt, Address } from "@graphprotocol/graph-ts"; + +/** + * This file contains the PoolManager, which is used to + * initialize new pools in the protocol. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +export class PoolManager { + protocol: ProtocolManager; + tokens: TokenManager; + + constructor(protocol: ProtocolManager, tokens: TokenManager) { + this.protocol = protocol; + this.tokens = tokens; + } + + loadPool(id: Bytes): Pool { + let entity = PoolSchema.load(id); + if (entity) { + return new Pool(this.protocol, entity, this.tokens, true); + } + + entity = new PoolSchema(id); + entity.protocol = this.protocol.getBytesID(); + + const pool = new Pool(this.protocol, entity, this.tokens, false); + pool.isInitialized = false; + return pool; + } +} + +export class Pool { + pool: PoolSchema; + protocol: ProtocolManager; + tokens: TokenManager; + snapshoter: PoolSnapshot | null = null; + + public isInitialized: boolean = true; + + constructor( + protocol: ProtocolManager, + pool: PoolSchema, + tokens: TokenManager, + isInitialized: bool + ) { + this.pool = pool; + this.protocol = protocol; + this.tokens = tokens; + + if (isInitialized) { + this.snapshoter = new PoolSnapshot(pool, protocol.event); + this.pool.lastUpdateTimestamp = protocol.event.block.timestamp; + this.save(); + } + } + + private save(): void { + this.pool.save(); + } + + initialize( + name: string, + symbol: string, + inputTokens: Bytes[], + outputToken: Token | null + ): void { + if (this.isInitialized) { + return; + } + + const event = this.protocol.getCurrentEvent(); + this.pool.protocol = this.protocol.getBytesID(); + this.pool.name = name; + this.pool.symbol = symbol; + this.pool.inputTokens = inputTokens; + this.pool.outputToken = outputToken ? outputToken.id : null; + this.pool.createdTimestamp = event.block.timestamp; + this.pool.createdBlockNumber = event.block.number; + + const inputTokenBalances: BigInt[] = []; + const inputTokenBalancesUSD: BigDecimal[] = []; + for (let i = 0; i < inputTokens.length; i++) { + inputTokenBalances.push(BIGINT_ZERO); + inputTokenBalancesUSD.push(BIGDECIMAL_ZERO); + } + this.pool.inputTokenBalances = inputTokenBalances; + this.pool.inputTokenBalancesUSD = inputTokenBalancesUSD; + this.pool.totalValueLockedUSD = BIGDECIMAL_ZERO; + this.pool.cumulativeSupplySideRevenueUSD = BIGDECIMAL_ZERO; + this.pool.cumulativeProtocolSideRevenueUSD = BIGDECIMAL_ZERO; + this.pool.cumulativeTotalRevenueUSD = BIGDECIMAL_ZERO; + + this.pool.lastSnapshotDayID = 0; + this.pool.lastUpdateTimestamp = BIGINT_ZERO; + this.save(); + + this.protocol.addPool(); + } + + /** + * Recalculates the total value locked for this pool based on its current input token balance. + * This function will also update the protocol's total value locked based on the change in this pool's. + */ + private refreshTotalValueLocked(): void { + let totalValueLockedUSD = BIGDECIMAL_ZERO; + + for (let idx = 0; idx < this.pool.inputTokens.length; idx++) { + const inputTokenBalanceUSD = this.pool.inputTokenBalancesUSD[idx]; + totalValueLockedUSD = totalValueLockedUSD.plus(inputTokenBalanceUSD); + } + + this.setTotalValueLocked(totalValueLockedUSD); + } + + /** + * Updates the total value locked for this pool to the given value. + * Will also update the protocol's total value locked based on the change in this pool's. + */ + setTotalValueLocked(newTVL: BigDecimal): void { + const delta = newTVL.minus(this.pool.totalValueLockedUSD); + this.addTotalValueLocked(delta); + this.save(); + } + + /** + * Adds the given delta to the total value locked for this pool. + * Will also update the protocol's total value locked based on the change in this pool's. + * + * @param delta The change in total value locked for this pool. + */ + addTotalValueLocked(delta: BigDecimal): void { + this.pool.totalValueLockedUSD = this.pool.totalValueLockedUSD.plus(delta); + this.protocol.addTotalValueLocked(delta); + this.save(); + } + + /** + * Utility function to update token price. + * + * @param token + * @returns + */ + setTokenPrice(token: Token): void { + if ( + !token.lastPriceBlockNumber || + (token.lastPriceBlockNumber && + token.lastPriceBlockNumber! < this.protocol.event.block.number) + ) { + const pricePerToken = this.protocol.getTokenPricer().getTokenPrice(token); + token.lastPriceUSD = pricePerToken; + token.lastPriceBlockNumber = this.protocol.event.block.number; + token.save(); + } + } + + /** + * Utility function to convert some amount of input token to USD. + * + * @param token + * @param amount the amount of inputToken to convert to USD + * @returns The converted amount. + */ + getInputTokenAmountPrice(token: Token, amount: BigInt): BigDecimal { + this.setTokenPrice(token); + + return this.protocol.getTokenPricer().getAmountValueUSD(token, amount); + } + + addInputTokenBalances( + amounts: BigInt[], + updateMetrics: boolean = true + ): void { + if (amounts.length != this.pool.inputTokenBalances.length) return; + + const newBalances: BigInt[] = []; + for (let idx = 0; idx < this.pool.inputTokenBalances.length; idx++) { + newBalances[idx] = this.pool.inputTokenBalances[idx].plus(amounts[idx]); + } + this.setInputTokenBalances(newBalances, updateMetrics); + } + + /** + * Sets the pool's input token balance to the given amount. It will optionally + * update the pool's and protocol's total value locked. If not stated, will default to true. + * + * @param amount amount to be set as the pool's input token balance. + * @param updateMetrics optional parameter to indicate whether to update the pool's and protocol's total value locked. + */ + setInputTokenBalances( + newBalances: BigInt[], + updateMetrics: boolean = true + ): void { + this.pool.inputTokenBalances = newBalances; + this.setInputTokenBalancesUSD(); + if (updateMetrics) { + this.refreshTotalValueLocked(); + } + } + + /** + * Sets the pool's input token balance USD by calculating it for each token. + */ + private setInputTokenBalancesUSD(): void { + const inputTokenBalancesUSD: BigDecimal[] = []; + for (let idx = 0; idx < this.pool.inputTokens.length; idx++) { + const inputTokenBalance = this.pool.inputTokenBalances[idx]; + const inputToken = this.tokens.getOrCreateToken( + Address.fromBytes(this.pool.inputTokens[idx]) + ); + + const amountUSD = this.getInputTokenAmountPrice( + inputToken, + inputTokenBalance + ); + inputTokenBalancesUSD.push(amountUSD); + } + this.pool.inputTokenBalancesUSD = inputTokenBalancesUSD; + } + + getBytesID(): Bytes { + return this.pool.id; + } + + /** + * Adds a given USD value to the pool and protocol supplySideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param rev {BigDecimal} The value to add to the protocol's supplySideRevenue. + */ + addSupplySideRevenueUSD(rev: BigDecimal): void { + this.pool.cumulativeTotalRevenueUSD = + this.pool.cumulativeTotalRevenueUSD.plus(rev); + this.pool.cumulativeSupplySideRevenueUSD = + this.pool.cumulativeSupplySideRevenueUSD.plus(rev); + this.save(); + + this.protocol.addSupplySideRevenueUSD(rev); + } + + /** + * Adds a given USD value to the pool and protocol protocolSideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param rev {BigDecimal} The value to add to the protocol's protocolSideRevenue. + */ + addProtocolSideRevenueUSD(rev: BigDecimal): void { + this.pool.cumulativeTotalRevenueUSD = + this.pool.cumulativeTotalRevenueUSD.plus(rev); + this.pool.cumulativeProtocolSideRevenueUSD = + this.pool.cumulativeProtocolSideRevenueUSD.plus(rev); + this.save(); + + this.protocol.addProtocolSideRevenueUSD(rev); + } + + /** + * Adds a given USD value to the pool and protocol's supplySideRevenue and protocolSideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param protocolSide {BigDecimal} The value to add to the protocol's protocolSideRevenue. + * @param supplySide {BigDecimal} The value to add to the protocol's supplySideRevenue. + */ + addRevenueUSD(protocolSide: BigDecimal, supplySide: BigDecimal): void { + this.addSupplySideRevenueUSD(supplySide); + this.addProtocolSideRevenueUSD(protocolSide); + } + + /** + * Convenience method to add revenue denominated in the pool's input token. It converts it to USD + * under the hood and calls addRevenueUSD. + */ + addRevenueNative( + inputToken: Token, + supplySide: BigInt, + protocolSide: BigInt + ): void { + const pricer = this.protocol.pricer; + + const pAmountUSD = pricer.getAmountValueUSD(inputToken, protocolSide); + const sAmountUSD = pricer.getAmountValueUSD(inputToken, supplySide); + this.addRevenueUSD(pAmountUSD, sAmountUSD); + } + + /** + * Adds a given amount to the pool's outputTokenSupply. It should only be used for pools + * of type LIQUIDITY. Or pools that emit some kind of LP token on deposit. + * @param amount + */ + addOutputTokenSupply(amount: BigInt): void { + if (!this.pool.outputTokenSupply) { + this.pool.outputTokenSupply = BIGINT_ZERO; + } + this.pool.outputTokenSupply = this.pool.outputTokenSupply!.plus(amount); + this.save(); + } + + /** + * Sets the pool's outputTokenSupply value. It should only be used for pools + * of type LIQUIDITY. Or pools that emit some kind of LP token on deposit. + * @param amount + */ + setOutputTokenSupply(amount: BigInt): void { + this.pool.outputTokenSupply = amount; + this.save(); + } +} diff --git a/subgraphs/gogopool/src/sdk/protocols/generic/poolSnapshot.ts b/subgraphs/gogopool/src/sdk/protocols/generic/poolSnapshot.ts new file mode 100644 index 0000000000..c7945dbb64 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/protocols/generic/poolSnapshot.ts @@ -0,0 +1,93 @@ +import { + Pool as PoolSchema, + PoolDailySnapshot, +} from "../../../../generated/schema"; +import { SECONDS_PER_DAY } from "../../util/constants"; +import { CustomEventType, getUnixDays, getUnixHours } from "../../util/events"; + +/** + * This file contains the PoolSnapshot, which is used to + * make all of the storage changes that occur in the pool daily and hourly snapshots. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +export class PoolSnapshot { + pool: PoolSchema; + event: CustomEventType; + dayID: i32; + hourID: i32; + + constructor(pool: PoolSchema, event: CustomEventType) { + this.pool = pool; + this.event = event; + this.dayID = getUnixDays(event.block); + this.hourID = getUnixHours(event.block); + this.takeSnapshots(); + } + + private takeSnapshots(): void { + if (!this.pool.lastUpdateTimestamp) return; + + const snapshotDayID = + this.pool.lastUpdateTimestamp.toI32() / SECONDS_PER_DAY; + + if (snapshotDayID != this.dayID) { + this.takeDailySnapshot(snapshotDayID); + this.pool.lastSnapshotDayID = snapshotDayID; + this.pool.save(); + } + } + + private takeDailySnapshot(day: i32): void { + const snapshot = new PoolDailySnapshot(this.pool.id.concatI32(day)); + const previousSnapshot = PoolDailySnapshot.load( + this.pool.id.concatI32(this.pool.lastSnapshotDayID) + ); + + snapshot.day = day; + snapshot.protocol = this.pool.protocol; + snapshot.pool = this.pool.id; + snapshot.timestamp = this.event.block.timestamp; + snapshot.blockNumber = this.event.block.number; + + // tvl and balances + snapshot.totalValueLockedUSD = this.pool.totalValueLockedUSD; + snapshot.inputTokenBalances = this.pool.inputTokenBalances; + snapshot.inputTokenBalancesUSD = this.pool.inputTokenBalancesUSD; + + // revenues + snapshot.cumulativeSupplySideRevenueUSD = + this.pool.cumulativeSupplySideRevenueUSD; + snapshot.cumulativeProtocolSideRevenueUSD = + this.pool.cumulativeProtocolSideRevenueUSD; + snapshot.cumulativeTotalRevenueUSD = this.pool.cumulativeTotalRevenueUSD; + + // deltas + let supplySideRevenueDelta = snapshot.cumulativeSupplySideRevenueUSD; + let protocolSideRevenueDelta = snapshot.cumulativeProtocolSideRevenueUSD; + let totalRevenueDelta = snapshot.cumulativeTotalRevenueUSD; + + if (previousSnapshot) { + supplySideRevenueDelta = snapshot.cumulativeSupplySideRevenueUSD.minus( + previousSnapshot.cumulativeSupplySideRevenueUSD + ); + protocolSideRevenueDelta = + snapshot.cumulativeProtocolSideRevenueUSD.minus( + previousSnapshot.cumulativeProtocolSideRevenueUSD + ); + totalRevenueDelta = snapshot.cumulativeTotalRevenueUSD.minus( + previousSnapshot.cumulativeTotalRevenueUSD + ); + } + snapshot.dailySupplySideRevenueUSD = supplySideRevenueDelta; + snapshot.dailyProtocolSideRevenueUSD = protocolSideRevenueDelta; + snapshot.dailyTotalRevenueUSD = totalRevenueDelta; + + snapshot.save(); + } +} diff --git a/subgraphs/gogopool/src/sdk/protocols/generic/protocol.ts b/subgraphs/gogopool/src/sdk/protocols/generic/protocol.ts new file mode 100644 index 0000000000..c09aac2905 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/protocols/generic/protocol.ts @@ -0,0 +1,257 @@ +import { SDK } from "."; +import { + dataSource, + Address, + Bytes, + BigDecimal, +} from "@graphprotocol/graph-ts"; +import { AccountWasActive } from "./account"; +import * as constants from "../../util/constants"; +import { BIGINT_ZERO } from "../../util/constants"; +import { CustomEventType } from "../../util/events"; +import { ProtocolSnapshot } from "./protocolSnapshot"; +import { ProtocolConfigurer, TokenPricer } from "../config"; +import { Protocol as ProtocolSchema } from "../../../../generated/schema"; +import { Versions } from "../../../../../../deployment/context/interface"; + +/** + * This file contains the ProtocolManager class, which is used to + * make all of the storage changes that occur in a protocol. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +/** + * ProtocolManager is a wrapper around the ProtocolSchema entity that takes care of + * safely and conveniently updating the entity. Updating the Protocol entity using this + * wrapper also takes care of the Financials and Usage snapshots. + */ +export class ProtocolManager { + protocol: ProtocolSchema; + event: CustomEventType; + pricer: TokenPricer; + snapshoter: ProtocolSnapshot; + sdk: SDK | null = null; + /** + * Creates a new Protocol instance. This should only be called by the Protocol.load + * @private + */ + private constructor( + protocol: ProtocolSchema, + pricer: TokenPricer, + event: CustomEventType + ) { + this.protocol = protocol; + this.event = event; + this.pricer = pricer; + this.snapshoter = new ProtocolSnapshot(protocol, event); + this.protocol.lastUpdateTimestamp = event.block.timestamp; + } + + /** + * This is the main function to instantiate a Protocol entity. Most times it is not called directly, but from the SDK initializer. + * + * @param conf {ProtocolConfigurer} An object that implements the ProtocolConfigurer interface, to set some of the protocol's properties + * @param pricer {TokenPricer} An object that implements the TokenPricer interface, to allow the wrapper to access pricing data + * @param event {CustomEventType} The event being handled at a time. + * @returns Protocol + */ + static load( + conf: ProtocolConfigurer, + pricer: TokenPricer, + event: CustomEventType + ): ProtocolManager { + const id = Address.fromString(conf.getID()); + let protocol = ProtocolSchema.load(id); + if (protocol) { + const proto = new ProtocolManager(protocol, pricer, event); + proto.setVersions(conf.getVersions()); + return proto; + } + + protocol = new ProtocolSchema(id); + protocol.name = conf.getName(); + protocol.slug = conf.getSlug(); + protocol.network = dataSource.network().toUpperCase().replace("-", "_"); + protocol.type = constants.ProtocolType.GENERIC; + protocol.totalValueLockedUSD = constants.BIGDECIMAL_ZERO; + protocol.cumulativeSupplySideRevenueUSD = constants.BIGDECIMAL_ZERO; + protocol.cumulativeProtocolSideRevenueUSD = constants.BIGDECIMAL_ZERO; + protocol.cumulativeTotalRevenueUSD = constants.BIGDECIMAL_ZERO; + + protocol.cumulativeTransactionCount = 0; + protocol.cumulativeUniqueUsers = 0; + protocol.totalPoolCount = 0; + + protocol.lastSnapshotDayID = 0; + protocol.lastUpdateTimestamp = BIGINT_ZERO; + + protocol.schemaVersion = conf.getVersions().getSchemaVersion(); + protocol.subgraphVersion = conf.getVersions().getSubgraphVersion(); + protocol.methodologyVersion = conf.getVersions().getMethodologyVersion(); + + const proto = new ProtocolManager(protocol, pricer, event); + proto.save(); + return proto; + } + + /** + * Updates the protocol entity versions. This is called on load to make sure we update the version + * if we've grafted the subgraph. + * + * @param versions {Versions} An object that implements the Versions interface, to get the protocol's versions + */ + private setVersions(versions: Versions): void { + this.protocol.schemaVersion = versions.getSchemaVersion(); + this.protocol.subgraphVersion = versions.getSubgraphVersion(); + this.protocol.methodologyVersion = versions.getMethodologyVersion(); + this.save(); + } + + /** + * This will save the entity to storage. If any other action needs to be performed on + * save, it should be added here. + * It is meant to be used internally. If you need to save the entity from outside the wrapper + * you should probably be using some of the setters instead. + * @private + */ + private save(): void { + this.protocol.save(); + } + + /** + * + * @returns {string} The ID of the protocol entity. + */ + getID(): string { + return this.protocol.id.toHexString(); + } + + /** + * + * @returns {Bytes} The ID of the protocol entity, as Bytes. + */ + getBytesID(): Bytes { + return this.protocol.id; + } + + /** + * + * @returns {CustomEventType} the event currently being handled. + */ + getCurrentEvent(): CustomEventType { + return this.event; + } + + /** + * + * @returns {TokenPricer} The pricer object used by the wrapper. + * @see TokenPricer + */ + getTokenPricer(): TokenPricer { + return this.pricer; + } + + /** + * Sets the TVL in USD for the protocol. Most times this will be called internally by + * other members of the library when TVL changes are made to them. But if the library + * is not well fitted to a given protocol and you need to set the TVL manually, you can + * use this method. + * It will also update the protocol's snapshots. + * @param tvl {BigDecimal} The new total value locked for the protocol. + */ + setTotalValueLocked(tvl: BigDecimal): void { + this.protocol.totalValueLockedUSD = tvl; + this.save(); + } + + /** + * Adds a given USD value to the protocol's TVL. It can be a positive or negative amount. + * Same as for setTotalValueLocked, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param tvl {BigDecimal} The value to add to the protocol's TVL. + */ + addTotalValueLocked(tvl: BigDecimal): void { + this.protocol.totalValueLockedUSD = + this.protocol.totalValueLockedUSD.plus(tvl); + this.save(); + } + + /** + * Adds a given USD value to the protocol supplySideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param rev {BigDecimal} The value to add to the protocol's supplySideRevenue. + */ + addSupplySideRevenueUSD(rev: BigDecimal): void { + this.protocol.cumulativeTotalRevenueUSD = + this.protocol.cumulativeTotalRevenueUSD.plus(rev); + this.protocol.cumulativeSupplySideRevenueUSD = + this.protocol.cumulativeSupplySideRevenueUSD.plus(rev); + this.save(); + } + + /** + * Adds a given USD value to the protocol protocolSideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param rev {BigDecimal} The value to add to the protocol's protocolSideRevenue. + */ + addProtocolSideRevenueUSD(rev: BigDecimal): void { + this.protocol.cumulativeTotalRevenueUSD = + this.protocol.cumulativeTotalRevenueUSD.plus(rev); + this.protocol.cumulativeProtocolSideRevenueUSD = + this.protocol.cumulativeProtocolSideRevenueUSD.plus(rev); + this.save(); + } + + /** + * Adds a given USD value to the protocol's supplySideRevenue and protocolSideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param protocolSide {BigDecimal} The value to add to the protocol's protocolSideRevenue. + * @param supplySide {BigDecimal} The value to add to the protocol's supplySideRevenue. + */ + addRevenueUSD(protocolSide: BigDecimal, supplySide: BigDecimal): void { + this.addSupplySideRevenueUSD(supplySide); + this.addProtocolSideRevenueUSD(protocolSide); + } + + /** + * Adds some value to the cumulativeUniqueUsers counter. If the value is omitted it will default to 1. + * If you are loading accounts with the AccountManager you won't need to use this method. + * @param count {u8} The value to add to the counter. + */ + addUser(count: u8 = 1): void { + this.protocol.cumulativeUniqueUsers += count; + this.save(); + } + + /** + * Will increase the hourly and daily active users counters. These will be reflected + * on the next Usage snapshot whenever it comes up. + */ + addActiveUser(activity: AccountWasActive): void { + this.snapshoter.addActiveUser(activity); + } + + /** + * Increases the totalPoolCount counter by the given value. + * If you are using the PoolManager class you won't need to use this method. + * @param count {u8} The value to add to the counter. + * @see PoolManager + */ + addPool(count: u8 = 1): void { + this.protocol.totalPoolCount += count; + this.save(); + } + + addTransaction(): void { + this.protocol.cumulativeTransactionCount += 1; + this.save(); + } +} diff --git a/subgraphs/gogopool/src/sdk/protocols/generic/protocolSnapshot.ts b/subgraphs/gogopool/src/sdk/protocols/generic/protocolSnapshot.ts new file mode 100644 index 0000000000..85d80bbc36 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/protocols/generic/protocolSnapshot.ts @@ -0,0 +1,165 @@ +import { + _ActivityHelper, + FinancialsDailySnapshot, + UsageMetricsDailySnapshot, + Protocol as ProtocolSchema, +} from "../../../../generated/schema"; +import { AccountWasActive } from "./account"; +import { Bytes } from "@graphprotocol/graph-ts"; +import { SECONDS_PER_DAY } from "../../util/constants"; +import { CustomEventType, getUnixDays, getUnixHours } from "../../util/events"; + +const ActivityHelperID = Bytes.fromUTF8("_ActivityHelper"); + +/** + * This file contains the ProtocolSnapshot, which is used to + * make all of the storage changes that occur in the protocol's + * daily and hourly snapshots. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +/** + * Helper class to manage Financials and Usage snapshots. + * It is not meant to be used directly, but rather by the Protocol and Account lib classes. + * Whenever it is instantiated it will check if it is time to take any of the + * dailyFinancials, dailyUsage or hourlyUsage snapshots. + * + * Snapshots are taken in a way that allows the snapshot entity to be immutable. + */ +export class ProtocolSnapshot { + protocol: ProtocolSchema; + event: CustomEventType; + dayID: i32; + hourID: i32; + activityHelper: _ActivityHelper; + + constructor(protocol: ProtocolSchema, event: CustomEventType) { + this.protocol = protocol; + this.event = event; + this.dayID = getUnixDays(event.block); + this.hourID = getUnixHours(event.block); + this.activityHelper = initActivityHelper(); + this.takeSnapshots(); + } + + addActiveUser(activity: AccountWasActive): void { + this.activityHelper.dailyActiveUsers += activity.daily ? 1 : 0; + this.activityHelper.save(); + } + + private takeSnapshots(): void { + const snapshotDayID = + this.protocol.lastUpdateTimestamp.toI32() / SECONDS_PER_DAY; + + if (snapshotDayID != this.dayID) { + this.takeFinancialsDailySnapshot(snapshotDayID); + this.takeUsageDailySnapshot(snapshotDayID); + this.protocol.lastSnapshotDayID = snapshotDayID; + this.protocol.save(); + } + } + + private takeFinancialsDailySnapshot(day: i32): void { + const snapshot = new FinancialsDailySnapshot(Bytes.fromI32(day)); + const previousSnapshot = FinancialsDailySnapshot.load( + Bytes.fromI32(this.protocol.lastSnapshotDayID) + ); + + snapshot.day = day; + snapshot.protocol = this.protocol.id; + snapshot.blockNumber = this.event.block.number; + snapshot.timestamp = this.event.block.timestamp; + + // tvl + snapshot.totalValueLockedUSD = this.protocol.totalValueLockedUSD; + + // revenues + snapshot.cumulativeSupplySideRevenueUSD = + this.protocol.cumulativeSupplySideRevenueUSD; + snapshot.cumulativeProtocolSideRevenueUSD = + this.protocol.cumulativeProtocolSideRevenueUSD; + snapshot.cumulativeTotalRevenueUSD = + this.protocol.cumulativeTotalRevenueUSD; + + // deltas + let supplySideRevenueDelta = snapshot.cumulativeSupplySideRevenueUSD; + let protocolSideRevenueDelta = snapshot.cumulativeProtocolSideRevenueUSD; + let totalRevenueDelta = snapshot.cumulativeTotalRevenueUSD; + + if (previousSnapshot) { + supplySideRevenueDelta = snapshot.cumulativeSupplySideRevenueUSD.minus( + previousSnapshot.cumulativeSupplySideRevenueUSD + ); + protocolSideRevenueDelta = + snapshot.cumulativeProtocolSideRevenueUSD.minus( + previousSnapshot.cumulativeProtocolSideRevenueUSD + ); + totalRevenueDelta = snapshot.cumulativeTotalRevenueUSD.minus( + previousSnapshot.cumulativeTotalRevenueUSD + ); + } + snapshot.dailySupplySideRevenueUSD = supplySideRevenueDelta; + snapshot.dailyProtocolSideRevenueUSD = protocolSideRevenueDelta; + snapshot.dailyTotalRevenueUSD = totalRevenueDelta; + + snapshot.save(); + } + + private takeUsageDailySnapshot(day: i32): void { + const activity = this.activityHelper; + + const snapshot = new UsageMetricsDailySnapshot(Bytes.fromI32(day)); + const previousSnapshot = UsageMetricsDailySnapshot.load( + Bytes.fromI32(this.protocol.lastSnapshotDayID) + ); + + snapshot.protocol = this.protocol.id; + snapshot.day = day; + snapshot.blockNumber = this.event.block.number; + snapshot.timestamp = this.event.block.timestamp; + + // unique users + snapshot.cumulativeUniqueUsers = this.protocol.cumulativeUniqueUsers; + + // daily activity + snapshot.dailyActiveUsers = activity.dailyActiveUsers; + + // transaction counts + snapshot.cumulativeTransactionCount = + this.protocol.cumulativeTransactionCount; + + // misc + snapshot.totalPoolCount = this.protocol.totalPoolCount; + + // deltas + let transactionDelta = snapshot.cumulativeTransactionCount; + + if (previousSnapshot) { + transactionDelta = + snapshot.cumulativeTransactionCount - + previousSnapshot.cumulativeTransactionCount; + } + snapshot.dailyTransactionCount = transactionDelta; + snapshot.save(); + + activity.dailyActiveUsers = 0; + activity.save(); + } +} + +function initActivityHelper(): _ActivityHelper { + let helper = _ActivityHelper.load(ActivityHelperID); + if (helper) { + return helper; + } + helper = new _ActivityHelper(ActivityHelperID); + helper.dailyActiveUsers = 0; + + helper.save(); + return helper; +} diff --git a/subgraphs/gogopool/src/sdk/protocols/generic/tokens.ts b/subgraphs/gogopool/src/sdk/protocols/generic/tokens.ts new file mode 100644 index 0000000000..7095cf896c --- /dev/null +++ b/subgraphs/gogopool/src/sdk/protocols/generic/tokens.ts @@ -0,0 +1,58 @@ +import { ProtocolManager } from "./protocol"; +import { Address } from "@graphprotocol/graph-ts"; +import { Token } from "../../../../generated/schema"; +import { BIGDECIMAL_ZERO } from "../../util/constants"; + +/** + * This file contains the TokenManagerClass, which initializes + * token entities. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +export interface TokenInitializer { + getTokenParams(address: Address): TokenParams; +} + +export class TokenParams { + name: string; + symbol: string; + decimals: i32; + + constructor(name: string, symbol: string, decimals: i32) { + this.name = name; + this.symbol = symbol; + this.decimals = decimals; + } +} + +export class TokenManager { + protocol: ProtocolManager; + initializer: TokenInitializer; + + constructor(protocol: ProtocolManager, init: TokenInitializer) { + this.protocol = protocol; + this.initializer = init; + } + + getOrCreateToken(address: Address): Token { + let token = Token.load(address); + if (token) { + return token; + } + + const params = this.initializer.getTokenParams(address); + token = new Token(address); + token.name = params.name; + token.symbol = params.symbol; + token.decimals = params.decimals; + token.lastPriceUSD = BIGDECIMAL_ZERO; + token.save(); + + return token; + } +} diff --git a/subgraphs/gogopool/src/sdk/util/arrays.ts b/subgraphs/gogopool/src/sdk/util/arrays.ts new file mode 100644 index 0000000000..d610008f16 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/util/arrays.ts @@ -0,0 +1,103 @@ +import { Bytes } from "@graphprotocol/graph-ts"; + +// A function which given 3 arrays of arbitrary types of the same length, +// where the first one holds the reference order, the second one holds the same elements +// as the first but in different order, and the third any arbitrary elements. It will return +// the third array after sorting it according to the order of the first one. +// For example: +// sortArrayByReference(['a', 'c', 'b'], ['a', 'b', 'c'], [1, 2, 3]) => [1, 3, 2] +export function sortArrayByReference( + reference: T[], + array: T[], + toSort: K[] +): K[] { + const sorted: K[] = new Array(); + for (let i = 0; i < reference.length; i++) { + const index = array.indexOf(reference[i]); + sorted.push(toSort[index]); + } + return sorted; +} + +// sortBytesArray will sort an array of Bytes in ascending order +// by comparing their hex string representation. +export function sortBytesArray(array: Bytes[]): Bytes[] { + const toSort = array.map((item) => item.toHexString()); + toSort.sort(); + return toSort.map((item) => Bytes.fromHexString(item)); +} + +export function updateArrayAtIndex(x: T[], item: T, index: i32): T[] { + if (x.length == 0) { + return [item]; + } + if (index == -1 || index > x.length) { + index = x.length; + } + const retval = new Array(); + let i = 0; + while (i < index) { + retval.push(x[i]); + i += 1; + } + retval.push(item); + i += 1; + while (i < x.length) { + retval.push(x[i]); + i += 1; + } + return retval; +} + +export function addToArrayAtIndex(x: T[], item: T, index: i32 = -1): T[] { + if (x.length == 0) { + return [item]; + } + if (index == -1 || index > x.length) { + index = x.length; + } + const retval = new Array(); + let i = 0; + while (i < index) { + retval.push(x[i]); + i += 1; + } + retval.push(item); + while (i < x.length) { + retval.push(x[i]); + i += 1; + } + return retval; +} + +export function addArrays(a: T[], b: T[]): T[] { + const retval = new Array(); + const arraysByLength = a.length <= b.length ? [a, b] : [b, a]; + + let i = 0; + while (i < arraysByLength[0].length) { + retval.push(a[i].plus(b[i])); + i += 1; + } + while (i < arraysByLength[1].length) { + retval.push(arraysByLength[1][i]); + i += 1; + } + return retval; +} + +export function subtractArrays(a: T[], b: T[]): T[] { + const retval = new Array(); + const arraysByLength = a.length <= b.length ? [a, b] : [b, a]; + + let i = 0; + while (i < arraysByLength[0].length) { + retval.push(a[i].minus(b[i])); + i += 1; + } + while (i < arraysByLength[1].length) { + retval.push(arraysByLength[1][i]); + i += 1; + } + return retval; +} diff --git a/subgraphs/gogopool/src/sdk/util/constants.ts b/subgraphs/gogopool/src/sdk/util/constants.ts new file mode 100644 index 0000000000..e1cb0a7149 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/util/constants.ts @@ -0,0 +1,229 @@ +import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; + +//////////////////////// +///// Schema Enums ///// +//////////////////////// + +// The network names corresponding to the Network enum in the schema. +// They also correspond to the ones in `dataSource.network()` after converting to lower case. +// See below for a complete list: +// https://thegraph.com/docs/en/hosted-service/what-is-hosted-service/#supported-networks-on-the-hosted-service +export namespace Network { + export const ARBITRUM_ONE = "ARBITRUM_ONE"; + export const AVALANCHE = "AVALANCHE"; + export const AURORA = "AURORA"; + export const BASE = "BASE"; + export const BSC = "BSC"; // aka BNB Chain + export const CELO = "CELO"; + export const MAINNET = "MAINNET"; // Ethereum mainnet + export const FANTOM = "FANTOM"; + export const FUSE = "FUSE"; + export const MOONBEAM = "MOONBEAM"; + export const MOONRIVER = "MOONRIVER"; + export const NEAR_MAINNET = "NEAR_MAINNET"; + export const OPTIMISM = "OPTIMISM"; + export const MATIC = "MATIC"; // aka Polygon + export const XDAI = "XDAI"; // aka Gnosis Chain + + // other networks + export const UBIQ = "UBIQ"; + export const SONGBIRD = "SONGBIRD"; + export const ELASTOS = "ELASTOS"; + export const KARDIACHAIN = "KARDIACHAIN"; + export const CRONOS = "CRONOS"; + export const RSK = "RSK"; + export const TELOS = "TELOS"; + export const XDC = "XDC"; + export const ZYX = "ZYX"; + export const CSC = "CSC"; + export const SYSCOIN = "SYSCOIN"; + export const GOCHAIN = "GOCHAIN"; + export const ETHEREUMCLASSIC = "ETHEREUMCLASSIC"; + export const OKEXCHAIN = "OKEXCHAIN"; + export const HOO = "HOO"; + export const METER = "METER"; + export const NOVA_NETWORK = "NOVA_NETWORK"; + export const TOMOCHAIN = "TOMOCHAIN"; + export const VELAS = "VELAS"; + export const THUNDERCORE = "THUNDERCORE"; + export const HECO = "HECO"; + export const XDAIARB = "XDAIARB"; + export const ENERGYWEB = "ENERGYWEB"; + export const HPB = "HPB"; + export const BOBA = "BOBA"; + export const KUCOIN = "KUCOIN"; + export const SHIDEN = "SHIDEN"; + export const THETA = "THETA"; + export const SX = "SX"; + export const CANDLE = "CANDLE"; + export const ASTAR = "ASTAR"; + export const CALLISTO = "CALLISTO"; + export const WANCHAIN = "WANCHAIN"; + export const METIS = "METIS"; + export const ULTRON = "ULTRON"; + export const STEP = "STEP"; + export const DOGECHAIN = "DOGECHAIN"; + export const RONIN = "RONIN"; + export const KAVA = "KAVA"; + export const IOTEX = "IOTEX"; + export const XLC = "XLC"; + export const NAHMII = "NAHMII"; + export const TOMBCHAIN = "TOMBCHAIN"; + export const CANTO = "CANTO"; + export const KLAYTN = "KLAYTN"; + export const EVMOS = "EVMOS"; + export const SMARTBCH = "SMARTBCH"; + export const BITGERT = "BITGERT"; + export const FUSION = "FUSION"; + export const OHO = "OHO"; + export const ARB_NOVA = "ARB_NOVA"; + export const OASIS = "OASIS"; + export const REI = "REI"; + export const REICHAIN = "REICHAIN"; + export const GODWOKEN = "GODWOKEN"; + export const POLIS = "POLIS"; + export const KEKCHAIN = "KEKCHAIN"; + export const VISION = "VISION"; + export const HARMONY = "HARMONY"; + export const PALM = "PALM"; + export const CURIO = "CURIO"; + + export const UNKNOWN_NETWORK = "UNKNOWN_NETWORK"; +} +export type Network = string; + +export namespace ProtocolType { + export const EXCHANGE = "EXCHANGE"; + export const LENDING = "LENDING"; + export const YIELD = "YIELD"; + export const BRIDGE = "BRIDGE"; + export const OPTION = "OPTION"; + export const PERPETUAL = "PERPETUAL"; + export const GENERIC = "GENERIC"; +} + +export namespace VaultFeeType { + export const MANAGEMENT_FEE = "MANAGEMENT_FEE"; + export const PERFORMANCE_FEE = "PERFORMANCE_FEE"; + export const DEPOSIT_FEE = "DEPOSIT_FEE"; + export const WITHDRAWAL_FEE = "WITHDRAWAL_FEE"; +} + +export namespace LiquidityPoolFeeType { + export const FIXED_TRADING_FEE = "FIXED_TRADING_FEE"; + export const TIERED_TRADING_FEE = "TIERED_TRADING_FEE"; + export const DYNAMIC_TRADING_FEE = "DYNAMIC_TRADING_FEE"; + export const FIXED_LP_FEE = "FIXED_LP_FEE"; + export const DYNAMIC_LP_FEE = "DYNAMIC_LP_FEE"; + export const FIXED_PROTOCOL_FEE = "FIXED_PROTOCOL_FEE"; + export const DYNAMIC_PROTOCOL_FEE = "DYNAMIC_PROTOCOL_FEE"; +} +export type LiquidityPoolFeeType = string; + +export namespace RewardTokenType { + export const DEPOSIT = "DEPOSIT"; + export const BORROW = "BORROW"; + export const STAKE = "STAKE"; +} +export type RewardTokenType = string; + +export namespace ActivityInterval { + export const HOURLY = "HOURLY"; + export const DAILY = "DAILY"; +} + +export namespace LendingType { + export const CDP = "CDP"; + export const POOLED = "POOLED"; +} + +export namespace RiskType { + export const GLOBAL = "GLOBAL"; + export const ISOLATED = "ISOLATED"; +} + +export namespace InterestRateType { + export const STABLE = "STABLE"; + export const VARIABLE = "VARIABLE"; + export const FIXED_TERM = "FIXED_TERM"; +} + +export namespace InterestRateSide { + export const LENDER = "LENDER"; + export const BORROWER = "BORROWER"; +} + +export namespace UsageType { + export const DEPOSIT = "DEPOSIT"; + export const WITHDRAW = "WITHDRAW"; + export const SWAP = "SWAP"; +} + +export namespace PositionSide { + export const LONG = "LONG"; + export const SHORT = "SHORT"; +} +export type PositionSide = string; + +////////////////////////////// +///// Ethereum Addresses ///// +////////////////////////////// + +export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; +export const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; + +//////////////////////// +///// Type Helpers ///// +//////////////////////// + +export const DEFAULT_DECIMALS = 18; + +export const USDC_DECIMALS = 6; +export const USDC_DENOMINATOR = BigDecimal.fromString("1000000"); + +export const BIGINT_ZERO = BigInt.fromI32(0); +export const BIGINT_ONE = BigInt.fromI32(1); +export const BIGINT_TWO = BigInt.fromI32(2); +export const BIGINT_TEN = BigInt.fromI32(10); +export const BIGINT_HUNDRED = BigInt.fromI32(100); +export const BIGINT_THOUSAND = BigInt.fromI32(1000); +export const BIGINT_TEN_TO_EIGHTEENTH = BigInt.fromString("10").pow(18); +export const BIGINT_MINUS_ONE = BigInt.fromI32(-1); +export const BIGINT_MAX = BigInt.fromString( + "115792089237316195423570985008687907853269984665640564039457584007913129639935" +); + +export const INT_NEGATIVE_ONE = -1 as i32; +export const INT_ZERO = 0 as i32; +export const INT_ONE = 1 as i32; +export const INT_TWO = 2 as i32; +export const INT_FOUR = 4 as i32; + +export const BIGDECIMAL_ZERO = new BigDecimal(BIGINT_ZERO); +export const BIGDECIMAL_ONE = new BigDecimal(BIGINT_ONE); +export const BIGDECIMAL_TWO = new BigDecimal(BIGINT_TWO); +export const BIGDECIMAL_HUNDRED = new BigDecimal(BIGINT_HUNDRED); +export const BIGDECIMAL_MINUS_ONE = new BigDecimal(BIGINT_MINUS_ONE); + +export const MAX_UINT = BigInt.fromI32(2).times(BigInt.fromI32(255)); + +///////////////////// +///// Date/Time ///// +///////////////////// + +export const SECONDS_PER_DAY = 60 * 60 * 24; // 86400 +export const SECONDS_PER_HOUR = 60 * 60; // 3600 +export const SECONDS_PER_DAY_BI = BigInt.fromI32(SECONDS_PER_DAY); +export const SECONDS_PER_HOUR_BI = BigInt.fromI32(SECONDS_PER_HOUR); +export const MS_PER_DAY = new BigDecimal(BigInt.fromI32(24 * 60 * 60 * 1000)); +export const DAYS_PER_YEAR = new BigDecimal(BigInt.fromI32(365)); +export const MS_PER_YEAR = DAYS_PER_YEAR.times( + new BigDecimal(BigInt.fromI32(24 * 60 * 60 * 1000)) +); + +//////////////// +///// Misc ///// +//////////////// + +export const ETH_SYMBOL = "ETH"; +export const ETH_NAME = "Ether"; diff --git a/subgraphs/gogopool/src/sdk/util/events.ts b/subgraphs/gogopool/src/sdk/util/events.ts new file mode 100644 index 0000000000..5c6ee1e4d1 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/util/events.ts @@ -0,0 +1,70 @@ +import { BigInt, Address, Bytes, ethereum } from "@graphprotocol/graph-ts"; +import { + BIGINT_ZERO, + SECONDS_PER_DAY, + SECONDS_PER_HOUR, + ZERO_ADDRESS, +} from "./constants"; + +export class CustomEventType { + block: ethereum.Block; + transaction: ethereum.Transaction; + logIndex: BigInt; + event: ethereum.Event | null; + + constructor() { + this.block = new ethereum.Block( + Bytes.empty(), + Bytes.empty(), + Bytes.empty(), + Address.fromString(ZERO_ADDRESS), + Bytes.empty(), + Bytes.empty(), + Bytes.empty(), + BIGINT_ZERO, + BIGINT_ZERO, + BIGINT_ZERO, + BIGINT_ZERO, + BIGINT_ZERO, + BIGINT_ZERO, + null, + null + ); + this.transaction = new ethereum.Transaction( + Bytes.empty(), + BIGINT_ZERO, + Address.fromString(ZERO_ADDRESS), + null, + BIGINT_ZERO, + BIGINT_ZERO, + BIGINT_ZERO, + Bytes.empty(), + BIGINT_ZERO + ); + this.logIndex = BIGINT_ZERO; + this.event = null; + } + + static initialize( + block: ethereum.Block, + transaction: ethereum.Transaction, + logIndex: BigInt, + event: ethereum.Event | null = null + ): CustomEventType { + const customEvent = new CustomEventType(); + customEvent.block = block; + customEvent.transaction = transaction; + customEvent.logIndex = logIndex; + customEvent.event = event; + + return customEvent; + } +} + +export function getUnixDays(block: ethereum.Block): i32 { + return block.timestamp.toI32() / SECONDS_PER_DAY; +} + +export function getUnixHours(block: ethereum.Block): i32 { + return block.timestamp.toI32() / SECONDS_PER_HOUR; +} diff --git a/subgraphs/gogopool/src/sdk/util/numbers.ts b/subgraphs/gogopool/src/sdk/util/numbers.ts new file mode 100644 index 0000000000..725140a922 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/util/numbers.ts @@ -0,0 +1,61 @@ +import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; +import { + BIGDECIMAL_ZERO, + BIGINT_TEN, + DEFAULT_DECIMALS, + INT_TWO, +} from "./constants"; + +export function bigIntToBigDecimal( + quantity: BigInt, + decimals: i32 = DEFAULT_DECIMALS +): BigDecimal { + return quantity.divDecimal(BIGINT_TEN.pow(decimals as u8).toBigDecimal()); +} + +export function bigDecimalToBigInt(input: BigDecimal): BigInt { + const str = input.truncate(0).toString(); + return BigInt.fromString(str); +} + +// returns 10^exp +export function exponentToBigDecimal(exp: i32 = DEFAULT_DECIMALS): BigDecimal { + let bd = BigDecimal.fromString("1"); + const ten = BigDecimal.fromString("10"); + for (let i = 0; i < exp; i++) { + bd = bd.times(ten); + } + return bd; +} + +export function calculateAverage(prices: BigDecimal[]): BigDecimal { + let sum = BigDecimal.fromString("0"); + for (let i = 0; i < prices.length; i++) { + sum = sum.plus(prices[i]); + } + + return sum.div( + BigDecimal.fromString(BigInt.fromI32(prices.length).toString()) + ); +} + +export function calculateMedian(prices: BigDecimal[]): BigDecimal { + const sorted = prices.sort((a, b) => { + return a.equals(b) ? 0 : a.gt(b) ? 1 : -1; + }); + + const mid = Math.ceil(sorted.length / 2) as i32; + if (sorted.length % 2 == 0) { + return sorted[mid] + .plus(sorted[mid - 1]) + .div(BigDecimal.fromString(INT_TWO.toString())); + } + + return sorted[mid - 1]; +} + +export function safeDivide(a: BigDecimal, b: BigDecimal): BigDecimal { + if (b == BIGDECIMAL_ZERO) return BIGDECIMAL_ZERO; + + return a.div(b); +} diff --git a/subgraphs/gogopool/src/sdk/util/rewards.ts b/subgraphs/gogopool/src/sdk/util/rewards.ts new file mode 100644 index 0000000000..ad68987205 --- /dev/null +++ b/subgraphs/gogopool/src/sdk/util/rewards.ts @@ -0,0 +1,295 @@ +///////////////////// +// VERSION 1.0.3 //// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// The purpose of this program is to dynamically estimate the blocks generated for the 24 HR period following the most recent update. // +// It does so by calculating the moving average block rate for an arbitrary length of time preceding the current block. // +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +import { log, BigDecimal, BigInt, dataSource } from "@graphprotocol/graph-ts"; +import { _CircularBuffer } from "../../../generated/schema"; +import { + Network, + BIGDECIMAL_ZERO, + INT_FOUR, + INT_NEGATIVE_ONE, + INT_ONE, + INT_TWO, + INT_ZERO, +} from "./constants"; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// WINDOW_SIZE_SECONDS, TIMESTAMP_STORAGE_INTERVALS, and BUFFER_SIZE can be modified. These are just recommended values - 'somewhat' arbitrary. // +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +// The storage interval tells you to only store blocks where the timestamps are separated by at least this amount. +// Increasing this value will mean less blocks stored and less frequently computes blocksSpeed. +export const TIMESTAMP_STORAGE_INTERVAL = 600; + +// The window size determines the range of blocks that you track from the current block minus the window size. +// Window of block time used to calculate the moving average. +// Increasing means less deviation but also less sensitivity to changing block speeds. +export const WINDOW_SIZE_SECONDS = 86400; + +// BUFFER_SIZE determined the size of the array +// Makes the buffer the maximum amount of blocks that can be stored given the block rate and storage interval +// Recommended value is (RATE_IN_SECODNDS / TIMESTAMP_STORAGE_INTERVAL) * 2 - > Round up to nearest even integer +export const BUFFER_SIZE = 288; + +// Add this entity to the schema. +// type _CircularBuffer @entity { +// " 'CIRCULAR_BUFFER' " +// id: ID! + +// " Array of sorted block numbers sorted continuously " +// blocks: [Int!]! + +// " The index in the blocks array which will be used with the newest block to calculate block speed (Usally set to about a day before newest block) " +// windowStartIndex: Int! + +// " The next index in the blocks array that will be replaced with the newest block " +// nextIndex: Int! + +// " This determines the size of the blocks array. Should be set to contain at least a days worth of blocks according to a 1 day window for measuring speed" +// bufferSize: Int! + +// " The current calculated number of blocks per day based on calculated block speed " +// blocksPerDay: BigDecimal! + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const CIRCULAR_BUFFER = "CIRCULAR_BUFFER"; + +// Describes whether the interval for which rewards are emitted is done by block or timestamp +export namespace RewardIntervalType { + export const BLOCK = "BLOCK"; + export const TIMESTAMP = "TIMESTAMP"; +} + +// Forecast period. This gives you the time period that you want to estimate count of blocks per interval, based on moving average block speed. +// 86400 = 1 Day +export const RATE_IN_SECONDS = 86400; +export const RATE_IN_SECONDS_BD = BigDecimal.fromString( + RATE_IN_SECONDS.toString() +); + +// Estimated seconds per block of the protocol +export const STARTING_BLOCKS_PER_DAY = RATE_IN_SECONDS_BD.div( + getStartingBlockRate() +); + +export const WINDOW_SIZE_SECONDS_BD = BigDecimal.fromString( + WINDOW_SIZE_SECONDS.toString() +); + +// Call this function in event handlers frequently enough so that it calls on blocks frequently enough +/** + * @param {BigInt} currentTimestamp - Timestamp for current event + * @param {BigInt} currentBlockNumber - Block nunmber of current event + * @param {BigInt} rewardRate - Rate of reward emissions per reward interval + * @param {BigInt} rewardType - Describes whether rewards are given per block or timestamp + * @returns {BigDecimal} - Returns estimated blocks for specified rate + */ +export function getRewardsPerDay( + currentTimestamp: BigInt, + currentBlockNumber: BigInt, + rewardRate: BigDecimal, + rewardType: string +): BigDecimal { + const circularBuffer = getOrCreateCircularBuffer(); + + // Create entity for the current block + const currentTimestampI32 = currentTimestamp.toI32(); + const currentBlockNumberI32 = currentBlockNumber.toI32(); + + const blocks = circularBuffer.blocks; + + // Interval between index and the index of the start of the window block + const windowWidth = abs( + circularBuffer.windowStartIndex - circularBuffer.nextIndex + ); + if (windowWidth == INT_ZERO) { + if (circularBuffer.nextIndex >= circularBuffer.bufferSize) { + blocks[INT_ZERO] = currentTimestampI32; + blocks[INT_ONE] = currentBlockNumberI32; + circularBuffer.nextIndex = INT_TWO; + } else { + blocks[circularBuffer.nextIndex] = currentTimestampI32; + blocks[circularBuffer.nextIndex + INT_ONE] = currentBlockNumberI32; + circularBuffer.nextIndex += INT_TWO; + } + + circularBuffer.save(); + + // return because there is only 1 reference point. + if (rewardType == RewardIntervalType.TIMESTAMP) { + return rewardRate.times(RATE_IN_SECONDS_BD); + } else { + return circularBuffer.blocksPerDay.times(rewardRate); + } + } + + // Add current timestamp and block numnber to array if new block is at least X blocks later than previously stored. + // Used to save memory and efficiency on array resizing. + let recentSavedTimestamp: i32; + if (circularBuffer.nextIndex == INT_ZERO) { + recentSavedTimestamp = blocks[circularBuffer.bufferSize - INT_TWO]; + } else { + recentSavedTimestamp = blocks[circularBuffer.nextIndex - INT_TWO]; + } + + if ( + currentTimestampI32 - recentSavedTimestamp <= + TIMESTAMP_STORAGE_INTERVAL + ) { + if (rewardType == RewardIntervalType.TIMESTAMP) { + return rewardRate.times(RATE_IN_SECONDS_BD); + } else { + return circularBuffer.blocksPerDay.times(rewardRate); + } + } + + blocks[circularBuffer.nextIndex] = currentTimestampI32; + blocks[circularBuffer.nextIndex + INT_ONE] = currentBlockNumberI32; + if (circularBuffer.nextIndex >= BUFFER_SIZE - INT_TWO) { + circularBuffer.nextIndex = INT_ZERO; + } else { + circularBuffer.nextIndex += INT_TWO; + } + // The timestamp at the start of the window (default 24 hours in seconds). + const startTimestamp = currentTimestampI32 - WINDOW_SIZE_SECONDS; + + // Make sure to still have 2 blocks to calculate rate (This shouldn't happen past the beginning). + while (true) { + if (circularBuffer.nextIndex > circularBuffer.windowStartIndex) { + if ( + circularBuffer.nextIndex - circularBuffer.windowStartIndex <= + INT_FOUR + ) { + break; + } + } else { + if ( + BUFFER_SIZE - + circularBuffer.windowStartIndex + + circularBuffer.nextIndex <= + INT_FOUR + ) { + break; + } + } + const windowIndexBlockTimestamp = blocks[circularBuffer.windowStartIndex]; + + // Shift the start of the window if the current timestamp moves out of desired rate window + if (windowIndexBlockTimestamp < startTimestamp) { + circularBuffer.windowStartIndex = + circularBuffer.windowStartIndex + INT_TWO; + if (circularBuffer.windowStartIndex >= circularBuffer.bufferSize) { + circularBuffer.windowStartIndex = INT_ZERO; + } + } else { + break; + } + } + + // Wideness of the window in seconds. + const windowSecondsCount = BigDecimal.fromString( + (currentTimestampI32 - blocks[circularBuffer.windowStartIndex]).toString() + ); + + // Wideness of the window in blocks. + const windowBlocksCount = BigDecimal.fromString( + ( + currentBlockNumberI32 - blocks[circularBuffer.windowStartIndex + INT_ONE] + ).toString() + ); + + // Estimate block speed for the window in seconds. + const unnormalizedBlockSpeed = + WINDOW_SIZE_SECONDS_BD.div(windowSecondsCount).times(windowBlocksCount); + + // block speed converted to specified rate. + const normalizedBlockSpeed = RATE_IN_SECONDS_BD.div( + WINDOW_SIZE_SECONDS_BD + ).times(unnormalizedBlockSpeed); + + // Update BlockTracker with new values. + circularBuffer.blocksPerDay = normalizedBlockSpeed; + circularBuffer.blocks = blocks; + + circularBuffer.save(); + + if (rewardType == RewardIntervalType.TIMESTAMP) { + return rewardRate.times(RATE_IN_SECONDS_BD); + } else { + return rewardRate.times(circularBuffer.blocksPerDay); + } +} + +function getOrCreateCircularBuffer(): _CircularBuffer { + let circularBuffer = _CircularBuffer.load(CIRCULAR_BUFFER); + + if (!circularBuffer) { + circularBuffer = new _CircularBuffer(CIRCULAR_BUFFER); + + const blocks = new Array(BUFFER_SIZE); + for (let i = INT_ZERO; i < BUFFER_SIZE; i += INT_TWO) { + blocks[i] = INT_NEGATIVE_ONE; + blocks[i + INT_ONE] = INT_NEGATIVE_ONE; + } + + circularBuffer.blocks = blocks; + circularBuffer.windowStartIndex = INT_ZERO; + circularBuffer.nextIndex = INT_ZERO; + circularBuffer.bufferSize = BUFFER_SIZE; + circularBuffer.blocksPerDay = STARTING_BLOCKS_PER_DAY; + + circularBuffer.save(); + } + + return circularBuffer; +} + +function getStartingBlockRate(): BigDecimal { + // Block rates pulled from google searches - rough estimates + + const network = dataSource.network().toUpperCase().replace("-", "_"); + if (network == Network.MAINNET) { + return BigDecimal.fromString("13.39"); + } else if (network == Network.ARBITRUM_ONE) { + return BigDecimal.fromString("15"); + } else if (network == Network.AURORA) { + return BigDecimal.fromString("1.03"); + } else if (network == Network.BSC) { + return BigDecimal.fromString("5"); + } else if (network == Network.CELO) { + return BigDecimal.fromString("5"); + } else if (network == Network.FANTOM) { + return BigDecimal.fromString("1"); + } else if (network == Network.FUSE) { + return BigDecimal.fromString("1"); + } else if (network == Network.OPTIMISM) { + return BigDecimal.fromString("12.5"); + } else if (network == Network.MATIC) { + return BigDecimal.fromString("2"); + } else if (network == Network.XDAI) { + return BigDecimal.fromString("5"); + } else if (network == Network.MOONBEAM) { + return BigDecimal.fromString("13.39"); + } else if (network == Network.MOONRIVER) { + return BigDecimal.fromString("13.39"); + } else if (network == Network.AVALANCHE) { + return BigDecimal.fromString("13.39"); + } else if (network == Network.CRONOS) { + return BigDecimal.fromString("5.5"); + } else if (network == Network.BASE) { + // assuming same block rate as OPTIMISM + return BigDecimal.fromString("12.5"); + } + + // else if (network == SubgraphNetwork.AVALANCHE) return BigDecimal.fromString("2.5") + // else if (dataSource.network() == "harmony") return BigDecimal.fromString("13.39") + else { + log.warning("getStartingBlockRate(): Network not found", []); + return BIGDECIMAL_ZERO; + } +} diff --git a/subgraphs/gogopool/tsconfig.json b/subgraphs/gogopool/tsconfig.json new file mode 100644 index 0000000000..5c5d17c928 --- /dev/null +++ b/subgraphs/gogopool/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", + "include": ["src"] +}