From 6ca80801ff448a08cadae3d29512abc19d9af54e Mon Sep 17 00:00:00 2001 From: Founder Date: Mon, 17 Apr 2023 20:40:51 +0800 Subject: [PATCH 1/5] Vela Exchange Subgraph --- subgraphs/vela-exchange/README.md | 124 + .../abis/ComplexRewarderPerSec.json | 404 ++ subgraphs/vela-exchange/abis/ERC20.json | 222 ++ .../vela-exchange/abis/PositionVault.json | 1008 +++++ .../vela-exchange/abis/Prices/AaveOracle.json | 159 + .../abis/Prices/Calculations/Curve.json | 143 + .../abis/Prices/Calculations/SushiSwap.json | 137 + .../vela-exchange/abis/Prices/ChainLink.json | 530 +++ .../vela-exchange/abis/Prices/Curve/Pool.json | 916 +++++ .../abis/Prices/Curve/Registry.json | 337 ++ .../vela-exchange/abis/Prices/ERC20.json | 828 ++++ .../abis/Prices/Uniswap/Factory.json | 125 + .../abis/Prices/Uniswap/Pair.json | 461 +++ .../abis/Prices/Uniswap/Router.json | 398 ++ .../vela-exchange/abis/Prices/YearnLens.json | 174 + subgraphs/vela-exchange/abis/Vault.json | 1202 ++++++ subgraphs/vela-exchange/abis/VaultUtils.json | 1086 ++++++ subgraphs/vela-exchange/package.json | 15 + .../configurations.json | 1 + .../templates/vela.exchange.template.yaml | 179 + subgraphs/vela-exchange/schema.graphql | 2028 ++++++++++ .../vela-exchange/src/entities/account.ts | 130 + subgraphs/vela-exchange/src/entities/event.ts | 314 ++ subgraphs/vela-exchange/src/entities/pool.ts | 715 ++++ .../vela-exchange/src/entities/position.ts | 354 ++ .../vela-exchange/src/entities/protocol.ts | 370 ++ .../vela-exchange/src/entities/snapshots.ts | 1105 ++++++ subgraphs/vela-exchange/src/entities/token.ts | 111 + .../src/mappings/ComplexRewarderPerSec.ts | 37 + subgraphs/vela-exchange/src/mappings/Vault.ts | 90 + .../vela-exchange/src/mappings/VaultUtils.ts | 406 ++ subgraphs/vela-exchange/src/prices/README.md | 240 ++ .../prices/calculations/CalculationsCurve.ts | 47 + .../calculations/CalculationsSushiswap.ts | 47 + .../src/prices/common/constants.ts | 38 + .../vela-exchange/src/prices/common/types.ts | 103 + .../vela-exchange/src/prices/common/utils.ts | 96 + .../src/prices/config/arbitrum.ts | 137 + .../vela-exchange/src/prices/config/aurora.ts | 124 + .../src/prices/config/avalanche.ts | 131 + .../vela-exchange/src/prices/config/bsc.ts | 122 + .../vela-exchange/src/prices/config/celo.ts | 123 + .../vela-exchange/src/prices/config/cronos.ts | 122 + .../vela-exchange/src/prices/config/fantom.ts | 136 + .../vela-exchange/src/prices/config/fuse.ts | 123 + .../vela-exchange/src/prices/config/gnosis.ts | 125 + .../src/prices/config/harmony.ts | 127 + .../src/prices/config/mainnet.ts | 174 + .../src/prices/config/moonbeam.ts | 124 + .../src/prices/config/optimism.ts | 136 + .../src/prices/config/polygon.ts | 130 + .../src/prices/config/template.ts | 114 + subgraphs/vela-exchange/src/prices/index.ts | 140 + .../src/prices/oracles/AaveOracle.ts | 44 + .../src/prices/oracles/ChainLinkFeed.ts | 53 + .../src/prices/oracles/YearnLensOracle.ts | 44 + .../src/prices/routers/CurveRouter.ts | 326 ++ .../src/prices/routers/UniswapForksRouter.ts | 221 ++ .../vela-exchange/src/utils/constants.ts | 188 + subgraphs/vela-exchange/src/utils/numbers.ts | 181 + subgraphs/vela-exchange/src/utils/strings.ts | 11 + subgraphs/vela-exchange/tsconfig.json | 4 + subgraphs/vela-exchange/yarn.lock | 3353 +++++++++++++++++ 63 files changed, 21193 insertions(+) create mode 100644 subgraphs/vela-exchange/README.md create mode 100644 subgraphs/vela-exchange/abis/ComplexRewarderPerSec.json create mode 100644 subgraphs/vela-exchange/abis/ERC20.json create mode 100644 subgraphs/vela-exchange/abis/PositionVault.json create mode 100644 subgraphs/vela-exchange/abis/Prices/AaveOracle.json create mode 100644 subgraphs/vela-exchange/abis/Prices/Calculations/Curve.json create mode 100644 subgraphs/vela-exchange/abis/Prices/Calculations/SushiSwap.json create mode 100644 subgraphs/vela-exchange/abis/Prices/ChainLink.json create mode 100644 subgraphs/vela-exchange/abis/Prices/Curve/Pool.json create mode 100644 subgraphs/vela-exchange/abis/Prices/Curve/Registry.json create mode 100644 subgraphs/vela-exchange/abis/Prices/ERC20.json create mode 100644 subgraphs/vela-exchange/abis/Prices/Uniswap/Factory.json create mode 100644 subgraphs/vela-exchange/abis/Prices/Uniswap/Pair.json create mode 100644 subgraphs/vela-exchange/abis/Prices/Uniswap/Router.json create mode 100644 subgraphs/vela-exchange/abis/Prices/YearnLens.json create mode 100644 subgraphs/vela-exchange/abis/Vault.json create mode 100644 subgraphs/vela-exchange/abis/VaultUtils.json create mode 100644 subgraphs/vela-exchange/package.json create mode 100644 subgraphs/vela-exchange/protocols/vela-exchange/config/deployments/vela-exchange-arbitrum/configurations.json create mode 100644 subgraphs/vela-exchange/protocols/vela-exchange/config/templates/vela.exchange.template.yaml create mode 100644 subgraphs/vela-exchange/schema.graphql create mode 100644 subgraphs/vela-exchange/src/entities/account.ts create mode 100644 subgraphs/vela-exchange/src/entities/event.ts create mode 100644 subgraphs/vela-exchange/src/entities/pool.ts create mode 100644 subgraphs/vela-exchange/src/entities/position.ts create mode 100644 subgraphs/vela-exchange/src/entities/protocol.ts create mode 100644 subgraphs/vela-exchange/src/entities/snapshots.ts create mode 100644 subgraphs/vela-exchange/src/entities/token.ts create mode 100644 subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts create mode 100644 subgraphs/vela-exchange/src/mappings/Vault.ts create mode 100644 subgraphs/vela-exchange/src/mappings/VaultUtils.ts create mode 100644 subgraphs/vela-exchange/src/prices/README.md create mode 100644 subgraphs/vela-exchange/src/prices/calculations/CalculationsCurve.ts create mode 100644 subgraphs/vela-exchange/src/prices/calculations/CalculationsSushiswap.ts create mode 100644 subgraphs/vela-exchange/src/prices/common/constants.ts create mode 100644 subgraphs/vela-exchange/src/prices/common/types.ts create mode 100644 subgraphs/vela-exchange/src/prices/common/utils.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/arbitrum.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/aurora.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/avalanche.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/bsc.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/celo.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/cronos.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/fantom.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/fuse.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/gnosis.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/harmony.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/mainnet.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/moonbeam.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/optimism.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/polygon.ts create mode 100644 subgraphs/vela-exchange/src/prices/config/template.ts create mode 100644 subgraphs/vela-exchange/src/prices/index.ts create mode 100644 subgraphs/vela-exchange/src/prices/oracles/AaveOracle.ts create mode 100644 subgraphs/vela-exchange/src/prices/oracles/ChainLinkFeed.ts create mode 100644 subgraphs/vela-exchange/src/prices/oracles/YearnLensOracle.ts create mode 100644 subgraphs/vela-exchange/src/prices/routers/CurveRouter.ts create mode 100644 subgraphs/vela-exchange/src/prices/routers/UniswapForksRouter.ts create mode 100644 subgraphs/vela-exchange/src/utils/constants.ts create mode 100644 subgraphs/vela-exchange/src/utils/numbers.ts create mode 100644 subgraphs/vela-exchange/src/utils/strings.ts create mode 100644 subgraphs/vela-exchange/tsconfig.json create mode 100644 subgraphs/vela-exchange/yarn.lock diff --git a/subgraphs/vela-exchange/README.md b/subgraphs/vela-exchange/README.md new file mode 100644 index 0000000000..510dff3a7a --- /dev/null +++ b/subgraphs/vela-exchange/README.md @@ -0,0 +1,124 @@ +# VELA Exchange Subgraph Metrics Methodology v1.0.0 + +This is for VELA Exchange Subgraph based on Messari Derivatives Perpetual Schema. + +## Business Summary + +VELA Exchange is a decentralized exchange with advanced perpetuals trading capabilities, community focused incentives, and scalable infrastructure. + +The business of the protocol can be divided and summarized as follows: + +### VLP + +VLP is the liquidity provider token for VELA Exchange platform. It’s based on USDC staking, and can be redeemed for USDC at any time. Anybody can stake USDC to mint VLP and earn fees based on generated trading volume on the platform. + +VLP is to provide liquidity for traders, allowing them to take positions with leverage. If traders take a loss then the VLP holders will make profit, if the traders take a profit then VLP holders will make a loss. Although VLP value is market neutral and is not directly affected by the crypto market volatility, holding VLP still bears risks. + +### Trading + +Start by selecting the direction of the leverage position traders would like to open: “Long” or “Short”. + +Collateral is used to open a position at the selected leverage. These two levers will define your position size. + +Collateral x Leverage Level = Position Size + +Example: If you select 10x leverage level with $500 collateral, the position size you purchase will be $5,000 worth of selected asset. + +After creating a position, traders can create a variety of triggers, edit collateral, add to positions, and close positions. + +## Rewards and Fees + +Rewards and incentives are provided to holders and stakers of Vela Exchange utility tokens via several different methods. + +### VLP + +A percentage of fees, realized losses, and liquidated collateral will go into the VLP vault, increasing the value of VLP for holders. By staking their VLP, users receive a share of 10% of the total perpetual fees in esVELA for each corresponding rewards cycle. + +### esVELA + +A rewards token claimable by stakers of $VELA, $esVELA and $VLP. esVELA may be staked to earn a portion of $VELA rewards, or vested over time to be claimed as $VELA. A percentage of fees, realized losses, and liquidated collateral will be used to buy back $VELA from supported market places to supply vested $VELA. + +### Fee Splits + +The fees generated from the perpetual exchange are split according to: + +- 55% in USDC + > 5% for staking VELA and esVELA + > 50% for holding VLP +- 20% in esVELA (via VELA buybacks which is kept as a reserve 1:1 for minting esVELA) + > 10% for staking VELA and esVELA + > 10% for staking VLP +- 25% to Treasury + +## Usage Metrics + +The usage metrics for VELA Exchange take the following user activities into accout. + +### VLP + +- Mint VLP token by supplying the asset +- Burn VLP tokens to redeem the asset + +### Spot & Perpetual Exchange Traders + +- Open a long or short position +- Provide specific amount of collateral +- Edit position to change the margin level +- Set stop-loss and take-profit orders +- Close the position + +## Financial Metrics + +### TVL + +> TVL of a Pool = ∑ value of all assets to be provided as liquidity in the pool + +> TVL of the Protocol = ∑ TVL of the pools + +_Note: The collateral of traders are also reserved in the GLP pool. Hence, there are two types of transactions to deposit tokens to the pool, which are the users who provide liquidity and another one for the traders who provide collaterals before trading. The subgraph only counts the tokens to be provided as liqiudity into TVL and does not add positions' collaterals to the pool's TVL, in order to be consistent with official measurement._ + +### Volume + +Total volumes in this subgraph refer to perp trading volume. Meanwhile, there are three types of volumes for perp trading: InflowVolume, OutflowVolume and ClosedInflowVolume: + +- Inflows are all funds that entered the protocol as part of long/short positions being opened. +- Outflows are all funds that left the protocol because of positions being closed. +- And then inflows at close: when a position closes, if it results in a gain to the protocol balance (the trader lost), whatever is the net increase would go here. If the trader wins (removing funds from the protocol balance) then this is untouched. It would be like the "settled inflow", which allows users to know if the protocol is making or losing money during a given period. + +### Total Revenue + +> Total Revenue of a Pool = ∑ poistion opening & closing fees, borrowing fees, and trading fees + +#### Supply Side Revenue + +> Supply Side Revenue = 60% \* Total Revenue + +#### Protocol Side Revenue + +> Protocol Side Revenue = 25% \* Total Revenue + +#### Stake Side Revenue + +> Protocol Side Revenue = 15% \* Total Revenue + +## Useful Links + +Protocol: + +- https://app.vela.exchange/ + +Docs: + +- https://vela-exchange.gitbook.io/ + +Smart contracts: + +- https://vela-exchange.gitbook.io/vela-knowledge-base/developers/contract-functions + +Smart contracts address: + +- https://vela-exchange.gitbook.io/vela-knowledge-base/developers/contract-addresses/mainnet + +Tokenomics: + +- https://vela-exchange.gitbook.io/vela-knowledge-base/token-economy diff --git a/subgraphs/vela-exchange/abis/ComplexRewarderPerSec.json b/subgraphs/vela-exchange/abis/ComplexRewarderPerSec.json new file mode 100644 index 0000000000..e9f444921d --- /dev/null +++ b/subgraphs/vela-exchange/abis/ComplexRewarderPerSec.json @@ -0,0 +1,404 @@ +[ + { + "inputs": [ + { + "internalType": "contract IBoringERC20", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "contract IFarmDistributor", + "name": "_distributor", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + } + ], + "name": "AddPool", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "phase", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "endTimestamp", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardPerSec", + "type": "uint256" + } + ], + "name": "AddRewardInfo", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "OnReward", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newRate", + "type": "uint256" + } + ], + "name": "RewardRateUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lastRewardTimestamp", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpSupply", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accTokenPerShare", + "type": "uint256" + } + ], + "name": "UpdatePool", + "type": "event" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { + "internalType": "uint256", + "name": "_startTimestamp", + "type": "uint256" + } + ], + "name": "add", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "uint256", "name": "_endTimestamp", "type": "uint256" }, + { "internalType": "uint256", "name": "_rewardPerSec", "type": "uint256" } + ], + "name": "addRewardInfo", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" } + ], + "name": "currentEndTimestamp", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "distributor", + "outputs": [ + { + "internalType": "contract IFarmDistributor", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "internalType": "address", "name": "_beneficiary", "type": "address" } + ], + "name": "emergencyRewardWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "internalType": "address", "name": "_beneficiary", "type": "address" } + ], + "name": "emergencyWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_from", "type": "uint256" }, + { "internalType": "uint256", "name": "_to", "type": "uint256" }, + { "internalType": "uint256", "name": "_endTimestamp", "type": "uint256" } + ], + "name": "getTimeElapsed", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "massUpdatePools", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "address", "name": "_user", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "onVelaReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "address", "name": "_user", "type": "address" } + ], + "name": "pendingTokens", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "poolIds", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "poolInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "accTokenPerShare", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastRewardTimestamp", + "type": "uint256" + }, + { "internalType": "uint256", "name": "totalRewards", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "name": "poolRewardInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "startTimestamp", + "type": "uint256" + }, + { "internalType": "uint256", "name": "endTimestamp", "type": "uint256" }, + { "internalType": "uint256", "name": "rewardPerSec", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" } + ], + "name": "poolRewardsPerSec", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardInfoLimit", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardToken", + "outputs": [ + { "internalType": "contract IBoringERC20", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_pid", "type": "uint256" } + ], + "name": "updatePool", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "accTokenPerShare", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastRewardTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalRewards", + "type": "uint256" + } + ], + "internalType": "struct ComplexRewarderPerSec.PoolInfo", + "name": "pool", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "userInfo", + "outputs": [ + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "uint256", "name": "rewardDebt", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/vela-exchange/abis/ERC20.json b/subgraphs/vela-exchange/abis/ERC20.json new file mode 100644 index 0000000000..405d6b3648 --- /dev/null +++ b/subgraphs/vela-exchange/abis/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/vela-exchange/abis/PositionVault.json b/subgraphs/vela-exchange/abis/PositionVault.json new file mode 100644 index 0000000000..99243a96db --- /dev/null +++ b/subgraphs/vela-exchange/abis/PositionVault.json @@ -0,0 +1,1008 @@ +[ + { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isPlus", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reserveAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "collateral", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "size", + "type": "uint256" + } + ], + "name": "AddOrRemoveCollateral", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bool", + "name": "confirmDelayStatus", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "collateral", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "size", + "type": "uint256" + } + ], + "name": "AddPosition", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "data", + "type": "uint256[]" + } + ], + "name": "AddTrailingStop", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bool", + "name": "confirmDelayStatus", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "collateral", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "size", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeUsd", + "type": "uint256" + } + ], + "name": "ConfirmDelayTransaction", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLong", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "DecreasePoolAmount", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLong", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "DecreaseReservedAmount", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLong", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "IncreasePoolAmount", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLong", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "IncreaseReservedAmount", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "indexToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLong", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "posId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "positionType", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "enum OrderStatus", + "name": "orderStatus", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "triggerData", + "type": "uint256[]" + } + ], + "name": "NewOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "positionType", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "enum OrderStatus", + "name": "orderStatus", + "type": "uint8" + } + ], + "name": "UpdateOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLong", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "UpdatePoolAmount", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLong", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "UpdateReservedAmount", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stpPrice", + "type": "uint256" + } + ], + "name": "UpdateTrailingStop", + "type": "event" + }, + { + "inputs": [], + "name": "BASIS_POINTS_DIVISOR", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_FUNDING_RATE_FACTOR", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_OPEN_INTEREST", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_VLP_PRICE", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FUNDING_RATE_PRECISION", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIQUIDATE_FEE_EXCEED", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIQUIDATE_NONE_EXCEED", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIQUIDATE_THRESHOLD_EXCEED", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_COOLDOWN_DURATION", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_DELTA_TIME", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_DEPOSIT_FEE", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FEE_BASIS_POINTS", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FEE_REWARD_BASIS_POINTS", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FUNDING_RATE_FACTOR", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FUNDING_RATE_INTERVAL", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_LIQUIDATION_FEE_USD", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_STAKING_FEE", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_TOKENFARM_COOLDOWN_DURATION", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_TRIGGER_GAS_FEE", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_VESTING_DURATION", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_FEE_REWARD_BASIS_POINTS", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_FUNDING_RATE_INTERVAL", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_LEVERAGE", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ORDER_FILLED", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ORDER_NOT_FILLED", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_LIMIT", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_MARKET", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_STOP_LIMIT", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_STOP_MARKET", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_TRAILING_STOP", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PRICE_PRECISION", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PID_FOR_CHARGE_FEE", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRAILING_STOP_TYPE_AMOUNT", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRAILING_STOP_TYPE_PERCENT", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VLP_DECIMALS", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ZERO_ADDRESS", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { "internalType": "uint256", "name": "_posId", "type": "uint256" }, + { "internalType": "bool", "name": "isPlus", "type": "bool" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "addOrRemoveCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { "internalType": "uint256", "name": "_posId", "type": "uint256" }, + { + "internalType": "uint256", + "name": "_collateralDelta", + "type": "uint256" + }, + { "internalType": "uint256", "name": "_sizeDelta", "type": "uint256" } + ], + "name": "addPosition", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { "internalType": "uint256", "name": "_posId", "type": "uint256" }, + { "internalType": "uint256[]", "name": "_params", "type": "uint256[]" } + ], + "name": "addTrailingStop", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { "internalType": "uint256", "name": "_posId", "type": "uint256" } + ], + "name": "cancelPendingOrder", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { "internalType": "uint256", "name": "_posId", "type": "uint256" } + ], + "name": "confirmDelayTransaction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "confirms", + "outputs": [ + { "internalType": "bool", "name": "confirmDelayStatus", "type": "bool" }, + { + "internalType": "uint256", + "name": "pendingDelayCollateral", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pendingDelaySize", + "type": "uint256" + }, + { "internalType": "uint256", "name": "delayStartTime", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "uint256", "name": "_sizeDelta", "type": "uint256" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { "internalType": "uint256", "name": "_posId", "type": "uint256" } + ], + "name": "decreasePosition", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { "internalType": "uint256", "name": "_posId", "type": "uint256" } + ], + "name": "getPosition", + "outputs": [ + { + "components": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "refer", "type": "address" }, + { "internalType": "int256", "name": "realisedPnl", "type": "int256" }, + { + "internalType": "uint256", + "name": "averagePrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "collateral", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "entryFundingRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastIncreasedTime", + "type": "uint256" + }, + { "internalType": "uint256", "name": "lastPrice", "type": "uint256" }, + { + "internalType": "uint256", + "name": "reserveAmount", + "type": "uint256" + }, + { "internalType": "uint256", "name": "size", "type": "uint256" } + ], + "internalType": "struct Position", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "enum OrderStatus", + "name": "status", + "type": "uint8" + }, + { "internalType": "uint256", "name": "lmtPrice", "type": "uint256" }, + { + "internalType": "uint256", + "name": "pendingSize", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pendingCollateral", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "positionType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stepAmount", + "type": "uint256" + }, + { "internalType": "uint256", "name": "stepType", "type": "uint256" }, + { "internalType": "uint256", "name": "stpPrice", "type": "uint256" } + ], + "internalType": "struct OrderInfo", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bool", + "name": "confirmDelayStatus", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "pendingDelayCollateral", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pendingDelaySize", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "delayStartTime", + "type": "uint256" + } + ], + "internalType": "struct ConfirmInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IPriceManager", + "name": "_priceManager", + "type": "address" + }, + { + "internalType": "contract ISettingsManager", + "name": "_settingsManager", + "type": "address" + }, + { + "internalType": "contract ITriggerOrderManager", + "name": "_triggerOrderManager", + "type": "address" + }, + { + "internalType": "contract IVault", + "name": "_vault", + "type": "address" + }, + { + "internalType": "contract IVaultUtils", + "name": "_vaultUtils", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "lastPosId", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { "internalType": "uint256", "name": "_posId", "type": "uint256" } + ], + "name": "liquidatePosition", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { + "internalType": "enum OrderType", + "name": "_orderType", + "type": "uint8" + }, + { "internalType": "uint256[]", "name": "_params", "type": "uint256[]" }, + { "internalType": "address", "name": "_refer", "type": "address" } + ], + "name": "newPositionOrder", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "orders", + "outputs": [ + { "internalType": "enum OrderStatus", "name": "status", "type": "uint8" }, + { "internalType": "uint256", "name": "lmtPrice", "type": "uint256" }, + { "internalType": "uint256", "name": "pendingSize", "type": "uint256" }, + { + "internalType": "uint256", + "name": "pendingCollateral", + "type": "uint256" + }, + { "internalType": "uint256", "name": "positionType", "type": "uint256" }, + { "internalType": "uint256", "name": "stepAmount", "type": "uint256" }, + { "internalType": "uint256", "name": "stepType", "type": "uint256" }, + { "internalType": "uint256", "name": "stpPrice", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "bool", "name": "", "type": "bool" } + ], + "name": "poolAmounts", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "name": "positions", + "outputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "refer", "type": "address" }, + { "internalType": "int256", "name": "realisedPnl", "type": "int256" }, + { "internalType": "uint256", "name": "averagePrice", "type": "uint256" }, + { "internalType": "uint256", "name": "collateral", "type": "uint256" }, + { + "internalType": "uint256", + "name": "entryFundingRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastIncreasedTime", + "type": "uint256" + }, + { "internalType": "uint256", "name": "lastPrice", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveAmount", "type": "uint256" }, + { "internalType": "uint256", "name": "size", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "bool", "name": "", "type": "bool" } + ], + "name": "reservedAmounts", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { "internalType": "uint256", "name": "_posId", "type": "uint256" } + ], + "name": "triggerPosition", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_indexToken", "type": "address" }, + { "internalType": "bool", "name": "_isLong", "type": "bool" }, + { "internalType": "uint256", "name": "_posId", "type": "uint256" } + ], + "name": "updateTrailingStop", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/subgraphs/vela-exchange/abis/Prices/AaveOracle.json b/subgraphs/vela-exchange/abis/Prices/AaveOracle.json new file mode 100644 index 0000000000..3149642bb9 --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Prices/Calculations/Curve.json b/subgraphs/vela-exchange/abis/Prices/Calculations/Curve.json new file mode 100644 index 0000000000..b1f6da3de4 --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Prices/Calculations/SushiSwap.json b/subgraphs/vela-exchange/abis/Prices/Calculations/SushiSwap.json new file mode 100644 index 0000000000..8b9718ae78 --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Prices/ChainLink.json b/subgraphs/vela-exchange/abis/Prices/ChainLink.json new file mode 100644 index 0000000000..55882931c3 --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Prices/Curve/Pool.json b/subgraphs/vela-exchange/abis/Prices/Curve/Pool.json new file mode 100644 index 0000000000..d4843cae7d --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Prices/Curve/Registry.json b/subgraphs/vela-exchange/abis/Prices/Curve/Registry.json new file mode 100644 index 0000000000..9747624cc9 --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Prices/ERC20.json b/subgraphs/vela-exchange/abis/Prices/ERC20.json new file mode 100644 index 0000000000..5c47f76a53 --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Prices/Uniswap/Factory.json b/subgraphs/vela-exchange/abis/Prices/Uniswap/Factory.json new file mode 100644 index 0000000000..1b14599d5d --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Prices/Uniswap/Pair.json b/subgraphs/vela-exchange/abis/Prices/Uniswap/Pair.json new file mode 100644 index 0000000000..e5efebf418 --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Prices/Uniswap/Router.json b/subgraphs/vela-exchange/abis/Prices/Uniswap/Router.json new file mode 100644 index 0000000000..efc7f31728 --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Prices/YearnLens.json b/subgraphs/vela-exchange/abis/Prices/YearnLens.json new file mode 100644 index 0000000000..60a45cc87c --- /dev/null +++ b/subgraphs/vela-exchange/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/vela-exchange/abis/Vault.json b/subgraphs/vela-exchange/abis/Vault.json new file mode 100644 index 0000000000..1e0121b80c --- /dev/null +++ b/subgraphs/vela-exchange/abis/Vault.json @@ -0,0 +1,1202 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_vlp", + "type": "address" + }, + { + "internalType": "address", + "name": "_vUSDC", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "Stake", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "refer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "name": "TakeVUSDIn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "refer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "name": "TakeVUSDOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TransferBounty", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "vlpAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "name": "Unstake", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [], + "name": "BASIS_POINTS_DIVISOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_FUNDING_RATE_FACTOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_OPEN_INTEREST", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_VLP_PRICE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FUNDING_RATE_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIQUIDATE_FEE_EXCEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIQUIDATE_NONE_EXCEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIQUIDATE_THRESHOLD_EXCEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_COOLDOWN_DURATION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_DELTA_TIME", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_DEPOSIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FEE_BASIS_POINTS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FEE_REWARD_BASIS_POINTS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FUNDING_RATE_FACTOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FUNDING_RATE_INTERVAL", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_LIQUIDATION_FEE_USD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_STAKING_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_TOKENFARM_COOLDOWN_DURATION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_TRIGGER_GAS_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_VESTING_DURATION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_FEE_REWARD_BASIS_POINTS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_FUNDING_RATE_INTERVAL", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_LEVERAGE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ORDER_FILLED", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ORDER_NOT_FILLED", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_LIMIT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_MARKET", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_STOP_LIMIT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_STOP_MARKET", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_TRAILING_STOP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PRICE_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PID_FOR_CHARGE_FEE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRAILING_STOP_TYPE_AMOUNT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRAILING_STOP_TYPE_PERCENT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VLP_DECIMALS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ZERO_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_hasProfit", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_adjustDelta", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + } + ], + "name": "accountDeltaAndFeeIntoTotalUSDC", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isPlus", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "addOrRemoveCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_collateralDelta", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_sizeDelta", + "type": "uint256" + } + ], + "name": "addPosition", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "_params", + "type": "uint256[]" + } + ], + "name": "addTrailingStop", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + } + ], + "name": "cancelPendingOrder", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_sizeDelta", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + } + ], + "name": "decreasePosition", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_refer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + } + ], + "name": "distributeFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getVLPPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastStakedAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "enum OrderType", + "name": "_orderType", + "type": "uint8" + }, + { + "internalType": "uint256[]", + "name": "_params", + "type": "uint256[]" + }, + { + "internalType": "address", + "name": "_refer", + "type": "address" + } + ], + "name": "newPositionOrder", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IPriceManager", + "name": "_priceManager", + "type": "address" + }, + { + "internalType": "contract ISettingsManager", + "name": "_settingsManager", + "type": "address" + }, + { + "internalType": "contract IPositionVault", + "name": "_positionVault", + "type": "address" + } + ], + "name": "setVaultSettings", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "stake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_refer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + } + ], + "name": "takeVUSDIn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_refer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_usdOut", + "type": "uint256" + } + ], + "name": "takeVUSDOut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "totalUSDC", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalVLP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "transferBounty", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_tokenOut", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_vlpAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "unstake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/subgraphs/vela-exchange/abis/VaultUtils.json b/subgraphs/vela-exchange/abis/VaultUtils.json new file mode 100644 index 0000000000..82ca0737b8 --- /dev/null +++ b/subgraphs/vela-exchange/abis/VaultUtils.json @@ -0,0 +1,1086 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_positionVault", + "type": "address" + }, + { + "internalType": "address", + "name": "_priceManager", + "type": "address" + }, + { + "internalType": "address", + "name": "_settingsManager", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "int256", + "name": "realisedPnl", + "type": "int256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "markPrice", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeUsd", + "type": "uint256" + } + ], + "name": "ClosePosition", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "indexToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLong", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "posId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "realisedPnl", + "type": "int256" + }, + { + "indexed": false, + "internalType": "uint256[7]", + "name": "posData", + "type": "uint256[7]" + } + ], + "name": "DecreasePosition", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "indexToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLong", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "posId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256[7]", + "name": "posData", + "type": "uint256[7]" + } + ], + "name": "IncreasePosition", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "int256", + "name": "realisedPnl", + "type": "int256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "markPrice", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeUsd", + "type": "uint256" + } + ], + "name": "LiquidatePosition", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "name": "SetDepositFee", + "type": "event" + }, + { + "inputs": [], + "name": "BASIS_POINTS_DIVISOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_FUNDING_RATE_FACTOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_OPEN_INTEREST", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_VLP_PRICE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FUNDING_RATE_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIQUIDATE_FEE_EXCEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIQUIDATE_NONE_EXCEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIQUIDATE_THRESHOLD_EXCEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_COOLDOWN_DURATION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_DELTA_TIME", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_DEPOSIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FEE_BASIS_POINTS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FEE_REWARD_BASIS_POINTS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FUNDING_RATE_FACTOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FUNDING_RATE_INTERVAL", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_LIQUIDATION_FEE_USD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_STAKING_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_TOKENFARM_COOLDOWN_DURATION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_TRIGGER_GAS_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_VESTING_DURATION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_FEE_REWARD_BASIS_POINTS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_FUNDING_RATE_INTERVAL", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_LEVERAGE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ORDER_FILLED", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ORDER_NOT_FILLED", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_LIMIT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_MARKET", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_STOP_LIMIT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_STOP_MARKET", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POSITION_TRAILING_STOP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PRICE_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PID_FOR_CHARGE_FEE", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRAILING_STOP_TYPE_AMOUNT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRAILING_STOP_TYPE_PERCENT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VLP_DECIMALS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ZERO_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + } + ], + "name": "emitClosePositionEvent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_sizeDelta", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + } + ], + "name": "emitDecreasePositionEvent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_collateralDelta", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_sizeDelta", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + } + ], + "name": "emitIncreasePositionEvent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + } + ], + "name": "emitLiquidatePositionEvent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_raise", + "type": "bool" + } + ], + "name": "validateConfirmDelay", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_raise", + "type": "bool" + } + ], + "name": "validateDecreasePosition", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_raise", + "type": "bool" + } + ], + "name": "validateLiquidation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "enum OrderType", + "name": "_orderType", + "type": "uint8" + }, + { + "internalType": "uint256[]", + "name": "_params", + "type": "uint256[]" + }, + { + "internalType": "bool", + "name": "_raise", + "type": "bool" + } + ], + "name": "validatePosData", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_size", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_collateral", + "type": "uint256" + } + ], + "name": "validateSizeCollateralAmount", + "outputs": [], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "_params", + "type": "uint256[]" + } + ], + "name": "validateTrailingStopInputData", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_raise", + "type": "bool" + } + ], + "name": "validateTrailingStopPrice", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_indexToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isLong", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_posId", + "type": "uint256" + } + ], + "name": "validateTrigger", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/subgraphs/vela-exchange/package.json b/subgraphs/vela-exchange/package.json new file mode 100644 index 0000000000..29591b7e5e --- /dev/null +++ b/subgraphs/vela-exchange/package.json @@ -0,0 +1,15 @@ +{ + "license": "MIT", + "scripts": { + "format": "npx prettier --write .", + "codegen": "graph codegen", + "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.39.0", + "@graphprotocol/graph-ts": "0.29.0" + }, + "devDependencies": { + "prettier": "^2.6.2" + } +} diff --git a/subgraphs/vela-exchange/protocols/vela-exchange/config/deployments/vela-exchange-arbitrum/configurations.json b/subgraphs/vela-exchange/protocols/vela-exchange/config/deployments/vela-exchange-arbitrum/configurations.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/subgraphs/vela-exchange/protocols/vela-exchange/config/deployments/vela-exchange-arbitrum/configurations.json @@ -0,0 +1 @@ +{} diff --git a/subgraphs/vela-exchange/protocols/vela-exchange/config/templates/vela.exchange.template.yaml b/subgraphs/vela-exchange/protocols/vela-exchange/config/templates/vela.exchange.template.yaml new file mode 100644 index 0000000000..11ad4afb42 --- /dev/null +++ b/subgraphs/vela-exchange/protocols/vela-exchange/config/templates/vela.exchange.template.yaml @@ -0,0 +1,179 @@ +specVersion: 0.0.4 +schema: + file: ./schema.graphql +dataSources: + - kind: ethereum/contract + name: Vault + network: arbitrum-one + source: + address: "0x5957582f020301a2f732ad17a69ab2d8b2741241" + abi: Vault + startBlock: 56425422 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: [] + abis: + ########################################### + ############## 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 + + - name: Vault + file: ./abis/Vault.json + - name: ERC20 + file: ./abis/ERC20.json + eventHandlers: + - event: Stake(indexed address,address,uint256,uint256) + handler: handleStake + - event: Unstake(indexed address,address,uint256,uint256) + handler: handleUnstake + file: ./src/mappings/Vault.ts + + - kind: ethereum + name: VaultUtils + network: arbitrum-one + source: + address: "0xda1a7ea276fbdb16ebabb5b38257b1d56b302e4a" + abi: VaultUtils + startBlock: 56425513 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: [] + abis: + ########################################### + ############## 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 + + - name: VaultUtils + file: ./abis/VaultUtils.json + - name: PositionVault + file: ./abis/PositionVault.json + - name: ERC20 + file: ./abis/ERC20.json + eventHandlers: + - event: IncreasePosition(bytes32,indexed address,indexed address,bool,uint256,uint256[7]) + handler: handleIncreasePosition + - event: DecreasePosition(bytes32,indexed address,indexed + address,bool,uint256,int256,uint256[7]) + handler: handleDecreasePosition + - event: ClosePosition(bytes32,int256,uint256,uint256) + handler: handleClosePosition + - event: LiquidatePosition(bytes32,int256,uint256,uint256) + handler: handleLiquidatePosition + file: ./src/mappings/VaultUtils.ts + + - kind: ethereum/contract + name: ComplexRewarderPerSec + network: arbitrum-one + source: + address: "0x482DBd9a2adDB5063FdD4453B94bFadB5a6c0E98" + abi: ComplexRewarderPerSec + startBlock: 56426558 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: [] + abis: + ########################################### + ############## 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 + + - name: ComplexRewarderPerSec + file: ./abis/ComplexRewarderPerSec.json + - name: ERC20 + file: ./abis/ERC20.json + eventHandlers: + - event: AddRewardInfo(indexed uint256,indexed uint256,uint256,uint256) + handler: handleAddRewardInfo + file: ./src/mappings/ComplexRewarderPerSec.ts diff --git a/subgraphs/vela-exchange/schema.graphql b/subgraphs/vela-exchange/schema.graphql new file mode 100644 index 0000000000..3d7cff2a07 --- /dev/null +++ b/subgraphs/vela-exchange/schema.graphql @@ -0,0 +1,2028 @@ +# Subgraph Schema: Derivatives Perpetual Futures +# Version: 1.2.1 +# 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 + XDAI # aka Gnosis Chain +} + +enum ProtocolType { + EXCHANGE + LENDING + YIELD + BRIDGE + OPTION + PERPETUAL + GENERIC + # Will add more +} + +type Token @entity { + " 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 +} + +enum RewardTokenType { + " For reward tokens awarded to LPs/lenders " + DEPOSIT + + " For reward tokens awarded to borrowers " + BORROW + + " For reward tokens awarded to stakers of native token (e.g. GMX stakers) " + STAKE +} + +type RewardToken @entity(immutable: true) { + " Bytes.fromI32(0|1).concat(rewardTokenAddress), where 0 is for deposit and 1 is for borrow " + id: Bytes! + + " Reference to the actual token " + token: Token! + + " The type of the reward token " + type: RewardTokenType! +} + +# Note that trading fee is the premium paid *by* the users, whereas LP fee, stake fee and +# protocol fee are fees paid *to* the corresponding parties. +# Most of the time, trading fee = liquidity provider fee + protocol fee+stake fee, +# but not always. Thus we explicitly specify all different fee types. +enum LiquidityPoolFeeType { + " Total fixed fee paid by the user per trade, as a percentage of the traded amount. e.g. 0.3% for Uniswap v2, 0.3% for Sushiswap, 0.04% for Curve v1. " + FIXED_TRADING_FEE + + " Some protocols use tiered fees instead of fixed fee (e.g. DYDX). Set `feePercentage` as 0 but handle the tiered fees in the mapping code. " + TIERED_TRADING_FEE + + " Some protocols use dynamic fees instead of fixed fee (e.g. Balancer v2). Set `feePercentage` as 0 but handle the dynamic fees in the mapping code. " + DYNAMIC_TRADING_FEE + + " Fixed fee that's paid to the LP, as a percentage of the traded amount. e.g. 10% of fees to GMX LP providers (GLP holders). " + FIXED_LP_FEE + + " Some protocols use dynamic LP fees . Set `feePercentage` as 0 but handle the dynamic fees in the mapping code. " + DYNAMIC_LP_FEE + + " Fixed fee that's paid to the protocol, as a percentage of the traded amount. e.g. 10% of GMX fees to protocol. " + FIXED_PROTOCOL_FEE + + " Some protocols use dynamic protocol fees. Set `feePercentage` as 0 but handle the dynamic fees in the mapping code. " + DYNAMIC_PROTOCOL_FEE + + " Fixed fee that's paid to the stakers, as a percentage of the traded amount. e.g. 15% of all fees on GMX to stakers. " + FIXED_STAKE_FEE + + " Some protocols use dynamic stakers fees. Set `feePercentage` as 0 but handle the dynamic fees in the mapping code. " + DYNAMIC_STAKE_FEE + + " One-time fee charged by the protocol during deposit, in percentages of the deposit token (e.g. dynamic fee collected for LP providers in GMX)" + DEPOSIT_FEE + + " One-time fee charged by the protocol (e.g. GMX charges a fee from certain pools with withdrawing) during withdrawal, in percentages of the withdrawal token " + WITHDRAWAL_FEE +} + +type LiquidityPoolFee @entity { + " { Fee type }-{ Pool address } " + id: Bytes! + + " Fee as a percentage of the trade (swap) amount. Does not always apply " + feePercentage: BigDecimal + + " Type of fee this pool uses " + feeType: LiquidityPoolFeeType! +} + +############################# +##### Protocol Metadata ##### +############################# + +interface Protocol { + " 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! + + " Current PCV (Protocol Controlled Value). Only relevant for protocols with PCV. " + protocolControlledValueUSD: BigDecimal + + " Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 70% of fees on GMX). Depositors on Lending Protocols. NFT sellers on OpenSea. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " Gross revenue for the protocol (revenue claimed by protocol). Examples: 15% on GMX goes to protocol . OpenSea 10% sell fee. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " Gross revenue for the stakers (this is defined as recieving a share of revenue or tokens equal to share e.g. buying eth with DAI revenue). Examples: GMX 15% of trade fees goes to stakers " + cumulativeStakeSideRevenueUSD: BigDecimal! + + " All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. " + cumulativeTotalRevenueUSD: BigDecimal! + + " All premium paid to enter a position. " + cumulativeEntryPremiumUSD: BigDecimal! + + " All premium paid to exit a position. " + cumulativeExitPremiumUSD: BigDecimal! + + " All premium paid. " + cumulativeTotalPremiumUSD: BigDecimal! + + " All premium paid to deposit in liquidity pools. " + cumulativeDepositPremiumUSD: BigDecimal! + + " All premium paid to withdraw from liquidity pools. " + cumulativeWithdrawPremiumUSD: BigDecimal! + + " All premium paid to enter and exit liquidity pool. " + cumulativeTotalLiquidityPremiumUSD: BigDecimal! + + " Number of cumulative unique users " + cumulativeUniqueUsers: Int! + + " Number of cumulative borrowers " + cumulativeUniqueBorrowers: Int! + + " Number of cumulative liquidators (accounts that performed liquidation) " + cumulativeUniqueLiquidators: Int! + + " Number of cumulative liquidatees (accounts that got liquidated) " + cumulativeUniqueLiquidatees: Int! + + " Notional value of all open long positions " + longOpenInterestUSD: BigDecimal! + + " Notional value of all open short positions " + shortOpenInterestUSD: BigDecimal! + + " Notional value of all open positions " + totalOpenInterestUSD: BigDecimal! + + " Total number of long positions (not cumulative) " + longPositionCount: Int! + + " Total number of short positions (not cumulative) " + shortPositionCount: Int! + + " Total number of open positions (not cumulative) " + openPositionCount: Int! + + " Total number of closed positions " + closedPositionCount: Int! + + " Total number of positions (open and closed) " + cumulativePositionCount: Int! + + " Total number of transactions " + transactionCount: Int! + + " Total number of deposits " + depositCount: Int! + + " Total number of withdrawals " + withdrawCount: Int! + + " Total number of borrows " + borrowCount: Int! + + " Total number of pools " + totalPoolCount: Int! + + ##### Snapshots ##### + + " Daily usage metrics for this protocol " + dailyUsageMetrics: [UsageMetricsDailySnapshot!]! + @derivedFrom(field: "protocol") + + " Hourly usage metrics for this protocol " + hourlyUsageMetrics: [UsageMetricsHourlySnapshot!]! + @derivedFrom(field: "protocol") + + " Daily financial metrics for this protocol " + financialMetrics: [FinancialsDailySnapshot!]! @derivedFrom(field: "protocol") +} + +type DerivPerpProtocol implements Protocol @entity { + " 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! + + " Current PCV (Protocol Controlled Value). Only relevant for protocols with PCV. " + protocolControlledValueUSD: BigDecimal + + " All historical Notional volume in USD " + cumulativeVolumeUSD: BigDecimal! + + " Inflow historical trade notional volume occurred in this protocol, in USD, based on value of underlying assets coming into protocol from trade, at the time of position opened. " + cumulativeInflowVolumeUSD: BigDecimal! + + " Inflow historical trade notional volume occurred in this protocol, in USD, based on value of underlying assets coming into protocol from trade, at the time of position closed. " + cumulativeClosedInflowVolumeUSD: BigDecimal! + + " Outflow historical trade notional volume occurred in this protocol, in USD, based on value of underlying assets coming out of protocol from trade. " + cumulativeOutflowVolumeUSD: 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! + + " Gross revenue for the stakers (this is defined as receiving a share of revenue or tokens equal to share e.g. buying eth with DAI revenue). Examples: GMX 15% of trade fees goes to stakers " + cumulativeStakeSideRevenueUSD: BigDecimal! + + " All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. " + cumulativeTotalRevenueUSD: BigDecimal! + + " All premium paid to enter a position. " + cumulativeEntryPremiumUSD: BigDecimal! + + " All premium paid to exit a position. " + cumulativeExitPremiumUSD: BigDecimal! + + " All premium paid. " + cumulativeTotalPremiumUSD: BigDecimal! + + " All premium paid to deposit in the protocol. " + cumulativeDepositPremiumUSD: BigDecimal! + + " All premium paid to withdraw from the protocol. " + cumulativeWithdrawPremiumUSD: BigDecimal! + + " All premium paid to enter and exit the protocol. " + cumulativeTotalLiquidityPremiumUSD: BigDecimal! + + " Number of cumulative unique users " + cumulativeUniqueUsers: Int! + + " Number of cumulative depositors " + cumulativeUniqueDepositors: Int! + + " Number of cumulative borrowers " + cumulativeUniqueBorrowers: Int! + + " Number of cumulative liquidators (accounts that performed liquidation) " + cumulativeUniqueLiquidators: Int! + + " Number of cumulative liquidatees (accounts that got liquidated) " + cumulativeUniqueLiquidatees: Int! + + " Notional value of all open long positions " + longOpenInterestUSD: BigDecimal! + + " Notional value of all open short positions " + shortOpenInterestUSD: BigDecimal! + + " Notional value of all open positions " + totalOpenInterestUSD: BigDecimal! + + " Total number of long positions (not cumulative) " + longPositionCount: Int! + + " Total number of short positions (not cumulative) " + shortPositionCount: Int! + + " Total number of open positions (not cumulative) " + openPositionCount: Int! + + " Total number of closed positions " + closedPositionCount: Int! + + " Total number of positions (open and closed) " + cumulativePositionCount: Int! + + " Total number of transactions " + transactionCount: Int! + + " Total number of deposits " + depositCount: Int! + + " Total number of withdrawals " + withdrawCount: Int! + + " Total number of borrows " + borrowCount: Int! + + " Total number of swaps " + swapCount: Int! + + " Total number of collateral In from traders " + collateralInCount: Int! + + " Total number of collateral Out from traders " + collateralOutCount: Int! + + " Total number of pools " + totalPoolCount: Int! + + ##### Snapshots ##### + + " Daily usage metrics for this protocol " + dailyUsageMetrics: [UsageMetricsDailySnapshot!]! + @derivedFrom(field: "protocol") + + " Hourly usage metrics for this protocol " + hourlyUsageMetrics: [UsageMetricsHourlySnapshot!]! + @derivedFrom(field: "protocol") + + " Daily financial metrics for this protocol " + financialMetrics: [FinancialsDailySnapshot!]! @derivedFrom(field: "protocol") + + ##### Pools ##### + + " All pools that belong to this protocol " + pools: [LiquidityPool!]! @derivedFrom(field: "protocol") + + " Day ID of the most recent daily snapshot " + _lastSnapshotDayID: Int + + " Timestamp of the last time this entity was updated " + _lastUpdateTimestamp: BigInt +} + +############################### +##### Protocol Timeseries ##### +############################### + +type UsageMetricsDailySnapshot @entity(immutable: true) { + " ID is # of days since Unix epoch time " + id: Bytes! + + " Number of days since Unix epoch time " + days: Int! + + " Protocol this snapshot is associated with " + protocol: DerivPerpProtocol! + + " Number of unique daily active users " + dailyActiveUsers: Int! + + " Number of cumulative unique users " + cumulativeUniqueUsers: Int! + + " Daily number of long positions " + dailyLongPositionCount: Int! + + " Total number of long positions (not cumulative) " + longPositionCount: Int! + + " Daily number of short positions " + dailyShortPositionCount: Int! + + " Total number of short positions (not cumulative) " + shortPositionCount: Int! + + " Daily number of open positions " + dailyOpenPositionCount: Int! + + " Total number of open positions (not cumulative) " + openPositionCount: Int! + + " Daily number of closed positions " + dailyClosedPositionCount: Int! + + " Total number of closed positions " + closedPositionCount: Int! + + " Daily number of positions (open and closed) " + dailyCumulativePositionCount: Int! + + " Total number of positions (open and closed) " + cumulativePositionCount: Int! + + " Daily number of transactions. Transactions include all entities that implement the Event interface. " + dailyTransactionCount: Int! + + " Daily number of deposits (add liquidity) " + dailyDepositCount: Int! + + " Daily number of withdrawals (remove liquidity) " + dailyWithdrawCount: Int! + + " Daily number of borrows for leverage " + dailyBorrowCount: Int! + + " Daily number of trades (swaps) " + dailySwapCount: Int! + + " Number of unique daily depositors " + dailyActiveDepositors: Int! + + " Number of cumulative depositors " + cumulativeUniqueDepositors: Int! + + " Number of unique daily borrowers " + dailyActiveBorrowers: Int! + + " Number of cumulative borrowers " + cumulativeUniqueBorrowers: Int! + + " Number of unique daily liquidators (accounts that performed liquidation) " + dailyActiveLiquidators: Int! + + " Number of cumulative liquidators (accounts that performed liquidation) " + cumulativeUniqueLiquidators: Int! + + " Number of unique daily liquidatees (accounts that got liquidated) " + dailyActiveLiquidatees: Int! + + " Number of cumulative liquidatees (accounts that got liquidated) " + cumulativeUniqueLiquidatees: Int! + + " Daily number of collateral In from traders " + dailyCollateralIn: Int! + + " Cumulative number of collateral In from traders " + cumulativeCollateralIn: Int! + + " Daily number of collateral Out from traders " + dailyCollateralOut: Int! + + " Cumulative number of collateral Out from traders " + cumulativeCollateralOut: Int! + + " Total number of pools " + totalPoolCount: Int! +} + +type UsageMetricsHourlySnapshot @entity(immutable: true) { + " { # of hours since Unix epoch time } " + id: Bytes! + + " Number of hours since Unix epoch time " + hours: Int! + + " Protocol this snapshot is associated with " + protocol: DerivPerpProtocol! + + " Number of unique hourly active users " + hourlyActiveUsers: Int! + + " Number of cumulative unique users " + cumulativeUniqueUsers: Int! + + " Total number of transactions occurred in an hour. Transactions include all entities that implement the Event interface. " + hourlyTransactionCount: Int! + + " Total number of deposits (add liquidity) in an hour " + hourlyDepositCount: Int! + + " Total number of withdrawals (remove liquidity) in an hour " + hourlyWithdrawCount: Int! + + " Total number of borrows (for additional leverage) in an hour " + hourlyBorrowCount: Int! + + " Total number of trades (swaps) in an hour " + hourlySwapCount: Int! +} + +type _TempUsageMetricsDailySnapshot @entity { + " ID is # of days since Unix epoch time " + id: Bytes! + + " Number of days since Unix epoch time " + days: Int! + + " Protocol this snapshot is associated with " + protocol: DerivPerpProtocol! + + " Daily number of long positions " + dailyLongPositionCount: Int! + + " Daily number of short positions " + dailyShortPositionCount: Int! + + " Daily number of open positions " + dailyOpenPositionCount: Int! + + " Daily number of closed positions " + dailyClosedPositionCount: Int! + + " Daily number of positions (open and closed) " + dailyCumulativePositionCount: Int! + + " Number of unique daily active users " + dailyActiveUsers: Int! + + " Daily number of transactions . Transactions include all entities that implement the Event interface. " + dailyTransactionCount: Int! + + " Daily number of deposits (add liquidity) " + dailyDepositCount: Int! + + " Daily number of withdrawals (remove liquidity) " + dailyWithdrawCount: Int! + + " Daily number of borrows for leverage " + dailyBorrowCount: Int! + + " Daily number of trades (swaps) " + dailySwapCount: Int! + + " Number of unique daily depositors " + dailyActiveDepositors: Int! + + " Number of unique daily borrowers " + dailyActiveBorrowers: Int! + + " Number of unique daily liquidators (accounts that performed liquidation) " + dailyActiveLiquidators: Int! + + " Number of unique daily liquidatees (accounts that got liquidated) " + dailyActiveLiquidatees: Int! + + " Daily number of collateral In from traders " + dailyCollateralIn: Int! + + " Daily number of collateral Out from traders " + dailyCollateralOut: Int! +} + +type _TempUsageMetricsHourlySnapshot @entity { + " { # of hours since Unix epoch time } " + id: Bytes! + + " Number of hours since Unix epoch time " + hours: Int! + + " Protocol this snapshot is associated with " + protocol: DerivPerpProtocol! + + " Number of unique hourly active users " + hourlyActiveUsers: Int! + + " Total number of transactions occurred in an hour. Transactions include all entities that implement the Event interface. " + hourlyTransactionCount: Int! + + " Total number of deposits (add liquidity) in an hour " + hourlyDepositCount: Int! + + " Total number of withdrawals (remove liquidity) in an hour " + hourlyWithdrawCount: Int! + + " Total number of borrows (for additional leverage) in an hour " + hourlyBorrowCount: Int! + + " Total number of trades (swaps) in an hour " + hourlySwapCount: Int! +} + +type FinancialsDailySnapshot @entity(immutable: true) { + " ID is # of days since Unix epoch time " + id: Bytes! + + " Number of days since Unix epoch time " + days: Int! + + " Protocol this snapshot is associated with " + protocol: DerivPerpProtocol! + + " Current TVL (Total Value Locked) of the entire protocol " + totalValueLockedUSD: BigDecimal! + + " Current PCV (Protocol Controlled Value). Only relevant for protocols with PCV. " + protocolControlledValueUSD: BigDecimal + + " Daily trade Notional volume, in USD " + dailyVolumeUSD: BigDecimal! + + " All historical trade Notional volume in USD " + cumulativeVolumeUSD: BigDecimal! + + " Daily Inflow trade Notional volume, in USD, based on value of underlying assets coming into protocol at the time of position open " + dailyInflowVolumeUSD: BigDecimal! + + " Inflow historical trade Notional volume in USD, based on value of underlying assets coming into protocol from trade at the time of position open " + cumulativeInflowVolumeUSD: BigDecimal! + + " Daily Inflow trade Notional volume, in USD, based on value of underlying assets coming into protocol at the time of position Closed " + dailyClosedInflowVolumeUSD: BigDecimal! + + " Inflow historical trade Notional volume in USD, based on value of underlying assets coming into protocol from trade at the time of position closed " + cumulativeClosedInflowVolumeUSD: BigDecimal! + + " Daily Outflow trade Notional volume, in USD, based on value of underlying assets coming out of protocol from trade " + dailyOutflowVolumeUSD: BigDecimal! + + " Outflow historical trade Notional volume in USD, based on value of underlying assets coming out of protocol from trade " + cumulativeOutflowVolumeUSD: BigDecimal! + + " Daily notional value of all open long positions " + dailyLongOpenInterestUSD: BigDecimal! + + " Daily notional value of all open short positions " + dailyShortOpenInterestUSD: BigDecimal! + + " Daily notional value of all open positions " + dailyTotalOpenInterestUSD: BigDecimal! + + " Daily 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! + + " Daily 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! + + " Daily revenue for the stakers (this is defined as recieving a share of revenue or tokens equal to share e.g. buying eth with DAI revenue). Examples: GMX 15% of trade fees goes to stakers " + dailyStakeSideRevenueUSD: BigDecimal! + + " Gross revenue for the stakers (this is defined as recieving a share of revenue or tokens equal to share e.g. buying eth with DAI revenue). Examples: GMX 15% of trade fees goes to stakers " + cumulativeStakeSideRevenueUSD: BigDecimal! + + " Daily 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! + + " Daily premium paid to enter a position. " + dailyEntryPremiumUSD: BigDecimal! + + " All premium paid to enter a position. " + cumulativeEntryPremiumUSD: BigDecimal! + + " Daily premium paid to exit a position. " + dailyExitPremiumUSD: BigDecimal! + + " All premium paid to exit a position. " + cumulativeExitPremiumUSD: BigDecimal! + + " Daily premium paid. " + dailyTotalPremiumUSD: BigDecimal! + + " All premium paid. " + cumulativeTotalPremiumUSD: BigDecimal! + + " Daily premium paid to deposit in liquidity pools. " + dailyDepositPremiumUSD: BigDecimal! + + " All premium paid to deposit in liquidity pools. " + cumulativeDepositPremiumUSD: BigDecimal! + + " Daily premium paid to withdraw from liquidity pools. " + dailyWithdrawPremiumUSD: BigDecimal! + + " All premium paid to withdraw from liquidity pools. " + cumulativeWithdrawPremiumUSD: BigDecimal! + + " Daily premium paid to enter and exit liquidity pool. " + dailyTotalLiquidityPremiumUSD: BigDecimal! + + " All premium paid to enter and exit liquidity pool. " + cumulativeTotalLiquidityPremiumUSD: BigDecimal! +} + +############################### +##### Pool-Level Metadata ##### +############################### + +type LiquidityPool @entity { + " Smart contract address of the pool " + id: Bytes! + + " The protocol this pool belongs to " + protocol: DerivPerpProtocol! + + " Name of liquidity pool (e.g. Curve.fi DAI/USDC/USDT) " + name: String + + " Symbol of liquidity pool (e.g. 3CRV) " + symbol: String + + " 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!]! + + " Token that is minted to track ownership of position in protocol " + outputToken: Token + + " Additional tokens that are given as reward for position in a protocol, usually in liquidity mining programs. e.g. SUSHI in the Onsen program, MATIC for Aave Polygon, usually in liquidity mining programs. e.g. SUSHI in the Onsen program, MATIC for Aave Polygon " + rewardTokens: [RewardToken!] + + " Fees per trade incurred to the user. Should include all fees that apply to a pool (e.g. Curve has a trading fee AND an admin fee, which is a portion of the trading fee. Uniswap only has a trading fee and no protocol fee. ) " + fees: [LiquidityPoolFee!]! + + " Name of oracle source (e.g. chainlink, uniswap, pyth) " + oracle: String + + " Creation timestamp " + createdTimestamp: BigInt! + + " Creation block number " + createdBlockNumber: BigInt! + + ##### Quantitative Data ##### + + " Current TVL (Total Value Locked) of this pool in USD " + totalValueLockedUSD: BigDecimal! + + " All funding rates for this liquidity pool. (Should be in APR format and the same order as inputTokens) " + fundingrate: [BigDecimal!]! + + " All revenue generated by the liquidity pool, accrued to the supply side. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " All revenue generated by the liquidity pool, accrued to the protocol. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " All revenue generated by the liquidity pool. " + cumulativeTotalRevenueUSD: BigDecimal! + + " All premium paid to enter a position. " + cumulativeEntryPremiumUSD: BigDecimal! + + " All premium paid to exit a position. " + cumulativeExitPremiumUSD: BigDecimal! + + " All premium paid. " + cumulativeTotalPremiumUSD: BigDecimal! + + " All premium paid to deposit in liquidity pools. " + cumulativeDepositPremiumUSD: BigDecimal! + + " All premium paid to withdraw from liquidity pools. " + cumulativeWithdrawPremiumUSD: BigDecimal! + + " All premium paid to enter and exit liquidity pool. " + cumulativeTotalLiquidityPremiumUSD: BigDecimal! + + " Number of cumulative unique users in this pool " + cumulativeUniqueUsers: Int! + + " Number of cumulative depositors in this pool " + cumulativeUniqueDepositors: Int! + + " Number of cumulative borrowers " + cumulativeUniqueBorrowers: Int! + + " Number of cumulative liquidators (accounts that performed liquidation) " + cumulativeUniqueLiquidators: Int! + + " Number of cumulative liquidatees (accounts that got liquidated) " + cumulativeUniqueLiquidatees: Int! + + " Notional value of all open long positions " + longOpenInterestUSD: BigDecimal! + + " Notional value of all open short positions " + shortOpenInterestUSD: BigDecimal! + + " Notional value of all open positions " + totalOpenInterestUSD: BigDecimal! + + " Total number of long positions (not cumulative) " + longPositionCount: Int! + + " Total number of short positions (not cumulative) " + shortPositionCount: Int! + + " Total number of open positions (not cumulative) " + openPositionCount: Int! + + " Total number of closed positions " + closedPositionCount: Int! + + " Total number of positions (open and closed) " + cumulativePositionCount: Int! + + " All historical trade notional volume occurred in this pool, in USD " + cumulativeVolumeUSD: BigDecimal! + + " Trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeVolumeByTokenAmount: [BigInt!]! + + " Trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeVolumeByTokenUSD: [BigDecimal!]! + + " Inflow historical trade notional volume occurred in this pool, in USD, based on value of underlying assets coming into protocol from trade, at the time of position opened. " + cumulativeInflowVolumeUSD: BigDecimal! + + " Inflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeInflowVolumeByTokenAmount: [BigInt!]! + + " Inflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeInflowVolumeByTokenUSD: [BigDecimal!]! + + " Inflow historical trade notional volume occurred in this pool, in USD, based on value of underlying assets coming into protocol from trade, at the time of position closed. " + cumulativeClosedInflowVolumeUSD: BigDecimal! + + " Inflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position closed The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeClosedInflowVolumeByTokenAmount: [BigInt!]! + + " Inflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position closed. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeClosedInflowVolumeByTokenUSD: [BigDecimal!]! + + " Outflow historical trade notional volume occurred in this pool, in USD, based on value of underlying assets coming outof protocol from trade. " + cumulativeOutflowVolumeUSD: BigDecimal! + + " Outflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeOutflowVolumeByTokenAmount: [BigInt!]! + + " Outflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeOutflowVolumeByTokenUSD: [BigDecimal!]! + + " Amount of input tokens in the pool. The ordering should be the same as the pool's `inputTokens` field. " + inputTokenBalances: [BigInt!]! + + " Weights of input tokens in the liquidity pool in percentage values. For example, 50/50 for Uniswap pools, 48.2/51.8 for a Curve pool, 10/10/80 for a Balancer pool " + inputTokenWeights: [BigDecimal!]! + + " Total supply of output token. Note that certain DEXes don't have an output token (e.g. Bancor) " + outputTokenSupply: BigInt + + " Price per share of output token in USD " + outputTokenPriceUSD: BigDecimal + + " Total supply of output tokens that are staked (usually in the MasterChef contract). Used to calculate reward APY. " + stakedOutputTokenAmount: BigInt + + " Per-block reward token emission as of the current block normalized to a day, in token's native amount. This should be ideally calculated as the theoretical rate instead of the realized amount. " + rewardTokenEmissionsAmount: [BigInt!] + + " Per-block reward token emission as of the current block normalized to a day, in USD value. This should be ideally calculated as the theoretical rate instead of the realized amount. " + rewardTokenEmissionsUSD: [BigDecimal!] + + ##### Snapshots ##### + + " Liquidity pool daily snapshots " + dailySnapshots: [LiquidityPoolDailySnapshot!]! @derivedFrom(field: "pool") + + " Liquidity pool hourly snapshots " + hourlySnapshots: [LiquidityPoolHourlySnapshot!]! @derivedFrom(field: "pool") + + ##### Events ##### + + " All deposit (add liquidity) events occurred in this pool " + deposits: [Deposit!]! @derivedFrom(field: "pool") + + " All withdraw (remove liquidity) events occurred in this pool " + withdraws: [Withdraw!]! @derivedFrom(field: "pool") + + " All trade (swap) events occurred in this pool " + swaps: [Swap!]! @derivedFrom(field: "pool") + + " Day ID of the most recent daily snapshot " + _lastSnapshotDayID: Int + + " Hour ID of the most recent hourly snapshot " + _lastSnapshotHourID: Int + + " Timestamp of the last time this entity was updated " + _lastUpdateTimestamp: BigInt +} + +################################# +##### Pool-Level Timeseries ##### +################################# + +type LiquidityPoolDailySnapshot @entity(immutable: true) { + " { Smart contract address of the pool }-{ # of days since Unix epoch time } " + id: Bytes! + + " Number of days since Unix epoch time " + days: Int! + + " The protocol this snapshot belongs to " + protocol: DerivPerpProtocol! + + " The pool this snapshot belongs to " + pool: LiquidityPool! + + ##### Quantitative Data ##### + + " Current TVL (Total Value Locked) of this pool " + totalValueLockedUSD: BigDecimal! + + " All revenue generated by the liquidity pool, accrued to the supply side. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " Daily revenue generated by the liquidity pool, accrued to the supply side. " + dailySupplySideRevenueUSD: BigDecimal! + + " All revenue generated by the liquidity pool, accrued to the protocol. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " Daily revenue generated by the liquidity pool, accrued to the protocol. " + dailyProtocolSideRevenueUSD: BigDecimal! + + " Daily revenue generated by the liquidity pool. " + dailyTotalRevenueUSD: BigDecimal! + + " All revenue generated by the liquidity pool. " + cumulativeTotalRevenueUSD: BigDecimal! + + " Daily funding rate based on rate given by protocol, inform us if this is not provided." + dailyFundingrate: [BigDecimal!]! + + " Daily notional value of all open long positions " + dailyLongOpenInterestUSD: BigDecimal! + + " Daily notional value of all open short positions " + dailyShortOpenInterestUSD: BigDecimal! + + " Daily notional value of all open positions " + dailyTotalOpenInterestUSD: BigDecimal! + + " Daily premium paid to enter a position. " + dailyEntryPremiumUSD: BigDecimal! + + " All premium paid to enter a position. " + cumulativeEntryPremiumUSD: BigDecimal! + + " Daily premium paid to exit a position. " + dailyExitPremiumUSD: BigDecimal! + + " All premium paid to exit a position. " + cumulativeExitPremiumUSD: BigDecimal! + + " Daily premium paid. " + dailyTotalPremiumUSD: BigDecimal! + + " All premium paid. " + cumulativeTotalPremiumUSD: BigDecimal! + + " Daily premium paid to deposit in liquidity pools. " + dailyDepositPremiumUSD: BigDecimal! + + " All premium paid to deposit in liquidity pools. " + cumulativeDepositPremiumUSD: BigDecimal! + + " Daily premium paid to withdraw from liquidity pools. " + dailyWithdrawPremiumUSD: BigDecimal! + + " All premium paid to withdraw from liquidity pools. " + cumulativeWithdrawPremiumUSD: BigDecimal! + + " Daily premium paid to enter and exit liquidity pool. " + dailyTotalLiquidityPremiumUSD: BigDecimal! + + " All premium paid to enter and exit liquidity pool. " + cumulativeTotalLiquidityPremiumUSD: BigDecimal! + + " Number of unique daily users " + dailyActiveUsers: Int! + + " Number of cumulative users " + _cumulativeUniqueUsers: Int! + + " Number of unique daily depositors " + dailyActiveDepositors: Int! + + " Number of cumulative depositors " + _cumulativeUniqueDepositors: Int! + + " Number of unique daily borrowers " + dailyActiveBorrowers: Int! + + " Number of cumulative borrowers " + cumulativeUniqueBorrowers: Int! + + " Number of unique daily liquidators (accounts that performed liquidation) " + dailyActiveLiquidators: Int! + + " Number of cumulative liquidators (accounts that performed liquidation) " + cumulativeUniqueLiquidators: Int! + + " Number of unique daily liquidatees (accounts that got liquidated) " + dailyActiveLiquidatees: Int! + + " Number of cumulative liquidatees (accounts that got liquidated) " + cumulativeUniqueLiquidatees: Int! + + " Daily number of long positions " + dailyLongPositionCount: Int! + + " Total number of long positions (not cumulative) " + longPositionCount: Int! + + " Daily number of short positions " + dailyShortPositionCount: Int! + + " Total number of short positions (not cumulative) " + shortPositionCount: Int! + + " Daily number of open positions " + dailyOpenPositionCount: Int! + + " Total number of open positions (not cumulative) " + openPositionCount: Int! + + " Daily number of closed positions " + dailyClosedPositionCount: Int! + + " Total number of closed positions " + closedPositionCount: Int! + + " Daily number of positions (open and closed) " + dailyCumulativePositionCount: Int! + + " Total number of positions (open and closed) " + cumulativePositionCount: Int! + + " Daily trade notional volume occurred in USD " + dailyVolumeUSD: BigDecimal! + + " Daily trade notional volume for a specific input token, in native amount. The ordering should be the same as the pool's `inputTokens` field. " + dailyVolumeByTokenAmount: [BigInt!]! + + " Daily trade notional volume for a specific input token, in USD. The ordering should be the same as the pool's `inputTokens` field. " + dailyVolumeByTokenUSD: [BigDecimal!]! + + " All historical trade notional volume occurred in this pool, in USD " + cumulativeVolumeUSD: BigDecimal! + + " Daily Inflow trade notional volume in this pool, in USD, based on value of underlying assets coming into protocol from trade, at time of position open" + dailyInflowVolumeUSD: BigDecimal! + + " Daily Inflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + dailyInflowVolumeByTokenAmount: [BigInt!]! + + " Daily Inflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + dailyInflowVolumeByTokenUSD: [BigDecimal!]! + + " Inflow historical trade notional volume occurred in this pool, in USD, based on value of underlying assets coming into protocol from trade, at the time of position open. " + cumulativeInflowVolumeUSD: BigDecimal! + + " Daily Inflow trade notional volume in this pool, in USD, based on value of underlying assets coming into protocol from trade, at time of position closed" + dailyClosedInflowVolumeUSD: BigDecimal! + + " Daily Inflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position closed The ordering should be the same as the pool's `inputTokens` field. " + dailyClosedInflowVolumeByTokenAmount: [BigInt!]! + + " Daily Inflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position closed. The ordering should be the same as the pool's `inputTokens` field. " + dailyClosedInflowVolumeByTokenUSD: [BigDecimal!]! + + " Inflow historical trade notional volume occurred in this pool, in USD, based on value of underlying assets coming into protocol from trade, at the time of position closed. " + cumulativeClosedInflowVolumeUSD: BigDecimal! + + " Daily Outflow trade notional volume occurred in this pool in USD, based on value of underlying assets coming out of protocol from trade " + dailyOutflowVolumeUSD: BigDecimal! + + " Daily Outflow trade notional volume occurred in this pool for a specific input token, in native amount. The ordering should be the same as the pool's `inputTokens` field. " + dailyOutflowVolumeByTokenAmount: [BigInt!]! + + " Daily Outflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming out of protocol from trade. The ordering should be the same as the pool's `inputTokens` field. " + dailyOutflowVolumeByTokenUSD: [BigDecimal!]! + + " Outflow historical trade notional volume occurred in this pool, in USD, based on value of underlying assets coming outof protocol from trade. " + cumulativeOutflowVolumeUSD: BigDecimal! + + " Trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeVolumeByTokenAmount: [BigInt!]! + + " Trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeVolumeByTokenUSD: [BigDecimal!]! + + " Inflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeInflowVolumeByTokenAmount: [BigInt!]! + + " Inflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeInflowVolumeByTokenUSD: [BigDecimal!]! + + " Inflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position closed The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeClosedInflowVolumeByTokenAmount: [BigInt!]! + + " Inflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position closed. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeClosedInflowVolumeByTokenUSD: [BigDecimal!]! + + " Outflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeOutflowVolumeByTokenAmount: [BigInt!]! + + " Outflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeOutflowVolumeByTokenUSD: [BigDecimal!]! + + " Array to account for multi-asset pools. " + _inputTokens: [Token!]! + + " Amount of input tokens in the pool. The ordering should be the same as the pool's `inputTokens` field. " + inputTokenBalances: [BigInt!]! + + " Weights of input tokens in the liquidity pool in percentage values. For example, 50/50 for Uniswap pools, 48.2/51.8 for a Curve pool, 10/10/80 for a Balancer pool " + inputTokenWeights: [BigDecimal!]! + + " Total supply of output token. Note that certain DEXes don't have an output token (e.g. Bancor) " + outputTokenSupply: BigInt + + " Price per share of output token in USD " + outputTokenPriceUSD: BigDecimal + + " Total supply of output tokens that are staked (usually in the MasterChef contract). Used to calculate reward APY. " + stakedOutputTokenAmount: BigInt + + " Per-block reward token emission as of the current block normalized to a day, in token's native amount. This should be ideally calculated as the theoretical rate instead of the realized amount. " + rewardTokenEmissionsAmount: [BigInt!] + + " Per-block reward token emission as of the current block normalized to a day, in USD value. This should be ideally calculated as the theoretical rate instead of the realized amount. " + rewardTokenEmissionsUSD: [BigDecimal!] +} + +type LiquidityPoolHourlySnapshot @entity(immutable: true) { + " { Smart contract address of the pool }-{ # of hours since Unix epoch time } " + id: Bytes! + + " Number of hours since Unix epoch time " + hours: Int! + + " The protocol this snapshot belongs to " + protocol: DerivPerpProtocol! + + " The pool this snapshot belongs to " + pool: LiquidityPool! + + ##### Quantitative Data ##### + + " Current TVL (Total Value Locked) of this pool " + totalValueLockedUSD: BigDecimal! + + " All revenue generated by the liquidity pool, accrued to the supply side. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " Hourly revenue generated by the liquidity pool, accrued to the supply side. " + hourlySupplySideRevenueUSD: BigDecimal! + + " All revenue generated by the liquidity pool, accrued to the protocol. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " Hourly revenue generated by the liquidity pool, accrued to the protocol. " + hourlyProtocolSideRevenueUSD: BigDecimal! + + " All revenue generated by the liquidity pool. " + cumulativeTotalRevenueUSD: BigDecimal! + + " Hourly revenue generated by the liquidity pool. " + hourlyTotalRevenueUSD: BigDecimal! + + " Hourly funding rate based on rate given by protocol, inform us if this is not provided." + hourlyFundingrate: [BigDecimal!]! + + " Hourly notional value of all open long positions " + hourlyLongOpenInterestUSD: BigDecimal! + + " Hourly notional value of all open short positions " + hourlyShortOpenInterestUSD: BigDecimal! + + " Hourly notional value of all open positions " + hourlyTotalOpenInterestUSD: BigDecimal! + + " All premium paid to enter a position. " + hourlyEntryPremiumUSD: BigDecimal! + + " All premium paid to enter a position. " + cumulativeEntryPremiumUSD: BigDecimal! + + " Hourly premium paid to exit a position. " + hourlyExitPremiumUSD: BigDecimal! + + " All premium paid to exit a position. " + cumulativeExitPremiumUSD: BigDecimal! + + " Hourly premium paid. " + hourlyTotalPremiumUSD: BigDecimal! + + " All premium paid. " + cumulativeTotalPremiumUSD: BigDecimal! + + " Hourly premium paid to deposit in liquidity pools. " + hourlyDepositPremiumUSD: BigDecimal! + + " All premium paid to deposit in liquidity pools. " + cumulativeDepositPremiumUSD: BigDecimal! + + " Hourly premium paid to withdraw from liquidity pools. " + hourlyWithdrawPremiumUSD: BigDecimal! + + " All premium paid to withdraw from liquidity pools. " + cumulativeWithdrawPremiumUSD: BigDecimal! + + " Hourly premium paid to enter and exit liquidity pool. " + hourlyTotalLiquidityPremiumUSD: BigDecimal! + + " All premium paid to enter and exit liquidity pool. " + cumulativeTotalLiquidityPremiumUSD: BigDecimal! + + "Hourly trade volume, in USD " + hourlyVolumeUSD: BigDecimal! + + " Hourly trade volume occurred in this pool for a specific input token, in native amount. The ordering should be the same as the pool's `inputTokens` field. " + hourlyVolumeByTokenAmount: [BigInt!]! + + " Hourly trade volume occurred in this pool for a specific input token, in USD. The ordering should be the same as the pool's `inputTokens` field. " + hourlyVolumeByTokenUSD: [BigDecimal!]! + + " All historical trade volume occurred in this pool, in USD " + cumulativeVolumeUSD: BigDecimal! + + " Hourly Inflow trade notional volume, in USD, at time position open. " + hourlyInflowVolumeUSD: BigDecimal! + + " Hourly Inflow trade notional volume occurred in this pool for a specific input token, in native amount, at time position open. The ordering should be the same as the pool's `inputTokens` field. " + hourlyInflowVolumeByTokenAmount: [BigInt!]! + + " Hourly Inflow trade notional volume occurred in in this pool for a specific input token, in USD, at time position open. The ordering should be the same as the pool's `inputTokens` field. " + hourlyInflowVolumeByTokenUSD: [BigDecimal!]! + + " Inflow historical trade notional volume occurred in this pool, in USD, at time position open. " + cumulativeInflowVolumeUSD: BigDecimal! + + " Hourly Inflow trade notional volume, in USD, at time position closed. " + hourlyClosedInflowVolumeUSD: BigDecimal! + + " Hourly Inflow trade notional volume occurred in this pool for a specific input token, in native amount, at time position closed. The ordering should be the same as the pool's `inputTokens` field. " + hourlyClosedInflowVolumeByTokenAmount: [BigInt!]! + + " Hourly Inflow trade notional volume occurred in in this pool for a specific input token, in USD, at time position closed. The ordering should be the same as the pool's `inputTokens` field. " + hourlyClosedInflowVolumeByTokenUSD: [BigDecimal!]! + + " Inflow historical trade notional volume occurred in this pool, in USD, at time position closed. " + cumulativeClosedInflowVolumeUSD: BigDecimal! + + " Hourly Outflow trade notional volume occurred in this pool, in USD " + hourlyOutflowVolumeUSD: BigDecimal! + + " Hourly Outflow trade notional volume occurred in this pool for a specific input token, in native amount. The ordering should be the same as the pool's `inputTokens` field. " + hourlyOutflowVolumeByTokenAmount: [BigInt!]! + + " Hourly Outflow trade notional volume occurred in this pool for a specific input token, in USD. The ordering should be the same as the pool's `inputTokens` field. " + hourlyOutflowVolumeByTokenUSD: [BigDecimal!]! + + " Outflow historical trade notional volume occurred in this pool, in USD " + cumulativeOutflowVolumeUSD: BigDecimal! + + " Trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeVolumeByTokenAmount: [BigInt!]! + + " Trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeVolumeByTokenUSD: [BigDecimal!]! + + " Inflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeInflowVolumeByTokenAmount: [BigInt!]! + + " Inflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeInflowVolumeByTokenUSD: [BigDecimal!]! + + " Inflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position closed The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeClosedInflowVolumeByTokenAmount: [BigInt!]! + + " Inflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position closed. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeClosedInflowVolumeByTokenUSD: [BigDecimal!]! + + " Outflow trade notional volume occurred in in this pool for a specific input token, in native amount, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeOutflowVolumeByTokenAmount: [BigInt!]! + + " Outflow trade notional volume occurred in this pool for a specific input token, in USD, based on value of underlying assets coming into protocol from trade, at time of position open. The ordering should be the same as the pool's `inputTokens` field. " + _cumulativeOutflowVolumeByTokenUSD: [BigDecimal!]! + + " Array to account for multi-asset pools. " + _inputTokens: [Token!]! + + " Amount of input tokens in the pool. The ordering should be the same as the pool's `inputTokens` field. " + inputTokenBalances: [BigInt!]! + + " Weights of input tokens in the liquidity pool in percentage values. For example, 50/50 for Uniswap pools, 48.2/51.8 for a Curve pool, 10/10/80 for a Balancer pool " + inputTokenWeights: [BigDecimal!]! + + " Total supply of output token. Note that certain DEXes don't have an output token (e.g. Bancor) " + outputTokenSupply: BigInt + + " Price per share of output token in USD " + outputTokenPriceUSD: BigDecimal + + " Total supply of output tokens that are staked (usually in the MasterChef contract). Used to calculate reward APY. " + stakedOutputTokenAmount: BigInt + + " Per-block reward token emission as of the current block normalized to a day (not hour), in token's native amount. This should be ideally calculated as the theoretical rate instead of the realized amount. " + rewardTokenEmissionsAmount: [BigInt!] + + " Per-block reward token emission as of the current block normalized to a day (not hour), in USD value. This should be ideally calculated as the theoretical rate instead of the realized amount. " + rewardTokenEmissionsUSD: [BigDecimal!] +} + +################################## +##### Transaction-Level Data ##### +################################## + +""" +An event is any user action that occurs in a protocol. Generally, they are Ethereum events +emitted by a function in the smart contracts, stored in transaction receipts as event logs. +However, some user actions of interest are function calls that don't emit events. For example, +the deposit and withdraw functions in Yearn do not emit any events. In our subgraphs, we still +store them as events, although they are not technically Ethereum events emitted by smart +contracts. +""" +interface Event { + " { Event type }-{ Transaction hash }-{ Log index } " + id: Bytes! + + " Transaction hash of the transaction that emitted this event " + hash: Bytes! + + " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " + logIndex: Int! + + " The protocol this transaction belongs to " + protocol: DerivPerpProtocol! + + " Address that received the tokens " + to: Bytes! + + " Address that sent the tokens " + from: Bytes! + + " Account that controls this transaction " + account: Account! + + " Block number of this event " + blockNumber: BigInt! + + " Timestamp of this event " + timestamp: BigInt! +} + +"Deposits in liquidity pool" +type Deposit implements Event @entity(immutable: true) { + " deposit-{ Transaction hash }-{ Log index } " + id: Bytes! + + " Transaction hash of the transaction that emitted this event " + hash: Bytes! + + " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " + logIndex: Int! + + " The protocol this transaction belongs to " + protocol: DerivPerpProtocol! + + " Address that received the tokens " + to: Bytes! + + " Address that sent the tokens " + from: Bytes! + + " Account that controls this transaction " + account: Account! + + " Block number of this event " + blockNumber: BigInt! + + " Timestamp of this event " + timestamp: BigInt! + + " Input tokens of the pool. E.g. WETH and USDC to a WETH-USDC pool " + inputTokens: [Token!]! + + " Output token of the pool. E.g. the UNI-LP token " + outputToken: Token + + " Amount of input tokens in the token's native unit " + inputTokenAmounts: [BigInt!]! + + " Amount of output tokens in the token's native unit " + outputTokenAmount: BigInt + + " USD-normalized value of the transaction of the underlying (e.g. sum of tokens deposited into a pool) " + amountUSD: BigDecimal! + + " The pool involving this transaction " + pool: LiquidityPool! +} + +"Withdraw in liquidity pool" +type Withdraw implements Event @entity(immutable: true) { + " withdraw-{ Transaction hash }-{ Log index }" + id: Bytes! + + " Transaction hash of the transaction that emitted this event " + hash: Bytes! + + " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " + logIndex: Int! + + " The protocol this transaction belongs to " + protocol: DerivPerpProtocol! + + " Address that received the tokens " + to: Bytes! + + " Address that sent the tokens " + from: Bytes! + + " Account that controls this transaction " + account: Account! + + " Block number of this event " + blockNumber: BigInt! + + " Timestamp of this event " + timestamp: BigInt! + + " Input tokens of the pool (not input tokens of the event/transaction). E.g. WETH and USDC from a WETH-USDC pool " + inputTokens: [Token!]! + + " Output token of the pool (not output token of the event/transaction). E.g. the UNI-LP token " + outputToken: Token + + " Amount of input tokens in the token's native unit " + inputTokenAmounts: [BigInt!]! + + " Amount of output tokens in the token's native unit " + outputTokenAmount: BigInt + + " USD-normalized value of the transaction of the underlying (e.g. sum of tokens withdrawn from a pool) " + amountUSD: BigDecimal! + + " The pool involving this transaction " + pool: LiquidityPool! +} + +type Borrow implements Event @entity(immutable: true) { + " borrow-{ Transaction hash }-{ Log index }" + id: Bytes! + + " Transaction hash of the transaction that emitted this event " + hash: Bytes! + + " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " + logIndex: Int! + + " The protocol this transaction belongs to " + protocol: DerivPerpProtocol! + + " The position this Borrow belongs to" + position: Position! + + " Address that received the tokens " + to: Bytes! + + " Address that sent the tokens " + from: Bytes! + + " Block number of this event " + blockNumber: BigInt! + + " Timestamp of this event " + timestamp: BigInt! + + " Account that is borrowing " + account: Account! + + " Asset borrowed " + asset: Token! + + " Amount of borrowed in token " + amount: BigInt! + + " Amount of borrowed in USD " + amountUSD: BigDecimal! + + " The pool involving this transaction " + pool: LiquidityPool! +} + +"Collateral In for trading" +type CollateralIn implements Event @entity(immutable: true) { + " collateralIn-{ Transaction hash }-{ Log index } " + id: Bytes! + + " Transaction hash of the transaction that emitted this event " + hash: Bytes! + + " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " + logIndex: Int! + + " The protocol this transaction belongs to " + protocol: DerivPerpProtocol! + + " The position this transaction belongs to as relates to Long or Short but not LP " + position: Position + + " Address that received the tokens " + to: Bytes! + + " Address that sent the tokens " + from: Bytes! + + " Account that controls this transaction " + account: Account! + + " Block number of this event " + blockNumber: BigInt! + + " Timestamp of this event " + timestamp: BigInt! + + " Input tokens of the pool. E.g. WETH and USDC to a WETH-USDC pool " + inputTokens: [Token!]! + + " Output token of the pool. E.g. the UNI-LP token " + outputToken: Token + + " Amount of input tokens in the token's native unit " + inputTokenAmounts: [BigInt!]! + + " Amount of output tokens in the token's native unit " + outputTokenAmount: BigInt + + " USD-normalized value of the transaction of the underlying (e.g. sum of tokens deposited into a pool) " + amountUSD: BigDecimal! + + " The pool involving this transaction " + pool: LiquidityPool! +} + +"Collateral out for trading" +type CollateralOut implements Event @entity(immutable: true) { + " collateralOut-{ Transaction hash }-{ Log index }" + id: Bytes! + + " Transaction hash of the transaction that emitted this event " + hash: Bytes! + + " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " + logIndex: Int! + + " The protocol this transaction belongs to " + protocol: DerivPerpProtocol! + + " The positionthis transaction belongs to as it relates to long or short, but not LP" + position: Position! + + " Address that received the tokens " + to: Bytes! + + " Address that sent the tokens " + from: Bytes! + + " Account that controls this transaction " + account: Account! + + " Block number of this event " + blockNumber: BigInt! + + " Timestamp of this event " + timestamp: BigInt! + + " Input tokens of the pool (not input tokens of the event/transaction). E.g. WETH and USDC from a WETH-USDC pool " + inputTokens: [Token!]! + + " Output token of the pool (not output token of the event/transaction). E.g. the UNI-LP token " + outputToken: Token + + " Amount of input tokens in the token's native unit " + inputTokenAmounts: [BigInt!]! + + " Amount of output tokens in the token's native unit " + outputTokenAmount: BigInt + + " USD-normalized value of the transaction of the underlying (e.g. sum of tokens withdrawn from a pool) " + amountUSD: BigDecimal! + + " The pool involving this transaction " + pool: LiquidityPool! +} + +#This only applies to protocols that have a DEX (e.g. DYDX). +type Swap implements Event @entity(immutable: true) { + " swap-{ Transaction hash }-{ Log index } " + id: Bytes! + + " Transaction hash of the transaction that emitted this event " + hash: Bytes! + + " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " + logIndex: Int! + + " The protocol this transaction belongs to " + protocol: DerivPerpProtocol! + + " Address that received the tokens " + to: Bytes! + + " Address that sent the tokens " + from: Bytes! + + " Account that controls this transaction " + account: Account! + + " Block number of this event " + blockNumber: BigInt! + + " Timestamp of this event " + timestamp: BigInt! + + " Token deposited into pool " + tokenIn: Token! + + " Amount of token deposited into pool in native units " + amountIn: BigInt! + + " Amount of token deposited into pool in USD " + amountInUSD: BigDecimal! + + " Token withdrawn from pool " + tokenOut: Token! + + " Amount of token withdrawn from pool in native units " + amountOut: BigInt! + + " Amount of token withdrawn from pool in USD " + amountOutUSD: BigDecimal! + + " The contract address for the trading pair or pool " + tradingPair: Bytes! + + " The pool involving this transaction " + pool: LiquidityPool! +} + +type Liquidate implements Event @entity(immutable: true) { + " liquidate-{ Transaction hash }-{ Log index }" + id: Bytes! + + " Transaction hash of the transaction that emitted this event " + hash: Bytes! + + " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " + logIndex: Int! + + " The protocol this transaction belongs to " + protocol: DerivPerpProtocol! + + " The position this Liquidate belongs to" + position: Position! + + " Address that received the tokens " + to: Bytes! + + " Address that sent the tokens " + from: Bytes! + + " Account that controls this transaction " + account: Account! + + " Block number of this event " + blockNumber: BigInt! + + " Timestamp of this event " + timestamp: BigInt! + + " Account that carried out the liquidation " + liquidator: Account! + + " Account that got liquidated " + liquidatee: Account! + + " Asset repaid (borrowed) " + asset: Token! + + " Amount of collateral liquidated in native units " + amount: BigInt! + + " Amount of collateral liquidated in USD " + amountUSD: BigDecimal! + + " Amount of profit from liquidation in USD " + profitUSD: BigDecimal! + + " The pool involving this transaction " + pool: LiquidityPool! +} + +# An account is a unique Ethereum address +# Helps to accumulate total unique users +type Account @entity { + " Address of the account " + id: Bytes! + + " All premium paid to enter a position. " + cumulativeEntryPremiumUSD: BigDecimal! + + " All premium paid to exit a position. " + cumulativeExitPremiumUSD: BigDecimal! + + " All premium paid. " + cumulativeTotalPremiumUSD: BigDecimal! + + " All premium paid to deposit in liquidity pools. " + cumulativeDepositPremiumUSD: BigDecimal! + + " All premium paid to withdraw from liquidity pools. " + cumulativeWithdrawPremiumUSD: BigDecimal! + + " All premium paid to enter and exit liquidity pool. " + cumulativeTotalLiquidityPremiumUSD: BigDecimal! + + " All Position events occurred in this account " + positions: [Position!]! @derivedFrom(field: "account") + + " Total number of long positions (not cumulative) " + longPositionCount: Int! + + " Total number of short positions (not cumulative) " + shortPositionCount: Int! + + " Total number of open positions (not cumulative) " + openPositionCount: Int! + + " Total number of closed positions " + closedPositionCount: Int! + + " Total number of liquidations " + cumulativeUniqueLiquidatees: Int! + + " All deposit (add liquidity) events occurred in this account " + deposits: [Deposit!]! @derivedFrom(field: "account") + + " Number of deposits in this account " + depositCount: Int! + + " All withdraw (remove liquidity) events occurred in this account " + withdraws: [Withdraw!]! @derivedFrom(field: "account") + + " Number of withdraws in this account " + withdrawCount: Int! + + " All collateral put into protocol for trading events occurred in this account " + collateralIn: [CollateralIn!]! @derivedFrom(field: "account") + + " Number of times collateral was put into protocol for trading in this account " + collateralInCount: Int! + + " All collateral taken out from trading events occurred in this account " + collateralOut: [CollateralOut!]! @derivedFrom(field: "account") + + " Number of times collateral was taken out from trading in this account " + collateralOutCount: Int! + + " All swaps events occurred in this account " + swaps: [Swap!]! @derivedFrom(field: "account") + + " Number of swaps in this account " + swapCount: Int! + + " All liquidation events where this account was the liquidator " + liquidates: [Liquidate!]! @derivedFrom(field: "liquidator") + + " Number of times this account liquidated a position " + liquidateCount: Int! + + " All liquidation events where this account got liquidated " + liquidations: [Liquidate!]! @derivedFrom(field: "liquidatee") + + " Number of times this account has been liquidated " + liquidationCount: Int! + + " All borrows events occurred in this account " + borrows: [Borrow!]! @derivedFrom(field: "account") + + " Number of borrows this account made " + borrowCount: Int! +} + +# Helper entity for calculating daily/hourly active users +type ActiveAccount @entity(immutable: true) { + " { daily/hourly }-{ Address of the account }-{ Days/hours since Unix epoch } " + id: Bytes! +} + +enum PositionSide { + " Position opened as long " + LONG + + " Position opened as short " + SHORT +} + +# A position is defined as who has what position in the protocol and distribution of longs and shorts at a positional level +type Position @entity { + " { Account address }-{ Pool address }-{ Position Side }-{ Counter } " + id: Bytes! + + " Account that owns this position " + account: Account! + + " The market in which this position was opened " + liquidityPool: LiquidityPool! + + " The asset in which this position was used as collateral " + collateral: Token! + + " The asset in which this position is long or short " + asset: Token! + + " The hash of the transaction that opened this position " + hashOpened: Bytes! + + " The hash of the transaction that closed this position (null if open) " + hashClosed: Bytes + + " Block number of when the position was opened " + blockNumberOpened: BigInt! + + " Block number of when the position was closed (null if open) " + blockNumberClosed: BigInt + + " Timestamp when the position was opened " + timestampOpened: BigInt! + + " Timestamp when the position was closed (null if open) " + timestampClosed: BigInt + + " Side of the position (either long or short) " + side: PositionSide! + + " Funding rate given by protocol at the time of position open, inform us if this is not provided." + fundingrateOpen: BigDecimal! + + " Funding rate given by protocol at the time of position open, inform us if this is not provided." + fundingrateClosed: BigDecimal + + " Multiplier leverage of position e.g. 10X or 2.5X " + leverage: BigDecimal! + + " Notional value of position, in asset units " + balance: BigInt! + + " Notional value of collateral position, in collateral units " + collateralBalance: BigInt! + + " Notional value of position, in USD, at time of open " + balanceUSD: BigDecimal! + + " Notional value of collateral position, in USD " + collateralBalanceUSD: BigDecimal! + + " Notional value of position right before position closed, in USD, only useful at close events. " + closeBalanceUSD: BigDecimal + + " Notional value of collateral position ight before position closed, in USD, only useful at close events " + closeCollateralBalanceUSD: BigDecimal + + " Realised profit and loss in USD at the time of close or event " + realisedPnlUSD: BigDecimal + + " All collateral put into protocol for trading events occurred in this account " + collateralIn: [CollateralIn!]! @derivedFrom(field: "position") + + " Number of collateral in related to this position " + collateralInCount: Int! + + " All collateral taken out from trading events occurred in this account " + collateralOut: [CollateralOut!]! @derivedFrom(field: "position") + + " Number of collateral out related to this position " + collateralOutCount: Int! + + " Liquidation event related to this position (if exists) " + liquidation: Liquidate @derivedFrom(field: "position") + + " Number of liquidations related to this position " + liquidationCount: Int! + + " Helper for this position's Id " + _posId: BigInt + + " Position daily snapshots for open positions " + snapshots: [PositionSnapshot!]! @derivedFrom(field: "position") +} + +type PositionSnapshot @entity(immutable: true) { + " { Position ID }-{ Transaction hash }-{ Log index } " + id: Bytes! + + " Transaction hash of the transaction that triggered this snapshot " + hash: Bytes! + + " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " + logIndex: Int! + + " Nonce of the transaction that triggered this snapshot " + nonce: BigInt! + + "Position this snapshot refers to" + position: Position! + + " Account that owns this position " + account: Account! + + " Funding rate given by protocol at the time of position at snapshot, inform us if this is not provided. " + fundingrate: BigDecimal + + " Notional value of position, in asset units " + balance: BigInt! + + " Notional value of collateral position, in collateral units " + collateralBalance: BigInt! + + " Notional value of position, in USD, at time of open " + balanceUSD: BigDecimal! + + " Notional value of collateral position, in USD " + collateralBalanceUSD: BigDecimal! + + " Realised profit and loss in USD at the time of close or event " + realisedPnlUSD: BigDecimal + + " Block number of this snapshot " + blockNumber: BigInt! + + " Timestamp of this snapshot " + timestamp: BigInt! +} + +# Helper entity to map position key to position id +type _PositionMap @entity { + " Position Key " + id: Bytes! + + " Position id " + positionId: Bytes! +} diff --git a/subgraphs/vela-exchange/src/entities/account.ts b/subgraphs/vela-exchange/src/entities/account.ts new file mode 100644 index 0000000000..0c0b4f29df --- /dev/null +++ b/subgraphs/vela-exchange/src/entities/account.ts @@ -0,0 +1,130 @@ +import { Address, BigDecimal, ethereum } from "@graphprotocol/graph-ts"; +import { Account } from "../../generated/schema"; +import { + incrementPoolUniqueUsers, + incrementPoolUniqueDepositors, + incrementPoolUniqueBorrowers, + incrementPoolUniqueLiquidators, + incrementPoolUniqueLiquidatees, +} from "./pool"; +import { EventType } from "./event"; +import { + BIGDECIMAL_ZERO, + INT_ONE, + INT_ZERO, + PositionSide, +} from "../utils/constants"; + +export function getOrCreateAccount( + event: ethereum.Event, + address: Address +): Account { + let account = Account.load(address); + if (!account) { + account = new Account(address); + account.cumulativeEntryPremiumUSD = BIGDECIMAL_ZERO; + account.cumulativeExitPremiumUSD = BIGDECIMAL_ZERO; + account.cumulativeTotalPremiumUSD = BIGDECIMAL_ZERO; + account.cumulativeDepositPremiumUSD = BIGDECIMAL_ZERO; + account.cumulativeWithdrawPremiumUSD = BIGDECIMAL_ZERO; + account.cumulativeTotalLiquidityPremiumUSD = BIGDECIMAL_ZERO; + + account.longPositionCount = INT_ZERO; + account.shortPositionCount = INT_ZERO; + account.openPositionCount = INT_ZERO; + account.closedPositionCount = INT_ZERO; + account.cumulativeUniqueLiquidatees = INT_ZERO; + + account.depositCount = INT_ZERO; + account.withdrawCount = INT_ZERO; + account.borrowCount = INT_ZERO; + account.collateralInCount = INT_ZERO; + account.collateralOutCount = INT_ZERO; + account.liquidateCount = INT_ZERO; + account.liquidationCount = INT_ZERO; + account.swapCount = INT_ZERO; + + account.save(); + + incrementPoolUniqueUsers(event); + } + return account; +} + +export function incrementAccountOpenPositionCount( + account: Account, + positionSide: string +): void { + if (PositionSide.LONG == positionSide) { + account.longPositionCount += INT_ONE; + } else { + account.shortPositionCount += INT_ONE; + } + account.openPositionCount += INT_ONE; + + account.save(); +} + +export function decrementAccountOpenPositionCount( + account: Account, + positionSide: string +): void { + if (PositionSide.LONG == positionSide) { + account.longPositionCount -= INT_ONE; + } else { + account.shortPositionCount -= INT_ONE; + } + account.openPositionCount -= INT_ONE; + account.closedPositionCount += INT_ONE; + + account.save(); +} + +export function incrementAccountEventCount( + event: ethereum.Event, + account: Account, + eventType: EventType, + sizeUSDDelta: BigDecimal +): void { + switch (eventType) { + case EventType.Deposit: + if (account.depositCount == INT_ZERO) { + incrementPoolUniqueDepositors(event); + } + account.depositCount += INT_ONE; + break; + case EventType.Withdraw: + account.withdrawCount += INT_ONE; + break; + case EventType.CollateralIn: + account.collateralInCount += INT_ONE; + if (sizeUSDDelta > BIGDECIMAL_ZERO) { + if (account.borrowCount == INT_ZERO) { + incrementPoolUniqueBorrowers(event); + } + account.borrowCount += INT_ONE; + } + break; + case EventType.CollateralOut: + account.collateralOutCount += INT_ONE; + break; + case EventType.Liquidate: + if (account.liquidateCount == INT_ZERO) { + incrementPoolUniqueLiquidators(event); + } + account.liquidateCount += INT_ONE; + break; + case EventType.Liquidated: + if (account.liquidationCount == INT_ZERO) { + incrementPoolUniqueLiquidatees(event); + } + account.liquidationCount += INT_ONE; + case EventType.Swap: + account.swapCount += INT_ONE; + break; + default: + break; + } + + account.save(); +} diff --git a/subgraphs/vela-exchange/src/entities/event.ts b/subgraphs/vela-exchange/src/entities/event.ts new file mode 100644 index 0000000000..75db5e4507 --- /dev/null +++ b/subgraphs/vela-exchange/src/entities/event.ts @@ -0,0 +1,314 @@ +import { + BigInt, + Address, + ethereum, + BigDecimal, + Bytes, +} from "@graphprotocol/graph-ts"; +import { + Deposit, + Withdraw, + Swap, + Position, + CollateralIn, + CollateralOut, + Liquidate, + Borrow, +} from "../../generated/schema"; +import { getOrCreateLiquidityPool } from "./pool"; +import { getOrCreateToken } from "./token"; +import { getOrCreateProtocol } from "./protocol"; +import { BIGINT_ZERO } from "../utils/constants"; + +export enum EventType { + Deposit, + Withdraw, + CollateralIn, + CollateralOut, + ClosePosition, + Swap, + Liquidate, + Liquidated, +} + +// Create a Deposit entity and update deposit count on a liquid providing event for the specific pool.. +export function createDeposit( + event: ethereum.Event, + accountAddress: Address, + inputTokenAddress: Address, + inputTokenAmount: BigInt, + inputTokenAmountUSD: BigDecimal, + outputTokenAmount: BigInt +): void { + const pool = getOrCreateLiquidityPool(event); + const protocol = getOrCreateProtocol(); + + const transactionHash = event.transaction.hash; + const logIndexI32 = event.logIndex.toI32(); + const deposit = new Deposit(transactionHash.concatI32(logIndexI32)); + + deposit.hash = transactionHash; + deposit.logIndex = logIndexI32; + deposit.protocol = protocol.id; + deposit.to = pool.id; + deposit.from = accountAddress; + deposit.account = accountAddress; + deposit.blockNumber = event.block.number; + deposit.timestamp = event.block.timestamp; + deposit.inputTokens = pool.inputTokens; + + const inputTokenAmounts = new Array(deposit.inputTokens.length).fill( + BIGINT_ZERO + ); + const inputToken = getOrCreateToken(event, inputTokenAddress); + const inputTokenIndex = deposit.inputTokens.indexOf(inputToken.id); + if (inputTokenIndex >= 0) { + inputTokenAmounts[inputTokenIndex] = inputTokenAmount; + } + deposit.inputTokenAmounts = inputTokenAmounts; + + deposit.outputToken = pool.outputToken; + deposit.outputTokenAmount = outputTokenAmount; + deposit.amountUSD = inputTokenAmountUSD; + deposit.pool = pool.id; + + deposit.save(); +} + +export function createWithdraw( + event: ethereum.Event, + accountAddress: Address, + inputTokenAddress: Address, + inputTokenAmount: BigInt, + inputTokenAmountUSD: BigDecimal, + outputTokenAmount: BigInt +): void { + const pool = getOrCreateLiquidityPool(event); + const protocol = getOrCreateProtocol(); + const transactionHash = event.transaction.hash; + const logIndexI32 = event.logIndex.toI32(); + const withdrawal = new Withdraw(transactionHash.concatI32(logIndexI32)); + + withdrawal.hash = transactionHash; + withdrawal.logIndex = logIndexI32; + withdrawal.protocol = protocol.id; + withdrawal.to = accountAddress; + withdrawal.from = pool.id; + withdrawal.account = accountAddress; + withdrawal.blockNumber = event.block.number; + withdrawal.timestamp = event.block.timestamp; + withdrawal.inputTokens = pool.inputTokens; + + const inputTokenAmounts = new Array( + withdrawal.inputTokens.length + ).fill(BIGINT_ZERO); + const inputToken = getOrCreateToken(event, inputTokenAddress); + const inputTokenIndex = withdrawal.inputTokens.indexOf(inputToken.id); + if (inputTokenIndex >= 0) { + inputTokenAmounts[inputTokenIndex] = inputTokenAmount; + } + withdrawal.inputTokenAmounts = inputTokenAmounts; + + withdrawal.outputToken = pool.outputToken; + withdrawal.outputTokenAmount = outputTokenAmount; + withdrawal.amountUSD = inputTokenAmountUSD; + withdrawal.pool = pool.id; + + withdrawal.save(); +} + +export function createBorrow( + event: ethereum.Event, + accountAddress: Address, + inputTokenAddress: Address, + inputTokenAmount: BigInt, + inputTokenAmountUSD: BigDecimal, + position: Position +): void { + const pool = getOrCreateLiquidityPool(event); + const protocol = getOrCreateProtocol(); + const transactionHash = event.transaction.hash; + const logIndexI32 = event.logIndex.toI32(); + const borrow = new Borrow( + Bytes.fromUTF8("borrow").concat(transactionHash.concatI32(logIndexI32)) + ); + + borrow.hash = transactionHash; + borrow.logIndex = logIndexI32; + borrow.protocol = protocol.id; + borrow.to = pool.id; + borrow.from = accountAddress; + borrow.account = accountAddress; + borrow.position = position.id; + borrow.blockNumber = event.block.number; + borrow.timestamp = event.block.timestamp; + borrow.asset = inputTokenAddress; + borrow.amount = inputTokenAmount; + borrow.amountUSD = inputTokenAmountUSD; + borrow.pool = pool.id; + + borrow.save(); +} + +export function createCollateralIn( + event: ethereum.Event, + accountAddress: Address, + inputTokenAddress: Address, + inputTokenAmount: BigInt, + inputTokenAmountUSD: BigDecimal, + outputTokenAmount: BigInt, + position: Position +): void { + const pool = getOrCreateLiquidityPool(event); + const protocol = getOrCreateProtocol(); + + const transactionHash = event.transaction.hash; + const logIndexI32 = event.logIndex.toI32(); + const collateralIn = new CollateralIn(transactionHash.concatI32(logIndexI32)); + + collateralIn.hash = transactionHash; + collateralIn.logIndex = logIndexI32; + collateralIn.protocol = protocol.id; + collateralIn.to = pool.id; + collateralIn.from = accountAddress; + collateralIn.account = accountAddress; + collateralIn.position = position.id; + collateralIn.blockNumber = event.block.number; + collateralIn.timestamp = event.block.timestamp; + collateralIn.inputTokens = pool.inputTokens; + + const inputTokenAmounts = new Array( + collateralIn.inputTokens.length + ).fill(BIGINT_ZERO); + const inputToken = getOrCreateToken(event, inputTokenAddress); + const inputTokenIndex = collateralIn.inputTokens.indexOf(inputToken.id); + if (inputTokenIndex >= 0) { + inputTokenAmounts[inputTokenIndex] = inputTokenAmount; + } + collateralIn.inputTokenAmounts = inputTokenAmounts; + + collateralIn.outputToken = pool.outputToken; + collateralIn.outputTokenAmount = outputTokenAmount; + collateralIn.amountUSD = inputTokenAmountUSD; + collateralIn.pool = pool.id; + + collateralIn.save(); +} + +export function createCollateralOut( + event: ethereum.Event, + accountAddress: Address, + inputTokenAddress: Address, + inputTokenAmount: BigInt, + inputTokenAmountUSD: BigDecimal, + outputTokenAmount: BigInt, + position: Position +): void { + const pool = getOrCreateLiquidityPool(event); + const protocol = getOrCreateProtocol(); + const transactionHash = event.transaction.hash; + const logIndexI32 = event.logIndex.toI32(); + const collateralOut = new CollateralOut( + transactionHash.concatI32(logIndexI32) + ); + + collateralOut.hash = transactionHash; + collateralOut.logIndex = logIndexI32; + collateralOut.protocol = protocol.id; + collateralOut.to = accountAddress; + collateralOut.from = pool.id; + collateralOut.account = accountAddress; + collateralOut.position = position.id; + collateralOut.blockNumber = event.block.number; + collateralOut.timestamp = event.block.timestamp; + collateralOut.inputTokens = pool.inputTokens; + + const inputTokenAmounts = new Array( + collateralOut.inputTokens.length + ).fill(BIGINT_ZERO); + const inputToken = getOrCreateToken(event, inputTokenAddress); + const inputTokenIndex = collateralOut.inputTokens.indexOf(inputToken.id); + if (inputTokenIndex >= 0) { + inputTokenAmounts[inputTokenIndex] = inputTokenAmount; + } + collateralOut.inputTokenAmounts = inputTokenAmounts; + + collateralOut.outputToken = pool.outputToken; + collateralOut.outputTokenAmount = outputTokenAmount; + collateralOut.amountUSD = inputTokenAmountUSD; + collateralOut.pool = pool.id; + + collateralOut.save(); +} + +export function createLiquidate( + event: ethereum.Event, + asset: Address, + amountLiquidated: BigInt, + amountLiquidatedUSD: BigDecimal, + profitUSD: BigDecimal, + liquidator: Address, + liquidatee: Address, + position: Position +): void { + const pool = getOrCreateLiquidityPool(event); + const protocol = getOrCreateProtocol(); + const transactionHash = event.transaction.hash; + const logIndexI32 = event.logIndex.toI32(); + const liquidate = new Liquidate(transactionHash.concatI32(logIndexI32)); + + liquidate.hash = transactionHash; + liquidate.logIndex = logIndexI32; + liquidate.protocol = protocol.id; + liquidate.position = position.id; + liquidate.to = liquidator; + liquidate.from = liquidatee; + liquidate.account = liquidatee; + liquidate.blockNumber = event.block.number; + liquidate.timestamp = event.block.timestamp; + liquidate.liquidator = liquidator; + liquidate.liquidatee = liquidatee; + liquidate.asset = asset; + liquidate.amount = amountLiquidated; + liquidate.amountUSD = amountLiquidatedUSD; + liquidate.profitUSD = profitUSD; + liquidate.pool = pool.id; + + liquidate.save(); +} + +export function createSwap( + event: ethereum.Event, + accountAddress: Address, + inputTokenAddress: Address, + inputTokenAmount: BigInt, + inputTokenAmountUSD: BigDecimal, + outputTokenAddress: Address, + outputTokenAmount: BigInt, + outputTokenAmountUSD: BigDecimal +): void { + const pool = getOrCreateLiquidityPool(event); + const protocol = getOrCreateProtocol(); + const transactionHash = event.transaction.hash; + const logIndexI32 = event.logIndex.toI32(); + const swap = new Swap(transactionHash.concatI32(logIndexI32)); + + swap.hash = transactionHash; + swap.logIndex = logIndexI32; + swap.protocol = protocol.id; + swap.to = pool.id; + swap.from = accountAddress; + swap.account = accountAddress; + swap.blockNumber = event.block.number; + swap.timestamp = event.block.timestamp; + swap.tokenIn = inputTokenAddress; + swap.amountIn = inputTokenAmount; + swap.amountInUSD = inputTokenAmountUSD; + swap.tokenOut = outputTokenAddress; + swap.amountOut = outputTokenAmount; + swap.amountOutUSD = outputTokenAmountUSD; + swap.tradingPair = pool.id; + swap.pool = pool.id; + + swap.save(); +} diff --git a/subgraphs/vela-exchange/src/entities/pool.ts b/subgraphs/vela-exchange/src/entities/pool.ts new file mode 100644 index 0000000000..cc1680573a --- /dev/null +++ b/subgraphs/vela-exchange/src/entities/pool.ts @@ -0,0 +1,715 @@ +import { + Address, + BigDecimal, + BigInt, + Bytes, + ethereum, + log, +} from "@graphprotocol/graph-ts"; +import { + LiquidityPool, + LiquidityPoolFee, + RewardToken, + Token, +} from "../../generated/schema"; +import { Vault } from "../../generated/Vault/Vault"; +import { EventType } from "./event"; +import { + increaseProtocolVolume, + decrementProtocolOpenPositionCount, + getOrCreateProtocol, + incrementProtocolOpenPositionCount, + updateProtocolTVL, + increaseProtocolPremium, + increaseProtocolSideRevenue, + increaseProtocolSupplySideRevenue, + updateProtocolOpenInterestUSD, + incrementProtocolUniqueUsers, + incrementProtocolUniqueDepositors, + incrementProtocolUniqueBorrowers, + incrementProtocolUniqueLiquidators, + incrementProtocolUniqueLiquidatees, +} from "./protocol"; +import { getOrCreateToken, updateTokenPrice } from "./token"; +import { + BIGDECIMAL_ZERO, + INT_ZERO, + BIGINT_ZERO, + PositionSide, + INT_ONE, + LiquidityPoolFeeType, + POOL_NAME, + POOL_SYMBOL, + INT_NEGATIVE_ONE, + VAULT_ADDRESS, + USDC_ADDRESS_ARBITRUM, + BIGDECIMAL_HUNDRED, + PRICE_PRECISION, +} from "../utils/constants"; +import { convertTokenToDecimal, multiArraySort } from "../utils/numbers"; +import { enumToPrefix } from "../utils/strings"; + +export function getOrCreateLiquidityPool(event: ethereum.Event): LiquidityPool { + const protocol = getOrCreateProtocol(); + const poolAddress = Bytes.fromHexString(VAULT_ADDRESS); + let pool = LiquidityPool.load(poolAddress); + + if (!pool) { + pool = new LiquidityPool(poolAddress); + + // Metadata + pool.protocol = protocol.id; + pool.name = POOL_NAME; + pool.symbol = POOL_SYMBOL; + pool.createdTimestamp = event.block.timestamp; + pool.createdBlockNumber = event.block.number; + + // Tokens + pool.inputTokens = []; + pool.outputToken = null; + pool.rewardTokens = []; + + pool.fees = createPoolFees(poolAddress); + + // Quantitative Revenue Data + pool.totalValueLockedUSD = BIGDECIMAL_ZERO; + pool.cumulativeSupplySideRevenueUSD = BIGDECIMAL_ZERO; + pool.cumulativeProtocolSideRevenueUSD = BIGDECIMAL_ZERO; + pool.cumulativeTotalRevenueUSD = BIGDECIMAL_ZERO; + + pool.cumulativeEntryPremiumUSD = BIGDECIMAL_ZERO; + pool.cumulativeExitPremiumUSD = BIGDECIMAL_ZERO; + pool.cumulativeTotalPremiumUSD = BIGDECIMAL_ZERO; + pool.cumulativeDepositPremiumUSD = BIGDECIMAL_ZERO; + pool.cumulativeWithdrawPremiumUSD = BIGDECIMAL_ZERO; + pool.cumulativeTotalLiquidityPremiumUSD = BIGDECIMAL_ZERO; + + pool.cumulativeUniqueUsers = INT_ZERO; + pool.cumulativeUniqueDepositors = INT_ZERO; + pool.cumulativeUniqueBorrowers = INT_ZERO; + pool.cumulativeUniqueLiquidators = INT_ZERO; + pool.cumulativeUniqueLiquidatees = INT_ZERO; + + pool.longOpenInterestUSD = BIGDECIMAL_ZERO; + pool.shortOpenInterestUSD = BIGDECIMAL_ZERO; + pool.totalOpenInterestUSD = BIGDECIMAL_ZERO; + pool.longPositionCount = INT_ZERO; + pool.shortPositionCount = INT_ZERO; + pool.openPositionCount = INT_ZERO; + pool.closedPositionCount = INT_ZERO; + pool.cumulativePositionCount = INT_ZERO; + + // Quantitative Token Data + pool.inputTokenBalances = []; + pool.inputTokenWeights = []; + pool.outputTokenSupply = BIGINT_ZERO; + pool.outputTokenPriceUSD = BIGDECIMAL_ZERO; + pool.stakedOutputTokenAmount = BIGINT_ZERO; + pool.rewardTokenEmissionsAmount = []; + pool.rewardTokenEmissionsUSD = []; + + pool.cumulativeVolumeUSD = BIGDECIMAL_ZERO; + pool._cumulativeVolumeByTokenAmount = []; + pool._cumulativeVolumeByTokenUSD = []; + pool.cumulativeInflowVolumeUSD = BIGDECIMAL_ZERO; + pool._cumulativeInflowVolumeByTokenAmount = []; + pool._cumulativeInflowVolumeByTokenUSD = []; + pool.cumulativeClosedInflowVolumeUSD = BIGDECIMAL_ZERO; + pool._cumulativeClosedInflowVolumeByTokenAmount = []; + pool._cumulativeClosedInflowVolumeByTokenUSD = []; + pool.cumulativeOutflowVolumeUSD = BIGDECIMAL_ZERO; + pool._cumulativeOutflowVolumeByTokenAmount = []; + pool._cumulativeOutflowVolumeByTokenUSD = []; + + pool.fundingrate = []; + pool.cumulativeUniqueUsers = INT_ZERO; + pool._lastSnapshotDayID = INT_ZERO; + pool._lastSnapshotHourID = INT_ZERO; + pool._lastUpdateTimestamp = BIGINT_ZERO; + + // update number of pools + protocol.totalPoolCount += 1; + protocol.save(); + + pool.save(); + } + + return pool; +} + +export function increasePoolVolume( + event: ethereum.Event, + pool: LiquidityPool, + sizeUSDDelta: BigDecimal, + collateralTokenAddress: Address | null, + collateralTokenAmountDelta: BigInt, + collateralUSDDelta: BigDecimal, + eventType: EventType +): void { + pool.cumulativeVolumeUSD = pool.cumulativeVolumeUSD.plus(sizeUSDDelta); + let collateralTokenIndex = INT_NEGATIVE_ONE; + if (collateralTokenAddress) { + collateralTokenIndex = pool.inputTokens.indexOf(collateralTokenAddress); + } + + switch (eventType) { + case EventType.CollateralIn: + pool.cumulativeInflowVolumeUSD = + pool.cumulativeInflowVolumeUSD.plus(collateralUSDDelta); + + const cumulativeInflowVolumeByTokenAmount = + pool._cumulativeInflowVolumeByTokenAmount; + const cumulativeInflowVolumeByTokenUSD = + pool._cumulativeInflowVolumeByTokenUSD; + if (collateralTokenIndex >= 0) { + cumulativeInflowVolumeByTokenAmount[collateralTokenIndex] = + cumulativeInflowVolumeByTokenAmount[collateralTokenIndex].plus( + collateralTokenAmountDelta + ); + cumulativeInflowVolumeByTokenUSD[collateralTokenIndex] = + cumulativeInflowVolumeByTokenUSD[collateralTokenIndex].plus( + collateralUSDDelta + ); + } + pool._cumulativeInflowVolumeByTokenAmount = + cumulativeInflowVolumeByTokenAmount; + pool._cumulativeInflowVolumeByTokenUSD = cumulativeInflowVolumeByTokenUSD; + + break; + case EventType.CollateralOut: + case EventType.ClosePosition: + pool.cumulativeOutflowVolumeUSD = + pool.cumulativeOutflowVolumeUSD.plus(collateralUSDDelta); + + const cumulativeOutflowVolumeByTokenAmount = + pool._cumulativeOutflowVolumeByTokenAmount; + const cumulativeOutflowVolumeByTokenUSD = + pool._cumulativeOutflowVolumeByTokenUSD; + if (collateralTokenIndex >= 0) { + cumulativeOutflowVolumeByTokenAmount[collateralTokenIndex] = + cumulativeOutflowVolumeByTokenAmount[collateralTokenIndex].plus( + collateralTokenAmountDelta + ); + cumulativeOutflowVolumeByTokenUSD[collateralTokenIndex] = + cumulativeOutflowVolumeByTokenUSD[collateralTokenIndex].plus( + collateralUSDDelta + ); + } + pool._cumulativeOutflowVolumeByTokenAmount = + cumulativeOutflowVolumeByTokenAmount; + pool._cumulativeOutflowVolumeByTokenUSD = + cumulativeOutflowVolumeByTokenUSD; + + break; + case EventType.Liquidated: + pool.cumulativeClosedInflowVolumeUSD = + pool.cumulativeClosedInflowVolumeUSD.plus(collateralUSDDelta); + + const cumulativeClosedInflowVolumeByTokenAmount = + pool._cumulativeClosedInflowVolumeByTokenAmount; + const cumulativeClosedInflowVolumeByTokenUSD = + pool._cumulativeClosedInflowVolumeByTokenUSD; + if (collateralTokenIndex >= 0) { + cumulativeClosedInflowVolumeByTokenAmount[collateralTokenIndex] = + cumulativeClosedInflowVolumeByTokenAmount[collateralTokenIndex].plus( + collateralTokenAmountDelta + ); + cumulativeClosedInflowVolumeByTokenUSD[collateralTokenIndex] = + cumulativeClosedInflowVolumeByTokenUSD[collateralTokenIndex].plus( + collateralUSDDelta + ); + } + pool._cumulativeClosedInflowVolumeByTokenAmount = + cumulativeClosedInflowVolumeByTokenAmount; + pool._cumulativeClosedInflowVolumeByTokenUSD = + cumulativeClosedInflowVolumeByTokenUSD; + + break; + + default: + break; + } + + const cumulativeVolumeByTokenAmount = pool._cumulativeVolumeByTokenAmount; + const cumulativeVolumeByTokenUSD = pool._cumulativeVolumeByTokenUSD; + if (collateralTokenIndex >= 0) { + cumulativeVolumeByTokenAmount[collateralTokenIndex] = + cumulativeVolumeByTokenAmount[collateralTokenIndex].plus( + collateralTokenAmountDelta + ); + cumulativeVolumeByTokenUSD[collateralTokenIndex] = + cumulativeVolumeByTokenUSD[collateralTokenIndex].plus(collateralUSDDelta); + } + pool._cumulativeVolumeByTokenAmount = cumulativeVolumeByTokenAmount; + pool._cumulativeVolumeByTokenUSD = cumulativeVolumeByTokenUSD; + + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + increaseProtocolVolume(event, sizeUSDDelta, collateralUSDDelta, eventType); +} + +export function increasePoolPremium( + event: ethereum.Event, + pool: LiquidityPool, + amountUSD: BigDecimal, + eventType: EventType +): void { + switch (eventType) { + case EventType.Deposit: + pool.cumulativeDepositPremiumUSD = + pool.cumulativeDepositPremiumUSD.plus(amountUSD); + pool.cumulativeTotalLiquidityPremiumUSD = + pool.cumulativeTotalLiquidityPremiumUSD.plus(amountUSD); + break; + case EventType.Withdraw: + pool.cumulativeWithdrawPremiumUSD = + pool.cumulativeWithdrawPremiumUSD.plus(amountUSD); + pool.cumulativeTotalLiquidityPremiumUSD = + pool.cumulativeTotalLiquidityPremiumUSD.plus(amountUSD); + break; + case EventType.CollateralIn: + pool.cumulativeEntryPremiumUSD = + pool.cumulativeEntryPremiumUSD.plus(amountUSD); + pool.cumulativeTotalPremiumUSD = + pool.cumulativeTotalPremiumUSD.plus(amountUSD); + break; + case EventType.CollateralOut: + case EventType.ClosePosition: + pool.cumulativeExitPremiumUSD = + pool.cumulativeExitPremiumUSD.plus(amountUSD); + pool.cumulativeTotalPremiumUSD = + pool.cumulativeTotalPremiumUSD.plus(amountUSD); + break; + + default: + break; + } + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + increaseProtocolPremium(event, amountUSD, eventType); +} + +export function incrementPoolOpenPositionCount( + event: ethereum.Event, + pool: LiquidityPool, + positionSide: string +): void { + if (PositionSide.LONG == positionSide) { + pool.longPositionCount += INT_ONE; + } else { + pool.shortPositionCount += INT_ONE; + } + pool.openPositionCount += INT_ONE; + + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + incrementProtocolOpenPositionCount(event, positionSide); +} + +export function decrementPoolOpenPositionCount( + event: ethereum.Event, + pool: LiquidityPool, + positionSide: string +): void { + if (PositionSide.LONG == positionSide) { + pool.longPositionCount -= INT_ONE; + } else { + pool.shortPositionCount -= INT_ONE; + } + pool.openPositionCount -= INT_ONE; + pool.closedPositionCount += INT_ONE; + + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + decrementProtocolOpenPositionCount(event, positionSide); +} + +export function addPoolInputToken( + event: ethereum.Event, + pool: LiquidityPool, + inputToken: Token +): void { + const inputTokens = pool.inputTokens; + const inputTokenIndex = inputTokens.indexOf(inputToken.id); + if (inputTokenIndex >= 0) { + log.error("Input token exist for {}", [inputToken.name]); + return; + } + + const inputTokenBalances = pool.inputTokenBalances; + const inputTokenWeights = pool.inputTokenWeights; + const fundingrates = pool.fundingrate; + const cumulativeVolumeByTokenAmount = pool._cumulativeVolumeByTokenAmount; + const cumulativeVolumeByTokenUSD = pool._cumulativeVolumeByTokenUSD; + const cumulativeInflowVolumeByTokenAmount = + pool._cumulativeInflowVolumeByTokenAmount; + const cumulativeInflowVolumeByTokenUSD = + pool._cumulativeInflowVolumeByTokenUSD; + const cumulativeClosedInflowVolumeByTokenAmount = + pool._cumulativeClosedInflowVolumeByTokenAmount; + const cumulativeClosedInflowVolumeByTokenUSD = + pool._cumulativeClosedInflowVolumeByTokenUSD; + const cumulativeOutflowVolumeByTokenAmount = + pool._cumulativeOutflowVolumeByTokenAmount; + const cumulativeOutflowVolumeByTokenUSD = + pool._cumulativeOutflowVolumeByTokenUSD; + + inputTokens.push(inputToken.id); + inputTokenBalances.push(BIGINT_ZERO); + fundingrates.push(BIGDECIMAL_ZERO); + inputTokenWeights.push(BIGDECIMAL_HUNDRED); + cumulativeVolumeByTokenAmount.push(BIGINT_ZERO); + cumulativeVolumeByTokenUSD.push(BIGDECIMAL_ZERO); + cumulativeInflowVolumeByTokenAmount.push(BIGINT_ZERO); + cumulativeInflowVolumeByTokenUSD.push(BIGDECIMAL_ZERO); + cumulativeClosedInflowVolumeByTokenAmount.push(BIGINT_ZERO); + cumulativeClosedInflowVolumeByTokenUSD.push(BIGDECIMAL_ZERO); + cumulativeOutflowVolumeByTokenAmount.push(BIGINT_ZERO); + cumulativeOutflowVolumeByTokenUSD.push(BIGDECIMAL_ZERO); + + pool.inputTokens = inputTokens; + pool.inputTokenBalances = inputTokenBalances; + pool.inputTokenWeights = inputTokenWeights; + pool.fundingrate = fundingrates; + pool._cumulativeVolumeByTokenAmount = cumulativeVolumeByTokenAmount; + pool._cumulativeVolumeByTokenUSD = cumulativeVolumeByTokenUSD; + pool._cumulativeInflowVolumeByTokenAmount = + cumulativeInflowVolumeByTokenAmount; + pool._cumulativeInflowVolumeByTokenUSD = cumulativeInflowVolumeByTokenUSD; + pool._cumulativeClosedInflowVolumeByTokenAmount = + cumulativeClosedInflowVolumeByTokenAmount; + pool._cumulativeClosedInflowVolumeByTokenUSD = + cumulativeClosedInflowVolumeByTokenUSD; + pool._cumulativeOutflowVolumeByTokenAmount = + cumulativeOutflowVolumeByTokenAmount; + pool._cumulativeOutflowVolumeByTokenUSD = cumulativeOutflowVolumeByTokenUSD; + + log.error("Input token does not exist for {}", [inputToken.name]); + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); +} + +export function updatePoolOutputToken( + event: ethereum.Event, + pool: LiquidityPool, + outputTokenAddress: Address +): void { + pool.outputToken = getOrCreateToken(event, outputTokenAddress).id; + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); +} + +export function updatePoolTvl( + event: ethereum.Event, + pool: LiquidityPool +): void { + const prevPoolTVL = pool.totalValueLockedUSD; + const vaultContract = Vault.bind(event.address); + const tryTotalUSDC = vaultContract.try_totalUSDC(); + if (!tryTotalUSDC.reverted) { + const inputTokenBalances = pool.inputTokenBalances; + inputTokenBalances[0] = tryTotalUSDC.value; + pool.inputTokenBalances = inputTokenBalances; + const inputToken = getOrCreateToken( + event, + Address.fromString(USDC_ADDRESS_ARBITRUM) + ); + pool.totalValueLockedUSD = tryTotalUSDC.value + .div(PRICE_PRECISION) + .toBigDecimal() + .times(inputToken.lastPriceUSD!); + } + const tvlChangeUSD = pool.totalValueLockedUSD.minus(prevPoolTVL); + + const outputToken = getOrCreateToken( + event, + Address.fromBytes(pool.outputToken!) + ); + const tryTotalVLP = vaultContract.try_totalVLP(); + if (!tryTotalVLP.reverted) { + pool.outputTokenSupply = tryTotalVLP.value; + pool.outputTokenPriceUSD = pool.totalValueLockedUSD.div( + convertTokenToDecimal(pool.outputTokenSupply!, outputToken.decimals) + ); + } + pool.stakedOutputTokenAmount = pool.outputTokenSupply; + + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + updateTokenPrice(event, outputToken, pool.outputTokenPriceUSD!); + + // Protocol + updateProtocolTVL(event, tvlChangeUSD); +} + +export function updatePoolOpenInterestUSD( + event: ethereum.Event, + pool: LiquidityPool, + amountChangeUSD: BigDecimal, + isIncrease: boolean, + isLong: boolean +): void { + if (isIncrease) { + pool.totalOpenInterestUSD = pool.totalOpenInterestUSD.plus(amountChangeUSD); + if (isLong) { + pool.longOpenInterestUSD = pool.longOpenInterestUSD.plus(amountChangeUSD); + } else { + pool.shortOpenInterestUSD = + pool.shortOpenInterestUSD.plus(amountChangeUSD); + } + } else { + pool.totalOpenInterestUSD = + pool.totalOpenInterestUSD.minus(amountChangeUSD); + if (isLong) { + pool.longOpenInterestUSD = + pool.longOpenInterestUSD.minus(amountChangeUSD); + } else { + pool.shortOpenInterestUSD = + pool.shortOpenInterestUSD.minus(amountChangeUSD); + } + } + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + // Protocol + updateProtocolOpenInterestUSD(event, amountChangeUSD, isIncrease, isLong); +} + +export function updatePoolRewardToken( + event: ethereum.Event, + rewardToken: RewardToken, + tokensPerDay: BigInt, + tokensPerDayUSD: BigDecimal +): void { + const pool = getOrCreateLiquidityPool(event); + const rewardTokens = pool.rewardTokens!; + const rewardTokenEmissionsAmount = pool.rewardTokenEmissionsAmount!; + const rewardTokenEmissionsUSD = pool.rewardTokenEmissionsUSD!; + + const rewardTokenIndex = rewardTokens.indexOf(rewardToken.id); + if (rewardTokenIndex >= 0) { + rewardTokenEmissionsAmount[rewardTokenIndex] = tokensPerDay; + rewardTokenEmissionsUSD[rewardTokenIndex] = tokensPerDayUSD; + } else { + rewardTokens.push(rewardToken.id); + rewardTokenEmissionsAmount.push(tokensPerDay); + rewardTokenEmissionsUSD.push(tokensPerDayUSD); + + multiArraySort( + rewardTokens, + rewardTokenEmissionsAmount, + rewardTokenEmissionsUSD + ); + } + pool.rewardTokens = rewardTokens; + pool.rewardTokenEmissionsAmount = rewardTokenEmissionsAmount; + pool.rewardTokenEmissionsUSD = rewardTokenEmissionsUSD; + + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); +} + +export function updatePoolFundingRate( + event: ethereum.Event, + fundingToken: Token, + fundingrate: BigDecimal +): void { + const pool = getOrCreateLiquidityPool(event); + const fundingTokens = pool.inputTokens; + const fundingrates = pool.fundingrate; + const fundingTokenIndex = fundingTokens.indexOf(fundingToken.id); + if (fundingTokenIndex >= 0) { + fundingrates[fundingTokenIndex] = fundingrate; + } + pool.fundingrate = fundingrates; + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); +} + +export function increasePoolProtocolSideRevenue( + event: ethereum.Event, + pool: LiquidityPool, + amountChangeUSD: BigDecimal +): void { + pool.cumulativeProtocolSideRevenueUSD = + pool.cumulativeProtocolSideRevenueUSD.plus(amountChangeUSD); + pool.cumulativeTotalRevenueUSD = + pool.cumulativeTotalRevenueUSD.plus(amountChangeUSD); + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + // Protocol + increaseProtocolSideRevenue(event, amountChangeUSD); +} + +export function increasePoolSupplySideRevenue( + event: ethereum.Event, + pool: LiquidityPool, + amountChangeUSD: BigDecimal +): void { + pool.cumulativeSupplySideRevenueUSD = + pool.cumulativeSupplySideRevenueUSD.plus(amountChangeUSD); + pool.cumulativeTotalRevenueUSD = + pool.cumulativeTotalRevenueUSD.plus(amountChangeUSD); + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + // Protocol + increaseProtocolSupplySideRevenue(event, amountChangeUSD); +} + +export function incrementPoolUniqueUsers(event: ethereum.Event): void { + const pool = getOrCreateLiquidityPool(event); + pool.cumulativeUniqueUsers += INT_ONE; + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + // Protocol + incrementProtocolUniqueUsers(event); +} + +export function incrementPoolUniqueDepositors(event: ethereum.Event): void { + const pool = getOrCreateLiquidityPool(event); + pool.cumulativeUniqueDepositors += INT_ONE; + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + // Protocol + incrementProtocolUniqueDepositors(event); +} + +export function incrementPoolUniqueBorrowers(event: ethereum.Event): void { + const pool = getOrCreateLiquidityPool(event); + pool.cumulativeUniqueBorrowers += INT_ONE; + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + // Protocol + incrementProtocolUniqueBorrowers(event); +} + +export function incrementPoolUniqueLiquidators(event: ethereum.Event): void { + const pool = getOrCreateLiquidityPool(event); + pool.cumulativeUniqueLiquidators += INT_ONE; + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + // Protocol + incrementProtocolUniqueLiquidators(event); +} + +export function incrementPoolUniqueLiquidatees(event: ethereum.Event): void { + const pool = getOrCreateLiquidityPool(event); + pool.cumulativeUniqueLiquidatees += INT_ONE; + pool._lastUpdateTimestamp = event.block.timestamp; + pool.save(); + + // Protocol + incrementProtocolUniqueLiquidatees(event); +} + +export function updatePoolSnapshotDayID( + event: ethereum.Event, + snapshotDayID: i32 +): void { + const pool = getOrCreateLiquidityPool(event); + pool._lastSnapshotDayID = snapshotDayID; + pool.save(); +} + +export function updatePoolSnapshotHourID( + event: ethereum.Event, + snapshotHourID: i32 +): void { + const pool = getOrCreateLiquidityPool(event); + pool._lastSnapshotHourID = snapshotHourID; + pool.save(); +} + +function createPoolFees(poolAddress: Bytes): Bytes[] { + // get or create fee entities, set fee types + const tradingFeeId = Bytes.fromUTF8( + enumToPrefix(LiquidityPoolFeeType.FIXED_TRADING_FEE) + ).concat(poolAddress); + const tradingFee = getOrCreateLiquidityPoolFee( + tradingFeeId, + LiquidityPoolFeeType.FIXED_TRADING_FEE + ); + + const protocolFeeId = Bytes.fromUTF8( + enumToPrefix(LiquidityPoolFeeType.FIXED_PROTOCOL_FEE) + ).concat(poolAddress); + const protocolFee = getOrCreateLiquidityPoolFee( + protocolFeeId, + LiquidityPoolFeeType.FIXED_PROTOCOL_FEE + ); + + const lpFeeId = Bytes.fromUTF8( + enumToPrefix(LiquidityPoolFeeType.FIXED_LP_FEE) + ).concat(poolAddress); + const lpFee = getOrCreateLiquidityPoolFee( + lpFeeId, + LiquidityPoolFeeType.FIXED_LP_FEE + ); + + const stakeFeeId = Bytes.fromUTF8( + enumToPrefix(LiquidityPoolFeeType.FIXED_STAKE_FEE) + ).concat(poolAddress); + const stakeFee = getOrCreateLiquidityPoolFee( + stakeFeeId, + LiquidityPoolFeeType.FIXED_STAKE_FEE + ); + + const depositFeeId = Bytes.fromUTF8( + enumToPrefix(LiquidityPoolFeeType.DEPOSIT_FEE) + ).concat(poolAddress); + const depositFee = getOrCreateLiquidityPoolFee( + depositFeeId, + LiquidityPoolFeeType.DEPOSIT_FEE + ); + + const withdrawalFeeId = Bytes.fromUTF8( + enumToPrefix(LiquidityPoolFeeType.WITHDRAWAL_FEE) + ).concat(poolAddress); + const withdrawalFee = getOrCreateLiquidityPoolFee( + withdrawalFeeId, + LiquidityPoolFeeType.WITHDRAWAL_FEE + ); + + return [ + tradingFee.id, + protocolFee.id, + lpFee.id, + stakeFee.id, + depositFee.id, + withdrawalFee.id, + ]; +} + +function getOrCreateLiquidityPoolFee( + feeId: Bytes, + feeType: string, + feePercentage: BigDecimal = BIGDECIMAL_ZERO +): LiquidityPoolFee { + let fees = LiquidityPoolFee.load(feeId); + + if (!fees) { + fees = new LiquidityPoolFee(feeId); + + fees.feeType = feeType; + fees.feePercentage = feePercentage; + + fees.save(); + } + + if (feePercentage.notEqual(BIGDECIMAL_ZERO)) { + fees.feePercentage = feePercentage; + fees.save(); + } + + return fees; +} diff --git a/subgraphs/vela-exchange/src/entities/position.ts b/subgraphs/vela-exchange/src/entities/position.ts new file mode 100644 index 0000000000..be76903730 --- /dev/null +++ b/subgraphs/vela-exchange/src/entities/position.ts @@ -0,0 +1,354 @@ +import { + ethereum, + BigDecimal, + BigInt, + Bytes, + Address, +} from "@graphprotocol/graph-ts"; +import { + Account, + LiquidityPool, + Position, + PositionSnapshot, + _PositionMap, +} from "../../generated/schema"; +import { PositionVault } from "../../generated/VaultUtils/PositionVault"; +import { + decrementAccountOpenPositionCount, + incrementAccountOpenPositionCount, +} from "./account"; +import { + decrementPoolOpenPositionCount, + incrementPoolOpenPositionCount, +} from "./pool"; +import { EventType } from "./event"; +import { getOrCreateToken } from "./token"; +import { + BIGDECIMAL_ZERO, + BIGINT_ZERO, + INT_ONE, + INT_ZERO, + PositionSide, + POSITION_VAULT_ADDRESS, + PRICE_PRECISION, +} from "../utils/constants"; +import { bigDecimalToBigInt, exponentToBigDecimal } from "../utils/numbers"; + +export function getUserPosition( + event: ethereum.Event, + account: Account, + pool: LiquidityPool, + collateralTokenAddress: Address, + indexTokenAddress: Address, + positionSide: string, + posId: BigInt +): Position | null { + const positionId = getPositionID( + account, + pool, + collateralTokenAddress, + indexTokenAddress, + positionSide, + posId + ); + return Position.load(positionId); +} + +export function createUserPosition( + event: ethereum.Event, + account: Account, + pool: LiquidityPool, + collateralTokenAddress: Address, + indexTokenAddress: Address, + positionSide: string, + posId: BigInt, + entryFundingRate: BigDecimal +): Position { + const positionId = getPositionID( + account, + pool, + collateralTokenAddress, + indexTokenAddress, + positionSide, + posId + ); + const position = new Position(positionId); + position.account = account.id; + position.liquidityPool = pool.id; + position.hashOpened = event.transaction.hash; + position.blockNumberOpened = event.block.number; + position.timestampOpened = event.block.timestamp; + position.collateral = collateralTokenAddress; + position.asset = indexTokenAddress; + position.side = positionSide; + + position.fundingrateOpen = entryFundingRate; + position.fundingrateClosed = BIGDECIMAL_ZERO; + position.leverage = BIGDECIMAL_ZERO; + position.balance = BIGINT_ZERO; + position.collateralBalance = BIGINT_ZERO; + position.balanceUSD = BIGDECIMAL_ZERO; + position.collateralBalanceUSD = BIGDECIMAL_ZERO; + position.collateralInCount = INT_ZERO; + position.collateralOutCount = INT_ZERO; + position.liquidationCount = INT_ZERO; + position._posId = posId; + position.save(); + + incrementAccountOpenPositionCount(account, positionSide); + incrementPoolOpenPositionCount(event, pool, positionSide); + + return position; +} + +export function getOrCreateUserPosition( + event: ethereum.Event, + account: Account, + pool: LiquidityPool, + collateralTokenAddress: Address, + indexTokenAddress: Address, + positionSide: string, + posId: BigInt, + entryFundingRate: BigDecimal +): Position { + const position = getUserPosition( + event, + account, + pool, + collateralTokenAddress, + indexTokenAddress, + positionSide, + posId + ); + if (position) { + return position; + } + + return createUserPosition( + event, + account, + pool, + collateralTokenAddress, + indexTokenAddress, + positionSide, + posId, + entryFundingRate + ); +} + +export function updateUserPosition( + event: ethereum.Event, + account: Account, + pool: LiquidityPool, + collateralTokenAddress: Address, + indexTokenAddress: Address, + positionSide: string, + posId: BigInt, + entryFundingRate: BigDecimal, + realisedPnl: BigInt, + eventType: EventType +): Position { + const position = getOrCreateUserPosition( + event, + account, + pool, + collateralTokenAddress, + indexTokenAddress, + positionSide, + posId, + entryFundingRate + ); + + const realisedPnlUSD = realisedPnl.div(PRICE_PRECISION).toBigDecimal(); + switch (eventType) { + case EventType.CollateralIn: + position.collateralInCount += INT_ONE; + break; + case EventType.CollateralOut: + case EventType.ClosePosition: + position.collateralOutCount += INT_ONE; + position.realisedPnlUSD = realisedPnlUSD; + break; + case EventType.Liquidated: + position.liquidationCount += INT_ONE; + position.realisedPnlUSD = realisedPnlUSD; + break; + default: + break; + } + + let isLong = true; + if (position.side == PositionSide.SHORT) { + isLong = false; + } + + const prevBalanceUSD = position.balanceUSD; + const prevCollateralBalanceUSD = position.collateralBalanceUSD; + const positionVaultContract = PositionVault.bind( + Address.fromString(POSITION_VAULT_ADDRESS) + ); + const tryGetPosition = positionVaultContract.try_getPosition( + Address.fromBytes(account.id), + indexTokenAddress, + isLong, + posId + ); + if (!tryGetPosition.reverted) { + position.balanceUSD = tryGetPosition.value + .getValue0() + .size.div(PRICE_PRECISION) + .toBigDecimal(); + position.collateralBalanceUSD = tryGetPosition.value + .getValue0() + .collateral.div(PRICE_PRECISION) + .toBigDecimal(); + + const indexToken = getOrCreateToken(event, indexTokenAddress); + if (indexToken.lastPriceUSD && indexToken.lastPriceUSD! > BIGDECIMAL_ZERO) { + position.balance = bigDecimalToBigInt( + position.balanceUSD + .times(exponentToBigDecimal(indexToken.decimals)) + .div(indexToken.lastPriceUSD!) + ); + } + const collateralToken = getOrCreateToken(event, collateralTokenAddress); + if ( + collateralToken.lastPriceUSD && + collateralToken.lastPriceUSD! > BIGDECIMAL_ZERO + ) { + position.collateralBalance = bigDecimalToBigInt( + position.collateralBalanceUSD + .times(exponentToBigDecimal(collateralToken.decimals)) + .div(collateralToken.lastPriceUSD!) + ); + } + + if (position.collateralBalanceUSD != BIGDECIMAL_ZERO) { + position.leverage = position.balanceUSD.div( + position.collateralBalanceUSD + ); + } + } + + position.save(); + + if ( + eventType == EventType.ClosePosition || + eventType == EventType.Liquidated + ) { + closePosition( + event, + account, + pool, + position, + prevBalanceUSD, + prevCollateralBalanceUSD + ); + } + + createPositionSnapshot(event, position); + + return position; +} + +export function createPositionSnapshot( + event: ethereum.Event, + position: Position +): void { + const id = position.id + .concat(event.transaction.hash) + .concatI32(event.transactionLogIndex.toI32()); + const snapshot = new PositionSnapshot(id); + + snapshot.account = position.account; + snapshot.hash = event.transaction.hash; + snapshot.logIndex = event.transactionLogIndex.toI32(); + snapshot.nonce = event.transaction.nonce; + snapshot.position = position.id; + snapshot.fundingrate = position.fundingrateOpen; + snapshot.balance = position.balance; + snapshot.collateralBalance = position.collateralBalance; + snapshot.realisedPnlUSD = position.realisedPnlUSD; + snapshot.balanceUSD = position.balanceUSD; + snapshot.collateralBalanceUSD = position.collateralBalanceUSD; + snapshot.blockNumber = event.block.number; + snapshot.timestamp = event.block.timestamp; + + snapshot.save(); +} + +export function createPositionMap( + positionKey: Bytes, + account: Account, + pool: LiquidityPool, + collateralTokenAddress: Address, + indexTokenAddress: Address, + positionSide: string, + posId: BigInt +): _PositionMap { + const positionMap = new _PositionMap(positionKey); + positionMap.positionId = getPositionID( + account, + pool, + collateralTokenAddress, + indexTokenAddress, + positionSide, + posId + ); + positionMap.save(); + + return positionMap; +} + +export function getPositionWithKey(positionKey: Bytes): Position | null { + const positionMap = _PositionMap.load(positionKey); + if (!positionMap) { + return null; + } + + return Position.load(positionMap.positionId); +} + +function closePosition( + event: ethereum.Event, + account: Account, + pool: LiquidityPool, + position: Position, + prevBalanceUSD: BigDecimal, + prevCollateralBalanceUSD: BigDecimal +): void { + const fundingTokenIndex = pool.inputTokens.indexOf(position.collateral); + if (fundingTokenIndex >= 0) { + position.fundingrateClosed = pool.fundingrate[fundingTokenIndex]; + } + position.leverage = BIGDECIMAL_ZERO; + position.balance = BIGINT_ZERO; + position.balanceUSD = BIGDECIMAL_ZERO; + position.collateralBalance = BIGINT_ZERO; + position.collateralBalanceUSD = BIGDECIMAL_ZERO; + position.closeBalanceUSD = prevBalanceUSD; + position.closeCollateralBalanceUSD = prevCollateralBalanceUSD; + position.hashClosed = event.transaction.hash; + position.blockNumberClosed = event.block.number; + position.timestampClosed = event.block.timestamp; + position.save(); + + decrementAccountOpenPositionCount(account, position.side); + decrementPoolOpenPositionCount(event, pool, position.side); +} + +function getPositionID( + account: Account, + pool: LiquidityPool, + collateralTokenAddress: Address, + indexTokenAddress: Address, + positionSide: string, + posId: BigInt +): Bytes { + return account.id + .concat(pool.id) + .concat(Bytes.fromUTF8(positionSide)) + .concat(collateralTokenAddress) + .concat(indexTokenAddress) + .concat(Bytes.fromByteArray(Bytes.fromBigInt(posId))); +} diff --git a/subgraphs/vela-exchange/src/entities/protocol.ts b/subgraphs/vela-exchange/src/entities/protocol.ts new file mode 100644 index 0000000000..340ddebc15 --- /dev/null +++ b/subgraphs/vela-exchange/src/entities/protocol.ts @@ -0,0 +1,370 @@ +import { BigDecimal, Bytes, ethereum, log } from "@graphprotocol/graph-ts"; +import { DerivPerpProtocol } from "../../generated/schema"; +import { Versions } from "../versions"; +import { EventType } from "./event"; +import { + BIGDECIMAL_ZERO, + BIGINT_ZERO, + INT_ONE, + INT_ZERO, + Network, + PositionSide, + ProtocolType, + PROTOCOL_NAME, + PROTOCOL_SLUG, + VAULT_ADDRESS, +} from "../utils/constants"; + +export function getOrCreateProtocol(): DerivPerpProtocol { + const vaultAddress = Bytes.fromHexString(VAULT_ADDRESS); + let protocol = DerivPerpProtocol.load(vaultAddress); + + if (!protocol) { + protocol = new DerivPerpProtocol(vaultAddress); + protocol.name = PROTOCOL_NAME; + protocol.slug = PROTOCOL_SLUG; + protocol.network = Network.ARBITRUM_ONE; + protocol.type = ProtocolType.PERPETUAL; + + protocol.totalValueLockedUSD = BIGDECIMAL_ZERO; + protocol.protocolControlledValueUSD = BIGDECIMAL_ZERO; + protocol.cumulativeVolumeUSD = BIGDECIMAL_ZERO; + protocol.cumulativeSupplySideRevenueUSD = BIGDECIMAL_ZERO; + protocol.cumulativeProtocolSideRevenueUSD = BIGDECIMAL_ZERO; + protocol.cumulativeStakeSideRevenueUSD = BIGDECIMAL_ZERO; + protocol.cumulativeTotalRevenueUSD = BIGDECIMAL_ZERO; + + protocol.cumulativeEntryPremiumUSD = BIGDECIMAL_ZERO; + protocol.cumulativeExitPremiumUSD = BIGDECIMAL_ZERO; + protocol.cumulativeTotalPremiumUSD = BIGDECIMAL_ZERO; + protocol.cumulativeDepositPremiumUSD = BIGDECIMAL_ZERO; + protocol.cumulativeWithdrawPremiumUSD = BIGDECIMAL_ZERO; + protocol.cumulativeTotalLiquidityPremiumUSD = BIGDECIMAL_ZERO; + + protocol.cumulativeUniqueUsers = INT_ZERO; + protocol.cumulativeUniqueDepositors = INT_ZERO; + protocol.cumulativeUniqueBorrowers = INT_ZERO; + protocol.cumulativeUniqueLiquidators = INT_ZERO; + protocol.cumulativeUniqueLiquidatees = INT_ZERO; + + protocol.longOpenInterestUSD = BIGDECIMAL_ZERO; + protocol.shortOpenInterestUSD = BIGDECIMAL_ZERO; + protocol.totalOpenInterestUSD = BIGDECIMAL_ZERO; + protocol.longPositionCount = INT_ZERO; + protocol.shortPositionCount = INT_ZERO; + protocol.openPositionCount = INT_ZERO; + protocol.closedPositionCount = INT_ZERO; + protocol.cumulativePositionCount = INT_ZERO; + + protocol.transactionCount = INT_ZERO; + protocol.depositCount = INT_ZERO; + protocol.withdrawCount = INT_ZERO; + protocol.collateralInCount = INT_ZERO; + protocol.collateralOutCount = INT_ZERO; + protocol.borrowCount = INT_ZERO; + protocol.swapCount = INT_ZERO; + + protocol.totalPoolCount = INT_ZERO; + + protocol.cumulativeInflowVolumeUSD = BIGDECIMAL_ZERO; + protocol.cumulativeClosedInflowVolumeUSD = BIGDECIMAL_ZERO; + protocol.cumulativeOutflowVolumeUSD = BIGDECIMAL_ZERO; + protocol._lastSnapshotDayID = INT_ZERO; + protocol._lastUpdateTimestamp = BIGINT_ZERO; + } + + protocol.schemaVersion = Versions.getSchemaVersion(); + protocol.subgraphVersion = Versions.getSubgraphVersion(); + protocol.methodologyVersion = Versions.getMethodologyVersion(); + protocol.save(); + + return protocol; +} + +export function increaseProtocolVolume( + event: ethereum.Event, + sizeUSDDelta: BigDecimal, + collateralUSDDelta: BigDecimal, + eventType: EventType +): void { + const protocol = getOrCreateProtocol(); + protocol.cumulativeVolumeUSD = + protocol.cumulativeVolumeUSD.plus(sizeUSDDelta); + switch (eventType) { + case EventType.CollateralIn: + protocol.cumulativeInflowVolumeUSD = + protocol.cumulativeInflowVolumeUSD.plus(collateralUSDDelta); + break; + case EventType.CollateralOut: + protocol.cumulativeOutflowVolumeUSD = + protocol.cumulativeOutflowVolumeUSD.plus(collateralUSDDelta); + break; + case EventType.ClosePosition: + case EventType.Liquidated: + protocol.cumulativeClosedInflowVolumeUSD = + protocol.cumulativeClosedInflowVolumeUSD.plus(collateralUSDDelta); + break; + default: + break; + } + + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function increaseProtocolPremium( + event: ethereum.Event, + amountUSD: BigDecimal, + eventType: EventType +): void { + const protocol = getOrCreateProtocol(); + switch (eventType) { + case EventType.Deposit: + protocol.cumulativeDepositPremiumUSD = + protocol.cumulativeDepositPremiumUSD.plus(amountUSD); + protocol.cumulativeTotalLiquidityPremiumUSD = + protocol.cumulativeTotalLiquidityPremiumUSD.plus(amountUSD); + break; + case EventType.Withdraw: + protocol.cumulativeWithdrawPremiumUSD = + protocol.cumulativeWithdrawPremiumUSD.plus(amountUSD); + protocol.cumulativeTotalLiquidityPremiumUSD = + protocol.cumulativeTotalLiquidityPremiumUSD.plus(amountUSD); + break; + case EventType.CollateralIn: + protocol.cumulativeEntryPremiumUSD = + protocol.cumulativeEntryPremiumUSD.plus(amountUSD); + protocol.cumulativeTotalPremiumUSD = + protocol.cumulativeTotalPremiumUSD.plus(amountUSD); + break; + case EventType.CollateralOut: + case EventType.ClosePosition: + protocol.cumulativeExitPremiumUSD = + protocol.cumulativeExitPremiumUSD.plus(amountUSD); + protocol.cumulativeTotalPremiumUSD = + protocol.cumulativeTotalPremiumUSD.plus(amountUSD); + break; + + default: + break; + } + + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function updateProtocolTVL( + event: ethereum.Event, + tvlChangeUSD: BigDecimal +): void { + const protocol = getOrCreateProtocol(); + protocol.totalValueLockedUSD = + protocol.totalValueLockedUSD.plus(tvlChangeUSD); + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function updateProtocolOpenInterestUSD( + event: ethereum.Event, + openInterestChangeUSD: BigDecimal, + isIncrease: boolean, + isLong: boolean +): void { + const protocol = getOrCreateProtocol(); + if (isIncrease) { + protocol.totalOpenInterestUSD = protocol.totalOpenInterestUSD.plus( + openInterestChangeUSD + ); + if (isLong) { + protocol.longOpenInterestUSD = protocol.longOpenInterestUSD.plus( + openInterestChangeUSD + ); + } else { + protocol.shortOpenInterestUSD = protocol.shortOpenInterestUSD.plus( + openInterestChangeUSD + ); + } + } else { + protocol.totalOpenInterestUSD = protocol.totalOpenInterestUSD.minus( + openInterestChangeUSD + ); + if (isLong) { + protocol.longOpenInterestUSD = protocol.longOpenInterestUSD.minus( + openInterestChangeUSD + ); + } else { + protocol.shortOpenInterestUSD = protocol.shortOpenInterestUSD.minus( + openInterestChangeUSD + ); + } + } + + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function incrementProtocolEventCount( + event: ethereum.Event, + eventType: EventType, + sizeUSDDelta: BigDecimal +): void { + const protocol = getOrCreateProtocol(); + switch (eventType) { + case EventType.Deposit: + protocol.depositCount += INT_ONE; + break; + case EventType.Withdraw: + protocol.withdrawCount += INT_ONE; + break; + case EventType.CollateralIn: + protocol.collateralInCount += INT_ONE; + if (sizeUSDDelta > BIGDECIMAL_ZERO) { + protocol.borrowCount += INT_ONE; + } + break; + case EventType.CollateralOut: + protocol.collateralOutCount += INT_ONE; + break; + case EventType.Swap: + protocol.swapCount += INT_ONE; + break; + default: + break; + } + + protocol.transactionCount += INT_ONE; + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function incrementProtocolUniqueUsers(event: ethereum.Event): void { + const protocol = getOrCreateProtocol(); + protocol.cumulativeUniqueUsers += INT_ONE; + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function incrementProtocolUniqueDepositors(event: ethereum.Event): void { + const protocol = getOrCreateProtocol(); + protocol.cumulativeUniqueDepositors += INT_ONE; + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function incrementProtocolUniqueBorrowers(event: ethereum.Event): void { + const protocol = getOrCreateProtocol(); + protocol.cumulativeUniqueBorrowers += INT_ONE; + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function incrementProtocolUniqueLiquidators( + event: ethereum.Event +): void { + const protocol = getOrCreateProtocol(); + protocol.cumulativeUniqueLiquidators += INT_ONE; + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function incrementProtocolUniqueLiquidatees( + event: ethereum.Event +): void { + const protocol = getOrCreateProtocol(); + protocol.cumulativeUniqueLiquidatees += INT_ONE; + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function incrementProtocolOpenPositionCount( + event: ethereum.Event, + positionSide: string +): void { + const protocol = getOrCreateProtocol(); + if (PositionSide.LONG == positionSide) { + protocol.longPositionCount += INT_ONE; + } else { + protocol.shortPositionCount += INT_ONE; + } + protocol.openPositionCount += INT_ONE; + protocol.cumulativePositionCount += INT_ONE; + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function decrementProtocolOpenPositionCount( + event: ethereum.Event, + positionSide: string +): void { + const protocol = getOrCreateProtocol(); + if (PositionSide.LONG == positionSide) { + protocol.longPositionCount = + protocol.longPositionCount - INT_ONE >= 0 + ? protocol.longPositionCount - INT_ONE + : INT_ZERO; + } else { + protocol.shortPositionCount = + protocol.shortPositionCount - INT_ONE >= 0 + ? protocol.shortPositionCount - INT_ONE + : INT_ZERO; + } + protocol.openPositionCount = + protocol.openPositionCount - INT_ONE >= 0 + ? protocol.openPositionCount - INT_ONE + : INT_ZERO; + protocol.closedPositionCount += INT_ONE; + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function incrementProtocolTotalPoolCount(event: ethereum.Event): void { + const protocol = getOrCreateProtocol(); + protocol.totalPoolCount += INT_ONE; + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function increaseProtocolSideRevenue( + event: ethereum.Event, + amountChangeUSD: BigDecimal +): void { + const protocol = getOrCreateProtocol(); + protocol.cumulativeProtocolSideRevenueUSD = + protocol.cumulativeProtocolSideRevenueUSD.plus(amountChangeUSD); + protocol.cumulativeTotalRevenueUSD = + protocol.cumulativeTotalRevenueUSD.plus(amountChangeUSD); + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function increaseProtocolSupplySideRevenue( + event: ethereum.Event, + amountChangeUSD: BigDecimal +): void { + const protocol = getOrCreateProtocol(); + protocol.cumulativeSupplySideRevenueUSD = + protocol.cumulativeSupplySideRevenueUSD.plus(amountChangeUSD); + protocol.cumulativeTotalRevenueUSD = + protocol.cumulativeTotalRevenueUSD.plus(amountChangeUSD); + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function increaseProtocolStakeSideRevenue( + event: ethereum.Event, + amountChangeUSD: BigDecimal +): void { + const protocol = getOrCreateProtocol(); + protocol.cumulativeStakeSideRevenueUSD = + protocol.cumulativeStakeSideRevenueUSD.plus(amountChangeUSD); + protocol.cumulativeTotalRevenueUSD = + protocol.cumulativeTotalRevenueUSD.plus(amountChangeUSD); + protocol._lastUpdateTimestamp = event.block.timestamp; + protocol.save(); +} + +export function updateProtocolSnapshotDayID(snapshotDayID: i32): void { + const protocol = getOrCreateProtocol(); + protocol._lastSnapshotDayID = snapshotDayID; + protocol.save(); +} diff --git a/subgraphs/vela-exchange/src/entities/snapshots.ts b/subgraphs/vela-exchange/src/entities/snapshots.ts new file mode 100644 index 0000000000..12971b3210 --- /dev/null +++ b/subgraphs/vela-exchange/src/entities/snapshots.ts @@ -0,0 +1,1105 @@ +import { + Address, + Bytes, + BigInt, + ethereum, + log, + BigDecimal, +} from "@graphprotocol/graph-ts"; +import { + ActiveAccount, + DerivPerpProtocol, + FinancialsDailySnapshot, + LiquidityPool, + LiquidityPoolDailySnapshot, + LiquidityPoolHourlySnapshot, + UsageMetricsDailySnapshot, + UsageMetricsHourlySnapshot, + _TempUsageMetricsDailySnapshot, + _TempUsageMetricsHourlySnapshot, +} from "../../generated/schema"; +import { EventType } from "./event"; +import { getOrCreateProtocol, updateProtocolSnapshotDayID } from "./protocol"; +import { + getOrCreateLiquidityPool, + updatePoolSnapshotDayID, + updatePoolSnapshotHourID, +} from "./pool"; +import { + BIGDECIMAL_ZERO, + INT_ONE, + INT_ZERO, + SECONDS_PER_HOUR, + SECONDS_PER_DAY, + PositionSide, + BIGINT_ZERO, +} from "../utils/constants"; + +// snapshots are only snapped once per interval for efficiency. +export function takeSnapshots(event: ethereum.Event): void { + const dayID = event.block.timestamp.toI32() / SECONDS_PER_DAY; + const hourID = event.block.timestamp.toI32() / SECONDS_PER_HOUR; + + const protocol = getOrCreateProtocol(); + const protocolSnapshotDayID = + protocol._lastUpdateTimestamp!.toI32() / SECONDS_PER_DAY; + const protocolSnapshotHourID = + protocol._lastUpdateTimestamp!.toI32() / SECONDS_PER_HOUR; + + if (protocolSnapshotDayID != dayID && protocolSnapshotDayID != INT_ZERO) { + takeFinancialDailySnapshot(protocol, protocolSnapshotDayID); + takeUsageMetricsDailySnapshot(protocol, protocolSnapshotDayID); + updateProtocolSnapshotDayID(protocolSnapshotDayID); + } + if (protocolSnapshotHourID != hourID && protocolSnapshotHourID != INT_ZERO) { + takeUsageMetricsHourlySnapshot(protocol, protocolSnapshotHourID); + } + + const pool = getOrCreateLiquidityPool(event); + const poolSnapshotDayID = + pool._lastUpdateTimestamp!.toI32() / SECONDS_PER_DAY; + const poolSnapshotHourID = + pool._lastUpdateTimestamp!.toI32() / SECONDS_PER_HOUR; + if (poolSnapshotDayID != dayID && poolSnapshotDayID != INT_ZERO) { + takeLiquidityPoolDailySnapshot(pool, poolSnapshotDayID); + updatePoolSnapshotDayID(event, poolSnapshotDayID); + } + if (poolSnapshotHourID != hourID && poolSnapshotHourID != INT_ZERO) { + takeLiquidityPoolHourlySnapshot(pool, poolSnapshotHourID); + updatePoolSnapshotHourID(event, poolSnapshotHourID); + } +} + +export function takeLiquidityPoolDailySnapshot( + pool: LiquidityPool, + day: i32 +): void { + const id = pool.id.concatI32(day); + if (LiquidityPoolDailySnapshot.load(id)) { + return; + } + const poolMetrics = new LiquidityPoolDailySnapshot(id); + const prevPoolMetrics = LiquidityPoolDailySnapshot.load( + pool.id.concatI32(pool._lastSnapshotDayID) + ); + const inputTokenLength = pool.inputTokens.length; + + let prevCumulativeVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeSupplySideRevenueUSD = BIGDECIMAL_ZERO; + let prevCumulativeProtocolSideRevenueUSD = BIGDECIMAL_ZERO; + + let prevCumulativeEntryPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeExitPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeTotalPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeDepositPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeWithdrawPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeTotalLiquidityPremiumUSD = BIGDECIMAL_ZERO; + + let prevInputTokens: Bytes[] = []; + let prevCumulativeInflowVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeClosedInflowVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeOutflowVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeVolumeByTokenAmount = new Array( + inputTokenLength + ).fill(BIGINT_ZERO); + let prevCumulativeVolumeByTokenUSD = new Array( + inputTokenLength + ).fill(BIGDECIMAL_ZERO); + let prevCumulativeInflowVolumeByTokenAmount = new Array( + inputTokenLength + ).fill(BIGINT_ZERO); + let prevCumulativeInflowVolumeByTokenUSD = new Array( + inputTokenLength + ).fill(BIGDECIMAL_ZERO); + let prevCumulativeOutflowVolumeByTokenAmount = new Array( + inputTokenLength + ).fill(BIGINT_ZERO); + let prevCumulativeOutflowVolumeByTokenUSD = new Array( + inputTokenLength + ).fill(BIGDECIMAL_ZERO); + let prevCumulativeClosedInflowVolumeByTokenAmount = new Array( + inputTokenLength + ).fill(BIGINT_ZERO); + let prevCumulativeClosedInflowVolumeByTokenUSD = new Array( + inputTokenLength + ).fill(BIGDECIMAL_ZERO); + + let prevCumulativeUniqueUsers = INT_ZERO; + let prevCumulativeUniqueDepositors = INT_ZERO; + let prevCumulativeUniqueBorrowers = INT_ZERO; + let prevCumulativeUniqueLiquidators = INT_ZERO; + let prevCumulativeUniqueLiquidatees = INT_ZERO; + + let prevLongPositionCount = INT_ZERO; + let prevShortPositionCount = INT_ZERO; + let prevOpenPositionCount = INT_ZERO; + let prevClosedPositionCount = INT_ZERO; + let prevCumulativePositionCount = INT_ZERO; + let prevCumulativeTotalRevenueUSD = BIGDECIMAL_ZERO; + + if (prevPoolMetrics) { + prevCumulativeVolumeUSD = prevPoolMetrics.cumulativeVolumeUSD; + prevCumulativeSupplySideRevenueUSD = + prevPoolMetrics.cumulativeSupplySideRevenueUSD; + prevCumulativeProtocolSideRevenueUSD = + prevPoolMetrics.cumulativeProtocolSideRevenueUSD; + prevCumulativeTotalRevenueUSD = prevPoolMetrics.cumulativeTotalRevenueUSD; + + prevCumulativeEntryPremiumUSD = prevPoolMetrics.cumulativeEntryPremiumUSD; + prevCumulativeExitPremiumUSD = prevPoolMetrics.cumulativeExitPremiumUSD; + prevCumulativeTotalPremiumUSD = prevPoolMetrics.cumulativeTotalPremiumUSD; + prevCumulativeDepositPremiumUSD = + prevPoolMetrics.cumulativeDepositPremiumUSD; + prevCumulativeWithdrawPremiumUSD = + prevPoolMetrics.cumulativeWithdrawPremiumUSD; + prevCumulativeTotalLiquidityPremiumUSD = + prevPoolMetrics.cumulativeTotalLiquidityPremiumUSD; + + prevInputTokens = prevPoolMetrics._inputTokens; + prevCumulativeInflowVolumeUSD = prevPoolMetrics.cumulativeInflowVolumeUSD; + prevCumulativeClosedInflowVolumeUSD = + prevPoolMetrics.cumulativeClosedInflowVolumeUSD; + prevCumulativeOutflowVolumeUSD = prevPoolMetrics.cumulativeOutflowVolumeUSD; + prevCumulativeVolumeByTokenAmount = + prevPoolMetrics._cumulativeVolumeByTokenAmount; + prevCumulativeVolumeByTokenUSD = + prevPoolMetrics._cumulativeVolumeByTokenUSD; + prevCumulativeInflowVolumeByTokenAmount = + prevPoolMetrics._cumulativeInflowVolumeByTokenAmount; + prevCumulativeInflowVolumeByTokenUSD = + prevPoolMetrics._cumulativeInflowVolumeByTokenUSD; + prevCumulativeOutflowVolumeByTokenAmount = + prevPoolMetrics._cumulativeOutflowVolumeByTokenAmount; + prevCumulativeOutflowVolumeByTokenUSD = + prevPoolMetrics._cumulativeOutflowVolumeByTokenUSD; + prevCumulativeClosedInflowVolumeByTokenAmount = + prevPoolMetrics._cumulativeClosedInflowVolumeByTokenAmount; + prevCumulativeClosedInflowVolumeByTokenUSD = + prevPoolMetrics._cumulativeClosedInflowVolumeByTokenUSD; + + prevCumulativeUniqueUsers = prevPoolMetrics._cumulativeUniqueUsers; + prevCumulativeUniqueDepositors = + prevPoolMetrics._cumulativeUniqueDepositors; + prevCumulativeUniqueBorrowers = prevPoolMetrics.cumulativeUniqueBorrowers; + prevCumulativeUniqueLiquidators = + prevPoolMetrics.cumulativeUniqueLiquidators; + prevCumulativeUniqueLiquidatees = + prevPoolMetrics.cumulativeUniqueLiquidatees; + + prevLongPositionCount = prevPoolMetrics.longPositionCount; + prevShortPositionCount = prevPoolMetrics.shortPositionCount; + prevOpenPositionCount = prevPoolMetrics.openPositionCount; + prevClosedPositionCount = prevPoolMetrics.closedPositionCount; + prevCumulativePositionCount = prevPoolMetrics.cumulativePositionCount; + } else if (pool._lastSnapshotDayID > INT_ZERO) { + log.error( + "Missing daily pool snapshot at ID that has been snapped: Pool {}, ID {} ", + [pool.id.toHexString(), pool._lastSnapshotDayID.toString()] + ); + } + + poolMetrics.days = day; + poolMetrics.protocol = pool.protocol; + poolMetrics.pool = pool.id; + + poolMetrics.totalValueLockedUSD = pool.totalValueLockedUSD; + poolMetrics.dailyLongOpenInterestUSD = pool.longOpenInterestUSD; + poolMetrics.dailyShortOpenInterestUSD = pool.shortOpenInterestUSD; + poolMetrics.dailyTotalOpenInterestUSD = pool.totalOpenInterestUSD; + + poolMetrics._inputTokens = pool.inputTokens; + poolMetrics.inputTokenBalances = pool.inputTokenBalances; + poolMetrics.inputTokenWeights = pool.inputTokenWeights; + poolMetrics.outputTokenSupply = pool.outputTokenSupply; + poolMetrics.outputTokenPriceUSD = pool.outputTokenPriceUSD; + poolMetrics.stakedOutputTokenAmount = pool.stakedOutputTokenAmount; + poolMetrics.rewardTokenEmissionsAmount = pool.rewardTokenEmissionsAmount; + poolMetrics.rewardTokenEmissionsUSD = pool.rewardTokenEmissionsUSD; + + poolMetrics.cumulativeSupplySideRevenueUSD = + pool.cumulativeSupplySideRevenueUSD; + poolMetrics.dailySupplySideRevenueUSD = + pool.cumulativeSupplySideRevenueUSD.minus( + prevCumulativeSupplySideRevenueUSD + ); + poolMetrics.cumulativeProtocolSideRevenueUSD = + pool.cumulativeProtocolSideRevenueUSD; + poolMetrics.dailyProtocolSideRevenueUSD = + pool.cumulativeProtocolSideRevenueUSD.minus( + prevCumulativeProtocolSideRevenueUSD + ); + poolMetrics.cumulativeTotalRevenueUSD = pool.cumulativeTotalRevenueUSD; + poolMetrics.dailyTotalRevenueUSD = pool.cumulativeTotalRevenueUSD.minus( + prevCumulativeTotalRevenueUSD + ); + + poolMetrics.dailyFundingrate = pool.fundingrate; + poolMetrics.dailyEntryPremiumUSD = pool.cumulativeEntryPremiumUSD.minus( + prevCumulativeEntryPremiumUSD + ); + poolMetrics.cumulativeEntryPremiumUSD = pool.cumulativeEntryPremiumUSD; + poolMetrics.dailyExitPremiumUSD = pool.cumulativeExitPremiumUSD.minus( + prevCumulativeExitPremiumUSD + ); + poolMetrics.cumulativeExitPremiumUSD = pool.cumulativeExitPremiumUSD; + poolMetrics.dailyTotalPremiumUSD = pool.cumulativeTotalPremiumUSD.minus( + prevCumulativeTotalPremiumUSD + ); + poolMetrics.cumulativeTotalPremiumUSD = pool.cumulativeTotalPremiumUSD; + poolMetrics.dailyDepositPremiumUSD = pool.cumulativeDepositPremiumUSD.minus( + prevCumulativeDepositPremiumUSD + ); + poolMetrics.cumulativeDepositPremiumUSD = pool.cumulativeDepositPremiumUSD; + poolMetrics.dailyWithdrawPremiumUSD = pool.cumulativeWithdrawPremiumUSD.minus( + prevCumulativeWithdrawPremiumUSD + ); + poolMetrics.cumulativeWithdrawPremiumUSD = pool.cumulativeWithdrawPremiumUSD; + poolMetrics.dailyTotalLiquidityPremiumUSD = + pool.cumulativeTotalLiquidityPremiumUSD.minus( + prevCumulativeTotalLiquidityPremiumUSD + ); + poolMetrics.cumulativeTotalLiquidityPremiumUSD = + pool.cumulativeTotalLiquidityPremiumUSD; + + poolMetrics.dailyVolumeUSD = pool.cumulativeVolumeUSD.minus( + prevCumulativeVolumeUSD + ); + poolMetrics.cumulativeVolumeUSD = pool.cumulativeVolumeUSD; + poolMetrics.dailyInflowVolumeUSD = pool.cumulativeInflowVolumeUSD.minus( + prevCumulativeInflowVolumeUSD + ); + poolMetrics.cumulativeInflowVolumeUSD = pool.cumulativeInflowVolumeUSD; + poolMetrics.dailyClosedInflowVolumeUSD = + pool.cumulativeClosedInflowVolumeUSD.minus( + prevCumulativeClosedInflowVolumeUSD + ); + poolMetrics.cumulativeClosedInflowVolumeUSD = + pool.cumulativeClosedInflowVolumeUSD; + poolMetrics.dailyOutflowVolumeUSD = pool.cumulativeOutflowVolumeUSD.minus( + prevCumulativeOutflowVolumeUSD + ); + poolMetrics.cumulativeOutflowVolumeUSD = pool.cumulativeOutflowVolumeUSD; + poolMetrics._cumulativeVolumeByTokenAmount = + pool._cumulativeVolumeByTokenAmount; + poolMetrics._cumulativeVolumeByTokenUSD = pool._cumulativeVolumeByTokenUSD; + poolMetrics._cumulativeInflowVolumeByTokenAmount = + pool._cumulativeInflowVolumeByTokenAmount; + poolMetrics._cumulativeInflowVolumeByTokenUSD = + pool._cumulativeInflowVolumeByTokenUSD; + poolMetrics._cumulativeOutflowVolumeByTokenAmount = + pool._cumulativeOutflowVolumeByTokenAmount; + poolMetrics._cumulativeOutflowVolumeByTokenUSD = + pool._cumulativeOutflowVolumeByTokenUSD; + poolMetrics._cumulativeClosedInflowVolumeByTokenAmount = + pool._cumulativeClosedInflowVolumeByTokenAmount; + poolMetrics._cumulativeClosedInflowVolumeByTokenUSD = + pool._cumulativeClosedInflowVolumeByTokenUSD; + const dailyVolumeByTokenAmount = pool._cumulativeVolumeByTokenAmount; + const dailyVolumeByTokenUSD = pool._cumulativeVolumeByTokenUSD; + const dailyInflowVolumeByTokenAmount = + pool._cumulativeInflowVolumeByTokenAmount; + const dailyInflowVolumeByTokenUSD = pool._cumulativeInflowVolumeByTokenUSD; + const dailyClosedInflowVolumeByTokenAmount = + pool._cumulativeClosedInflowVolumeByTokenAmount; + const dailyClosedInflowVolumeByTokenUSD = + pool._cumulativeClosedInflowVolumeByTokenUSD; + const dailyOutflowVolumeByTokenAmount = + pool._cumulativeOutflowVolumeByTokenAmount; + const dailyOutflowVolumeByTokenUSD = pool._cumulativeOutflowVolumeByTokenUSD; + + for (let i = 0; i < inputTokenLength; i++) { + for (let j = 0; j < prevInputTokens.length; j++) { + if (pool.inputTokens[i] == prevInputTokens[j]) { + dailyVolumeByTokenAmount[i] = dailyVolumeByTokenAmount[i].minus( + prevCumulativeVolumeByTokenAmount[j] + ); + dailyVolumeByTokenUSD[i] = dailyVolumeByTokenUSD[i].minus( + prevCumulativeVolumeByTokenUSD[j] + ); + dailyInflowVolumeByTokenAmount[i] = dailyInflowVolumeByTokenAmount[ + i + ].minus(prevCumulativeInflowVolumeByTokenAmount[j]); + + dailyInflowVolumeByTokenUSD[i] = dailyInflowVolumeByTokenUSD[i].minus( + prevCumulativeInflowVolumeByTokenUSD[j] + ); + dailyClosedInflowVolumeByTokenAmount[i] = + dailyClosedInflowVolumeByTokenAmount[i].minus( + prevCumulativeClosedInflowVolumeByTokenAmount[j] + ); + dailyClosedInflowVolumeByTokenUSD[i] = + dailyClosedInflowVolumeByTokenUSD[i].minus( + prevCumulativeClosedInflowVolumeByTokenUSD[j] + ); + dailyOutflowVolumeByTokenAmount[i] = dailyOutflowVolumeByTokenAmount[ + i + ].minus(prevCumulativeOutflowVolumeByTokenAmount[j]); + dailyOutflowVolumeByTokenUSD[i] = dailyOutflowVolumeByTokenUSD[i].minus( + prevCumulativeOutflowVolumeByTokenUSD[j] + ); + } + } + } + + poolMetrics.dailyVolumeByTokenAmount = dailyVolumeByTokenAmount; + poolMetrics.dailyVolumeByTokenUSD = dailyVolumeByTokenUSD; + poolMetrics.dailyInflowVolumeByTokenAmount = dailyInflowVolumeByTokenAmount; + poolMetrics.dailyInflowVolumeByTokenUSD = dailyInflowVolumeByTokenUSD; + poolMetrics.dailyClosedInflowVolumeByTokenAmount = + dailyClosedInflowVolumeByTokenAmount; + poolMetrics.dailyClosedInflowVolumeByTokenUSD = + dailyClosedInflowVolumeByTokenUSD; + poolMetrics.dailyOutflowVolumeByTokenAmount = dailyOutflowVolumeByTokenAmount; + poolMetrics.dailyOutflowVolumeByTokenUSD = dailyOutflowVolumeByTokenUSD; + + poolMetrics.dailyActiveUsers = + pool.cumulativeUniqueUsers - prevCumulativeUniqueUsers; + poolMetrics._cumulativeUniqueUsers = pool.cumulativeUniqueUsers; + poolMetrics.dailyActiveDepositors = + pool.cumulativeUniqueDepositors - prevCumulativeUniqueDepositors; + poolMetrics._cumulativeUniqueDepositors = pool.cumulativeUniqueDepositors; + poolMetrics.dailyActiveBorrowers = + pool.cumulativeUniqueBorrowers - prevCumulativeUniqueBorrowers; + poolMetrics.cumulativeUniqueBorrowers = pool.cumulativeUniqueBorrowers; + poolMetrics.dailyActiveLiquidators = + pool.cumulativeUniqueLiquidators - prevCumulativeUniqueLiquidators; + poolMetrics.cumulativeUniqueLiquidators = pool.cumulativeUniqueLiquidators; + poolMetrics.dailyActiveLiquidatees = + pool.cumulativeUniqueLiquidatees - prevCumulativeUniqueLiquidatees; + poolMetrics.cumulativeUniqueLiquidatees = pool.cumulativeUniqueLiquidatees; + + poolMetrics.dailyLongPositionCount = + pool.longPositionCount - prevLongPositionCount >= 0 + ? pool.longPositionCount - prevLongPositionCount + : INT_ZERO; + poolMetrics.longPositionCount = pool.longPositionCount; + poolMetrics.dailyShortPositionCount = + pool.shortPositionCount - prevShortPositionCount >= 0 + ? pool.shortPositionCount - prevShortPositionCount + : INT_ZERO; + poolMetrics.shortPositionCount = pool.shortPositionCount; + poolMetrics.dailyOpenPositionCount = + pool.openPositionCount - prevOpenPositionCount >= 0 + ? pool.openPositionCount - prevOpenPositionCount + : INT_ZERO; + poolMetrics.openPositionCount = pool.openPositionCount; + poolMetrics.dailyClosedPositionCount = + pool.closedPositionCount - prevClosedPositionCount; + poolMetrics.closedPositionCount = pool.closedPositionCount; + poolMetrics.dailyCumulativePositionCount = + pool.cumulativePositionCount - prevCumulativePositionCount; + poolMetrics.cumulativePositionCount = pool.cumulativePositionCount; + + poolMetrics.save(); +} + +export function takeLiquidityPoolHourlySnapshot( + pool: LiquidityPool, + hour: i32 +): void { + const id = pool.id.concatI32(hour); + if (LiquidityPoolHourlySnapshot.load(id)) { + return; + } + const poolMetrics = new LiquidityPoolHourlySnapshot(id); + const prevPoolMetrics = LiquidityPoolHourlySnapshot.load( + pool.id.concatI32(pool._lastSnapshotHourID) + ); + const inputTokenLength = pool.inputTokens.length; + + let prevCumulativeVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeSupplySideRevenueUSD = BIGDECIMAL_ZERO; + let prevCumulativeProtocolSideRevenueUSD = BIGDECIMAL_ZERO; + + let prevCumulativeEntryPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeExitPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeTotalPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeDepositPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeWithdrawPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeTotalLiquidityPremiumUSD = BIGDECIMAL_ZERO; + + let prevInputTokens: Bytes[] = []; + let prevCumulativeInflowVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeClosedInflowVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeOutflowVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeVolumeByTokenAmount = new Array( + inputTokenLength + ).fill(BIGINT_ZERO); + let prevCumulativeVolumeByTokenUSD = new Array( + inputTokenLength + ).fill(BIGDECIMAL_ZERO); + let prevCumulativeInflowVolumeByTokenAmount = new Array( + inputTokenLength + ).fill(BIGINT_ZERO); + let prevCumulativeInflowVolumeByTokenUSD = new Array( + inputTokenLength + ).fill(BIGDECIMAL_ZERO); + let prevCumulativeOutflowVolumeByTokenAmount = new Array( + inputTokenLength + ).fill(BIGINT_ZERO); + let prevCumulativeOutflowVolumeByTokenUSD = new Array( + inputTokenLength + ).fill(BIGDECIMAL_ZERO); + let prevCumulativeClosedInflowVolumeByTokenAmount = new Array( + inputTokenLength + ).fill(BIGINT_ZERO); + let prevCumulativeClosedInflowVolumeByTokenUSD = new Array( + inputTokenLength + ).fill(BIGDECIMAL_ZERO); + + let prevCumulativeTotalRevenueUSD = BIGDECIMAL_ZERO; + + if (prevPoolMetrics) { + prevCumulativeVolumeUSD = prevPoolMetrics.cumulativeVolumeUSD; + prevCumulativeSupplySideRevenueUSD = + prevPoolMetrics.cumulativeSupplySideRevenueUSD; + prevCumulativeProtocolSideRevenueUSD = + prevPoolMetrics.cumulativeProtocolSideRevenueUSD; + prevCumulativeTotalRevenueUSD = prevPoolMetrics.cumulativeTotalRevenueUSD; + + prevCumulativeEntryPremiumUSD = prevPoolMetrics.cumulativeEntryPremiumUSD; + prevCumulativeExitPremiumUSD = prevPoolMetrics.cumulativeExitPremiumUSD; + prevCumulativeTotalPremiumUSD = prevPoolMetrics.cumulativeTotalPremiumUSD; + prevCumulativeDepositPremiumUSD = + prevPoolMetrics.cumulativeDepositPremiumUSD; + prevCumulativeWithdrawPremiumUSD = + prevPoolMetrics.cumulativeWithdrawPremiumUSD; + prevCumulativeTotalLiquidityPremiumUSD = + prevPoolMetrics.cumulativeTotalLiquidityPremiumUSD; + + prevInputTokens = prevPoolMetrics._inputTokens; + prevCumulativeInflowVolumeUSD = prevPoolMetrics.cumulativeInflowVolumeUSD; + prevCumulativeClosedInflowVolumeUSD = + prevPoolMetrics.cumulativeClosedInflowVolumeUSD; + prevCumulativeOutflowVolumeUSD = prevPoolMetrics.cumulativeOutflowVolumeUSD; + prevCumulativeVolumeByTokenAmount = + prevPoolMetrics._cumulativeVolumeByTokenAmount; + prevCumulativeVolumeByTokenUSD = + prevPoolMetrics._cumulativeVolumeByTokenUSD; + prevCumulativeInflowVolumeByTokenAmount = + prevPoolMetrics._cumulativeInflowVolumeByTokenAmount; + prevCumulativeInflowVolumeByTokenUSD = + prevPoolMetrics._cumulativeInflowVolumeByTokenUSD; + prevCumulativeOutflowVolumeByTokenAmount = + prevPoolMetrics._cumulativeOutflowVolumeByTokenAmount; + prevCumulativeOutflowVolumeByTokenUSD = + prevPoolMetrics._cumulativeOutflowVolumeByTokenUSD; + prevCumulativeClosedInflowVolumeByTokenAmount = + prevPoolMetrics._cumulativeClosedInflowVolumeByTokenAmount; + prevCumulativeClosedInflowVolumeByTokenUSD = + prevPoolMetrics._cumulativeClosedInflowVolumeByTokenUSD; + } else if (pool._lastSnapshotHourID > INT_ZERO) { + log.error( + "Missing hourly pool snapshot at ID that has been snapped: Pool {}, ID {} ", + [pool.id.toHexString(), pool._lastSnapshotHourID.toString()] + ); + } + + poolMetrics.hours = hour; + poolMetrics.protocol = pool.protocol; + poolMetrics.pool = pool.id; + + poolMetrics.totalValueLockedUSD = pool.totalValueLockedUSD; + poolMetrics.hourlyLongOpenInterestUSD = pool.longOpenInterestUSD; + poolMetrics.hourlyShortOpenInterestUSD = pool.shortOpenInterestUSD; + poolMetrics.hourlyTotalOpenInterestUSD = pool.totalOpenInterestUSD; + + poolMetrics._inputTokens = pool.inputTokens; + poolMetrics.inputTokenBalances = pool.inputTokenBalances; + poolMetrics.inputTokenWeights = pool.inputTokenWeights; + poolMetrics.outputTokenSupply = pool.outputTokenSupply; + poolMetrics.outputTokenPriceUSD = pool.outputTokenPriceUSD; + poolMetrics.stakedOutputTokenAmount = pool.stakedOutputTokenAmount; + poolMetrics.rewardTokenEmissionsAmount = pool.rewardTokenEmissionsAmount; + poolMetrics.rewardTokenEmissionsUSD = pool.rewardTokenEmissionsUSD; + + poolMetrics.cumulativeSupplySideRevenueUSD = + pool.cumulativeSupplySideRevenueUSD; + poolMetrics.hourlySupplySideRevenueUSD = + pool.cumulativeSupplySideRevenueUSD.minus( + prevCumulativeSupplySideRevenueUSD + ); + poolMetrics.cumulativeProtocolSideRevenueUSD = + pool.cumulativeProtocolSideRevenueUSD; + poolMetrics.hourlyProtocolSideRevenueUSD = + pool.cumulativeProtocolSideRevenueUSD.minus( + prevCumulativeProtocolSideRevenueUSD + ); + poolMetrics.cumulativeTotalRevenueUSD = pool.cumulativeTotalRevenueUSD; + poolMetrics.hourlyTotalRevenueUSD = pool.cumulativeTotalRevenueUSD.minus( + prevCumulativeTotalRevenueUSD + ); + + poolMetrics.hourlyFundingrate = pool.fundingrate; + poolMetrics.hourlyEntryPremiumUSD = pool.cumulativeEntryPremiumUSD.minus( + prevCumulativeEntryPremiumUSD + ); + poolMetrics.cumulativeEntryPremiumUSD = pool.cumulativeEntryPremiumUSD; + poolMetrics.hourlyExitPremiumUSD = pool.cumulativeExitPremiumUSD.minus( + prevCumulativeExitPremiumUSD + ); + poolMetrics.cumulativeExitPremiumUSD = pool.cumulativeExitPremiumUSD; + poolMetrics.hourlyTotalPremiumUSD = pool.cumulativeTotalPremiumUSD.minus( + prevCumulativeTotalPremiumUSD + ); + poolMetrics.cumulativeTotalPremiumUSD = pool.cumulativeTotalPremiumUSD; + poolMetrics.hourlyDepositPremiumUSD = pool.cumulativeDepositPremiumUSD.minus( + prevCumulativeDepositPremiumUSD + ); + poolMetrics.cumulativeDepositPremiumUSD = pool.cumulativeDepositPremiumUSD; + poolMetrics.hourlyWithdrawPremiumUSD = + pool.cumulativeWithdrawPremiumUSD.minus(prevCumulativeWithdrawPremiumUSD); + poolMetrics.cumulativeWithdrawPremiumUSD = pool.cumulativeWithdrawPremiumUSD; + poolMetrics.hourlyTotalLiquidityPremiumUSD = + pool.cumulativeTotalLiquidityPremiumUSD.minus( + prevCumulativeTotalLiquidityPremiumUSD + ); + poolMetrics.cumulativeTotalLiquidityPremiumUSD = + pool.cumulativeTotalLiquidityPremiumUSD; + + poolMetrics.hourlyVolumeUSD = pool.cumulativeVolumeUSD.minus( + prevCumulativeVolumeUSD + ); + poolMetrics.cumulativeVolumeUSD = pool.cumulativeVolumeUSD; + poolMetrics.hourlyInflowVolumeUSD = pool.cumulativeInflowVolumeUSD.minus( + prevCumulativeInflowVolumeUSD + ); + poolMetrics.cumulativeInflowVolumeUSD = pool.cumulativeInflowVolumeUSD; + poolMetrics.hourlyClosedInflowVolumeUSD = + pool.cumulativeClosedInflowVolumeUSD.minus( + prevCumulativeClosedInflowVolumeUSD + ); + poolMetrics.cumulativeClosedInflowVolumeUSD = + pool.cumulativeClosedInflowVolumeUSD; + poolMetrics.hourlyOutflowVolumeUSD = pool.cumulativeOutflowVolumeUSD.minus( + prevCumulativeOutflowVolumeUSD + ); + poolMetrics.cumulativeOutflowVolumeUSD = pool.cumulativeOutflowVolumeUSD; + poolMetrics._cumulativeVolumeByTokenAmount = + pool._cumulativeVolumeByTokenAmount; + poolMetrics._cumulativeVolumeByTokenUSD = pool._cumulativeVolumeByTokenUSD; + poolMetrics._cumulativeInflowVolumeByTokenAmount = + pool._cumulativeInflowVolumeByTokenAmount; + poolMetrics._cumulativeInflowVolumeByTokenUSD = + pool._cumulativeInflowVolumeByTokenUSD; + poolMetrics._cumulativeOutflowVolumeByTokenAmount = + pool._cumulativeOutflowVolumeByTokenAmount; + poolMetrics._cumulativeOutflowVolumeByTokenUSD = + pool._cumulativeOutflowVolumeByTokenUSD; + poolMetrics._cumulativeClosedInflowVolumeByTokenAmount = + pool._cumulativeClosedInflowVolumeByTokenAmount; + poolMetrics._cumulativeClosedInflowVolumeByTokenUSD = + pool._cumulativeClosedInflowVolumeByTokenUSD; + const hourlyVolumeByTokenAmount = pool._cumulativeVolumeByTokenAmount; + const hourlyVolumeByTokenUSD = pool._cumulativeVolumeByTokenUSD; + const hourlyInflowVolumeByTokenAmount = + pool._cumulativeInflowVolumeByTokenAmount; + const hourlyInflowVolumeByTokenUSD = pool._cumulativeInflowVolumeByTokenUSD; + const hourlyClosedInflowVolumeByTokenAmount = + pool._cumulativeClosedInflowVolumeByTokenAmount; + const hourlyClosedInflowVolumeByTokenUSD = + pool._cumulativeClosedInflowVolumeByTokenUSD; + const hourlyOutflowVolumeByTokenAmount = + pool._cumulativeOutflowVolumeByTokenAmount; + const hourlyOutflowVolumeByTokenUSD = pool._cumulativeOutflowVolumeByTokenUSD; + + for (let i = 0; i < inputTokenLength; i++) { + for (let j = 0; j < prevInputTokens.length; j++) { + if (pool.inputTokens[i] == prevInputTokens[j]) { + hourlyVolumeByTokenAmount[i] = hourlyVolumeByTokenAmount[i].minus( + prevCumulativeVolumeByTokenAmount[j] + ); + hourlyVolumeByTokenUSD[i] = hourlyVolumeByTokenUSD[i].minus( + prevCumulativeVolumeByTokenUSD[j] + ); + hourlyInflowVolumeByTokenAmount[i] = hourlyInflowVolumeByTokenAmount[ + i + ].minus(prevCumulativeInflowVolumeByTokenAmount[j]); + hourlyInflowVolumeByTokenUSD[i] = hourlyInflowVolumeByTokenUSD[i].minus( + prevCumulativeInflowVolumeByTokenUSD[j] + ); + hourlyClosedInflowVolumeByTokenAmount[i] = + hourlyClosedInflowVolumeByTokenAmount[i].minus( + prevCumulativeClosedInflowVolumeByTokenAmount[j] + ); + hourlyClosedInflowVolumeByTokenUSD[i] = + hourlyClosedInflowVolumeByTokenUSD[i].minus( + prevCumulativeClosedInflowVolumeByTokenUSD[j] + ); + hourlyOutflowVolumeByTokenAmount[i] = hourlyOutflowVolumeByTokenAmount[ + i + ].minus(prevCumulativeOutflowVolumeByTokenAmount[j]); + hourlyOutflowVolumeByTokenUSD[i] = hourlyOutflowVolumeByTokenUSD[ + i + ].minus(prevCumulativeOutflowVolumeByTokenUSD[j]); + } + } + } + poolMetrics.hourlyVolumeByTokenAmount = hourlyVolumeByTokenAmount; + poolMetrics.hourlyVolumeByTokenUSD = hourlyVolumeByTokenUSD; + poolMetrics.hourlyInflowVolumeByTokenAmount = hourlyInflowVolumeByTokenAmount; + poolMetrics.hourlyInflowVolumeByTokenUSD = hourlyInflowVolumeByTokenUSD; + poolMetrics.hourlyClosedInflowVolumeByTokenAmount = + hourlyClosedInflowVolumeByTokenAmount; + poolMetrics.hourlyClosedInflowVolumeByTokenUSD = + hourlyClosedInflowVolumeByTokenUSD; + poolMetrics.hourlyOutflowVolumeByTokenAmount = + hourlyOutflowVolumeByTokenAmount; + poolMetrics.hourlyOutflowVolumeByTokenUSD = hourlyOutflowVolumeByTokenUSD; + + poolMetrics.save(); +} + +export function takeFinancialDailySnapshot( + protocol: DerivPerpProtocol, + day: i32 +): void { + const id = Bytes.fromI32(day); + if (FinancialsDailySnapshot.load(id)) { + return; + } + + const financialMetrics = new FinancialsDailySnapshot(id); + const prevFinancialMetrics = FinancialsDailySnapshot.load( + Bytes.fromI32(protocol._lastSnapshotDayID) + ); + + let prevCumulativeVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeInflowVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeClosedInflowVolumeUSD = BIGDECIMAL_ZERO; + let prevCumulativeOutflowVolumeUSD = BIGDECIMAL_ZERO; + + let prevCumulativeSupplySideRevenueUSD = BIGDECIMAL_ZERO; + let prevCumulativeProtocolSideRevenueUSD = BIGDECIMAL_ZERO; + let prevCumulativeStakeSideRevenueUSD = BIGDECIMAL_ZERO; + let prevCumulativeTotalRevenueUSD = BIGDECIMAL_ZERO; + let prevCumulativeEntryPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeExitPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeTotalPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeDepositPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeWithdrawPremiumUSD = BIGDECIMAL_ZERO; + let prevCumulativeTotalLiquidityPremiumUSD = BIGDECIMAL_ZERO; + + if (prevFinancialMetrics) { + prevCumulativeVolumeUSD = prevFinancialMetrics.cumulativeVolumeUSD; + prevCumulativeInflowVolumeUSD = + prevFinancialMetrics.cumulativeInflowVolumeUSD; + prevCumulativeClosedInflowVolumeUSD = + prevFinancialMetrics.cumulativeClosedInflowVolumeUSD; + prevCumulativeOutflowVolumeUSD = + prevFinancialMetrics.cumulativeOutflowVolumeUSD; + prevCumulativeSupplySideRevenueUSD = + prevFinancialMetrics.cumulativeSupplySideRevenueUSD; + prevCumulativeProtocolSideRevenueUSD = + prevFinancialMetrics.cumulativeProtocolSideRevenueUSD; + prevCumulativeStakeSideRevenueUSD = + prevFinancialMetrics.cumulativeStakeSideRevenueUSD; + prevCumulativeTotalRevenueUSD = + prevFinancialMetrics.cumulativeTotalRevenueUSD; + prevCumulativeEntryPremiumUSD = + prevFinancialMetrics.cumulativeEntryPremiumUSD; + prevCumulativeExitPremiumUSD = + prevFinancialMetrics.cumulativeExitPremiumUSD; + prevCumulativeTotalPremiumUSD = + prevFinancialMetrics.cumulativeTotalPremiumUSD; + prevCumulativeDepositPremiumUSD = + prevFinancialMetrics.cumulativeDepositPremiumUSD; + prevCumulativeWithdrawPremiumUSD = + prevFinancialMetrics.cumulativeWithdrawPremiumUSD; + prevCumulativeTotalLiquidityPremiumUSD = + prevFinancialMetrics.cumulativeTotalLiquidityPremiumUSD; + } else if (protocol._lastSnapshotDayID > INT_ZERO) { + log.error( + "Missing protocol snapshot at ID that has been snapped: Protocol {}, ID {} ", + [protocol.id.toHexString(), protocol._lastSnapshotDayID.toString()] + ); + } + + financialMetrics.days = day; + financialMetrics.protocol = protocol.id; + financialMetrics.totalValueLockedUSD = protocol.totalValueLockedUSD; + financialMetrics.protocolControlledValueUSD = + protocol.protocolControlledValueUSD; + financialMetrics.cumulativeVolumeUSD = protocol.cumulativeVolumeUSD; + financialMetrics.dailyVolumeUSD = protocol.cumulativeVolumeUSD.minus( + prevCumulativeVolumeUSD + ); + financialMetrics.cumulativeInflowVolumeUSD = + protocol.cumulativeInflowVolumeUSD; + financialMetrics.dailyInflowVolumeUSD = + protocol.cumulativeInflowVolumeUSD.minus(prevCumulativeInflowVolumeUSD); + financialMetrics.cumulativeClosedInflowVolumeUSD = + protocol.cumulativeClosedInflowVolumeUSD; + financialMetrics.dailyClosedInflowVolumeUSD = + protocol.cumulativeClosedInflowVolumeUSD.minus( + prevCumulativeClosedInflowVolumeUSD + ); + financialMetrics.cumulativeOutflowVolumeUSD = + protocol.cumulativeOutflowVolumeUSD; + financialMetrics.dailyOutflowVolumeUSD = + protocol.cumulativeOutflowVolumeUSD.minus(prevCumulativeOutflowVolumeUSD); + financialMetrics.cumulativeSupplySideRevenueUSD = + protocol.cumulativeSupplySideRevenueUSD; + financialMetrics.dailySupplySideRevenueUSD = + protocol.cumulativeSupplySideRevenueUSD.minus( + prevCumulativeSupplySideRevenueUSD + ); + financialMetrics.cumulativeProtocolSideRevenueUSD = + protocol.cumulativeProtocolSideRevenueUSD; + financialMetrics.dailyProtocolSideRevenueUSD = + protocol.cumulativeProtocolSideRevenueUSD.minus( + prevCumulativeProtocolSideRevenueUSD + ); + financialMetrics.cumulativeTotalRevenueUSD = + protocol.cumulativeTotalRevenueUSD; + financialMetrics.dailyTotalRevenueUSD = + protocol.cumulativeTotalRevenueUSD.minus(prevCumulativeTotalRevenueUSD); + financialMetrics.cumulativeStakeSideRevenueUSD = + protocol.cumulativeStakeSideRevenueUSD; + financialMetrics.dailyStakeSideRevenueUSD = + protocol.cumulativeStakeSideRevenueUSD.minus( + prevCumulativeStakeSideRevenueUSD + ); + financialMetrics.dailyEntryPremiumUSD = + protocol.cumulativeEntryPremiumUSD.minus(prevCumulativeEntryPremiumUSD); + financialMetrics.cumulativeEntryPremiumUSD = + protocol.cumulativeEntryPremiumUSD; + financialMetrics.dailyExitPremiumUSD = + protocol.cumulativeExitPremiumUSD.minus(prevCumulativeExitPremiumUSD); + financialMetrics.cumulativeExitPremiumUSD = protocol.cumulativeExitPremiumUSD; + financialMetrics.dailyTotalPremiumUSD = + protocol.cumulativeTotalPremiumUSD.minus(prevCumulativeTotalPremiumUSD); + financialMetrics.cumulativeTotalPremiumUSD = + protocol.cumulativeTotalPremiumUSD; + financialMetrics.dailyDepositPremiumUSD = + protocol.cumulativeDepositPremiumUSD.minus(prevCumulativeDepositPremiumUSD); + financialMetrics.cumulativeDepositPremiumUSD = + protocol.cumulativeDepositPremiumUSD; + financialMetrics.dailyWithdrawPremiumUSD = + protocol.cumulativeWithdrawPremiumUSD.minus( + prevCumulativeWithdrawPremiumUSD + ); + financialMetrics.cumulativeWithdrawPremiumUSD = + protocol.cumulativeWithdrawPremiumUSD; + financialMetrics.dailyTotalLiquidityPremiumUSD = + protocol.cumulativeTotalLiquidityPremiumUSD.minus( + prevCumulativeTotalLiquidityPremiumUSD + ); + financialMetrics.cumulativeTotalLiquidityPremiumUSD = + protocol.cumulativeTotalLiquidityPremiumUSD; + financialMetrics.dailyLongOpenInterestUSD = protocol.longOpenInterestUSD; + financialMetrics.dailyShortOpenInterestUSD = protocol.shortOpenInterestUSD; + financialMetrics.dailyTotalOpenInterestUSD = protocol.totalOpenInterestUSD; + + financialMetrics.save(); +} + +export function takeUsageMetricsDailySnapshot( + protocol: DerivPerpProtocol, + day: i32 +): void { + // Create unique id for the day + const id = Bytes.fromI32(day); + if (UsageMetricsDailySnapshot.load(id)) { + return; + } + + const usageMetrics = new UsageMetricsDailySnapshot(Bytes.fromI32(day)); + usageMetrics.days = day; + usageMetrics.protocol = protocol.id; + + const tempUsageMetrics = _TempUsageMetricsDailySnapshot.load(id); + if (tempUsageMetrics) { + usageMetrics.dailyLongPositionCount = + tempUsageMetrics.dailyLongPositionCount; + usageMetrics.dailyShortPositionCount = + tempUsageMetrics.dailyShortPositionCount; + usageMetrics.dailyOpenPositionCount = + tempUsageMetrics.dailyOpenPositionCount; + usageMetrics.dailyClosedPositionCount = + tempUsageMetrics.dailyClosedPositionCount; + usageMetrics.dailyCumulativePositionCount = + tempUsageMetrics.dailyCumulativePositionCount; + + usageMetrics.dailyTransactionCount = tempUsageMetrics.dailyTransactionCount; + usageMetrics.dailyDepositCount = tempUsageMetrics.dailyDepositCount; + usageMetrics.dailyWithdrawCount = tempUsageMetrics.dailyWithdrawCount; + usageMetrics.dailyBorrowCount = tempUsageMetrics.dailyBorrowCount; + usageMetrics.dailySwapCount = tempUsageMetrics.dailySwapCount; + + usageMetrics.dailyActiveDepositors = tempUsageMetrics.dailyActiveDepositors; + usageMetrics.dailyActiveBorrowers = tempUsageMetrics.dailyActiveBorrowers; + usageMetrics.dailyActiveLiquidators = + tempUsageMetrics.dailyActiveLiquidators; + usageMetrics.dailyActiveLiquidatees = + tempUsageMetrics.dailyActiveLiquidatees; + usageMetrics.dailyActiveUsers = tempUsageMetrics.dailyActiveUsers; + + usageMetrics.dailyCollateralIn = tempUsageMetrics.dailyCollateralIn; + usageMetrics.dailyCollateralOut = tempUsageMetrics.dailyCollateralOut; + } else { + usageMetrics.dailyLongPositionCount = INT_ZERO; + usageMetrics.dailyShortPositionCount = INT_ZERO; + usageMetrics.dailyOpenPositionCount = INT_ZERO; + usageMetrics.dailyClosedPositionCount = INT_ZERO; + usageMetrics.dailyCumulativePositionCount = INT_ZERO; + + usageMetrics.dailyTransactionCount = INT_ZERO; + usageMetrics.dailyDepositCount = INT_ZERO; + usageMetrics.dailyWithdrawCount = INT_ZERO; + usageMetrics.dailyBorrowCount = INT_ZERO; + usageMetrics.dailySwapCount = INT_ZERO; + + usageMetrics.dailyActiveDepositors = INT_ZERO; + usageMetrics.dailyActiveBorrowers = INT_ZERO; + usageMetrics.dailyActiveLiquidators = INT_ZERO; + usageMetrics.dailyActiveLiquidatees = INT_ZERO; + usageMetrics.dailyActiveUsers = INT_ZERO; + + usageMetrics.dailyCollateralIn = INT_ZERO; + usageMetrics.dailyCollateralOut = INT_ZERO; + } + + usageMetrics.longPositionCount = protocol.longPositionCount; + usageMetrics.shortPositionCount = protocol.shortPositionCount; + usageMetrics.openPositionCount = protocol.openPositionCount; + usageMetrics.closedPositionCount = protocol.closedPositionCount; + usageMetrics.cumulativePositionCount = protocol.cumulativePositionCount; + + usageMetrics.cumulativeUniqueDepositors = protocol.cumulativeUniqueDepositors; + usageMetrics.cumulativeUniqueBorrowers = protocol.cumulativeUniqueBorrowers; + usageMetrics.cumulativeUniqueLiquidators = + protocol.cumulativeUniqueLiquidators; + usageMetrics.cumulativeUniqueLiquidatees = + protocol.cumulativeUniqueLiquidatees; + usageMetrics.cumulativeUniqueUsers = protocol.cumulativeUniqueUsers; + + usageMetrics.cumulativeCollateralIn = protocol.collateralInCount; + usageMetrics.cumulativeCollateralOut = protocol.collateralOutCount; + + usageMetrics.totalPoolCount = protocol.totalPoolCount; + + usageMetrics.save(); +} + +export function takeUsageMetricsHourlySnapshot( + protocol: DerivPerpProtocol, + hour: i32 +): void { + // Create unique id for the hour + const id = Bytes.fromI32(hour); + if (UsageMetricsHourlySnapshot.load(id)) { + return; + } + + const usageMetrics = new UsageMetricsHourlySnapshot(id); + usageMetrics.hours = hour; + usageMetrics.protocol = protocol.id; + + const tempUsageMetrics = _TempUsageMetricsHourlySnapshot.load(id); + if (tempUsageMetrics) { + usageMetrics.hourlyActiveUsers = tempUsageMetrics.hourlyActiveUsers; + usageMetrics.hourlyTransactionCount = + tempUsageMetrics.hourlyTransactionCount; + usageMetrics.hourlyDepositCount = tempUsageMetrics.hourlyDepositCount; + usageMetrics.hourlyWithdrawCount = tempUsageMetrics.hourlyWithdrawCount; + usageMetrics.hourlySwapCount = tempUsageMetrics.hourlySwapCount; + usageMetrics.hourlyBorrowCount = tempUsageMetrics.hourlyBorrowCount; + } else { + usageMetrics.hourlyActiveUsers = INT_ZERO; + usageMetrics.hourlyTransactionCount = INT_ZERO; + usageMetrics.hourlyDepositCount = INT_ZERO; + usageMetrics.hourlyWithdrawCount = INT_ZERO; + usageMetrics.hourlySwapCount = INT_ZERO; + usageMetrics.hourlyBorrowCount = INT_ZERO; + } + + usageMetrics.cumulativeUniqueUsers = protocol.cumulativeUniqueUsers; + + usageMetrics.save(); + + return; +} + +export function getOrCreateTempUsageMetricsDailySnapshot( + event: ethereum.Event +): _TempUsageMetricsDailySnapshot { + const protocol = getOrCreateProtocol(); + // Number of days since Unix epoch + const day = event.block.timestamp.toI32() / SECONDS_PER_DAY; + // Create unique id for the day + const id = Bytes.fromI32(day); + let usageMetrics = _TempUsageMetricsDailySnapshot.load(id); + + if (!usageMetrics) { + usageMetrics = new _TempUsageMetricsDailySnapshot(id); + usageMetrics.days = day; + usageMetrics.protocol = protocol.id; + + usageMetrics.dailyLongPositionCount = INT_ZERO; + usageMetrics.dailyShortPositionCount = INT_ZERO; + usageMetrics.dailyOpenPositionCount = INT_ZERO; + usageMetrics.dailyClosedPositionCount = INT_ZERO; + usageMetrics.dailyCumulativePositionCount = INT_ZERO; + + usageMetrics.dailyTransactionCount = INT_ZERO; + usageMetrics.dailyDepositCount = INT_ZERO; + usageMetrics.dailyWithdrawCount = INT_ZERO; + usageMetrics.dailyBorrowCount = INT_ZERO; + usageMetrics.dailySwapCount = INT_ZERO; + + usageMetrics.dailyActiveDepositors = INT_ZERO; + usageMetrics.dailyActiveBorrowers = INT_ZERO; + usageMetrics.dailyActiveLiquidators = INT_ZERO; + usageMetrics.dailyActiveLiquidatees = INT_ZERO; + usageMetrics.dailyActiveUsers = INT_ZERO; + + usageMetrics.dailyCollateralIn = INT_ZERO; + usageMetrics.dailyCollateralOut = INT_ZERO; + + usageMetrics.save(); + } + + return usageMetrics; +} + +export function getOrCreateTempUsageMetricsHourlySnapshot( + event: ethereum.Event +): _TempUsageMetricsHourlySnapshot { + const protocol = getOrCreateProtocol(); + // Number of hours since Unix epoch + const hour = event.block.timestamp.toI32() / SECONDS_PER_HOUR; + const id = Bytes.fromI32(hour); + // Create unique id for the day + let usageMetrics = _TempUsageMetricsHourlySnapshot.load(id); + + if (!usageMetrics) { + usageMetrics = new _TempUsageMetricsHourlySnapshot(id); + usageMetrics.hours = hour; + usageMetrics.protocol = protocol.id; + + usageMetrics.hourlyActiveUsers = INT_ZERO; + usageMetrics.hourlyTransactionCount = INT_ZERO; + usageMetrics.hourlyDepositCount = INT_ZERO; + usageMetrics.hourlyWithdrawCount = INT_ZERO; + usageMetrics.hourlySwapCount = INT_ZERO; + usageMetrics.hourlyBorrowCount = INT_ZERO; + + usageMetrics.save(); + } + + return usageMetrics; +} + +// Update temp usage metrics entities +export function updateTempUsageMetrics( + event: ethereum.Event, + fromAddress: Address, + eventType: EventType, + openPositionCount: i32, + positionSide: string | null +): void { + const usageMetricsDaily = getOrCreateTempUsageMetricsDailySnapshot(event); + const usageMetricsHourly = getOrCreateTempUsageMetricsHourlySnapshot(event); + + usageMetricsDaily.dailyTransactionCount += INT_ONE; + usageMetricsHourly.hourlyTransactionCount += INT_ONE; + + switch (eventType) { + case EventType.Deposit: + usageMetricsDaily.dailyDepositCount += INT_ONE; + usageMetricsHourly.hourlyDepositCount += INT_ONE; + if (isUniqueDailyUser(event, fromAddress, eventType)) { + usageMetricsDaily.dailyActiveDepositors += INT_ONE; + } + break; + case EventType.Withdraw: + usageMetricsDaily.dailyWithdrawCount += INT_ONE; + usageMetricsHourly.hourlyWithdrawCount += INT_ONE; + break; + case EventType.CollateralIn: + usageMetricsDaily.dailyCollateralIn += INT_ONE; + usageMetricsDaily.dailyBorrowCount += INT_ONE; + usageMetricsHourly.hourlyBorrowCount += INT_ONE; + if (isUniqueDailyUser(event, fromAddress, eventType)) { + usageMetricsDaily.dailyActiveBorrowers += INT_ONE; + } + break; + case EventType.CollateralOut: + case EventType.ClosePosition: + usageMetricsDaily.dailyCollateralOut += INT_ONE; + break; + case EventType.Swap: + usageMetricsDaily.dailySwapCount += INT_ONE; + usageMetricsHourly.hourlySwapCount += INT_ONE; + break; + case EventType.Liquidate: + if (isUniqueDailyUser(event, fromAddress, eventType)) { + usageMetricsDaily.dailyActiveLiquidators += INT_ONE; + } + break; + case EventType.Liquidated: + if (isUniqueDailyUser(event, fromAddress, eventType)) { + usageMetricsDaily.dailyActiveLiquidatees += INT_ONE; + } + break; + + default: + break; + } + + // Number of days since Unix epoch + const day = event.block.timestamp.toI32() / SECONDS_PER_DAY; + const hour = event.block.timestamp.toI32() / SECONDS_PER_HOUR; + + // Combine the id and the user address to generate a unique user id for the day + const dailyActiveAccountId = fromAddress.concatI32(day); + let dailyActiveAccount = ActiveAccount.load(dailyActiveAccountId); + if (!dailyActiveAccount) { + dailyActiveAccount = new ActiveAccount(dailyActiveAccountId); + usageMetricsDaily.dailyActiveUsers += INT_ONE; + dailyActiveAccount.save(); + } + + const hourlyActiveAccountId = fromAddress.concatI32(hour); + let hourlyActiveAccount = ActiveAccount.load(hourlyActiveAccountId); + if (!hourlyActiveAccount) { + hourlyActiveAccount = new ActiveAccount(hourlyActiveAccountId); + usageMetricsHourly.hourlyActiveUsers += INT_ONE; + hourlyActiveAccount.save(); + } + + if (openPositionCount > INT_ZERO) { + if (PositionSide.LONG == positionSide) { + usageMetricsDaily.dailyLongPositionCount += INT_ONE; + } else { + usageMetricsDaily.dailyShortPositionCount += INT_ONE; + } + usageMetricsDaily.dailyOpenPositionCount += INT_ONE; + usageMetricsDaily.dailyCumulativePositionCount += INT_ONE; + } else if (openPositionCount < INT_ZERO) { + usageMetricsDaily.dailyClosedPositionCount += INT_ONE; + } + + usageMetricsDaily.save(); + usageMetricsHourly.save(); +} + +function isUniqueDailyUser( + event: ethereum.Event, + fromAddress: Address, + eventType: EventType +): boolean { + const day = event.block.timestamp.toI32() / SECONDS_PER_DAY; + // Combine the id, user address, and action to generate a unique user id for the day + const dailyActionActiveAccountId = fromAddress + .concatI32(day) + .concat(Bytes.fromUTF8(eventType.toString())); + let dailyActionActiveAccount = ActiveAccount.load(dailyActionActiveAccountId); + if (!dailyActionActiveAccount) { + dailyActionActiveAccount = new ActiveAccount(dailyActionActiveAccountId); + dailyActionActiveAccount.save(); + return true; + } + return false; +} diff --git a/subgraphs/vela-exchange/src/entities/token.ts b/subgraphs/vela-exchange/src/entities/token.ts new file mode 100644 index 0000000000..35b682dfdd --- /dev/null +++ b/subgraphs/vela-exchange/src/entities/token.ts @@ -0,0 +1,111 @@ +import { Address, BigDecimal, Bytes, ethereum } from "@graphprotocol/graph-ts"; +import { ERC20 } from "../../generated/Vault/ERC20"; +import { Token, RewardToken } from "../../generated/schema"; +import { getUsdPricePerToken } from "../prices"; +import { + BIGDECIMAL_ZERO, + RewardTokenType, + PRICE_CACHING_BLOCKS, + INT_ZERO, + VLP_ADDRESS, +} from "../utils/constants"; + +export function getOrCreateToken( + event: ethereum.Event, + tokenAddress: Address +): Token { + let token = Token.load(tokenAddress); + + if (!token) { + token = new Token(tokenAddress); + + token.name = fetchTokenName(tokenAddress); + token.symbol = fetchTokenSymbol(tokenAddress); + token.decimals = fetchTokenDecimals(tokenAddress) as i32; + token.lastPriceUSD = BIGDECIMAL_ZERO; + token.lastPriceBlockNumber = event.block.number; + token.save(); + } + + // VLP price will be computed elsewhere. + if (tokenAddress == Address.fromHexString(VLP_ADDRESS)) { + return token; + } + + if ( + token.lastPriceUSD && + token.lastPriceBlockNumber && + event.block.number + .minus(token.lastPriceBlockNumber!) + .lt(PRICE_CACHING_BLOCKS) + ) { + return token; + } + + // Optional lastPriceUSD and lastPriceBlockNumber, but used in financialMetrics + const price = getUsdPricePerToken(tokenAddress, event.block); + if (!price.reverted) { + token.lastPriceUSD = price.usdPrice; + } + + token.lastPriceBlockNumber = event.block.number; + token.save(); + + return token; +} + +export function updateTokenPrice( + event: ethereum.Event, + token: Token, + tokenPriceUSD: BigDecimal +): void { + token.lastPriceUSD = tokenPriceUSD; + token.lastPriceBlockNumber = event.block.number; + token.save(); +} + +export function getOrCreateRewardToken( + event: ethereum.Event, + address: Address +): RewardToken { + const id = Bytes.fromI32(INT_ZERO).concat(address); + let rewardToken = RewardToken.load(id); + if (!rewardToken) { + const token = getOrCreateToken(event, address); + rewardToken = new RewardToken(id); + rewardToken.token = token.id; + rewardToken.type = RewardTokenType.DEPOSIT; + rewardToken.save(); + } + return rewardToken; +} + +function fetchTokenName(tokenAddress: Address): string { + const tokenContract = ERC20.bind(tokenAddress); + const call = tokenContract.try_name(); + if (call.reverted) { + return tokenAddress.toHexString(); + } else { + return call.value; + } +} + +function fetchTokenSymbol(tokenAddress: Address): string { + const tokenContract = ERC20.bind(tokenAddress); + const call = tokenContract.try_symbol(); + if (call.reverted) { + return " "; + } else { + return call.value; + } +} + +function fetchTokenDecimals(tokenAddress: Address): number { + const tokenContract = ERC20.bind(tokenAddress); + const call = tokenContract.try_decimals(); + if (call.reverted) { + return 0; + } else { + return call.value; + } +} diff --git a/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts b/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts new file mode 100644 index 0000000000..841ea5bbf5 --- /dev/null +++ b/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts @@ -0,0 +1,37 @@ +import { Address, BigInt, log } from "@graphprotocol/graph-ts"; +import { + AddRewardInfo, + ComplexRewarderPerSec, +} from "../../generated/ComplexRewarderPerSec/ComplexRewarderPerSec"; +import { getOrCreateToken, getOrCreateRewardToken } from "../entities/token"; +import { updatePoolRewardToken } from "../entities/pool"; +import { takeSnapshots } from "../entities/snapshots"; +import { convertTokenToDecimal } from "../utils/numbers"; +import { + SECONDS_PER_DAY, +} from "../utils/constants"; + +export function handleAddRewardInfo(event: AddRewardInfo): void { + takeSnapshots(event); + + const complexRewarderPerSecContract = ComplexRewarderPerSec.bind( + event.address + ); + const tryRewardToken = complexRewarderPerSecContract.try_rewardToken(); + if (tryRewardToken.reverted) { + return; + } + const rewardTokenAddress = tryRewardToken.value; + + // Based on the emissions rate for the pool, calculate the rewards per day for the pool. + const tokensPerDay = event.params.rewardPerSec.times( + BigInt.fromI32(SECONDS_PER_DAY) + ); + const rewardToken = getOrCreateRewardToken(event, rewardTokenAddress); + const token = getOrCreateToken(event, rewardTokenAddress); + const tokensPerDayUSD = convertTokenToDecimal( + tokensPerDay, + token.decimals + ).times(token.lastPriceUSD!); + updatePoolRewardToken(event, rewardToken, tokensPerDay, tokensPerDayUSD); +} diff --git a/subgraphs/vela-exchange/src/mappings/Vault.ts b/subgraphs/vela-exchange/src/mappings/Vault.ts new file mode 100644 index 0000000000..cbf2ebe3e9 --- /dev/null +++ b/subgraphs/vela-exchange/src/mappings/Vault.ts @@ -0,0 +1,90 @@ +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Stake, Unstake } from "../../generated/Vault/Vault"; +import { incrementProtocolEventCount } from "../entities/protocol"; +import { + getOrCreateLiquidityPool, + updatePoolTvl, + updatePoolOutputToken, + addPoolInputToken, +} from "../entities/pool"; +import { createDeposit, createWithdraw, EventType } from "../entities/event"; +import { + getOrCreateAccount, + incrementAccountEventCount, +} from "../entities/account"; +import { takeSnapshots, updateTempUsageMetrics } from "../entities/snapshots"; +import { convertTokenToDecimal } from "../utils/numbers"; +import { BIGDECIMAL_ZERO, INT_ZERO, VLP_ADDRESS } from "../utils/constants"; +import { getOrCreateToken } from "../entities/token"; + +export function handleStake(event: Stake): void { + handleUpdateLiquidityEvent( + event, + event.params.account, + event.params.token, + event.params.amount, + event.params.mintAmount, + EventType.Deposit + ); +} + +export function handleUnstake(event: Unstake): void { + handleUpdateLiquidityEvent( + event, + event.params.account, + event.params.token, + event.params.amountOut, + event.params.vlpAmount, + EventType.Withdraw + ); +} + +function handleUpdateLiquidityEvent( + event: ethereum.Event, + accountAddress: Address, + inputTokenAddress: Address, + inputTokenAmount: BigInt, + outputTokenAmount: BigInt, + eventType: EventType +): void { + takeSnapshots(event); + + const account = getOrCreateAccount(event, accountAddress); + incrementAccountEventCount(event, account, eventType, BIGDECIMAL_ZERO); + incrementProtocolEventCount(event, eventType, BIGDECIMAL_ZERO); + + const pool = getOrCreateLiquidityPool(event); + const inputToken = getOrCreateToken(event, inputTokenAddress); + addPoolInputToken(event, pool, inputToken); + const usdAmount = convertTokenToDecimal( + inputTokenAmount, + inputToken.decimals + ).times(inputToken.lastPriceUSD!); + if (eventType == EventType.Deposit) { + if (!pool.outputToken) { + updatePoolOutputToken(event, pool, Address.fromString(VLP_ADDRESS)); + } + + createDeposit( + event, + accountAddress, + inputTokenAddress, + inputTokenAmount, + usdAmount, + outputTokenAmount + ); + } else if (eventType == EventType.Withdraw) { + createWithdraw( + event, + accountAddress, + inputTokenAddress, + inputTokenAmount, + usdAmount, + outputTokenAmount + ); + } + + updatePoolTvl(event, pool); + + updateTempUsageMetrics(event, accountAddress, eventType, INT_ZERO, null); +} diff --git a/subgraphs/vela-exchange/src/mappings/VaultUtils.ts b/subgraphs/vela-exchange/src/mappings/VaultUtils.ts new file mode 100644 index 0000000000..034d7a8f8d --- /dev/null +++ b/subgraphs/vela-exchange/src/mappings/VaultUtils.ts @@ -0,0 +1,406 @@ +import { + Address, + BigDecimal, + BigInt, + Bytes, + ethereum, + log, +} from "@graphprotocol/graph-ts"; +import { + IncreasePosition, + DecreasePosition, + ClosePosition, + LiquidatePosition, +} from "../../generated/VaultUtils/VaultUtils"; +import { + createBorrow, + createCollateralIn, + createCollateralOut, + createLiquidate, + EventType, +} from "../entities/event"; +import { getOrCreateToken, updateTokenPrice } from "../entities/token"; +import { + getOrCreateAccount, + incrementAccountEventCount, +} from "../entities/account"; +import { + createPositionMap, + getPositionWithKey, + getUserPosition, + updateUserPosition, +} from "../entities/position"; +import { + increaseProtocolStakeSideRevenue, + incrementProtocolEventCount, +} from "../entities/protocol"; +import { + getOrCreateLiquidityPool, + increasePoolProtocolSideRevenue, + increasePoolSupplySideRevenue, + updatePoolOpenInterestUSD, + increasePoolPremium, + increasePoolVolume, +} from "../entities/pool"; +import { takeSnapshots, updateTempUsageMetrics } from "../entities/snapshots"; +import { + BIGDECIMAL_ONE, + BIGDECIMAL_ZERO, + BIGINT_ZERO, + FUNDING_PRECISION, + INT_NEGATIVE_ONE, + INT_ONE, + INT_ZERO, + PositionSide, + PRICE_PRECISION, + PROTOCOL_SIDE_REVENUE_PERCENT, + STAKE_SIDE_REVENUE_PERCENT, + USDC_ADDRESS_ARBITRUM, +} from "../utils/constants"; +import { bigDecimalToBigInt, exponentToBigDecimal } from "../utils/numbers"; +import { LiquidityPool } from "../../generated/schema"; + +export function handleIncreasePosition(event: IncreasePosition): void { + event.params.posData; + handleUpdatePositionEvent( + event, + event.params.key, + event.params.account, + Address.fromString(USDC_ADDRESS_ARBITRUM), + event.params.posData[0].div(PRICE_PRECISION).toBigDecimal(), + event.params.indexToken, + event.params.posData[1].div(PRICE_PRECISION).toBigDecimal(), + event.params.posData[5], + event.params.posData[6], + event.params.isLong, + event.params.posId, + event.params.posData[3].divDecimal(FUNDING_PRECISION), + BIGINT_ZERO, + EventType.CollateralIn + ); +} + +export function handleDecreasePosition(event: DecreasePosition): void { + handleUpdatePositionEvent( + event, + event.params.key, + event.params.account, + Address.fromString(USDC_ADDRESS_ARBITRUM), + event.params.posData[0].div(PRICE_PRECISION).toBigDecimal(), + event.params.indexToken, + event.params.posData[1].div(PRICE_PRECISION).toBigDecimal(), + event.params.posData[5], + event.params.posData[6], + event.params.isLong, + event.params.posId, + event.params.posData[3].divDecimal(FUNDING_PRECISION), + event.params.realisedPnl, + EventType.CollateralOut + ); +} + +export function handleClosePosition(event: ClosePosition): void { + const position = getPositionWithKey(event.params.key); + if (!position) { + return; + } + + let isLong = true; + if (position.side == PositionSide.SHORT) { + isLong = false; + } + handleUpdatePositionEvent( + event, + event.params.key, + Address.fromBytes(position.account), + Address.fromString(USDC_ADDRESS_ARBITRUM), + position.collateralBalanceUSD, + Address.fromBytes(position.asset), + position.balanceUSD, + event.params.markPrice, + event.params.feeUsd, + isLong, + position._posId!, + BIGDECIMAL_ZERO, + event.params.realisedPnl, + EventType.ClosePosition + ); +} + +export function handleLiquidatePosition(event: LiquidatePosition): void { + const position = getPositionWithKey(event.params.key); + if (!position) { + return; + } + + let isLong = true; + if (position.side == PositionSide.SHORT) { + isLong = false; + } + handleUpdatePositionEvent( + event, + event.params.key, + Address.fromBytes(position.account), + Address.fromString(USDC_ADDRESS_ARBITRUM), + position.collateralBalanceUSD, + Address.fromBytes(position.asset), + position.balanceUSD, + event.params.markPrice, + BIGINT_ZERO, + isLong, + position._posId!, + BIGDECIMAL_ZERO, + event.params.realisedPnl, + EventType.Liquidated + ); +} + +export function handleUpdatePositionEvent( + event: ethereum.Event, + positionKey: Bytes, + accountAddress: Address, + collateralTokenAddress: Address, + collateralUSDDelta: BigDecimal, + indexTokenAddress: Address, + sizeUSDDelta: BigDecimal, + indexTokenPrice: BigInt, + fee: BigInt, + isLong: boolean, + posId: BigInt, + entryFundingRate: BigDecimal, + realisedPnl: BigInt, + eventType: EventType +): void { + takeSnapshots(event); + + const account = getOrCreateAccount(event, accountAddress); + incrementAccountEventCount(event, account, eventType, sizeUSDDelta); + incrementProtocolEventCount(event, eventType, sizeUSDDelta); + + const indexToken = getOrCreateToken(event, indexTokenAddress); + updateTokenPrice( + event, + indexToken, + indexTokenPrice.div(PRICE_PRECISION).toBigDecimal() + ); + const collateralToken = getOrCreateToken(event, collateralTokenAddress); + let collateralTokenAmountDelta = BIGINT_ZERO; + if ( + collateralToken.lastPriceUSD && + collateralToken.lastPriceUSD! > BIGDECIMAL_ZERO + ) { + collateralTokenAmountDelta = bigDecimalToBigInt( + collateralUSDDelta + .times(exponentToBigDecimal(collateralToken.decimals)) + .div(collateralToken.lastPriceUSD!) + ); + } + + const pool = getOrCreateLiquidityPool(event); + let positionSide = PositionSide.SHORT; + if (isLong) { + positionSide = PositionSide.LONG; + } + let OpenPositionCount = INT_ZERO; + if (eventType == EventType.CollateralIn) { + const existingPosition = getUserPosition( + event, + account, + pool, + collateralTokenAddress, + indexTokenAddress, + positionSide, + posId + ); + if (!existingPosition) { + OpenPositionCount = INT_ONE; + createPositionMap( + positionKey, + account, + pool, + collateralTokenAddress, + indexTokenAddress, + positionSide, + posId + ); + } + } else if ( + eventType == EventType.ClosePosition || + eventType == EventType.Liquidated + ) { + OpenPositionCount = INT_NEGATIVE_ONE; + } + const position = updateUserPosition( + event, + account, + pool, + collateralTokenAddress, + indexTokenAddress, + positionSide, + posId, + entryFundingRate, + realisedPnl, + eventType + ); + + increasePoolPremium( + event, + pool, + fee.div(PRICE_PRECISION).toBigDecimal(), + eventType + ); + + increasePoolVolume( + event, + pool, + sizeUSDDelta, + collateralTokenAddress, + collateralTokenAmountDelta, + collateralUSDDelta, + eventType + ); + + increaseCollectedFees(event, pool, fee); + + switch (eventType) { + case EventType.CollateralIn: + updatePoolOpenInterestUSD(event, pool, sizeUSDDelta, true, isLong); + + createCollateralIn( + event, + accountAddress, + collateralTokenAddress, + collateralTokenAmountDelta, + collateralUSDDelta, + BIGINT_ZERO, + position + ); + + if (sizeUSDDelta > BIGDECIMAL_ZERO) { + let indexTokenAmountDelta = BIGINT_ZERO; + if ( + indexToken.lastPriceUSD && + indexToken.lastPriceUSD! > BIGDECIMAL_ZERO + ) { + indexTokenAmountDelta = bigDecimalToBigInt( + sizeUSDDelta + .times(exponentToBigDecimal(indexToken.decimals)) + .div(indexToken.lastPriceUSD!) + ); + } + createBorrow( + event, + accountAddress, + indexTokenAddress, + indexTokenAmountDelta, + sizeUSDDelta, + position + ); + } + + updateTempUsageMetrics( + event, + accountAddress, + eventType, + OpenPositionCount, + positionSide + ); + break; + case EventType.CollateralOut: + case EventType.ClosePosition: + updatePoolOpenInterestUSD(event, pool, sizeUSDDelta, false, isLong); + + createCollateralOut( + event, + accountAddress, + collateralTokenAddress, + collateralTokenAmountDelta, + collateralUSDDelta, + BIGINT_ZERO, + position + ); + + updateTempUsageMetrics( + event, + accountAddress, + eventType, + OpenPositionCount, + positionSide + ); + break; + case EventType.Liquidated: + updatePoolOpenInterestUSD(event, pool, sizeUSDDelta, false, isLong); + + createLiquidate( + event, + indexTokenAddress, + collateralTokenAmountDelta, + collateralUSDDelta, + realisedPnl.div(PRICE_PRECISION).toBigDecimal(), + event.transaction.from, + accountAddress, + position + ); + + const liquidatorAccount = getOrCreateAccount( + event, + event.transaction.from + ); + incrementAccountEventCount( + event, + liquidatorAccount, + EventType.Liquidate, + BIGDECIMAL_ZERO + ); + + updateTempUsageMetrics( + event, + event.transaction.from, + EventType.Liquidate, + INT_ZERO, + positionSide + ); + updateTempUsageMetrics( + event, + accountAddress, + EventType.Liquidated, + INT_NEGATIVE_ONE, + positionSide + ); + break; + + default: + break; + } +} + +function increaseCollectedFees( + event: ethereum.Event, + pool: LiquidityPool, + feeUsd: BigInt +): void { + const totalFee = feeUsd.div(PRICE_PRECISION).toBigDecimal(); + + // log.error("IincreasePoolProtocolSideRevenue {}", [ + // totalFee.times(PROTOCOL_SIDE_REVENUE_PERCENT).toString(), + // ]); + + increasePoolProtocolSideRevenue( + event, + pool, + totalFee.times(PROTOCOL_SIDE_REVENUE_PERCENT) + ); + increaseProtocolStakeSideRevenue( + event, + totalFee.times(STAKE_SIDE_REVENUE_PERCENT) + ); + increasePoolSupplySideRevenue( + event, + pool, + totalFee.times( + BIGDECIMAL_ONE.minus(PROTOCOL_SIDE_REVENUE_PERCENT).minus( + STAKE_SIDE_REVENUE_PERCENT + ) + ) + ); +} diff --git a/subgraphs/vela-exchange/src/prices/README.md b/subgraphs/vela-exchange/src/prices/README.md new file mode 100644 index 0000000000..51fc9fb576 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/README.md @@ -0,0 +1,240 @@ +# 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 { getUsdPricePerToken, getUsdPrice } from "../Oracle"; + +// Method 1 +// Using function getUsdPricePerToken(tokenAddr: Address): CustomPriceType + +let tokenPrice: BigDecimal; +let fetchPrice = getUsdPricePerToken(tokenAddr); + +// fetchPrice.reverted: Bool +// fetchPrice.usdPrice: BigDecimal +// fetchPrice.decimals: number + +tokenPrice = fetchPrice.usdPrice * amount + +// Method 2 +// Using function getUsdPrice(tokenAddr: Address, amount: BigDecimal): BigDecimal + +let tokenPrice = getUsdPrice(tokenAddr, amount); +``` + +## Optimizations + +- Reorder the methods present in `index.ts`, depending on which method works best for you. + +## Folder Structure + +``` +Prices +├── calculations +│ ├── CalculationsCurve.ts +│ └── CalculationsSushiSwap.ts +├── common +│ ├── types.ts +│ ├── constants.ts +│ └── utils.ts +├── config +│ ├── arbitrum.ts +│ ├── aurora.ts +│ ├── avalanche.ts +│ ├── bsc.ts +│ ├── fantom.ts +│ ├── gnosis.ts +│ ├── harmony.ts +│ ├── mainnet.ts +│ ├── moonbeam.ts +│ ├── optimism.ts +│ └── polygon.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` | ✅ | + +### 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` | ✅ | + +### 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/vela-exchange/src/prices/calculations/CalculationsCurve.ts b/subgraphs/vela-exchange/src/prices/calculations/CalculationsCurve.ts new file mode 100644 index 0000000000..1282d11c94 --- /dev/null +++ b/subgraphs/vela-exchange/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/Vault/CalculationsCurve"; + +export function getCalculationsCurveContract( + contract: OracleContract, + block: ethereum.Block +): CalculationsCurveContract | null { + if ( + contract.startBlock.gt(block.number) || + utils.isNullAddress(contract.address) + ) + return null; + + return CalculationsCurveContract.bind(contract.address); +} + +export function getTokenPriceUSDC( + tokenAddr: Address, + block: ethereum.Block +): 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/vela-exchange/src/prices/calculations/CalculationsSushiswap.ts b/subgraphs/vela-exchange/src/prices/calculations/CalculationsSushiswap.ts new file mode 100644 index 0000000000..88ee4f9b7f --- /dev/null +++ b/subgraphs/vela-exchange/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/Vault/CalculationsSushiSwap"; + +export function getSushiSwapContract( + contract: OracleContract, + block: ethereum.Block +): CalculationsSushiContract | null { + if ( + contract.startBlock.gt(block.number) || + utils.isNullAddress(contract.address) + ) + return null; + + return CalculationsSushiContract.bind(contract.address); +} + +export function getTokenPriceUSDC( + tokenAddr: Address, + block: ethereum.Block +): 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/vela-exchange/src/prices/common/constants.ts b/subgraphs/vela-exchange/src/prices/common/constants.ts new file mode 100644 index 0000000000..32100b7a08 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/common/constants.ts @@ -0,0 +1,38 @@ +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.2.0"; + +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/vela-exchange/src/prices/common/types.ts b/subgraphs/vela-exchange/src/prices/common/types.ts new file mode 100644 index 0000000000..7227bf05c5 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/common/types.ts @@ -0,0 +1,103 @@ +import * as constants from "./constants"; +import { Address, BigDecimal, BigInt } 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; + + constructor() { + this._usdPrice = new Wrapped(constants.BIGDECIMAL_ZERO); + this._decimals = new Wrapped(constants.BIGINT_ZERO.toI32() as u8); + this._oracleType = ""; + } + + static initialize( + _usdPrice: BigDecimal, + _decimals: i32 = 0, + _oracleType: string = "" + ): CustomPriceType { + const result = new CustomPriceType(); + result._usdPrice = new Wrapped(_usdPrice); + result._decimals = new Wrapped(_decimals as u8); + result._oracleType = _oracleType; + + 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; + } +} + +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; +} diff --git a/subgraphs/vela-exchange/src/prices/common/utils.ts b/subgraphs/vela-exchange/src/prices/common/utils.ts new file mode 100644 index 0000000000..2f69ca1371 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/common/utils.ts @@ -0,0 +1,96 @@ +import * as BSC from "../config/bsc"; +import * as CELO from "../config/celo"; +import * as FUSE from "../config/fuse"; +import * as XDAI from "../config/gnosis"; +import * as CRONOS from "../config/cronos"; +import * as AURORA from "../config/aurora"; +import * as FANTOM from "../config/fantom"; +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 { Configurations } from "./types"; +import * as constants from "./constants"; +import * as TEMPLATE from "../config/template"; +import { _ERC20 } from "../../../generated/Vault/_ERC20"; +import { Address, BigInt, dataSource, ethereum } from "@graphprotocol/graph-ts"; + +export function isNullAddress(tokenAddr: Address): boolean { + return tokenAddr.equals(constants.NULL.TYPE_ADDRESS); +} + +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(); + } + + return new TEMPLATE.config(); +} diff --git a/subgraphs/vela-exchange/src/prices/config/arbitrum.ts b/subgraphs/vela-exchange/src/prices/config/arbitrum.ts new file mode 100644 index 0000000000..2c0b11099c --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/arbitrum.ts @@ -0,0 +1,137 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/aurora.ts b/subgraphs/vela-exchange/src/prices/config/aurora.ts new file mode 100644 index 0000000000..833b94911b --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/aurora.ts @@ -0,0 +1,124 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/avalanche.ts b/subgraphs/vela-exchange/src/prices/config/avalanche.ts new file mode 100644 index 0000000000..f012ea6af4 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/avalanche.ts @@ -0,0 +1,131 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/bsc.ts b/subgraphs/vela-exchange/src/prices/config/bsc.ts new file mode 100644 index 0000000000..db5cb1d2b1 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/bsc.ts @@ -0,0 +1,122 @@ +import * as constants from "../common/constants"; +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/celo.ts b/subgraphs/vela-exchange/src/prices/config/celo.ts new file mode 100644 index 0000000000..035dcf448b --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/celo.ts @@ -0,0 +1,123 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/cronos.ts b/subgraphs/vela-exchange/src/prices/config/cronos.ts new file mode 100644 index 0000000000..f0be429d49 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/cronos.ts @@ -0,0 +1,122 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/fantom.ts b/subgraphs/vela-exchange/src/prices/config/fantom.ts new file mode 100644 index 0000000000..c43f5497a7 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/fantom.ts @@ -0,0 +1,136 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/fuse.ts b/subgraphs/vela-exchange/src/prices/config/fuse.ts new file mode 100644 index 0000000000..eee170f6a5 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/fuse.ts @@ -0,0 +1,123 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/gnosis.ts b/subgraphs/vela-exchange/src/prices/config/gnosis.ts new file mode 100644 index 0000000000..7e326f9717 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/gnosis.ts @@ -0,0 +1,125 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/harmony.ts b/subgraphs/vela-exchange/src/prices/config/harmony.ts new file mode 100644 index 0000000000..39d4b0b16c --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/harmony.ts @@ -0,0 +1,127 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/mainnet.ts b/subgraphs/vela-exchange/src/prices/config/mainnet.ts new file mode 100644 index 0000000000..4614a69788 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/mainnet.ts @@ -0,0 +1,174 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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 +); + +export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [ + new OracleContract("0x7d86446ddb609ed0f5f8684acf30380a356b2b4c", 11154794), + new OracleContract("0x8f942c20d02befc377d41445793068908e2250d0", 13986752), +]; + +/////////////////////////////////////////////////////////////////////////// +/////////////////////////// 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 +]; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/moonbeam.ts b/subgraphs/vela-exchange/src/prices/config/moonbeam.ts new file mode 100644 index 0000000000..f3009cdb3c --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/moonbeam.ts @@ -0,0 +1,124 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/optimism.ts b/subgraphs/vela-exchange/src/prices/config/optimism.ts new file mode 100644 index 0000000000..a270efacc3 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/optimism.ts @@ -0,0 +1,136 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/polygon.ts b/subgraphs/vela-exchange/src/prices/config/polygon.ts new file mode 100644 index 0000000000..c8d174fdf9 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/polygon.ts @@ -0,0 +1,130 @@ +import { BigInt, Address } from "@graphprotocol/graph-ts"; +import { Configurations, 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/config/template.ts b/subgraphs/vela-exchange/src/prices/config/template.ts new file mode 100644 index 0000000000..1916693083 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/config/template.ts @@ -0,0 +1,114 @@ +import * as constants from "../common/constants"; +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Configurations, 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[] = []; + +/////////////////////////////////////////////////////////////////////////// +///////////////////////////////// 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; + } +} diff --git a/subgraphs/vela-exchange/src/prices/index.ts b/subgraphs/vela-exchange/src/prices/index.ts new file mode 100644 index 0000000000..95f8f0621f --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/index.ts @@ -0,0 +1,140 @@ +import { + log, + Address, + ethereum, + BigDecimal, + dataSource, +} from "@graphprotocol/graph-ts"; +import { CustomPriceType } 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 +): 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 + ); + } + + // 1. Yearn Lens Oracle + const yearnLensPrice = YearnLensOracle.getTokenPriceUSDC(tokenAddr, block); + if (!yearnLensPrice.reverted) { + log.info("[YearnLensOracle] tokenAddress: {}, Price: {}", [ + tokenAddr.toHexString(), + yearnLensPrice.usdPrice.toString(), + ]); + return yearnLensPrice; + } + + // 2. ChainLink Feed Registry + const chainLinkPrice = ChainLinkFeed.getTokenPriceUSDC(tokenAddr, block); + if (!chainLinkPrice.reverted) { + log.info("[ChainLinkFeed] tokenAddress: {}, Price: {}", [ + tokenAddr.toHexString(), + chainLinkPrice.usdPrice.toString(), + ]); + return chainLinkPrice; + } + + // 3. CalculationsCurve + const calculationsCurvePrice = CurveCalculations.getTokenPriceUSDC( + tokenAddr, + block + ); + if (!calculationsCurvePrice.reverted) { + log.info("[CalculationsCurve] tokenAddress: {}, Price: {}", [ + tokenAddr.toHexString(), + calculationsCurvePrice.usdPrice.toString(), + ]); + return calculationsCurvePrice; + } + + // 4. CalculationsSushiSwap + const calculationsSushiSwapPrice = SushiCalculations.getTokenPriceUSDC( + tokenAddr, + block + ); + if (!calculationsSushiSwapPrice.reverted) { + log.info("[CalculationsSushiSwap] tokenAddress: {}, Price: {}", [ + tokenAddr.toHexString(), + calculationsSushiSwapPrice.usdPrice.toString(), + ]); + return calculationsSushiSwapPrice; + } + + // 6. Aave Oracle + const aaveOraclePrice = AaveOracle.getTokenPriceUSDC(tokenAddr, block); + if (!aaveOraclePrice.reverted) { + log.info("[AaveOracle] tokenAddress: {}, Price: {}", [ + tokenAddr.toHexString(), + aaveOraclePrice.usdPrice.toString(), + ]); + return aaveOraclePrice; + } + + // 7. Curve Router + const curvePrice = CurveRouter.getCurvePriceUsdc(tokenAddr, block); + if (!curvePrice.reverted) { + log.info("[CurveRouter] tokenAddress: {}, Price: {}", [ + tokenAddr.toHexString(), + curvePrice.usdPrice.toString(), + ]); + return curvePrice; + } + + // 8. Uniswap Router + const uniswapPrice = UniswapForksRouter.getTokenPriceUSDC(tokenAddr, block); + if (!uniswapPrice.reverted) { + log.info("[UniswapRouter] tokenAddress: {}, Price: {}", [ + tokenAddr.toHexString(), + uniswapPrice.usdPrice.toString(), + ]); + return uniswapPrice; + } + + log.warning("[Oracle] Failed to Fetch Price, Name: {} Address: {}", [ + utils.getTokenName(tokenAddr), + tokenAddr.toHexString(), + ]); + + return new CustomPriceType(); +} + +export function getUsdPrice( + tokenAddr: Address, + amount: BigDecimal, + block: ethereum.Block +): BigDecimal { + const tokenPrice = getUsdPricePerToken(tokenAddr, block); + + if (!tokenPrice.reverted) { + return tokenPrice.usdPrice.times(amount); + } + + return constants.BIGDECIMAL_ZERO; +} diff --git a/subgraphs/vela-exchange/src/prices/oracles/AaveOracle.ts b/subgraphs/vela-exchange/src/prices/oracles/AaveOracle.ts new file mode 100644 index 0000000000..887104a255 --- /dev/null +++ b/subgraphs/vela-exchange/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/Vault/AaveOracleContract"; + +export function getAaveOracleContract( + contract: OracleContract, + block: ethereum.Block +): AaveOracleContract | null { + if ( + contract.startBlock.gt(block.number) || + utils.isNullAddress(contract.address) + ) + return null; + + return AaveOracleContract.bind(contract.address); +} + +export function getTokenPriceUSDC( + tokenAddr: Address, + block: ethereum.Block +): 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/vela-exchange/src/prices/oracles/ChainLinkFeed.ts b/subgraphs/vela-exchange/src/prices/oracles/ChainLinkFeed.ts new file mode 100644 index 0000000000..6fc8611776 --- /dev/null +++ b/subgraphs/vela-exchange/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/Vault/ChainLinkContract"; + +export function getChainLinkContract( + contract: OracleContract, + block: ethereum.Block +): ChainLinkContract | null { + if ( + contract.startBlock.gt(block.number) || + utils.isNullAddress(contract.address) + ) + return null; + + return ChainLinkContract.bind(contract.address); +} + +export function getTokenPriceUSDC( + tokenAddr: Address, + block: ethereum.Block +): 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/vela-exchange/src/prices/oracles/YearnLensOracle.ts b/subgraphs/vela-exchange/src/prices/oracles/YearnLensOracle.ts new file mode 100644 index 0000000000..c7e744c60c --- /dev/null +++ b/subgraphs/vela-exchange/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/Vault/YearnLensContract"; + +export function getYearnLensContract( + contract: OracleContract, + block: ethereum.Block +): YearnLensContract | null { + if ( + contract.startBlock.gt(block.number) || + utils.isNullAddress(contract.address) + ) + return null; + + return YearnLensContract.bind(contract.address); +} + +export function getTokenPriceUSDC( + tokenAddr: Address, + block: ethereum.Block +): 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/vela-exchange/src/prices/routers/CurveRouter.ts b/subgraphs/vela-exchange/src/prices/routers/CurveRouter.ts new file mode 100644 index 0000000000..a7d06f60b4 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/routers/CurveRouter.ts @@ -0,0 +1,326 @@ +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/Vault/CurvePool"; +import { CurveRegistry as CurveRegistryContract } from "../../../generated/Vault/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 +): Address { + const config = utils.getConfig(); + const curveRegistryAdresses = config.curveRegistry(); + + for (let idx = 0; idx < curveRegistryAdresses.length; idx++) { + const curveRegistry = curveRegistryAdresses[idx]; + if (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 +): 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 +): 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() + ); + + return CustomPriceType.initialize( + priceUsdc, + decimalsAdjustment.plus(constants.DEFAULT_DECIMALS).toI32() as u8, + constants.OracleType.CURVE_ROUTER + ); +} + +export function getBasePrice( + lpAddress: Address, + block: ethereum.Block +): 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 +): Address { + const config = utils.getConfig(); + const curveRegistryAdresses = config.curveRegistry(); + + for (let idx = 0; idx < curveRegistryAdresses.length; idx++) { + const curveRegistry = curveRegistryAdresses[idx]; + if (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 +): BigInt { + const config = utils.getConfig(); + const curveRegistryAdresses = config.curveRegistry(); + + for (let idx = 0; idx < curveRegistryAdresses.length; idx++) { + const curveRegistry = curveRegistryAdresses[idx]; + if (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 +): CustomPriceType { + return getUsdPricePerToken(tokenAddress, block); +} + +export function cryptoPoolLpPriceUsdc( + lpAddress: Address, + block: ethereum.Block +): 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 +): 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 +): 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 + ); +} diff --git a/subgraphs/vela-exchange/src/prices/routers/UniswapForksRouter.ts b/subgraphs/vela-exchange/src/prices/routers/UniswapForksRouter.ts new file mode 100644 index 0000000000..8e82ba26c1 --- /dev/null +++ b/subgraphs/vela-exchange/src/prices/routers/UniswapForksRouter.ts @@ -0,0 +1,221 @@ +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/Vault/UniswapPair"; +import { UniswapRouter as UniswapRouterContract } from "../../../generated/Vault/UniswapRouter"; + +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 +): 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 +): CustomPriceType { + return getPriceFromRouter(tokenAddress, usdcAddress, block); +} + +export function getPriceFromRouter( + token0Address: Address, + token1Address: Address, + block: ethereum.Block +): 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 amountOut = constants.BIGINT_ZERO; + for (let idx = 0; idx < routerAddresses.length; idx++) { + const routerAddress = routerAddresses[idx]; + if (routerAddress.startBlock.gt(block.number)) continue; + + const uniswapForkRouter = UniswapRouterContract.bind(routerAddress.address); + const amountOutArray = uniswapForkRouter.try_getAmountsOut(amountIn, path); + + if (!amountOutArray.reverted) { + 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(); + + return CustomPriceType.initialize( + amountOutBigDecimal, + config.usdcTokenDecimals().toI32() as u8, + constants.OracleType.UNISWAP_FORKS_ROUTER + ); +} + +export function getLpTokenPriceUsdc( + tokenAddress: Address, + block: ethereum.Block +): 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 +): 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 + .div(constants.BIGINT_TEN.pow(token0Decimals.toI32() as u8)) + .toBigDecimal() + .times(token0Price.usdPrice); + + const liquidity1 = reserve1 + .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(); +} diff --git a/subgraphs/vela-exchange/src/utils/constants.ts b/subgraphs/vela-exchange/src/utils/constants.ts new file mode 100644 index 0000000000..8976ce50df --- /dev/null +++ b/subgraphs/vela-exchange/src/utils/constants.ts @@ -0,0 +1,188 @@ +import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; + +//////////////////// +///// Versions ///// +//////////////////// + +export const PROTOCOL_NAME = "vela-exchange"; +export const PROTOCOL_SLUG = "vela"; + +//////////////////////// +///// 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 ARWEAVE_MAINNET = "ARWEAVE_MAINNET"; + export const AVALANCHE = "AVALANCHE"; + export const BOBA = "BOBA"; + export const AURORA = "AURORA"; + export const BSC = "BSC"; // aka BNB Chain + export const CELO = "CELO"; + export const COSMOS = "COSMOS"; + export const CRONOS = "CRONOS"; + export const MAINNET = "MAINNET"; // Ethereum mainnet + export const FANTOM = "FANTOM"; + export const FUSE = "FUSE"; + export const HARMONY = "HARMONY"; + export const JUNO = "JUNO"; + export const MOONBEAM = "MOONBEAM"; + export const MOONRIVER = "MOONRIVER"; + export const NEAR_MAINNET = "NEAR_MAINNET"; + export const OPTIMISM = "OPTIMISM"; + export const OSMOSIS = "OSMOSIS"; + export const MATIC = "MATIC"; // aka Polygon + export const XDAI = "XDAI"; // aka Gnosis Chain +} + +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 const FIXED_STAKE_FEE = "FIXED_STAKE_FEE"; + export const DYNAMIC_STAKE_FEE = "DYNAMIC_STAKE_FEE"; + export const DEPOSIT_FEE = "DEPOSIT_FEE"; + export const WITHDRAWAL_FEE = "WITHDRAWAL_FEE"; +} + +export namespace RewardTokenType { + export const DEPOSIT = "DEPOSIT"; + export const BORROW = "BORROW"; +} + +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 = "FIXED"; +} + +export namespace InterestRateSide { + export const LENDER = "LENDER"; + export const BORROWER = "BORROWER"; +} + +export namespace PositionSide { + export const LONG = "LONG"; + export const SHORT = "SHORT"; +} + +////////////////////////////// +///// Ethereum Addresses ///// +////////////////////////////// + +export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; +export const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; + +export const UNISWAP_V2_FACTORY = "0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f"; + +export const WETH_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"; +export const USDC_WETH_PAIR = "0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc"; // created 10008355 +export const DAI_WETH_PAIR = "0xa478c2975ab1ea89e8196811f51a7b7ade33eb11"; // created block 10042267 +export const USDT_WETH_PAIR = "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852"; // created block 10093341 + +//////////////////////// +///// Type Helpers ///// +//////////////////////// + +export const DEFAULT_DECIMALS = 18; + +export const USDC_DECIMALS = 6; +export const USDC_DENOMINATOR = BigDecimal.fromString("1000000"); + +export const BIGINT_NEGONE = BigInt.fromI32(-1); +export const BIGINT_ZERO = BigInt.fromI32(0); +export const BIGINT_ONE = BigInt.fromI32(1); +export const BIGINT_TWO = BigInt.fromI32(2); +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_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_THOUSAND = new BigDecimal(BIGINT_THOUSAND); + +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 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"; + +///////////////////////////// +///// Protocol Specific ///// +///////////////////////////// + +export const PROTOCOL_ID = "Vela"; +export const POOL_NAME = "VelaVault"; +export const POOL_SYMBOL = "VAULT"; +export const VAULT_ADDRESS = "0x5957582f020301a2f732ad17a69ab2d8b2741241"; +export const POSITION_VAULT_ADDRESS = + "0x79e04946f0ed05a60395f3c9a4ae4A7d84eca80e"; +export const VLP_ADDRESS = "0x4e0d4a5a5b4faf5c2ecc1c63c8d19bb0804a96f1"; +export const USDC_ADDRESS_ARBITRUM = + "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8"; +export const PRICE_CACHING_BLOCKS = BigInt.fromI32(7000); +export const PRICE_PRECISION = BigInt.fromI32(10).pow(30); +export const FUNDING_PRECISION = BigDecimal.fromString("1000000"); +export const PROTOCOL_SIDE_REVENUE_PERCENT = BigDecimal.fromString("0.25"); +export const STAKE_SIDE_REVENUE_PERCENT = BigDecimal.fromString("0.15"); diff --git a/subgraphs/vela-exchange/src/utils/numbers.ts b/subgraphs/vela-exchange/src/utils/numbers.ts new file mode 100644 index 0000000000..7eff00af40 --- /dev/null +++ b/subgraphs/vela-exchange/src/utils/numbers.ts @@ -0,0 +1,181 @@ +import { BigDecimal, BigInt, Bytes } from "@graphprotocol/graph-ts"; +import { INT_ZERO } from "./constants"; + +export function bigDecimalToBigInt(input: BigDecimal): BigInt { + const str = input.truncate(0).toString(); + return BigInt.fromString(str); +} + +// convert emitted values to tokens count +export function convertTokenToDecimal( + tokenAmount: BigInt, + exchangeDecimals: i32 = 18 +): BigDecimal { + if (exchangeDecimals == INT_ZERO) { + return tokenAmount.toBigDecimal(); + } + + return tokenAmount.toBigDecimal().div(exponentToBigDecimal(exchangeDecimals)); +} + +// returns 10^exp +export function exponentToBigDecimal(exp: i32): 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("2")); + } + + return sorted[mid - 1]; +} + +// insert value into arr at index +export function insert( + arr: Array, + index: i32, + value: Type +): Array { + const result: Type[] = []; + for (let i = 0; i < index; i++) { + result.push(arr[i]); + } + result.push(value); + for (let i = index; i < arr.length; i++) { + result.push(arr[i]); + } + return result; +} + +// Ray is 27 decimal Wad is 18 decimal +// These functions were made for the AAVE subgraph. Visit the following link to verify that AAVE's definition for RAY units match what are needed for your protocol +// https://docs.aave.com/developers/v/2.0/glossary + +export function rayToWad(a: BigInt): BigInt { + const halfRatio = BigInt.fromI32(10).pow(9).div(BigInt.fromI32(2)); + return halfRatio.plus(a).div(BigInt.fromI32(10).pow(9)); +} + +export function wadToRay(a: BigInt): BigInt { + const result = a.times(BigInt.fromI32(10).pow(9)); + return result; +} + +export function multiArraySort( + ref: Array, + arr1: Array, + arr2: Array +): void { + if (ref.length != arr1.length || ref.length != arr2.length) { + // cannot sort + return; + } + + const sorter: Array> = []; + for (let i = 0; i < ref.length; i++) { + sorter[i] = [ref[i].toHexString(), arr1[i].toString(), arr2[i].toString()]; + } + + sorter.sort(function (a: Array, b: Array): i32 { + if (a[0] < b[0]) { + return -1; + } + return 1; + }); + + for (let i = 0; i < sorter.length; i++) { + ref[i] = Bytes.fromHexString(sorter[i][0]); + arr1[i] = BigInt.fromString(sorter[i][1]); + arr2[i] = BigDecimal.fromString(sorter[i][2]); + } +} + +export function poolArraySort( + ref: Array, + arr1: Array, + arr2: Array, + arr3: Array, + arr4: Array, + arr5: Array, + arr6: Array, + arr7: Array, + arr8: Array, + arr9: Array, + arr10: Array +): void { + if ( + ref.length != arr1.length || + ref.length != arr2.length || + ref.length != arr3.length || + ref.length != arr4.length || + ref.length != arr5.length || + ref.length != arr6.length || + ref.length != arr7.length || + ref.length != arr8.length || + ref.length != arr9.length || + ref.length != arr10.length + ) { + // cannot sort + return; + } + + const sorter: Array> = []; + for (let i = 0; i < ref.length; i++) { + sorter[i] = [ + ref[i].toHexString(), + arr1[i].toString(), + arr2[i].toString(), + arr3[i].toString(), + arr4[i].toString(), + arr5[i].toString(), + arr6[i].toString(), + arr7[i].toString(), + arr8[i].toString(), + arr9[i].toString(), + arr10[i].toString(), + ]; + } + + sorter.sort(function (a: Array, b: Array): i32 { + if (a[0] < b[0]) { + return -1; + } + return 1; + }); + + for (let i = 0; i < sorter.length; i++) { + ref[i] = Bytes.fromHexString(sorter[i][0]); + arr1[i] = BigInt.fromString(sorter[i][1]); + arr2[i] = BigDecimal.fromString(sorter[i][2]); + arr3[i] = BigInt.fromString(sorter[i][3]); + arr4[i] = BigDecimal.fromString(sorter[i][4]); + arr5[i] = BigInt.fromString(sorter[i][5]); + arr6[i] = BigDecimal.fromString(sorter[i][6]); + arr7[i] = BigInt.fromString(sorter[i][7]); + arr8[i] = BigDecimal.fromString(sorter[i][8]); + arr9[i] = BigInt.fromString(sorter[i][9]); + arr10[i] = BigDecimal.fromString(sorter[i][10]); + } +} diff --git a/subgraphs/vela-exchange/src/utils/strings.ts b/subgraphs/vela-exchange/src/utils/strings.ts new file mode 100644 index 0000000000..1c027cfa2d --- /dev/null +++ b/subgraphs/vela-exchange/src/utils/strings.ts @@ -0,0 +1,11 @@ +// Converts upper snake case to lower kebab case and appends a hyphen. +// (e.g. "TRADING_FEE" to "trading-fee-"), mainly used to create entity IDs +export function enumToPrefix(snake: string): string { + return snake.toLowerCase().replace("_", "-") + "-"; +} + +// Prefix an ID with a enum string in order to differentiate IDs +// e.g. combine TRADING_FEE and 0x1234 into trading-fee-0x1234 +export function prefixID(enumString: string, ID: string): string { + return enumToPrefix(enumString) + ID; +} diff --git a/subgraphs/vela-exchange/tsconfig.json b/subgraphs/vela-exchange/tsconfig.json new file mode 100644 index 0000000000..5c5d17c928 --- /dev/null +++ b/subgraphs/vela-exchange/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", + "include": ["src"] +} diff --git a/subgraphs/vela-exchange/yarn.lock b/subgraphs/vela-exchange/yarn.lock new file mode 100644 index 0000000000..80b327c51d --- /dev/null +++ b/subgraphs/vela-exchange/yarn.lock @@ -0,0 +1,3353 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/code-frame@^7.0.0": + "integrity" "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==" + "resolved" "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz" + "version" "7.16.7" + dependencies: + "@babel/highlight" "^7.16.7" + +"@babel/helper-validator-identifier@^7.16.7": + "integrity" "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==" + "resolved" "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz" + "version" "7.16.7" + +"@babel/highlight@^7.16.7": + "integrity" "sha512-7yykMVF3hfZY2jsHZEEgLc+3x4o1O+fYyULu11GynEUQNwB6lua+IIQn1FiJxNucd5UlyJryrwsOh8PL9Sn8Qg==" + "resolved" "https://registry.npmjs.org/@babel/highlight/-/highlight-7.17.12.tgz" + "version" "7.17.12" + dependencies: + "@babel/helper-validator-identifier" "^7.16.7" + "chalk" "^2.0.0" + "js-tokens" "^4.0.0" + +"@babel/runtime@^7.9.2": + "integrity" "sha512-38Y8f7YUhce/K7RMwTp7m0uCumpv9hZkitCbBClqQIow1qSbCvGkcegKOXpEWCQLfWmevgRiWokZ1GkpfhbZug==" + "resolved" "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.3.tgz" + "version" "7.18.3" + dependencies: + "regenerator-runtime" "^0.13.4" + +"@ethersproject/abi@5.0.7": + "integrity" "sha512-Cqktk+hSIckwP/W8O47Eef60VwmoSC/L3lY0+dIBhQPCNn9E4V7rwmm2aFrNRRDJfFlGuZ1khkQUOc3oBX+niw==" + "resolved" "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.0.7.tgz" + "version" "5.0.7" + dependencies: + "@ethersproject/address" "^5.0.4" + "@ethersproject/bignumber" "^5.0.7" + "@ethersproject/bytes" "^5.0.4" + "@ethersproject/constants" "^5.0.4" + "@ethersproject/hash" "^5.0.4" + "@ethersproject/keccak256" "^5.0.3" + "@ethersproject/logger" "^5.0.5" + "@ethersproject/properties" "^5.0.3" + "@ethersproject/strings" "^5.0.4" + +"@ethersproject/abstract-provider@^5.6.1": + "integrity" "sha512-BxlIgogYJtp1FS8Muvj8YfdClk3unZH0vRMVX791Z9INBNT/kuACZ9GzaY1Y4yFq+YSy6/w4gzj3HCRKrK9hsQ==" + "resolved" "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.6.1.tgz" + "version" "5.6.1" + dependencies: + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/networks" "^5.6.3" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/transactions" "^5.6.2" + "@ethersproject/web" "^5.6.1" + +"@ethersproject/abstract-signer@^5.6.2": + "integrity" "sha512-n1r6lttFBG0t2vNiI3HoWaS/KdOt8xyDjzlP2cuevlWLG6EX0OwcKLyG/Kp/cuwNxdy/ous+R/DEMdTUwWQIjQ==" + "resolved" "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.6.2.tgz" + "version" "5.6.2" + dependencies: + "@ethersproject/abstract-provider" "^5.6.1" + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + +"@ethersproject/address@^5.0.4", "@ethersproject/address@^5.6.1": + "integrity" "sha512-uOgF0kS5MJv9ZvCz7x6T2EXJSzotiybApn4XlOgoTX0xdtyVIJ7pF+6cGPxiEq/dpBiTfMiw7Yc81JcwhSYA0Q==" + "resolved" "https://registry.npmjs.org/@ethersproject/address/-/address-5.6.1.tgz" + "version" "5.6.1" + dependencies: + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/keccak256" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/rlp" "^5.6.1" + +"@ethersproject/base64@^5.6.1": + "integrity" "sha512-qB76rjop6a0RIYYMiB4Eh/8n+Hxu2NIZm8S/Q7kNo5pmZfXhHGHmS4MinUainiBC54SCyRnwzL+KZjj8zbsSsw==" + "resolved" "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.6.1.tgz" + "version" "5.6.1" + dependencies: + "@ethersproject/bytes" "^5.6.1" + +"@ethersproject/bignumber@^5.0.7", "@ethersproject/bignumber@^5.6.2": + "integrity" "sha512-v7+EEUbhGqT3XJ9LMPsKvXYHFc8eHxTowFCG/HgJErmq4XHJ2WR7aeyICg3uTOAQ7Icn0GFHAohXEhxQHq4Ubw==" + "resolved" "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.6.2.tgz" + "version" "5.6.2" + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "bn.js" "^5.2.1" + +"@ethersproject/bytes@^5.0.4", "@ethersproject/bytes@^5.6.1": + "integrity" "sha512-NwQt7cKn5+ZE4uDn+X5RAXLp46E1chXoaMmrxAyA0rblpxz8t58lVkrHXoRIn0lz1joQElQ8410GqhTqMOwc6g==" + "resolved" "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.6.1.tgz" + "version" "5.6.1" + dependencies: + "@ethersproject/logger" "^5.6.0" + +"@ethersproject/constants@^5.0.4", "@ethersproject/constants@^5.6.1": + "integrity" "sha512-QSq9WVnZbxXYFftrjSjZDUshp6/eKp6qrtdBtUCm0QxCV5z1fG/w3kdlcsjMCQuQHUnAclKoK7XpXMezhRDOLg==" + "resolved" "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.6.1.tgz" + "version" "5.6.1" + dependencies: + "@ethersproject/bignumber" "^5.6.2" + +"@ethersproject/hash@^5.0.4": + "integrity" "sha512-L1xAHurbaxG8VVul4ankNX5HgQ8PNCTrnVXEiFnE9xoRnaUcgfD12tZINtDinSllxPLCtGwguQxJ5E6keE84pA==" + "resolved" "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.6.1.tgz" + "version" "5.6.1" + dependencies: + "@ethersproject/abstract-signer" "^5.6.2" + "@ethersproject/address" "^5.6.1" + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/keccak256" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/strings" "^5.6.1" + +"@ethersproject/keccak256@^5.0.3", "@ethersproject/keccak256@^5.6.1": + "integrity" "sha512-bB7DQHCTRDooZZdL3lk9wpL0+XuG3XLGHLh3cePnybsO3V0rdCAOQGpn/0R3aODmnTOOkCATJiD2hnL+5bwthA==" + "resolved" "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.6.1.tgz" + "version" "5.6.1" + dependencies: + "@ethersproject/bytes" "^5.6.1" + "js-sha3" "0.8.0" + +"@ethersproject/logger@^5.0.5", "@ethersproject/logger@^5.6.0": + "integrity" "sha512-BiBWllUROH9w+P21RzoxJKzqoqpkyM1pRnEKG69bulE9TSQD8SAIvTQqIMZmmCO8pUNkgLP1wndX1gKghSpBmg==" + "resolved" "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.6.0.tgz" + "version" "5.6.0" + +"@ethersproject/networks@^5.6.3": + "integrity" "sha512-KShHeHPahHI2UlWdtDMn2lJETcbtaJge4k7XSjDR9h79QTd6yQJmv6Cp2ZA4JdqWnhszAOLSuJEd9C0PRw7hSQ==" + "resolved" "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.6.4.tgz" + "version" "5.6.4" + dependencies: + "@ethersproject/logger" "^5.6.0" + +"@ethersproject/properties@^5.0.3", "@ethersproject/properties@^5.6.0": + "integrity" "sha512-szoOkHskajKePTJSZ46uHUWWkbv7TzP2ypdEK6jGMqJaEt2sb0jCgfBo0gH0m2HBpRixMuJ6TBRaQCF7a9DoCg==" + "resolved" "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.6.0.tgz" + "version" "5.6.0" + dependencies: + "@ethersproject/logger" "^5.6.0" + +"@ethersproject/rlp@^5.6.1": + "integrity" "sha512-uYjmcZx+DKlFUk7a5/W9aQVaoEC7+1MOBgNtvNg13+RnuUwT4F0zTovC0tmay5SmRslb29V1B7Y5KCri46WhuQ==" + "resolved" "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.6.1.tgz" + "version" "5.6.1" + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + +"@ethersproject/signing-key@^5.6.2": + "integrity" "sha512-jVbu0RuP7EFpw82vHcL+GP35+KaNruVAZM90GxgQnGqB6crhBqW/ozBfFvdeImtmb4qPko0uxXjn8l9jpn0cwQ==" + "resolved" "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.6.2.tgz" + "version" "5.6.2" + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + "bn.js" "^5.2.1" + "elliptic" "6.5.4" + "hash.js" "1.1.7" + +"@ethersproject/strings@^5.0.4", "@ethersproject/strings@^5.6.1": + "integrity" "sha512-2X1Lgk6Jyfg26MUnsHiT456U9ijxKUybz8IM1Vih+NJxYtXhmvKBcHOmvGqpFSVJ0nQ4ZCoIViR8XlRw1v/+Cw==" + "resolved" "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.6.1.tgz" + "version" "5.6.1" + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/constants" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + +"@ethersproject/transactions@^5.6.2": + "integrity" "sha512-BuV63IRPHmJvthNkkt9G70Ullx6AcM+SDc+a8Aw/8Yew6YwT51TcBKEp1P4oOQ/bP25I18JJr7rcFRgFtU9B2Q==" + "resolved" "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.6.2.tgz" + "version" "5.6.2" + dependencies: + "@ethersproject/address" "^5.6.1" + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/constants" "^5.6.1" + "@ethersproject/keccak256" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/rlp" "^5.6.1" + "@ethersproject/signing-key" "^5.6.2" + +"@ethersproject/web@^5.6.1": + "integrity" "sha512-/vSyzaQlNXkO1WV+RneYKqCJwualcUdx/Z3gseVovZP0wIlOFcCE1hkRhKBH8ImKbGQbMl9EAAyJFrJu7V0aqA==" + "resolved" "https://registry.npmjs.org/@ethersproject/web/-/web-5.6.1.tgz" + "version" "5.6.1" + dependencies: + "@ethersproject/base64" "^5.6.1" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/strings" "^5.6.1" + +"@graphprotocol/graph-cli@0.30.4": + "integrity" "sha512-BZNnkSJBgGIVvSx/cxlep1ytKhvGM1ZUZU/73Lu4yH+lpGQN3UtKjlUzcasHqPEwqyp47OifMHlHxDBm4+CVoQ==" + "resolved" "https://registry.npmjs.org/@graphprotocol/graph-cli/-/graph-cli-0.30.4.tgz" + "version" "0.30.4" + dependencies: + "assemblyscript" "0.19.10" + "binary-install-raw" "0.0.13" + "chalk" "3.0.0" + "chokidar" "3.5.1" + "debug" "4.1.1" + "docker-compose" "0.23.4" + "dockerode" "2.5.8" + "fs-extra" "9.0.0" + "glob" "7.1.6" + "gluegun" "git+https://github.com/edgeandnode/gluegun.git#v4.3.1-pin-colors-dep" + "graphql" "15.5.0" + "immutable" "3.8.2" + "ipfs-http-client" "34.0.0" + "jayson" "3.2.0" + "js-yaml" "3.13.1" + "node-fetch" "2.6.0" + "pkginfo" "0.4.1" + "prettier" "1.19.1" + "request" "2.88.2" + "semver" "7.3.5" + "sync-request" "6.1.0" + "tmp-promise" "3.0.2" + "web3-eth-abi" "1.7.0" + "which" "2.0.2" + "yaml" "1.9.2" + +"@graphprotocol/graph-ts@0.27.0": + "integrity" "sha512-r1SPDIZVQiGMxcY8rhFSM0y7d/xAbQf5vHMWUf59js1KgoyWpM6P3tczZqmQd7JTmeyNsDGIPzd9FeaxllsU4w==" + "resolved" "https://registry.npmjs.org/@graphprotocol/graph-ts/-/graph-ts-0.27.0.tgz" + "version" "0.27.0" + dependencies: + "assemblyscript" "0.19.10" + +"@types/bn.js@^5.1.0": + "integrity" "sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA==" + "resolved" "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz" + "version" "5.1.0" + dependencies: + "@types/node" "*" + +"@types/concat-stream@^1.6.0": + "integrity" "sha512-eHE4cQPoj6ngxBZMvVf6Hw7Mh4jMW4U9lpGmS5GBPB9RYxlFg+CHaVN7ErNY4W9XfLIEn20b4VDYaIrbq0q4uA==" + "resolved" "https://registry.npmjs.org/@types/concat-stream/-/concat-stream-1.6.1.tgz" + "version" "1.6.1" + dependencies: + "@types/node" "*" + +"@types/connect@^3.4.32": + "integrity" "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==" + "resolved" "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz" + "version" "3.4.35" + dependencies: + "@types/node" "*" + +"@types/express-serve-static-core@^4.16.9": + "integrity" "sha512-uMd++6dMKS32EOuw1Uli3e3BPgdLIXmezcfHv7N4c1s3gkhikBplORPpMq3fuWkxncZN1reb16d5n8yhQ80x7Q==" + "resolved" "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.29.tgz" + "version" "4.17.29" + dependencies: + "@types/node" "*" + "@types/qs" "*" + "@types/range-parser" "*" + +"@types/form-data@0.0.33": + "integrity" "sha512-8BSvG1kGm83cyJITQMZSulnl6QV8jqAGreJsc5tPu1Jq0vTSOiY/k24Wx82JRpWwZSqrala6sd5rWi6aNXvqcw==" + "resolved" "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz" + "version" "0.0.33" + dependencies: + "@types/node" "*" + +"@types/lodash@^4.14.139": + "integrity" "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==" + "resolved" "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.182.tgz" + "version" "4.14.182" + +"@types/node@*", "@types/node@^12.7.7": + "integrity" "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" + "resolved" "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz" + "version" "12.20.55" + +"@types/node@^10.0.3": + "integrity" "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==" + "resolved" "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz" + "version" "10.17.60" + +"@types/node@^8.0.0": + "integrity" "sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw==" + "resolved" "https://registry.npmjs.org/@types/node/-/node-8.10.66.tgz" + "version" "8.10.66" + +"@types/parse-json@^4.0.0": + "integrity" "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" + "resolved" "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz" + "version" "4.0.0" + +"@types/pbkdf2@^3.0.0": + "integrity" "sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ==" + "resolved" "https://registry.npmjs.org/@types/pbkdf2/-/pbkdf2-3.1.0.tgz" + "version" "3.1.0" + dependencies: + "@types/node" "*" + +"@types/qs@*", "@types/qs@^6.2.31": + "integrity" "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==" + "resolved" "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz" + "version" "6.9.7" + +"@types/range-parser@*": + "integrity" "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" + "resolved" "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz" + "version" "1.2.4" + +"@types/secp256k1@^4.0.1": + "integrity" "sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w==" + "resolved" "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.3.tgz" + "version" "4.0.3" + dependencies: + "@types/node" "*" + +"abort-controller@^3.0.0": + "integrity" "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==" + "resolved" "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz" + "version" "3.0.0" + dependencies: + "event-target-shim" "^5.0.0" + +"ajv@^6.12.3": + "integrity" "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==" + "resolved" "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz" + "version" "6.12.6" + dependencies: + "fast-deep-equal" "^3.1.1" + "fast-json-stable-stringify" "^2.0.0" + "json-schema-traverse" "^0.4.1" + "uri-js" "^4.2.2" + +"ansi-colors@^3.2.1": + "integrity" "sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==" + "resolved" "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz" + "version" "3.2.4" + +"ansi-regex@^3.0.0": + "integrity" "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==" + "resolved" "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz" + "version" "3.0.1" + +"ansi-regex@^5.0.1": + "integrity" "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + "resolved" "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz" + "version" "5.0.1" + +"ansi-styles@^3.2.1": + "integrity" "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==" + "resolved" "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz" + "version" "3.2.1" + dependencies: + "color-convert" "^1.9.0" + +"ansi-styles@^4.1.0": + "integrity" "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==" + "resolved" "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz" + "version" "4.3.0" + dependencies: + "color-convert" "^2.0.1" + +"anymatch@~3.1.1": + "integrity" "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==" + "resolved" "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz" + "version" "3.1.2" + dependencies: + "normalize-path" "^3.0.0" + "picomatch" "^2.0.4" + +"apisauce@^1.0.1": + "integrity" "sha512-gKC8qb/bDJsPsnEXLZnXJ7gVx7dh87CEVNeIwv1dvaffnXoh5GHwac5pWR1P2broLiVj/fqFMQvLDDt/RhjiqA==" + "resolved" "https://registry.npmjs.org/apisauce/-/apisauce-1.1.5.tgz" + "version" "1.1.5" + dependencies: + "axios" "^0.21.2" + "ramda" "^0.25.0" + +"app-module-path@^2.2.0": + "integrity" "sha512-gkco+qxENJV+8vFcDiiFhuoSvRXb2a/QPqpSoWhVz829VNJfOTnELbBmPmNKFxf3xdNnw4DWCkzkDaavcX/1YQ==" + "resolved" "https://registry.npmjs.org/app-module-path/-/app-module-path-2.2.0.tgz" + "version" "2.2.0" + +"argparse@^1.0.7": + "integrity" "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==" + "resolved" "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz" + "version" "1.0.10" + dependencies: + "sprintf-js" "~1.0.2" + +"asap@~2.0.6": + "integrity" "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" + "resolved" "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz" + "version" "2.0.6" + +"asmcrypto.js@^2.3.2": + "integrity" "sha512-3FgFARf7RupsZETQ1nHnhLUUvpcttcCq1iZCaVAbJZbCZ5VNRrNyvpDyHTOb0KC3llFcsyOT/a99NZcCbeiEsA==" + "resolved" "https://registry.npmjs.org/asmcrypto.js/-/asmcrypto.js-2.3.2.tgz" + "version" "2.3.2" + +"asn1.js@^5.0.1": + "integrity" "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==" + "resolved" "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz" + "version" "5.4.1" + dependencies: + "bn.js" "^4.0.0" + "inherits" "^2.0.1" + "minimalistic-assert" "^1.0.0" + "safer-buffer" "^2.1.0" + +"asn1@~0.2.3": + "integrity" "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==" + "resolved" "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz" + "version" "0.2.6" + dependencies: + "safer-buffer" "~2.1.0" + +"assemblyscript@0.19.10": + "integrity" "sha512-HavcUBXB3mBTRGJcpvaQjmnmaqKHBGREjSPNsIvnAk2f9dj78y4BkMaSSdvBQYWcDDzsHQjyUC8stICFkD1Odg==" + "resolved" "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.10.tgz" + "version" "0.19.10" + dependencies: + "binaryen" "101.0.0-nightly.20210723" + "long" "^4.0.0" + +"assert-plus@^1.0.0", "assert-plus@1.0.0": + "integrity" "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==" + "resolved" "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz" + "version" "1.0.0" + +"async@^2.6.1", "async@^2.6.2", "async@^2.6.3": + "integrity" "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==" + "resolved" "https://registry.npmjs.org/async/-/async-2.6.4.tgz" + "version" "2.6.4" + dependencies: + "lodash" "^4.17.14" + +"asynckit@^0.4.0": + "integrity" "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + "resolved" "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" + "version" "0.4.0" + +"at-least-node@^1.0.0": + "integrity" "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==" + "resolved" "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz" + "version" "1.0.0" + +"aws-sign2@~0.7.0": + "integrity" "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==" + "resolved" "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz" + "version" "0.7.0" + +"aws4@^1.8.0": + "integrity" "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==" + "resolved" "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz" + "version" "1.11.0" + +"axios@^0.21.1", "axios@^0.21.2": + "integrity" "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==" + "resolved" "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz" + "version" "0.21.4" + dependencies: + "follow-redirects" "^1.14.0" + +"balanced-match@^1.0.0": + "integrity" "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "resolved" "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz" + "version" "1.0.2" + +"base-x@^3.0.2", "base-x@^3.0.8": + "integrity" "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==" + "resolved" "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz" + "version" "3.0.9" + dependencies: + "safe-buffer" "^5.0.1" + +"base64-js@^1.3.1": + "integrity" "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + "resolved" "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz" + "version" "1.5.1" + +"bcrypt-pbkdf@^1.0.0": + "integrity" "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==" + "resolved" "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz" + "version" "1.0.2" + dependencies: + "tweetnacl" "^0.14.3" + +"bignumber.js@^9.0.0": + "integrity" "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==" + "resolved" "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz" + "version" "9.0.2" + +"binary-extensions@^2.0.0": + "integrity" "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" + "resolved" "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" + "version" "2.2.0" + +"binary-install-raw@0.0.13": + "integrity" "sha512-v7ms6N/H7iciuk6QInon3/n2mu7oRX+6knJ9xFPsJ3rQePgAqcR3CRTwUheFd8SLbiq4LL7Z4G/44L9zscdt9A==" + "resolved" "https://registry.npmjs.org/binary-install-raw/-/binary-install-raw-0.0.13.tgz" + "version" "0.0.13" + dependencies: + "axios" "^0.21.1" + "rimraf" "^3.0.2" + "tar" "^6.1.0" + +"binaryen@101.0.0-nightly.20210723": + "integrity" "sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA==" + "resolved" "https://registry.npmjs.org/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz" + "version" "101.0.0-nightly.20210723" + +"bindings@^1.5.0": + "integrity" "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==" + "resolved" "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz" + "version" "1.5.0" + dependencies: + "file-uri-to-path" "1.0.0" + +"bip66@^1.1.5": + "integrity" "sha512-nemMHz95EmS38a26XbbdxIYj5csHd3RMP3H5bwQknX0WYHF01qhpufP42mLOwVICuH2JmhIhXiWs89MfUGL7Xw==" + "resolved" "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz" + "version" "1.1.5" + dependencies: + "safe-buffer" "^5.0.1" + +"bl@^1.0.0": + "integrity" "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==" + "resolved" "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz" + "version" "1.2.3" + dependencies: + "readable-stream" "^2.3.5" + "safe-buffer" "^5.1.1" + +"bl@^3.0.0": + "integrity" "sha512-jrCW5ZhfQ/Vt07WX1Ngs+yn9BDqPL/gw28S7s9H6QK/gupnizNzJAss5akW20ISgOrbLTlXOOCTJeNUQqruAWQ==" + "resolved" "https://registry.npmjs.org/bl/-/bl-3.0.1.tgz" + "version" "3.0.1" + dependencies: + "readable-stream" "^3.0.1" + +"bl@^4.0.3": + "integrity" "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==" + "resolved" "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz" + "version" "4.1.0" + dependencies: + "buffer" "^5.5.0" + "inherits" "^2.0.4" + "readable-stream" "^3.4.0" + +"blakejs@^1.1.0": + "integrity" "sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==" + "resolved" "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz" + "version" "1.2.1" + +"bn.js@^4.0.0", "bn.js@^4.11.8", "bn.js@^4.11.9": + "integrity" "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + "resolved" "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz" + "version" "4.12.0" + +"bn.js@^5.1.2": + "integrity" "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + "resolved" "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz" + "version" "5.2.1" + +"bn.js@^5.2.0": + "integrity" "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + "resolved" "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz" + "version" "5.2.1" + +"bn.js@^5.2.1": + "integrity" "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + "resolved" "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz" + "version" "5.2.1" + +"bn.js@4.11.6": + "integrity" "sha512-XWwnNNFCuuSQ0m3r3C4LE3EiORltHd9M05pq6FOlVeiophzRbMo50Sbz1ehl8K3Z+jw9+vmgnXefY1hz8X+2wA==" + "resolved" "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz" + "version" "4.11.6" + +"borc@^2.1.2": + "integrity" "sha512-Sy9eoUi4OiKzq7VovMn246iTo17kzuyHJKomCfpWMlI6RpfN1gk95w7d7gH264nApVLg0HZfcpz62/g4VH1Y4w==" + "resolved" "https://registry.npmjs.org/borc/-/borc-2.1.2.tgz" + "version" "2.1.2" + dependencies: + "bignumber.js" "^9.0.0" + "buffer" "^5.5.0" + "commander" "^2.15.0" + "ieee754" "^1.1.13" + "iso-url" "~0.4.7" + "json-text-sequence" "~0.1.0" + "readable-stream" "^3.6.0" + +"brace-expansion@^1.1.7": + "integrity" "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==" + "resolved" "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz" + "version" "1.1.11" + dependencies: + "balanced-match" "^1.0.0" + "concat-map" "0.0.1" + +"braces@~3.0.2": + "integrity" "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==" + "resolved" "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz" + "version" "3.0.2" + dependencies: + "fill-range" "^7.0.1" + +"brorand@^1.1.0": + "integrity" "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" + "resolved" "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz" + "version" "1.1.0" + +"browserify-aes@^1.0.6", "browserify-aes@^1.2.0": + "integrity" "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==" + "resolved" "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz" + "version" "1.2.0" + dependencies: + "buffer-xor" "^1.0.3" + "cipher-base" "^1.0.0" + "create-hash" "^1.1.0" + "evp_bytestokey" "^1.0.3" + "inherits" "^2.0.1" + "safe-buffer" "^5.0.1" + +"bs58@^4.0.0", "bs58@^4.0.1": + "integrity" "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==" + "resolved" "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz" + "version" "4.0.1" + dependencies: + "base-x" "^3.0.2" + +"bs58check@^2.1.2": + "integrity" "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==" + "resolved" "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz" + "version" "2.1.2" + dependencies: + "bs58" "^4.0.0" + "create-hash" "^1.1.0" + "safe-buffer" "^5.1.2" + +"buffer-alloc-unsafe@^1.1.0": + "integrity" "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + "resolved" "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz" + "version" "1.1.0" + +"buffer-alloc@^1.2.0": + "integrity" "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==" + "resolved" "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz" + "version" "1.2.0" + dependencies: + "buffer-alloc-unsafe" "^1.1.0" + "buffer-fill" "^1.0.0" + +"buffer-fill@^1.0.0": + "integrity" "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==" + "resolved" "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz" + "version" "1.0.0" + +"buffer-from@^1.0.0": + "integrity" "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + "resolved" "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz" + "version" "1.1.2" + +"buffer-xor@^1.0.3": + "integrity" "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==" + "resolved" "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz" + "version" "1.0.3" + +"buffer@^5.2.1", "buffer@^5.4.2", "buffer@^5.4.3", "buffer@^5.5.0", "buffer@^5.6.0": + "integrity" "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==" + "resolved" "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz" + "version" "5.7.1" + dependencies: + "base64-js" "^1.3.1" + "ieee754" "^1.1.13" + +"buffer@^6.0.3": + "integrity" "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==" + "resolved" "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz" + "version" "6.0.3" + dependencies: + "base64-js" "^1.3.1" + "ieee754" "^1.2.1" + +"builtin-status-codes@^3.0.0": + "integrity" "sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ==" + "resolved" "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz" + "version" "3.0.0" + +"call-bind@^1.0.0": + "integrity" "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==" + "resolved" "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz" + "version" "1.0.2" + dependencies: + "function-bind" "^1.1.1" + "get-intrinsic" "^1.0.2" + +"callsites@^3.0.0": + "integrity" "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==" + "resolved" "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz" + "version" "3.1.0" + +"camelcase@^5.0.0": + "integrity" "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" + "resolved" "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz" + "version" "5.3.1" + +"caseless@^0.12.0", "caseless@~0.12.0": + "integrity" "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==" + "resolved" "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz" + "version" "0.12.0" + +"chalk@^2.0.0": + "integrity" "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==" + "resolved" "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz" + "version" "2.4.2" + dependencies: + "ansi-styles" "^3.2.1" + "escape-string-regexp" "^1.0.5" + "supports-color" "^5.3.0" + +"chalk@^2.4.2": + "integrity" "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==" + "resolved" "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz" + "version" "2.4.2" + dependencies: + "ansi-styles" "^3.2.1" + "escape-string-regexp" "^1.0.5" + "supports-color" "^5.3.0" + +"chalk@^3.0.0", "chalk@3.0.0": + "integrity" "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==" + "resolved" "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz" + "version" "3.0.0" + dependencies: + "ansi-styles" "^4.1.0" + "supports-color" "^7.1.0" + +"chokidar@3.5.1": + "integrity" "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==" + "resolved" "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz" + "version" "3.5.1" + dependencies: + "anymatch" "~3.1.1" + "braces" "~3.0.2" + "glob-parent" "~5.1.0" + "is-binary-path" "~2.1.0" + "is-glob" "~4.0.1" + "normalize-path" "~3.0.0" + "readdirp" "~3.5.0" + optionalDependencies: + "fsevents" "~2.3.1" + +"chownr@^1.0.1": + "integrity" "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + "resolved" "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz" + "version" "1.1.4" + +"chownr@^2.0.0": + "integrity" "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" + "resolved" "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz" + "version" "2.0.0" + +"cids@~0.7.0", "cids@~0.7.1": + "integrity" "sha512-zT7mPeghoWAu+ppn8+BS1tQ5qGmbMfB4AregnQjA/qHY3GC1m1ptI9GkWNlgeu38r7CuRdXB47uY2XgAYt6QVA==" + "resolved" "https://registry.npmjs.org/cids/-/cids-0.7.5.tgz" + "version" "0.7.5" + dependencies: + "buffer" "^5.5.0" + "class-is" "^1.1.0" + "multibase" "~0.6.0" + "multicodec" "^1.0.0" + "multihashes" "~0.4.15" + +"cids@~0.8.0": + "integrity" "sha512-yoXTbV3llpm+EBGWKeL9xKtksPE/s6DPoDSY4fn8I8TEW1zehWXPSB0pwAXVDlLaOlrw+sNynj995uD9abmPhA==" + "resolved" "https://registry.npmjs.org/cids/-/cids-0.8.3.tgz" + "version" "0.8.3" + dependencies: + "buffer" "^5.6.0" + "class-is" "^1.1.0" + "multibase" "^1.0.0" + "multicodec" "^1.0.1" + "multihashes" "^1.0.1" + +"cipher-base@^1.0.0", "cipher-base@^1.0.1", "cipher-base@^1.0.3": + "integrity" "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==" + "resolved" "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz" + "version" "1.0.4" + dependencies: + "inherits" "^2.0.1" + "safe-buffer" "^5.0.1" + +"class-is@^1.1.0": + "integrity" "sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw==" + "resolved" "https://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz" + "version" "1.1.0" + +"cli-cursor@^3.1.0": + "integrity" "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==" + "resolved" "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz" + "version" "3.1.0" + dependencies: + "restore-cursor" "^3.1.0" + +"cli-spinners@^2.2.0": + "integrity" "sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g==" + "resolved" "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.6.1.tgz" + "version" "2.6.1" + +"cli-table3@~0.5.0": + "integrity" "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==" + "resolved" "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz" + "version" "0.5.1" + dependencies: + "object-assign" "^4.1.0" + "string-width" "^2.1.1" + optionalDependencies: + "colors" "^1.1.2" + +"clone@^1.0.2": + "integrity" "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==" + "resolved" "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz" + "version" "1.0.4" + +"color-convert@^1.9.0": + "integrity" "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==" + "resolved" "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz" + "version" "1.9.3" + dependencies: + "color-name" "1.1.3" + +"color-convert@^2.0.1": + "integrity" "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==" + "resolved" "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz" + "version" "2.0.1" + dependencies: + "color-name" "~1.1.4" + +"color-name@~1.1.4": + "integrity" "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + "resolved" "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz" + "version" "1.1.4" + +"color-name@1.1.3": + "integrity" "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" + "resolved" "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz" + "version" "1.1.3" + +"colors@^1.1.2", "colors@1.3.3": + "integrity" "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==" + "resolved" "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz" + "version" "1.3.3" + +"combined-stream@^1.0.6", "combined-stream@~1.0.6": + "integrity" "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==" + "resolved" "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz" + "version" "1.0.8" + dependencies: + "delayed-stream" "~1.0.0" + +"commander@^2.12.2", "commander@^2.15.0": + "integrity" "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + "resolved" "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz" + "version" "2.20.3" + +"concat-map@0.0.1": + "integrity" "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "resolved" "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + "version" "0.0.1" + +"concat-stream@^1.6.0", "concat-stream@^1.6.2", "concat-stream@~1.6.2": + "integrity" "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==" + "resolved" "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz" + "version" "1.6.2" + dependencies: + "buffer-from" "^1.0.0" + "inherits" "^2.0.3" + "readable-stream" "^2.2.2" + "typedarray" "^0.0.6" + +"concat-stream@github:hugomrdias/concat-stream#feat/smaller": + "integrity" "sha512-wWqEOxEP+TusF0vcXO/4+6J1DJzN4NWQq9iG5LLlz+vtwDbfE0eiWXRtJWL6CZUAS45cvL9UdGCB/RSVOF6/kg==" + "resolved" "https://codeload.github.com/hugomrdias/concat-stream/tar.gz/057bc7b5d6d8df26c8cf00a3f151b6721a0a8034" + "version" "2.0.0" + dependencies: + "inherits" "^2.0.3" + "readable-stream" "^3.0.2" + +"core-util-is@~1.0.0": + "integrity" "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + "resolved" "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz" + "version" "1.0.3" + +"core-util-is@1.0.2": + "integrity" "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==" + "resolved" "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" + "version" "1.0.2" + +"cosmiconfig@6.0.0": + "integrity" "sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg==" + "resolved" "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz" + "version" "6.0.0" + dependencies: + "@types/parse-json" "^4.0.0" + "import-fresh" "^3.1.0" + "parse-json" "^5.0.0" + "path-type" "^4.0.0" + "yaml" "^1.7.2" + +"create-hash@^1.1.0", "create-hash@^1.1.2", "create-hash@^1.2.0": + "integrity" "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==" + "resolved" "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz" + "version" "1.2.0" + dependencies: + "cipher-base" "^1.0.1" + "inherits" "^2.0.1" + "md5.js" "^1.3.4" + "ripemd160" "^2.0.1" + "sha.js" "^2.4.0" + +"create-hmac@^1.1.4", "create-hmac@^1.1.7": + "integrity" "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==" + "resolved" "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz" + "version" "1.1.7" + dependencies: + "cipher-base" "^1.0.3" + "create-hash" "^1.1.0" + "inherits" "^2.0.1" + "ripemd160" "^2.0.0" + "safe-buffer" "^5.0.1" + "sha.js" "^2.4.8" + +"cross-spawn@^7.0.0": + "integrity" "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==" + "resolved" "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz" + "version" "7.0.3" + dependencies: + "path-key" "^3.1.0" + "shebang-command" "^2.0.0" + "which" "^2.0.1" + +"dashdash@^1.12.0": + "integrity" "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==" + "resolved" "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz" + "version" "1.14.1" + dependencies: + "assert-plus" "^1.0.0" + +"debug@^3.2.6": + "integrity" "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==" + "resolved" "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz" + "version" "3.2.7" + dependencies: + "ms" "^2.1.1" + +"debug@^4.1.0", "debug@4.1.1": + "integrity" "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==" + "resolved" "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz" + "version" "4.1.1" + dependencies: + "ms" "^2.1.1" + +"decamelize@^1.2.0": + "integrity" "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==" + "resolved" "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz" + "version" "1.2.0" + +"defaults@^1.0.3": + "integrity" "sha512-s82itHOnYrN0Ib8r+z7laQz3sdE+4FP3d9Q7VLO7U+KRT+CR0GsWuyHxzdAY82I7cXv0G/twrqomTJLOssO5HA==" + "resolved" "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz" + "version" "1.0.3" + dependencies: + "clone" "^1.0.2" + +"delayed-stream@~1.0.0": + "integrity" "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" + "resolved" "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" + "version" "1.0.0" + +"delimit-stream@0.1.0": + "integrity" "sha512-a02fiQ7poS5CnjiJBAsjGLPp5EwVoGHNeu9sziBd9huppRfsAFIpv5zNLv0V1gbop53ilngAf5Kf331AwcoRBQ==" + "resolved" "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz" + "version" "0.1.0" + +"detect-node@^2.0.4": + "integrity" "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==" + "resolved" "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz" + "version" "2.1.0" + +"docker-compose@0.23.4": + "integrity" "sha512-yWdXby9uQ8o4syOfvoSJ9ZlTnLipvUmDn59uaYY5VGIUSUAfMPPGqE1DE3pOCnfSg9Tl9UOOFO0PCSAzuIHmuA==" + "resolved" "https://registry.npmjs.org/docker-compose/-/docker-compose-0.23.4.tgz" + "version" "0.23.4" + +"docker-modem@^1.0.8": + "integrity" "sha512-lVjqCSCIAUDZPAZIeyM125HXfNvOmYYInciphNrLrylUtKyW66meAjSPXWchKVzoIYZx69TPnAepVSSkeawoIw==" + "resolved" "https://registry.npmjs.org/docker-modem/-/docker-modem-1.0.9.tgz" + "version" "1.0.9" + dependencies: + "debug" "^3.2.6" + "JSONStream" "1.3.2" + "readable-stream" "~1.0.26-4" + "split-ca" "^1.0.0" + +"dockerode@2.5.8": + "integrity" "sha512-+7iOUYBeDTScmOmQqpUYQaE7F4vvIt6+gIZNHWhqAQEI887tiPFB9OvXI/HzQYqfUNvukMK+9myLW63oTJPZpw==" + "resolved" "https://registry.npmjs.org/dockerode/-/dockerode-2.5.8.tgz" + "version" "2.5.8" + dependencies: + "concat-stream" "~1.6.2" + "docker-modem" "^1.0.8" + "tar-fs" "~1.16.3" + +"drbg.js@^1.0.1": + "integrity" "sha512-F4wZ06PvqxYLFEZKkFxTDcns9oFNk34hvmJSEwdzsxVQ8YI5YaxtACgQatkYgv2VI2CFkUd2Y+xosPQnHv809g==" + "resolved" "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz" + "version" "1.0.1" + dependencies: + "browserify-aes" "^1.0.6" + "create-hash" "^1.1.2" + "create-hmac" "^1.1.4" + +"ecc-jsbn@~0.1.1": + "integrity" "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==" + "resolved" "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz" + "version" "0.1.2" + dependencies: + "jsbn" "~0.1.0" + "safer-buffer" "^2.1.0" + +"ejs@^2.6.1": + "integrity" "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==" + "resolved" "https://registry.npmjs.org/ejs/-/ejs-2.7.4.tgz" + "version" "2.7.4" + +"elliptic@^6.5.2", "elliptic@^6.5.4", "elliptic@6.5.4": + "integrity" "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==" + "resolved" "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz" + "version" "6.5.4" + dependencies: + "bn.js" "^4.11.9" + "brorand" "^1.1.0" + "hash.js" "^1.0.0" + "hmac-drbg" "^1.0.1" + "inherits" "^2.0.4" + "minimalistic-assert" "^1.0.1" + "minimalistic-crypto-utils" "^1.0.1" + +"end-of-stream@^1.0.0", "end-of-stream@^1.1.0", "end-of-stream@^1.4.1": + "integrity" "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==" + "resolved" "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz" + "version" "1.4.4" + dependencies: + "once" "^1.4.0" + +"enquirer@2.3.4": + "integrity" "sha512-pkYrrDZumL2VS6VBGDhqbajCM2xpkUNLuKfGPjfKaSIBKYopQbqEFyrOkRMIb2HDR/rO1kGhEt/5twBwtzKBXw==" + "resolved" "https://registry.npmjs.org/enquirer/-/enquirer-2.3.4.tgz" + "version" "2.3.4" + dependencies: + "ansi-colors" "^3.2.1" + +"err-code@^1.1.2": + "integrity" "sha512-CJAN+O0/yA1CKfRn9SXOGctSpEM7DCon/r/5r2eXFMY2zCCJBasFhcM5I+1kh3Ap11FsQCX+vGHceNPvpWKhoA==" + "resolved" "https://registry.npmjs.org/err-code/-/err-code-1.1.2.tgz" + "version" "1.1.2" + +"err-code@^2.0.0": + "integrity" "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==" + "resolved" "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz" + "version" "2.0.3" + +"error-ex@^1.3.1": + "integrity" "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==" + "resolved" "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz" + "version" "1.3.2" + dependencies: + "is-arrayish" "^0.2.1" + +"es6-promise@^4.0.3": + "integrity" "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + "resolved" "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz" + "version" "4.2.8" + +"es6-promisify@^5.0.0": + "integrity" "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==" + "resolved" "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz" + "version" "5.0.0" + dependencies: + "es6-promise" "^4.0.3" + +"escape-string-regexp@^1.0.5": + "integrity" "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==" + "resolved" "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz" + "version" "1.0.5" + +"esprima@^4.0.0": + "integrity" "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + "resolved" "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz" + "version" "4.0.1" + +"ethereum-bloom-filters@^1.0.6": + "integrity" "sha512-rxJ5OFN3RwjQxDcFP2Z5+Q9ho4eIdEmSc2ht0fCu8Se9nbXjZ7/031uXoUYJ87KHCOdVeiUuwSnoS7hmYAGVHA==" + "resolved" "https://registry.npmjs.org/ethereum-bloom-filters/-/ethereum-bloom-filters-1.0.10.tgz" + "version" "1.0.10" + dependencies: + "js-sha3" "^0.8.0" + +"ethereum-cryptography@^0.1.3": + "integrity" "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==" + "resolved" "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz" + "version" "0.1.3" + dependencies: + "@types/pbkdf2" "^3.0.0" + "@types/secp256k1" "^4.0.1" + "blakejs" "^1.1.0" + "browserify-aes" "^1.2.0" + "bs58check" "^2.1.2" + "create-hash" "^1.2.0" + "create-hmac" "^1.1.7" + "hash.js" "^1.1.7" + "keccak" "^3.0.0" + "pbkdf2" "^3.0.17" + "randombytes" "^2.1.0" + "safe-buffer" "^5.1.2" + "scrypt-js" "^3.0.0" + "secp256k1" "^4.0.1" + "setimmediate" "^1.0.5" + +"ethereumjs-util@^7.1.0": + "integrity" "sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg==" + "resolved" "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.5.tgz" + "version" "7.1.5" + dependencies: + "@types/bn.js" "^5.1.0" + "bn.js" "^5.1.2" + "create-hash" "^1.1.2" + "ethereum-cryptography" "^0.1.3" + "rlp" "^2.2.4" + +"ethjs-unit@0.1.6": + "integrity" "sha512-/Sn9Y0oKl0uqQuvgFk/zQgR7aw1g36qX/jzSQ5lSwlO0GigPymk4eGQfeNTD03w1dPOqfz8V77Cy43jH56pagw==" + "resolved" "https://registry.npmjs.org/ethjs-unit/-/ethjs-unit-0.1.6.tgz" + "version" "0.1.6" + dependencies: + "bn.js" "4.11.6" + "number-to-bn" "1.7.0" + +"event-target-shim@^5.0.0": + "integrity" "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" + "resolved" "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz" + "version" "5.0.1" + +"evp_bytestokey@^1.0.3": + "integrity" "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==" + "resolved" "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz" + "version" "1.0.3" + dependencies: + "md5.js" "^1.3.4" + "safe-buffer" "^5.1.1" + +"execa@^3.0.0": + "integrity" "sha512-r9vdGQk4bmCuK1yKQu1KTwcT2zwfWdbdaXfCtAh+5nU/4fSX+JAb7vZGvI5naJrQlvONrEB20jeruESI69530g==" + "resolved" "https://registry.npmjs.org/execa/-/execa-3.4.0.tgz" + "version" "3.4.0" + dependencies: + "cross-spawn" "^7.0.0" + "get-stream" "^5.0.0" + "human-signals" "^1.1.1" + "is-stream" "^2.0.0" + "merge-stream" "^2.0.0" + "npm-run-path" "^4.0.0" + "onetime" "^5.1.0" + "p-finally" "^2.0.0" + "signal-exit" "^3.0.2" + "strip-final-newline" "^2.0.0" + +"explain-error@^1.0.4": + "integrity" "sha512-/wSgNMxFusiYRy1rd19LT2SQlIXDppHpumpWo06wxjflD1OYxDLbl6rMVw+U3bxD5Nuhex4TKqv9Aem4D0lVzQ==" + "resolved" "https://registry.npmjs.org/explain-error/-/explain-error-1.0.4.tgz" + "version" "1.0.4" + +"extend@~3.0.2": + "integrity" "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + "resolved" "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz" + "version" "3.0.2" + +"extsprintf@^1.2.0", "extsprintf@1.3.0": + "integrity" "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==" + "resolved" "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz" + "version" "1.3.0" + +"eyes@^0.1.8": + "integrity" "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==" + "resolved" "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz" + "version" "0.1.8" + +"fast-deep-equal@^3.1.1": + "integrity" "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "resolved" "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz" + "version" "3.1.3" + +"fast-json-stable-stringify@^2.0.0": + "integrity" "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + "resolved" "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz" + "version" "2.1.0" + +"file-uri-to-path@1.0.0": + "integrity" "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + "resolved" "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz" + "version" "1.0.0" + +"fill-range@^7.0.1": + "integrity" "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==" + "resolved" "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz" + "version" "7.0.1" + dependencies: + "to-regex-range" "^5.0.1" + +"flatmap@0.0.3": + "integrity" "sha512-OuR+o7kHVe+x9RtIujPay7Uw3bvDZBZFSBXClEphZuSDLmZTqMdclasf4vFSsogC8baDz0eaC2NdO/2dlXHBKQ==" + "resolved" "https://registry.npmjs.org/flatmap/-/flatmap-0.0.3.tgz" + "version" "0.0.3" + +"follow-redirects@^1.14.0": + "integrity" "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==" + "resolved" "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz" + "version" "1.15.1" + +"forever-agent@~0.6.1": + "integrity" "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==" + "resolved" "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz" + "version" "0.6.1" + +"form-data@^2.2.0", "form-data@~2.3.2": + "integrity" "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==" + "resolved" "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz" + "version" "2.3.3" + dependencies: + "asynckit" "^0.4.0" + "combined-stream" "^1.0.6" + "mime-types" "^2.1.12" + +"fs-constants@^1.0.0": + "integrity" "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + "resolved" "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz" + "version" "1.0.0" + +"fs-extra@9.0.0": + "integrity" "sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g==" + "resolved" "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.0.tgz" + "version" "9.0.0" + dependencies: + "at-least-node" "^1.0.0" + "graceful-fs" "^4.2.0" + "jsonfile" "^6.0.1" + "universalify" "^1.0.0" + +"fs-jetpack@^2.2.2": + "integrity" "sha512-S/o9Dd7K9A7gicVU32eT8G0kHcmSu0rCVdP79P0MWInKFb8XpTc8Syhoo66k9no+HDshtlh4pUJTws8X+8fdFQ==" + "resolved" "https://registry.npmjs.org/fs-jetpack/-/fs-jetpack-2.4.0.tgz" + "version" "2.4.0" + dependencies: + "minimatch" "^3.0.2" + "rimraf" "^2.6.3" + +"fs-minipass@^2.0.0": + "integrity" "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==" + "resolved" "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz" + "version" "2.1.0" + dependencies: + "minipass" "^3.0.0" + +"fs.realpath@^1.0.0": + "integrity" "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + "resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" + "version" "1.0.0" + +"fsevents@~2.3.1": + "integrity" "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==" + "resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" + "version" "2.3.2" + +"function-bind@^1.1.1": + "integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" + "version" "1.1.1" + +"get-intrinsic@^1.0.2": + "integrity" "sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==" + "resolved" "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.2.tgz" + "version" "1.1.2" + dependencies: + "function-bind" "^1.1.1" + "has" "^1.0.3" + "has-symbols" "^1.0.3" + +"get-port@^3.1.0": + "integrity" "sha512-x5UJKlgeUiNT8nyo/AcnwLnZuZNcSjSw0kogRB+Whd1fjjFq4B1hySFxSFWWSn4mIBzg3sRNUDFYc4g5gjPoLg==" + "resolved" "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz" + "version" "3.2.0" + +"get-stream@^5.0.0": + "integrity" "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==" + "resolved" "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz" + "version" "5.2.0" + dependencies: + "pump" "^3.0.0" + +"getpass@^0.1.1": + "integrity" "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==" + "resolved" "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz" + "version" "0.1.7" + dependencies: + "assert-plus" "^1.0.0" + +"glob-parent@~5.1.0": + "integrity" "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==" + "resolved" "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" + "version" "5.1.2" + dependencies: + "is-glob" "^4.0.1" + +"glob@^7.1.3", "glob@7.1.6": + "integrity" "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==" + "resolved" "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz" + "version" "7.1.6" + dependencies: + "fs.realpath" "^1.0.0" + "inflight" "^1.0.4" + "inherits" "2" + "minimatch" "^3.0.4" + "once" "^1.3.0" + "path-is-absolute" "^1.0.0" + +"gluegun@git+https://github.com/edgeandnode/gluegun.git#v4.3.1-pin-colors-dep": + "resolved" "git+ssh://git@github.com/edgeandnode/gluegun.git#b34b9003d7bf556836da41b57ef36eb21570620a" + "version" "4.3.1" + dependencies: + "apisauce" "^1.0.1" + "app-module-path" "^2.2.0" + "cli-table3" "~0.5.0" + "colors" "1.3.3" + "cosmiconfig" "6.0.0" + "cross-spawn" "^7.0.0" + "ejs" "^2.6.1" + "enquirer" "2.3.4" + "execa" "^3.0.0" + "fs-jetpack" "^2.2.2" + "lodash.camelcase" "^4.3.0" + "lodash.kebabcase" "^4.1.1" + "lodash.lowercase" "^4.3.0" + "lodash.lowerfirst" "^4.3.1" + "lodash.pad" "^4.5.1" + "lodash.padend" "^4.6.1" + "lodash.padstart" "^4.6.1" + "lodash.repeat" "^4.1.0" + "lodash.snakecase" "^4.1.1" + "lodash.startcase" "^4.4.0" + "lodash.trim" "^4.5.1" + "lodash.trimend" "^4.5.1" + "lodash.trimstart" "^4.5.1" + "lodash.uppercase" "^4.3.0" + "lodash.upperfirst" "^4.3.1" + "ora" "^4.0.0" + "pluralize" "^8.0.0" + "ramdasauce" "^2.1.0" + "semver" "^7.0.0" + "which" "^2.0.0" + "yargs-parser" "^16.1.0" + +"graceful-fs@^4.1.6", "graceful-fs@^4.2.0": + "integrity" "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" + "resolved" "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz" + "version" "4.2.10" + +"graphql@15.5.0": + "integrity" "sha512-OmaM7y0kaK31NKG31q4YbD2beNYa6jBBKtMFT6gLYJljHLJr42IqJ8KX08u3Li/0ifzTU5HjmoOOrwa5BRLeDA==" + "resolved" "https://registry.npmjs.org/graphql/-/graphql-15.5.0.tgz" + "version" "15.5.0" + +"har-schema@^2.0.0": + "integrity" "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==" + "resolved" "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz" + "version" "2.0.0" + +"har-validator@~5.1.3": + "integrity" "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==" + "resolved" "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz" + "version" "5.1.5" + dependencies: + "ajv" "^6.12.3" + "har-schema" "^2.0.0" + +"has-flag@^3.0.0": + "integrity" "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==" + "resolved" "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz" + "version" "3.0.0" + +"has-flag@^4.0.0": + "integrity" "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + "resolved" "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz" + "version" "4.0.0" + +"has-symbols@^1.0.3": + "integrity" "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" + "resolved" "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz" + "version" "1.0.3" + +"has@^1.0.3": + "integrity" "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==" + "resolved" "https://registry.npmjs.org/has/-/has-1.0.3.tgz" + "version" "1.0.3" + dependencies: + "function-bind" "^1.1.1" + +"hash-base@^3.0.0": + "integrity" "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==" + "resolved" "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz" + "version" "3.1.0" + dependencies: + "inherits" "^2.0.4" + "readable-stream" "^3.6.0" + "safe-buffer" "^5.2.0" + +"hash.js@^1.0.0", "hash.js@^1.0.3", "hash.js@^1.1.7", "hash.js@1.1.7": + "integrity" "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==" + "resolved" "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz" + "version" "1.1.7" + dependencies: + "inherits" "^2.0.3" + "minimalistic-assert" "^1.0.1" + +"hi-base32@~0.5.0": + "integrity" "sha512-EmBBpvdYh/4XxsnUybsPag6VikPYnN30td+vQk+GI3qpahVEG9+gTkG0aXVxTjBqQ5T6ijbWIu77O+C5WFWsnA==" + "resolved" "https://registry.npmjs.org/hi-base32/-/hi-base32-0.5.1.tgz" + "version" "0.5.1" + +"hmac-drbg@^1.0.1": + "integrity" "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==" + "resolved" "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz" + "version" "1.0.1" + dependencies: + "hash.js" "^1.0.3" + "minimalistic-assert" "^1.0.0" + "minimalistic-crypto-utils" "^1.0.1" + +"http-basic@^8.1.1": + "integrity" "sha512-/EcDMwJZh3mABI2NhGfHOGOeOZITqfkEO4p/xK+l3NpyncIHUQBoMvCSF/b5GqvKtySC2srL/GGG3+EtlqlmCw==" + "resolved" "https://registry.npmjs.org/http-basic/-/http-basic-8.1.3.tgz" + "version" "8.1.3" + dependencies: + "caseless" "^0.12.0" + "concat-stream" "^1.6.2" + "http-response-object" "^3.0.1" + "parse-cache-control" "^1.0.1" + +"http-response-object@^3.0.1": + "integrity" "sha512-bqX0XTF6fnXSQcEJ2Iuyr75yVakyjIDCqroJQ/aHfSdlM743Cwqoi2nDYMzLGWUcuTWGWy8AAvOKXTfiv6q9RA==" + "resolved" "https://registry.npmjs.org/http-response-object/-/http-response-object-3.0.2.tgz" + "version" "3.0.2" + dependencies: + "@types/node" "^10.0.3" + +"http-signature@~1.2.0": + "integrity" "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==" + "resolved" "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz" + "version" "1.2.0" + dependencies: + "assert-plus" "^1.0.0" + "jsprim" "^1.2.2" + "sshpk" "^1.7.0" + +"human-signals@^1.1.1": + "integrity" "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==" + "resolved" "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz" + "version" "1.1.1" + +"ieee754@^1.1.13", "ieee754@^1.2.1": + "integrity" "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + "resolved" "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz" + "version" "1.2.1" + +"immutable@3.8.2": + "integrity" "sha512-15gZoQ38eYjEjxkorfbcgBKBL6R7T459OuK+CpcWt7O3KF4uPCx2tD0uFETlUDIyo+1789crbMhTvQBSR5yBMg==" + "resolved" "https://registry.npmjs.org/immutable/-/immutable-3.8.2.tgz" + "version" "3.8.2" + +"import-fresh@^3.1.0": + "integrity" "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==" + "resolved" "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz" + "version" "3.3.0" + dependencies: + "parent-module" "^1.0.0" + "resolve-from" "^4.0.0" + +"inflight@^1.0.4": + "integrity" "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==" + "resolved" "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz" + "version" "1.0.6" + dependencies: + "once" "^1.3.0" + "wrappy" "1" + +"inherits@^2.0.1", "inherits@^2.0.3", "inherits@^2.0.4", "inherits@~2.0.1", "inherits@~2.0.3", "inherits@2": + "integrity" "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "resolved" "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" + "version" "2.0.4" + +"ip-regex@^2.0.0": + "integrity" "sha512-58yWmlHpp7VYfcdTwMTvwMmqx/Elfxjd9RXTDyMsbL7lLWmhMylLEqiYVLKuLzOZqVgiWXD9MfR62Vv89VRxkw==" + "resolved" "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz" + "version" "2.1.0" + +"ip-regex@^4.0.0": + "integrity" "sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==" + "resolved" "https://registry.npmjs.org/ip-regex/-/ip-regex-4.3.0.tgz" + "version" "4.3.0" + +"ip@^1.1.5": + "integrity" "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==" + "resolved" "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz" + "version" "1.1.8" + +"ipfs-block@~0.8.1": + "integrity" "sha512-0FaCpmij+jZBoUYhjoB5ptjdl9QzvrdRIoBmUU5JiBnK2GA+4YM/ifklaB8ePRhA/rRzhd+KYBjvMFMAL4NrVQ==" + "resolved" "https://registry.npmjs.org/ipfs-block/-/ipfs-block-0.8.1.tgz" + "version" "0.8.1" + dependencies: + "cids" "~0.7.0" + "class-is" "^1.1.0" + +"ipfs-http-client@34.0.0": + "integrity" "sha512-4RCkk8ix4Dqn6sxqFVwuXWCZ1eLFPsVaj6Ijvu1fs9VYgxgVudsW9PWwarlr4mw1xUCmPWYyXnEbGgzBrfMy0Q==" + "resolved" "https://registry.npmjs.org/ipfs-http-client/-/ipfs-http-client-34.0.0.tgz" + "version" "34.0.0" + dependencies: + "abort-controller" "^3.0.0" + "async" "^2.6.1" + "bignumber.js" "^9.0.0" + "bl" "^3.0.0" + "bs58" "^4.0.1" + "buffer" "^5.4.2" + "cids" "~0.7.1" + "concat-stream" "github:hugomrdias/concat-stream#feat/smaller" + "debug" "^4.1.0" + "detect-node" "^2.0.4" + "end-of-stream" "^1.4.1" + "err-code" "^2.0.0" + "explain-error" "^1.0.4" + "flatmap" "0.0.3" + "glob" "^7.1.3" + "ipfs-block" "~0.8.1" + "ipfs-utils" "~0.0.3" + "ipld-dag-cbor" "~0.15.0" + "ipld-dag-pb" "~0.17.3" + "ipld-raw" "^4.0.0" + "is-ipfs" "~0.6.1" + "is-pull-stream" "0.0.0" + "is-stream" "^2.0.0" + "iso-stream-http" "~0.1.2" + "iso-url" "~0.4.6" + "iterable-ndjson" "^1.1.0" + "just-kebab-case" "^1.1.0" + "just-map-keys" "^1.1.0" + "kind-of" "^6.0.2" + "ky" "^0.11.2" + "ky-universal" "^0.2.2" + "lru-cache" "^5.1.1" + "multiaddr" "^6.0.6" + "multibase" "~0.6.0" + "multicodec" "~0.5.1" + "multihashes" "~0.4.14" + "ndjson" "github:hugomrdias/ndjson#feat/readable-stream3" + "once" "^1.4.0" + "peer-id" "~0.12.3" + "peer-info" "~0.15.1" + "promise-nodeify" "^3.0.1" + "promisify-es6" "^1.0.3" + "pull-defer" "~0.2.3" + "pull-stream" "^3.6.9" + "pull-to-stream" "~0.1.1" + "pump" "^3.0.0" + "qs" "^6.5.2" + "readable-stream" "^3.1.1" + "stream-to-pull-stream" "^1.7.2" + "tar-stream" "^2.0.1" + "through2" "^3.0.1" + +"ipfs-utils@~0.0.3": + "integrity" "sha512-7cZf6aGj2FG3XJWhCNwn4mS93Q0GEWjtBZvEHqzgI43U2qzNDCyzfS1pei1Y5F+tw/zDJ5U4XG0G9reJxR53Ig==" + "resolved" "https://registry.npmjs.org/ipfs-utils/-/ipfs-utils-0.0.4.tgz" + "version" "0.0.4" + dependencies: + "buffer" "^5.2.1" + "is-buffer" "^2.0.3" + "is-electron" "^2.2.0" + "is-pull-stream" "0.0.0" + "is-stream" "^2.0.0" + "kind-of" "^6.0.2" + "readable-stream" "^3.4.0" + +"ipld-dag-cbor@~0.15.0": + "integrity" "sha512-m23nG7ZyoVFnkK55/bLAErc7EfiMgaEQlqHWDTGzPI+O5r6bPfp+qbL5zTVSIT8tpbHmu174dwerVtLoVgeVyA==" + "resolved" "https://registry.npmjs.org/ipld-dag-cbor/-/ipld-dag-cbor-0.15.3.tgz" + "version" "0.15.3" + dependencies: + "borc" "^2.1.2" + "buffer" "^5.5.0" + "cids" "~0.8.0" + "is-circular" "^1.0.2" + "multicodec" "^1.0.0" + "multihashing-async" "~0.8.0" + +"ipld-dag-pb@~0.17.3": + "integrity" "sha512-YwCxETEMuXVspOKOhjIOHJvKvB/OZfCDkpSFiYBQN2/JQjM9y/RFCYzIQGm0wg7dCFLrhvfjAZLTSaKs65jzWA==" + "resolved" "https://registry.npmjs.org/ipld-dag-pb/-/ipld-dag-pb-0.17.4.tgz" + "version" "0.17.4" + dependencies: + "cids" "~0.7.0" + "class-is" "^1.1.0" + "multicodec" "~0.5.1" + "multihashing-async" "~0.7.0" + "protons" "^1.0.1" + "stable" "~0.1.8" + +"ipld-raw@^4.0.0": + "integrity" "sha512-WjIdtZ06jJEar8zh+BHB84tE6ZdbS/XNa7+XCArOYfmeJ/c01T9VQpeMwdJQYn5c3s5UvvCu7y4VIi3vk2g1bA==" + "resolved" "https://registry.npmjs.org/ipld-raw/-/ipld-raw-4.0.1.tgz" + "version" "4.0.1" + dependencies: + "cids" "~0.7.0" + "multicodec" "^1.0.0" + "multihashing-async" "~0.8.0" + +"is-arrayish@^0.2.1": + "integrity" "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" + "resolved" "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz" + "version" "0.2.1" + +"is-binary-path@~2.1.0": + "integrity" "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==" + "resolved" "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz" + "version" "2.1.0" + dependencies: + "binary-extensions" "^2.0.0" + +"is-buffer@^2.0.3": + "integrity" "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==" + "resolved" "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz" + "version" "2.0.5" + +"is-circular@^1.0.2": + "integrity" "sha512-YttjnrswnUYRVJvxCvu8z+PGMUSzC2JttP0OEXezlAEdp3EXzhf7IZ3j0gRAybJBQupedIZFhY61Tga6E0qASA==" + "resolved" "https://registry.npmjs.org/is-circular/-/is-circular-1.0.2.tgz" + "version" "1.0.2" + +"is-electron@^2.2.0": + "integrity" "sha512-r8EEQQsqT+Gn0aXFx7lTFygYQhILLCB+wn0WCDL5LZRINeLH/Rvw1j2oKodELLXYNImQ3CRlVsY8wW4cGOsyuw==" + "resolved" "https://registry.npmjs.org/is-electron/-/is-electron-2.2.1.tgz" + "version" "2.2.1" + +"is-extglob@^2.1.1": + "integrity" "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" + "resolved" "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz" + "version" "2.1.1" + +"is-fullwidth-code-point@^2.0.0": + "integrity" "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==" + "resolved" "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz" + "version" "2.0.0" + +"is-glob@^4.0.1", "is-glob@~4.0.1": + "integrity" "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==" + "resolved" "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" + "version" "4.0.3" + dependencies: + "is-extglob" "^2.1.1" + +"is-hex-prefixed@1.0.0": + "integrity" "sha512-WvtOiug1VFrE9v1Cydwm+FnXd3+w9GaeVUss5W4v/SLy3UW00vP+6iNF2SdnfiBoLy4bTqVdkftNGTUeOFVsbA==" + "resolved" "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz" + "version" "1.0.0" + +"is-interactive@^1.0.0": + "integrity" "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==" + "resolved" "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz" + "version" "1.0.0" + +"is-ip@^2.0.0": + "integrity" "sha512-9MTn0dteHETtyUx8pxqMwg5hMBi3pvlyglJ+b79KOCca0po23337LbVV2Hl4xmMvfw++ljnO0/+5G6G+0Szh6g==" + "resolved" "https://registry.npmjs.org/is-ip/-/is-ip-2.0.0.tgz" + "version" "2.0.0" + dependencies: + "ip-regex" "^2.0.0" + +"is-ip@^3.1.0": + "integrity" "sha512-35vd5necO7IitFPjd/YBeqwWnyDWbuLH9ZXQdMfDA8TEo7pv5X8yfrvVO3xbJbLUlERCMvf6X0hTUamQxCYJ9Q==" + "resolved" "https://registry.npmjs.org/is-ip/-/is-ip-3.1.0.tgz" + "version" "3.1.0" + dependencies: + "ip-regex" "^4.0.0" + +"is-ipfs@~0.6.1": + "integrity" "sha512-HyRot1dvLcxImtDqPxAaY1miO6WsiP/z7Yxpg2qpaLWv5UdhAPtLvHJ4kMLM0w8GSl8AFsVF23PHe1LzuWrUlQ==" + "resolved" "https://registry.npmjs.org/is-ipfs/-/is-ipfs-0.6.3.tgz" + "version" "0.6.3" + dependencies: + "bs58" "^4.0.1" + "cids" "~0.7.0" + "mafmt" "^7.0.0" + "multiaddr" "^7.2.1" + "multibase" "~0.6.0" + "multihashes" "~0.4.13" + +"is-number@^7.0.0": + "integrity" "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + "resolved" "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz" + "version" "7.0.0" + +"is-promise@~1", "is-promise@~1.0.0": + "integrity" "sha512-mjWH5XxnhMA8cFnDchr6qRP9S/kLntKuEfIYku+PaN1CnS8v+OG9O/BKpRCVRJvpIkgAZm0Pf5Is3iSSOILlcg==" + "resolved" "https://registry.npmjs.org/is-promise/-/is-promise-1.0.1.tgz" + "version" "1.0.1" + +"is-pull-stream@0.0.0": + "integrity" "sha512-NWLwqCc95I6m8FZDYLAmVJc9Xgk8O+8pPOoDKFTC293FH4S7FBcbLCw3WWPCdiT8uUSdzPy47VM08WPDMJJrag==" + "resolved" "https://registry.npmjs.org/is-pull-stream/-/is-pull-stream-0.0.0.tgz" + "version" "0.0.0" + +"is-stream@^2.0.0": + "integrity" "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" + "resolved" "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz" + "version" "2.0.1" + +"is-typedarray@~1.0.0": + "integrity" "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" + "resolved" "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz" + "version" "1.0.0" + +"isarray@~1.0.0": + "integrity" "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + "resolved" "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" + "version" "1.0.0" + +"isarray@0.0.1": + "integrity" "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" + "resolved" "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" + "version" "0.0.1" + +"isexe@^2.0.0": + "integrity" "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + "resolved" "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz" + "version" "2.0.0" + +"iso-random-stream@^1.1.0": + "integrity" "sha512-7y0tsBBgQs544iTYjyrMp5xvgrbYR8b+plQq1Bryp+03p0LssrxC9C1M0oHv4QESDt7d95c74XvMk/yawKqX+A==" + "resolved" "https://registry.npmjs.org/iso-random-stream/-/iso-random-stream-1.1.2.tgz" + "version" "1.1.2" + dependencies: + "buffer" "^6.0.3" + "readable-stream" "^3.4.0" + +"iso-stream-http@~0.1.2": + "integrity" "sha512-oHEDNOysIMTNypbg2f1SlydqRBvjl4ZbSE9+0awVxnkx3K2stGTFwB/kpVqnB6UEfF8QD36kAjDwZvqyXBLMnQ==" + "resolved" "https://registry.npmjs.org/iso-stream-http/-/iso-stream-http-0.1.2.tgz" + "version" "0.1.2" + dependencies: + "builtin-status-codes" "^3.0.0" + "inherits" "^2.0.1" + "readable-stream" "^3.1.1" + +"iso-url@~0.4.6", "iso-url@~0.4.7": + "integrity" "sha512-27fFRDnPAMnHGLq36bWTpKET+eiXct3ENlCcdcMdk+mjXrb2kw3mhBUg1B7ewAC0kVzlOPhADzQgz1SE6Tglog==" + "resolved" "https://registry.npmjs.org/iso-url/-/iso-url-0.4.7.tgz" + "version" "0.4.7" + +"isstream@~0.1.2": + "integrity" "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" + "resolved" "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz" + "version" "0.1.2" + +"iterable-ndjson@^1.1.0": + "integrity" "sha512-OOp1Lb0o3k5MkXHx1YaIY5Z0ELosZfTnBaas9f8opJVcZGBIONA2zY/6CYE+LKkqrSDooIneZbrBGgOZnHPkrg==" + "resolved" "https://registry.npmjs.org/iterable-ndjson/-/iterable-ndjson-1.1.0.tgz" + "version" "1.1.0" + dependencies: + "string_decoder" "^1.2.0" + +"jayson@3.2.0": + "integrity" "sha512-DZQnwA57GcStw4soSYB2VntWXFfoWvmSarlaWePDYOWhjxT72PBM4atEBomaTaS1uqk3jFC9UO9AyWjlujo3xw==" + "resolved" "https://registry.npmjs.org/jayson/-/jayson-3.2.0.tgz" + "version" "3.2.0" + dependencies: + "@types/connect" "^3.4.32" + "@types/express-serve-static-core" "^4.16.9" + "@types/lodash" "^4.14.139" + "@types/node" "^12.7.7" + "commander" "^2.12.2" + "es6-promisify" "^5.0.0" + "eyes" "^0.1.8" + "json-stringify-safe" "^5.0.1" + "JSONStream" "^1.3.1" + "lodash" "^4.17.15" + "uuid" "^3.2.1" + +"js-sha3@^0.8.0", "js-sha3@~0.8.0", "js-sha3@0.8.0": + "integrity" "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + "resolved" "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz" + "version" "0.8.0" + +"js-tokens@^4.0.0": + "integrity" "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + "resolved" "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz" + "version" "4.0.0" + +"js-yaml@3.13.1": + "integrity" "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==" + "resolved" "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz" + "version" "3.13.1" + dependencies: + "argparse" "^1.0.7" + "esprima" "^4.0.0" + +"jsbn@~0.1.0": + "integrity" "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" + "resolved" "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz" + "version" "0.1.1" + +"json-parse-even-better-errors@^2.3.0": + "integrity" "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" + "resolved" "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz" + "version" "2.3.1" + +"json-schema-traverse@^0.4.1": + "integrity" "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + "resolved" "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz" + "version" "0.4.1" + +"json-schema@0.4.0": + "integrity" "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" + "resolved" "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz" + "version" "0.4.0" + +"json-stringify-safe@^5.0.1", "json-stringify-safe@~5.0.1": + "integrity" "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" + "resolved" "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" + "version" "5.0.1" + +"json-text-sequence@~0.1.0": + "integrity" "sha512-L3mEegEWHRekSHjc7+sc8eJhba9Clq1PZ8kMkzf8OxElhXc8O4TS5MwcVlj9aEbm5dr81N90WHC5nAz3UO971w==" + "resolved" "https://registry.npmjs.org/json-text-sequence/-/json-text-sequence-0.1.1.tgz" + "version" "0.1.1" + dependencies: + "delimit-stream" "0.1.0" + +"jsonfile@^6.0.1": + "integrity" "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==" + "resolved" "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz" + "version" "6.1.0" + dependencies: + "universalify" "^2.0.0" + optionalDependencies: + "graceful-fs" "^4.1.6" + +"jsonparse@^1.2.0": + "integrity" "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==" + "resolved" "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz" + "version" "1.3.1" + +"JSONStream@^1.3.1", "JSONStream@1.3.2": + "integrity" "sha512-mn0KSip7N4e0UDPZHnqDsHECo5uGQrixQKnAskOM1BIB8hd7QKbd6il8IPRPudPHOeHiECoCFqhyMaRO9+nWyA==" + "resolved" "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz" + "version" "1.3.2" + dependencies: + "jsonparse" "^1.2.0" + "through" ">=2.2.7 <3" + +"jsprim@^1.2.2": + "integrity" "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==" + "resolved" "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz" + "version" "1.4.2" + dependencies: + "assert-plus" "1.0.0" + "extsprintf" "1.3.0" + "json-schema" "0.4.0" + "verror" "1.10.0" + +"just-kebab-case@^1.1.0": + "integrity" "sha512-QkuwuBMQ9BQHMUEkAtIA4INLrkmnnveqlFB1oFi09gbU0wBdZo6tTnyxNWMR84zHxBuwK7GLAwqN8nrvVxOLTA==" + "resolved" "https://registry.npmjs.org/just-kebab-case/-/just-kebab-case-1.1.0.tgz" + "version" "1.1.0" + +"just-map-keys@^1.1.0": + "integrity" "sha512-Dmyz1Cy2SWM+PpqDPB1kdDglyexdzMthnAsvOIE9w4OPj8NDRuY1mh20x/JfG5w6fCGw9F0WmcofJhYZ4MiuyA==" + "resolved" "https://registry.npmjs.org/just-map-keys/-/just-map-keys-1.2.1.tgz" + "version" "1.2.1" + +"keccak@^3.0.0": + "integrity" "sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ==" + "resolved" "https://registry.npmjs.org/keccak/-/keccak-3.0.2.tgz" + "version" "3.0.2" + dependencies: + "node-addon-api" "^2.0.0" + "node-gyp-build" "^4.2.0" + "readable-stream" "^3.6.0" + +"keypair@^1.0.1": + "integrity" "sha512-zwhgOhhniaL7oxMgUMKKw5219PWWABMO+dgMnzJOQ2/5L3XJtTJGhW2PEXlxXj9zaccdReZJZ83+4NPhVfNVDg==" + "resolved" "https://registry.npmjs.org/keypair/-/keypair-1.0.4.tgz" + "version" "1.0.4" + +"kind-of@^6.0.2": + "integrity" "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" + "resolved" "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz" + "version" "6.0.3" + +"ky-universal@^0.2.2": + "integrity" "sha512-fb32o/fKy/ux2ALWa9HU2hvGtfOq7/vn2nH0FpVE+jwNzyTeORlAbj3Fiw+WLMbUlmVqZIWupnLZ2USHvqwZHw==" + "resolved" "https://registry.npmjs.org/ky-universal/-/ky-universal-0.2.2.tgz" + "version" "0.2.2" + dependencies: + "abort-controller" "^3.0.0" + "node-fetch" "^2.3.0" + +"ky@^0.11.2", "ky@>=0.10.0": + "integrity" "sha512-5Aou5BWue5/mkPqIRqzSWW+0Hkl403pr/2AIrCKYw7cVl/Xoe8Xe4KLBO0PRjbz7GnRe1/8wW1KhqQNFFE7/GQ==" + "resolved" "https://registry.npmjs.org/ky/-/ky-0.11.2.tgz" + "version" "0.11.2" + +"libp2p-crypto-secp256k1@~0.3.0": + "integrity" "sha512-evrfK/CeUSd/lcELUdDruyPBvxDmLairth75S32OLl3H+++2m2fV24JEtxzdFS9JH3xEFw0h6JFO8DBa1bP9dA==" + "resolved" "https://registry.npmjs.org/libp2p-crypto-secp256k1/-/libp2p-crypto-secp256k1-0.3.1.tgz" + "version" "0.3.1" + dependencies: + "async" "^2.6.2" + "bs58" "^4.0.1" + "multihashing-async" "~0.6.0" + "nodeify" "^1.0.1" + "safe-buffer" "^5.1.2" + "secp256k1" "^3.6.2" + +"libp2p-crypto@~0.16.1": + "integrity" "sha512-II8HxKc9jbmQp34pprlluNxsBCWJDjHRPYJzuRy7ragztNip9Zb7uJ4lCje6gGzz4DNAcHkAUn+GqCIK1592iA==" + "resolved" "https://registry.npmjs.org/libp2p-crypto/-/libp2p-crypto-0.16.4.tgz" + "version" "0.16.4" + dependencies: + "asmcrypto.js" "^2.3.2" + "asn1.js" "^5.0.1" + "async" "^2.6.1" + "bn.js" "^4.11.8" + "browserify-aes" "^1.2.0" + "bs58" "^4.0.1" + "iso-random-stream" "^1.1.0" + "keypair" "^1.0.1" + "libp2p-crypto-secp256k1" "~0.3.0" + "multihashing-async" "~0.5.1" + "node-forge" "^0.10.0" + "pem-jwk" "^2.0.0" + "protons" "^1.0.1" + "rsa-pem-to-jwk" "^1.1.3" + "tweetnacl" "^1.0.0" + "ursa-optional" "~0.10.0" + +"lines-and-columns@^1.1.6": + "integrity" "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" + "resolved" "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz" + "version" "1.2.4" + +"lodash.camelcase@^4.3.0": + "integrity" "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==" + "resolved" "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz" + "version" "4.3.0" + +"lodash.kebabcase@^4.1.1": + "integrity" "sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g==" + "resolved" "https://registry.npmjs.org/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz" + "version" "4.1.1" + +"lodash.lowercase@^4.3.0": + "integrity" "sha512-UcvP1IZYyDKyEL64mmrwoA1AbFu5ahojhTtkOUr1K9dbuxzS9ev8i4TxMMGCqRC9TE8uDaSoufNAXxRPNTseVA==" + "resolved" "https://registry.npmjs.org/lodash.lowercase/-/lodash.lowercase-4.3.0.tgz" + "version" "4.3.0" + +"lodash.lowerfirst@^4.3.1": + "integrity" "sha512-UUKX7VhP1/JL54NXg2aq/E1Sfnjjes8fNYTNkPU8ZmsaVeBvPHKdbNaN79Re5XRL01u6wbq3j0cbYZj71Fcu5w==" + "resolved" "https://registry.npmjs.org/lodash.lowerfirst/-/lodash.lowerfirst-4.3.1.tgz" + "version" "4.3.1" + +"lodash.pad@^4.5.1": + "integrity" "sha512-mvUHifnLqM+03YNzeTBS1/Gr6JRFjd3rRx88FHWUvamVaT9k2O/kXha3yBSOwB9/DTQrSTLJNHvLBBt2FdX7Mg==" + "resolved" "https://registry.npmjs.org/lodash.pad/-/lodash.pad-4.5.1.tgz" + "version" "4.5.1" + +"lodash.padend@^4.6.1": + "integrity" "sha512-sOQs2aqGpbl27tmCS1QNZA09Uqp01ZzWfDUoD+xzTii0E7dSQfRKcRetFwa+uXaxaqL+TKm7CgD2JdKP7aZBSw==" + "resolved" "https://registry.npmjs.org/lodash.padend/-/lodash.padend-4.6.1.tgz" + "version" "4.6.1" + +"lodash.padstart@^4.6.1": + "integrity" "sha512-sW73O6S8+Tg66eY56DBk85aQzzUJDtpoXFBgELMd5P/SotAguo+1kYO6RuYgXxA4HJH3LFTFPASX6ET6bjfriw==" + "resolved" "https://registry.npmjs.org/lodash.padstart/-/lodash.padstart-4.6.1.tgz" + "version" "4.6.1" + +"lodash.repeat@^4.1.0": + "integrity" "sha512-eWsgQW89IewS95ZOcr15HHCX6FVDxq3f2PNUIng3fyzsPev9imFQxIYdFZ6crl8L56UR6ZlGDLcEb3RZsCSSqw==" + "resolved" "https://registry.npmjs.org/lodash.repeat/-/lodash.repeat-4.1.0.tgz" + "version" "4.1.0" + +"lodash.snakecase@^4.1.1": + "integrity" "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==" + "resolved" "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz" + "version" "4.1.1" + +"lodash.startcase@^4.4.0": + "integrity" "sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==" + "resolved" "https://registry.npmjs.org/lodash.startcase/-/lodash.startcase-4.4.0.tgz" + "version" "4.4.0" + +"lodash.trim@^4.5.1": + "integrity" "sha512-nJAlRl/K+eiOehWKDzoBVrSMhK0K3A3YQsUNXHQa5yIrKBAhsZgSu3KoAFoFT+mEgiyBHddZ0pRk1ITpIp90Wg==" + "resolved" "https://registry.npmjs.org/lodash.trim/-/lodash.trim-4.5.1.tgz" + "version" "4.5.1" + +"lodash.trimend@^4.5.1": + "integrity" "sha512-lsD+k73XztDsMBKPKvzHXRKFNMohTjoTKIIo4ADLn5dA65LZ1BqlAvSXhR2rPEC3BgAUQnzMnorqDtqn2z4IHA==" + "resolved" "https://registry.npmjs.org/lodash.trimend/-/lodash.trimend-4.5.1.tgz" + "version" "4.5.1" + +"lodash.trimstart@^4.5.1": + "integrity" "sha512-b/+D6La8tU76L/61/aN0jULWHkT0EeJCmVstPBn/K9MtD2qBW83AsBNrr63dKuWYwVMO7ucv13QNO/Ek/2RKaQ==" + "resolved" "https://registry.npmjs.org/lodash.trimstart/-/lodash.trimstart-4.5.1.tgz" + "version" "4.5.1" + +"lodash.uppercase@^4.3.0": + "integrity" "sha512-+Nbnxkj7s8K5U8z6KnEYPGUOGp3woZbB7Ecs7v3LkkjLQSm2kP9SKIILitN1ktn2mB/tmM9oSlku06I+/lH7QA==" + "resolved" "https://registry.npmjs.org/lodash.uppercase/-/lodash.uppercase-4.3.0.tgz" + "version" "4.3.0" + +"lodash.upperfirst@^4.3.1": + "integrity" "sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg==" + "resolved" "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz" + "version" "4.3.1" + +"lodash@^4.17.14", "lodash@^4.17.15": + "integrity" "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "resolved" "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" + "version" "4.17.21" + +"log-symbols@^3.0.0": + "integrity" "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==" + "resolved" "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz" + "version" "3.0.0" + dependencies: + "chalk" "^2.4.2" + +"long@^4.0.0": + "integrity" "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + "resolved" "https://registry.npmjs.org/long/-/long-4.0.0.tgz" + "version" "4.0.0" + +"looper@^3.0.0": + "integrity" "sha512-LJ9wplN/uSn72oJRsXTx+snxPet5c8XiZmOKCm906NVYu+ag6SB6vUcnJcWxgnl2NfbIyeobAn7Bwv6xRj2XJg==" + "resolved" "https://registry.npmjs.org/looper/-/looper-3.0.0.tgz" + "version" "3.0.0" + +"lru-cache@^5.1.1": + "integrity" "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==" + "resolved" "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz" + "version" "5.1.1" + dependencies: + "yallist" "^3.0.2" + +"lru-cache@^6.0.0": + "integrity" "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==" + "resolved" "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz" + "version" "6.0.0" + dependencies: + "yallist" "^4.0.0" + +"mafmt@^6.0.2": + "integrity" "sha512-FjHDnew6dW9lUu3eYwP0FvvJl9uvNbqfoJM+c1WJcSyutNEIlyu6v3f/rlPnD1cnmue38IjuHlhBdIh3btAiyw==" + "resolved" "https://registry.npmjs.org/mafmt/-/mafmt-6.0.10.tgz" + "version" "6.0.10" + dependencies: + "multiaddr" "^6.1.0" + +"mafmt@^7.0.0": + "integrity" "sha512-vpeo9S+hepT3k2h5iFxzEHvvR0GPBx9uKaErmnRzYNcaKb03DgOArjEMlgG4a9LcuZZ89a3I8xbeto487n26eA==" + "resolved" "https://registry.npmjs.org/mafmt/-/mafmt-7.1.0.tgz" + "version" "7.1.0" + dependencies: + "multiaddr" "^7.3.0" + +"md5.js@^1.3.4": + "integrity" "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==" + "resolved" "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz" + "version" "1.3.5" + dependencies: + "hash-base" "^3.0.0" + "inherits" "^2.0.1" + "safe-buffer" "^5.1.2" + +"merge-stream@^2.0.0": + "integrity" "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + "resolved" "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz" + "version" "2.0.0" + +"mime-db@1.52.0": + "integrity" "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" + "resolved" "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz" + "version" "1.52.0" + +"mime-types@^2.1.12", "mime-types@~2.1.19": + "integrity" "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==" + "resolved" "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz" + "version" "2.1.35" + dependencies: + "mime-db" "1.52.0" + +"mimic-fn@^2.1.0": + "integrity" "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + "resolved" "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz" + "version" "2.1.0" + +"minimalistic-assert@^1.0.0", "minimalistic-assert@^1.0.1": + "integrity" "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + "resolved" "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz" + "version" "1.0.1" + +"minimalistic-crypto-utils@^1.0.1": + "integrity" "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" + "resolved" "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz" + "version" "1.0.1" + +"minimatch@^3.0.2", "minimatch@^3.0.4": + "integrity" "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==" + "resolved" "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" + "version" "3.1.2" + dependencies: + "brace-expansion" "^1.1.7" + +"minimist@^1.2.0", "minimist@^1.2.6": + "integrity" "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + "resolved" "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz" + "version" "1.2.6" + +"minipass@^3.0.0": + "integrity" "sha512-N0BOsdFAlNRfmwMhjAsLVWOk7Ljmeb39iqFlsV1At+jqRhSUP9yeof8FyJu4imaJiSUp8vQebWD/guZwGQC8iA==" + "resolved" "https://registry.npmjs.org/minipass/-/minipass-3.3.3.tgz" + "version" "3.3.3" + dependencies: + "yallist" "^4.0.0" + +"minizlib@^2.1.1": + "integrity" "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==" + "resolved" "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz" + "version" "2.1.2" + dependencies: + "minipass" "^3.0.0" + "yallist" "^4.0.0" + +"mkdirp@^0.5.1": + "integrity" "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==" + "resolved" "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz" + "version" "0.5.6" + dependencies: + "minimist" "^1.2.6" + +"mkdirp@^1.0.3": + "integrity" "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" + "resolved" "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" + "version" "1.0.4" + +"ms@^2.1.1": + "integrity" "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + "resolved" "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" + "version" "2.1.3" + +"multiaddr@^6.0.3", "multiaddr@^6.0.6", "multiaddr@^6.1.0": + "integrity" "sha512-Q1Ika0F9MNhMtCs62Ue+GWIJtRFEhZ3Xz8wH7/MZDVZTWhil1/H2bEGN02kUees3hkI3q1oHSjmXYDM0gxaFjQ==" + "resolved" "https://registry.npmjs.org/multiaddr/-/multiaddr-6.1.1.tgz" + "version" "6.1.1" + dependencies: + "bs58" "^4.0.1" + "class-is" "^1.1.0" + "hi-base32" "~0.5.0" + "ip" "^1.1.5" + "is-ip" "^2.0.0" + "varint" "^5.0.0" + +"multiaddr@^7.2.1": + "integrity" "sha512-GvhHsIGDULh06jyb6ev+VfREH9evJCFIRnh3jUt9iEZ6XDbyoisZRFEI9bMvK/AiR6y66y6P+eoBw9mBYMhMvw==" + "resolved" "https://registry.npmjs.org/multiaddr/-/multiaddr-7.5.0.tgz" + "version" "7.5.0" + dependencies: + "buffer" "^5.5.0" + "cids" "~0.8.0" + "class-is" "^1.1.0" + "is-ip" "^3.1.0" + "multibase" "^0.7.0" + "varint" "^5.0.0" + +"multiaddr@^7.3.0": + "integrity" "sha512-GvhHsIGDULh06jyb6ev+VfREH9evJCFIRnh3jUt9iEZ6XDbyoisZRFEI9bMvK/AiR6y66y6P+eoBw9mBYMhMvw==" + "resolved" "https://registry.npmjs.org/multiaddr/-/multiaddr-7.5.0.tgz" + "version" "7.5.0" + dependencies: + "buffer" "^5.5.0" + "cids" "~0.8.0" + "class-is" "^1.1.0" + "is-ip" "^3.1.0" + "multibase" "^0.7.0" + "varint" "^5.0.0" + +"multibase@^0.7.0": + "integrity" "sha512-TW8q03O0f6PNFTQDvh3xxH03c8CjGaaYrjkl9UQPG6rz53TQzzxJVCIWVjzcbN/Q5Y53Zd0IBQBMVktVgNx4Fg==" + "resolved" "https://registry.npmjs.org/multibase/-/multibase-0.7.0.tgz" + "version" "0.7.0" + dependencies: + "base-x" "^3.0.8" + "buffer" "^5.5.0" + +"multibase@^1.0.0", "multibase@^1.0.1": + "integrity" "sha512-KcCxpBVY8fdVKu4dJMAahq4F/2Z/9xqEjIiR7PiMe7LRGeorFn2NLmicN6nLBCqQvft6MG2Lc9X5P0IdyvnxEw==" + "resolved" "https://registry.npmjs.org/multibase/-/multibase-1.0.1.tgz" + "version" "1.0.1" + dependencies: + "base-x" "^3.0.8" + "buffer" "^5.5.0" + +"multibase@~0.6.0": + "integrity" "sha512-pFfAwyTjbbQgNc3G7D48JkJxWtoJoBMaR4xQUOuB8RnCgRqaYmWNFeJTTvrJ2w51bjLq2zTby6Rqj9TQ9elSUw==" + "resolved" "https://registry.npmjs.org/multibase/-/multibase-0.6.1.tgz" + "version" "0.6.1" + dependencies: + "base-x" "^3.0.8" + "buffer" "^5.5.0" + +"multicodec@^1.0.0", "multicodec@^1.0.1": + "integrity" "sha512-NDd7FeS3QamVtbgfvu5h7fd1IlbaC4EQ0/pgU4zqE2vdHCmBGsUa0TiM8/TdSeG6BMPC92OOCf8F1ocE/Wkrrg==" + "resolved" "https://registry.npmjs.org/multicodec/-/multicodec-1.0.4.tgz" + "version" "1.0.4" + dependencies: + "buffer" "^5.6.0" + "varint" "^5.0.0" + +"multicodec@^1.0.1": + "integrity" "sha512-NDd7FeS3QamVtbgfvu5h7fd1IlbaC4EQ0/pgU4zqE2vdHCmBGsUa0TiM8/TdSeG6BMPC92OOCf8F1ocE/Wkrrg==" + "resolved" "https://registry.npmjs.org/multicodec/-/multicodec-1.0.4.tgz" + "version" "1.0.4" + dependencies: + "buffer" "^5.6.0" + "varint" "^5.0.0" + +"multicodec@~0.5.1": + "integrity" "sha512-PscoRxm3f+88fAtELwUnZxGDkduE2HD9Q6GHUOywQLjOGT/HAdhjLDYNZ1e7VR0s0TP0EwZ16LNUTFpoBGivOA==" + "resolved" "https://registry.npmjs.org/multicodec/-/multicodec-0.5.7.tgz" + "version" "0.5.7" + dependencies: + "varint" "^5.0.0" + +"multihashes@^1.0.1": + "integrity" "sha512-S27Tepg4i8atNiFaU5ZOm3+gl3KQlUanLs/jWcBxQHFttgq+5x1OgbQmf2d8axJ/48zYGBd/wT9d723USMFduw==" + "resolved" "https://registry.npmjs.org/multihashes/-/multihashes-1.0.1.tgz" + "version" "1.0.1" + dependencies: + "buffer" "^5.6.0" + "multibase" "^1.0.1" + "varint" "^5.0.0" + +"multihashes@~0.4.13", "multihashes@~0.4.14", "multihashes@~0.4.15": + "integrity" "sha512-uVSvmeCWf36pU2nB4/1kzYZjsXD9vofZKpgudqkceYY5g2aZZXJ5r9lxuzoRLl1OAp28XljXsEJ/X/85ZsKmKw==" + "resolved" "https://registry.npmjs.org/multihashes/-/multihashes-0.4.21.tgz" + "version" "0.4.21" + dependencies: + "buffer" "^5.5.0" + "multibase" "^0.7.0" + "varint" "^5.0.0" + +"multihashing-async@~0.5.1": + "integrity" "sha512-mmyG6M/FKxrpBh9xQDUvuJ7BbqT93ZeEeH5X6LeMYKoYshYLr9BDdCsvDtZvn+Egf+/Xi+aOznrWL4vp3s+p0Q==" + "resolved" "https://registry.npmjs.org/multihashing-async/-/multihashing-async-0.5.2.tgz" + "version" "0.5.2" + dependencies: + "blakejs" "^1.1.0" + "js-sha3" "~0.8.0" + "multihashes" "~0.4.13" + "murmurhash3js" "^3.0.1" + "nodeify" "^1.0.1" + +"multihashing-async@~0.6.0": + "integrity" "sha512-Qv8pgg99Lewc191A5nlXy0bSd2amfqlafNJZmarU6Sj7MZVjpR94SCxQjf4DwPtgWZkiLqsjUQBXA2RSq+hYyA==" + "resolved" "https://registry.npmjs.org/multihashing-async/-/multihashing-async-0.6.0.tgz" + "version" "0.6.0" + dependencies: + "blakejs" "^1.1.0" + "js-sha3" "~0.8.0" + "multihashes" "~0.4.13" + "murmurhash3js" "^3.0.1" + "nodeify" "^1.0.1" + +"multihashing-async@~0.7.0": + "integrity" "sha512-SCbfl3f+DzJh+/5piukga9ofIOxwfT05t8R4jfzZIJ88YE9zU9+l3K2X+XB19MYyxqvyK9UJRNWbmQpZqQlbRA==" + "resolved" "https://registry.npmjs.org/multihashing-async/-/multihashing-async-0.7.0.tgz" + "version" "0.7.0" + dependencies: + "blakejs" "^1.1.0" + "buffer" "^5.2.1" + "err-code" "^1.1.2" + "js-sha3" "~0.8.0" + "multihashes" "~0.4.13" + "murmurhash3js-revisited" "^3.0.0" + +"multihashing-async@~0.8.0": + "integrity" "sha512-2lKa1autuCy8x7KIEj9aVNbAb3aIMRFYIwN7mq/zD4pxgNIVgGlm+f6GKY4880EOF2Y3GktHYssRy7TAJQ2DyQ==" + "resolved" "https://registry.npmjs.org/multihashing-async/-/multihashing-async-0.8.2.tgz" + "version" "0.8.2" + dependencies: + "blakejs" "^1.1.0" + "buffer" "^5.4.3" + "err-code" "^2.0.0" + "js-sha3" "^0.8.0" + "multihashes" "^1.0.1" + "murmurhash3js-revisited" "^3.0.0" + +"murmurhash3js-revisited@^3.0.0": + "integrity" "sha512-/sF3ee6zvScXMb1XFJ8gDsSnY+X8PbOyjIuBhtgis10W2Jx4ZjIhikUCIF9c4gpJxVnQIsPAFrSwTCuAjicP6g==" + "resolved" "https://registry.npmjs.org/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz" + "version" "3.0.0" + +"murmurhash3js@^3.0.1": + "integrity" "sha512-KL8QYUaxq7kUbcl0Yto51rMcYt7E/4N4BG3/c96Iqw1PQrTRspu8Cpx4TZ4Nunib1d4bEkIH3gjCYlP2RLBdow==" + "resolved" "https://registry.npmjs.org/murmurhash3js/-/murmurhash3js-3.0.1.tgz" + "version" "3.0.1" + +"mute-stream@0.0.8": + "integrity" "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" + "resolved" "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz" + "version" "0.0.8" + +"nan@^2.14.0", "nan@^2.14.2": + "integrity" "sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA==" + "resolved" "https://registry.npmjs.org/nan/-/nan-2.16.0.tgz" + "version" "2.16.0" + +"ndjson@github:hugomrdias/ndjson#feat/readable-stream3": + "integrity" "sha512-lI3H8wQcQCAKqsPd5bzdEYe49lVsm91TUuLQdmtYYWCzOXd9ZnR1uNf3/dBdGHeCyV6mMulEsZvWvtMFI4aT0A==" + "resolved" "https://codeload.github.com/hugomrdias/ndjson/tar.gz/4db16da6b42e5b39bf300c3a7cde62abb3fa3a11" + "version" "1.5.0" + dependencies: + "json-stringify-safe" "^5.0.1" + "minimist" "^1.2.0" + "split2" "^3.1.0" + "through2" "^3.0.0" + +"node-addon-api@^2.0.0": + "integrity" "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" + "resolved" "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz" + "version" "2.0.2" + +"node-fetch@^2.3.0", "node-fetch@2.6.0": + "integrity" "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + "resolved" "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz" + "version" "2.6.0" + +"node-forge@^0.10.0": + "integrity" "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==" + "resolved" "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz" + "version" "0.10.0" + +"node-gyp-build@^4.2.0": + "integrity" "sha512-amJnQCcgtRVw9SvoebO3BKGESClrfXGCUTX9hSn1OuGQTQBOZmVd0Z0OlecpuRksKvbsUqALE8jls/ErClAPuQ==" + "resolved" "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.4.0.tgz" + "version" "4.4.0" + +"nodeify@^1.0.1": + "integrity" "sha512-n7C2NyEze8GCo/z73KdbjRsBiLbv6eBn1FxwYKQ23IqGo7pQY3mhQan61Sv7eEDJCiyUjTVrVkXTzJCo1dW7Aw==" + "resolved" "https://registry.npmjs.org/nodeify/-/nodeify-1.0.1.tgz" + "version" "1.0.1" + dependencies: + "is-promise" "~1.0.0" + "promise" "~1.3.0" + +"normalize-path@^3.0.0", "normalize-path@~3.0.0": + "integrity" "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + "resolved" "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" + "version" "3.0.0" + +"npm-run-path@^4.0.0": + "integrity" "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==" + "resolved" "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz" + "version" "4.0.1" + dependencies: + "path-key" "^3.0.0" + +"number-to-bn@1.7.0": + "integrity" "sha512-wsJ9gfSz1/s4ZsJN01lyonwuxA1tml6X1yBDnfpMglypcBRFZZkus26EdPSlqS5GJfYddVZa22p3VNb3z5m5Ig==" + "resolved" "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz" + "version" "1.7.0" + dependencies: + "bn.js" "4.11.6" + "strip-hex-prefix" "1.0.0" + +"oauth-sign@~0.9.0": + "integrity" "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + "resolved" "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz" + "version" "0.9.0" + +"object-assign@^2.0.0": + "integrity" "sha512-CdsOUYIh5wIiozhJ3rLQgmUTgcyzFwZZrqhkKhODMoGtPKM+wt0h0CNIoauJWMsS9822EdzPsF/6mb4nLvPN5g==" + "resolved" "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz" + "version" "2.1.1" + +"object-assign@^4.1.0": + "integrity" "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" + "resolved" "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz" + "version" "4.1.1" + +"object-inspect@^1.9.0": + "integrity" "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==" + "resolved" "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz" + "version" "1.12.2" + +"once@^1.3.0", "once@^1.3.1", "once@^1.4.0": + "integrity" "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==" + "resolved" "https://registry.npmjs.org/once/-/once-1.4.0.tgz" + "version" "1.4.0" + dependencies: + "wrappy" "1" + +"onetime@^5.1.0": + "integrity" "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==" + "resolved" "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz" + "version" "5.1.2" + dependencies: + "mimic-fn" "^2.1.0" + +"optimist@~0.3.5": + "integrity" "sha512-TCx0dXQzVtSCg2OgY/bO9hjM9cV4XYx09TVK+s3+FhkjT6LovsLe+pPMzpWf+6yXK/hUizs2gUoTw3jHM0VaTQ==" + "resolved" "https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz" + "version" "0.3.7" + dependencies: + "wordwrap" "~0.0.2" + +"ora@^4.0.0": + "integrity" "sha512-sjYP8QyVWBpBZWD6Vr1M/KwknSw6kJOz41tvGMlwWeClHBtYKTbHMki1PsLZnxKpXMPbTKv9b3pjQu3REib96A==" + "resolved" "https://registry.npmjs.org/ora/-/ora-4.1.1.tgz" + "version" "4.1.1" + dependencies: + "chalk" "^3.0.0" + "cli-cursor" "^3.1.0" + "cli-spinners" "^2.2.0" + "is-interactive" "^1.0.0" + "log-symbols" "^3.0.0" + "mute-stream" "0.0.8" + "strip-ansi" "^6.0.0" + "wcwidth" "^1.0.1" + +"p-finally@^2.0.0": + "integrity" "sha512-vpm09aKwq6H9phqRQzecoDpD8TmVyGw70qmWlyq5onxY7tqyTTFVvxMykxQSQKILBSFlbXpypIw2T1Ml7+DDtw==" + "resolved" "https://registry.npmjs.org/p-finally/-/p-finally-2.0.1.tgz" + "version" "2.0.1" + +"parent-module@^1.0.0": + "integrity" "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==" + "resolved" "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz" + "version" "1.0.1" + dependencies: + "callsites" "^3.0.0" + +"parse-cache-control@^1.0.1": + "integrity" "sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg==" + "resolved" "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz" + "version" "1.0.1" + +"parse-json@^5.0.0": + "integrity" "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==" + "resolved" "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz" + "version" "5.2.0" + dependencies: + "@babel/code-frame" "^7.0.0" + "error-ex" "^1.3.1" + "json-parse-even-better-errors" "^2.3.0" + "lines-and-columns" "^1.1.6" + +"path-is-absolute@^1.0.0": + "integrity" "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" + "resolved" "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" + "version" "1.0.1" + +"path-key@^3.0.0", "path-key@^3.1.0": + "integrity" "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + "resolved" "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz" + "version" "3.1.1" + +"path-type@^4.0.0": + "integrity" "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==" + "resolved" "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz" + "version" "4.0.0" + +"pbkdf2@^3.0.17": + "integrity" "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==" + "resolved" "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz" + "version" "3.1.2" + dependencies: + "create-hash" "^1.1.2" + "create-hmac" "^1.1.4" + "ripemd160" "^2.0.1" + "safe-buffer" "^5.0.1" + "sha.js" "^2.4.8" + +"peer-id@~0.12.2", "peer-id@~0.12.3": + "integrity" "sha512-3xVWrtIvNm9/OPzaQBgXDrfWNx63AftgFQkvqO6YSZy7sP3Fuadwwbn54F/VO9AnpyW/26i0WRQz9FScivXrmw==" + "resolved" "https://registry.npmjs.org/peer-id/-/peer-id-0.12.5.tgz" + "version" "0.12.5" + dependencies: + "async" "^2.6.3" + "class-is" "^1.1.0" + "libp2p-crypto" "~0.16.1" + "multihashes" "~0.4.15" + +"peer-info@~0.15.1": + "integrity" "sha512-Y91Q2tZRC0CpSTPd1UebhGqniOrOAk/aj60uYUcWJXCoLTAnGu+4LJGoiay8ayudS6ice7l3SKhgL/cS62QacA==" + "resolved" "https://registry.npmjs.org/peer-info/-/peer-info-0.15.1.tgz" + "version" "0.15.1" + dependencies: + "mafmt" "^6.0.2" + "multiaddr" "^6.0.3" + "peer-id" "~0.12.2" + "unique-by" "^1.0.0" + +"pem-jwk@^2.0.0": + "integrity" "sha512-rFxu7rVoHgQ5H9YsP50dDWf0rHjreVA2z0yPiWr5WdH/UHb29hKtF7h6l8vNd1cbYR1t0QL+JKhW55a2ZV4KtA==" + "resolved" "https://registry.npmjs.org/pem-jwk/-/pem-jwk-2.0.0.tgz" + "version" "2.0.0" + dependencies: + "asn1.js" "^5.0.1" + +"performance-now@^2.1.0": + "integrity" "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" + "resolved" "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz" + "version" "2.1.0" + +"picomatch@^2.0.4", "picomatch@^2.2.1": + "integrity" "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + "resolved" "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" + "version" "2.3.1" + +"pkginfo@0.4.1": + "integrity" "sha512-8xCNE/aT/EXKenuMDZ+xTVwkT8gsoHN2z/Q29l80u0ppGEXVvsKRzNMbtKhg8LS8k1tJLAHHylf6p4VFmP6XUQ==" + "resolved" "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz" + "version" "0.4.1" + +"pluralize@^8.0.0": + "integrity" "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==" + "resolved" "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz" + "version" "8.0.0" + +"prettier@1.19.1": + "integrity" "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==" + "resolved" "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz" + "version" "1.19.1" + +"process-nextick-args@~2.0.0": + "integrity" "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + "resolved" "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz" + "version" "2.0.1" + +"promise-nodeify@^3.0.1": + "integrity" "sha512-ghsSuzZXJX8iO7WVec2z7GI+Xk/EyiD+JZK7AZKhUqYfpLa/Zs4ylUD+CwwnKlG6G3HnkUPMAi6PO7zeqGKssg==" + "resolved" "https://registry.npmjs.org/promise-nodeify/-/promise-nodeify-3.0.1.tgz" + "version" "3.0.1" + +"promise@^8.0.0": + "integrity" "sha512-W04AqnILOL/sPRXziNicCjSNRruLAuIHEOVBazepu0545DDNGYHz7ar9ZgZ1fMU8/MA4mVxp5rkBWRi6OXIy3Q==" + "resolved" "https://registry.npmjs.org/promise/-/promise-8.1.0.tgz" + "version" "8.1.0" + dependencies: + "asap" "~2.0.6" + +"promise@~1.3.0": + "integrity" "sha512-R9WrbTF3EPkVtWjp7B7umQGVndpsi+rsDAfrR4xAALQpFLa/+2OriecLhawxzvii2gd9+DZFwROWDuUUaqS5yA==" + "resolved" "https://registry.npmjs.org/promise/-/promise-1.3.0.tgz" + "version" "1.3.0" + dependencies: + "is-promise" "~1" + +"promisify-es6@^1.0.3": + "integrity" "sha512-N9iVG+CGJsI4b4ZGazjwLnxErD2d9Pe4DPvvXSxYA9tFNu8ymXME4Qs5HIQ0LMJpNM7zj+m0NlNnNeqFpKzqnA==" + "resolved" "https://registry.npmjs.org/promisify-es6/-/promisify-es6-1.0.3.tgz" + "version" "1.0.3" + +"protocol-buffers-schema@^3.3.1": + "integrity" "sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw==" + "resolved" "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz" + "version" "3.6.0" + +"protons@^1.0.1": + "integrity" "sha512-2oqDyc/SN+tNcJf8XxrXhYL7sQn2/OMl8mSdD7NVGsWjMEmAbks4eDVnCyf0vAoRbBWyWTEXWk4D8XfuKVl3zg==" + "resolved" "https://registry.npmjs.org/protons/-/protons-1.2.1.tgz" + "version" "1.2.1" + dependencies: + "buffer" "^5.5.0" + "protocol-buffers-schema" "^3.3.1" + "signed-varint" "^2.0.1" + "varint" "^5.0.0" + +"psl@^1.1.28": + "integrity" "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==" + "resolved" "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz" + "version" "1.8.0" + +"pull-defer@~0.2.3": + "integrity" "sha512-/An3KE7mVjZCqNhZsr22k1Tx8MACnUnHZZNPSJ0S62td8JtYr/AiRG42Vz7Syu31SoTLUzVIe61jtT/pNdjVYA==" + "resolved" "https://registry.npmjs.org/pull-defer/-/pull-defer-0.2.3.tgz" + "version" "0.2.3" + +"pull-stream@^3.2.3", "pull-stream@^3.6.9": + "integrity" "sha512-KIqdvpqHHaTUA2mCYcLG1ibEbu/LCKoJZsBWyv9lSYtPkJPBq8m3Hxa103xHi6D2thj5YXa0TqK3L3GUkwgnew==" + "resolved" "https://registry.npmjs.org/pull-stream/-/pull-stream-3.6.14.tgz" + "version" "3.6.14" + +"pull-to-stream@~0.1.1": + "integrity" "sha512-thZkMv6F9PILt9zdvpI2gxs19mkDrlixYKX6cOBxAW16i1NZH+yLAmF4r8QfJ69zuQh27e01JZP9y27tsH021w==" + "resolved" "https://registry.npmjs.org/pull-to-stream/-/pull-to-stream-0.1.1.tgz" + "version" "0.1.1" + dependencies: + "readable-stream" "^3.1.1" + +"pump@^1.0.0": + "integrity" "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==" + "resolved" "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz" + "version" "1.0.3" + dependencies: + "end-of-stream" "^1.1.0" + "once" "^1.3.1" + +"pump@^3.0.0": + "integrity" "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==" + "resolved" "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz" + "version" "3.0.0" + dependencies: + "end-of-stream" "^1.1.0" + "once" "^1.3.1" + +"punycode@^2.1.0", "punycode@^2.1.1": + "integrity" "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + "resolved" "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz" + "version" "2.1.1" + +"qs@^6.4.0", "qs@^6.5.2": + "integrity" "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==" + "resolved" "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz" + "version" "6.11.0" + dependencies: + "side-channel" "^1.0.4" + +"qs@~6.5.2": + "integrity" "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==" + "resolved" "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz" + "version" "6.5.3" + +"ramda@^0.24.1": + "integrity" "sha512-HEm619G8PaZMfkqCa23qiOe7r3R0brPu7ZgOsgKUsnvLhd0qhc/vTjkUovomgPWa5ECBa08fJZixth9LaoBo5w==" + "resolved" "https://registry.npmjs.org/ramda/-/ramda-0.24.1.tgz" + "version" "0.24.1" + +"ramda@^0.25.0": + "integrity" "sha512-GXpfrYVPwx3K7RQ6aYT8KPS8XViSXUVJT1ONhoKPE9VAleW42YE+U+8VEyGWt41EnEQW7gwecYJriTI0pKoecQ==" + "resolved" "https://registry.npmjs.org/ramda/-/ramda-0.25.0.tgz" + "version" "0.25.0" + +"ramdasauce@^2.1.0": + "integrity" "sha512-Ml3CPim4SKwmg5g9UI77lnRSeKr/kQw7YhQ6rfdMcBYy6DMlwmkEwQqjygJ3OhxPR+NfFfpjKl3Tf8GXckaqqg==" + "resolved" "https://registry.npmjs.org/ramdasauce/-/ramdasauce-2.1.3.tgz" + "version" "2.1.3" + dependencies: + "ramda" "^0.24.1" + +"randombytes@^2.1.0": + "integrity" "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==" + "resolved" "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz" + "version" "2.1.0" + dependencies: + "safe-buffer" "^5.1.0" + +"readable-stream@^2.2.2", "readable-stream@^2.3.0", "readable-stream@^2.3.5", "readable-stream@2 || 3": + "integrity" "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==" + "resolved" "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz" + "version" "2.3.7" + dependencies: + "core-util-is" "~1.0.0" + "inherits" "~2.0.3" + "isarray" "~1.0.0" + "process-nextick-args" "~2.0.0" + "safe-buffer" "~5.1.1" + "string_decoder" "~1.1.1" + "util-deprecate" "~1.0.1" + +"readable-stream@^3.0.0": + "integrity" "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==" + "resolved" "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz" + "version" "3.6.0" + dependencies: + "inherits" "^2.0.3" + "string_decoder" "^1.1.1" + "util-deprecate" "^1.0.1" + +"readable-stream@^3.0.1": + "integrity" "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==" + "resolved" "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz" + "version" "3.6.0" + dependencies: + "inherits" "^2.0.3" + "string_decoder" "^1.1.1" + "util-deprecate" "^1.0.1" + +"readable-stream@^3.0.2", "readable-stream@^3.1.1", "readable-stream@^3.4.0": + "integrity" "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==" + "resolved" "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz" + "version" "3.6.0" + dependencies: + "inherits" "^2.0.3" + "string_decoder" "^1.1.1" + "util-deprecate" "^1.0.1" + +"readable-stream@^3.6.0": + "integrity" "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==" + "resolved" "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz" + "version" "3.6.0" + dependencies: + "inherits" "^2.0.3" + "string_decoder" "^1.1.1" + "util-deprecate" "^1.0.1" + +"readable-stream@~1.0.26-4": + "integrity" "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==" + "resolved" "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz" + "version" "1.0.34" + dependencies: + "core-util-is" "~1.0.0" + "inherits" "~2.0.1" + "isarray" "0.0.1" + "string_decoder" "~0.10.x" + +"readdirp@~3.5.0": + "integrity" "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==" + "resolved" "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz" + "version" "3.5.0" + dependencies: + "picomatch" "^2.2.1" + +"regenerator-runtime@^0.13.4": + "integrity" "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" + "resolved" "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz" + "version" "0.13.9" + +"request@2.88.2": + "integrity" "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==" + "resolved" "https://registry.npmjs.org/request/-/request-2.88.2.tgz" + "version" "2.88.2" + dependencies: + "aws-sign2" "~0.7.0" + "aws4" "^1.8.0" + "caseless" "~0.12.0" + "combined-stream" "~1.0.6" + "extend" "~3.0.2" + "forever-agent" "~0.6.1" + "form-data" "~2.3.2" + "har-validator" "~5.1.3" + "http-signature" "~1.2.0" + "is-typedarray" "~1.0.0" + "isstream" "~0.1.2" + "json-stringify-safe" "~5.0.1" + "mime-types" "~2.1.19" + "oauth-sign" "~0.9.0" + "performance-now" "^2.1.0" + "qs" "~6.5.2" + "safe-buffer" "^5.1.2" + "tough-cookie" "~2.5.0" + "tunnel-agent" "^0.6.0" + "uuid" "^3.3.2" + +"resolve-from@^4.0.0": + "integrity" "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==" + "resolved" "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz" + "version" "4.0.0" + +"restore-cursor@^3.1.0": + "integrity" "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==" + "resolved" "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz" + "version" "3.1.0" + dependencies: + "onetime" "^5.1.0" + "signal-exit" "^3.0.2" + +"rimraf@^2.6.3": + "integrity" "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==" + "resolved" "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz" + "version" "2.7.1" + dependencies: + "glob" "^7.1.3" + +"rimraf@^3.0.0", "rimraf@^3.0.2": + "integrity" "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==" + "resolved" "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz" + "version" "3.0.2" + dependencies: + "glob" "^7.1.3" + +"ripemd160@^2.0.0", "ripemd160@^2.0.1": + "integrity" "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==" + "resolved" "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz" + "version" "2.0.2" + dependencies: + "hash-base" "^3.0.0" + "inherits" "^2.0.1" + +"rlp@^2.2.4": + "integrity" "sha512-d5gdPmgQ0Z+AklL2NVXr/IoSjNZFfTVvQWzL/AM2AOcSzYP2xjlb0AC8YyCLc41MSNf6P6QVtjgPdmVtzb+4lQ==" + "resolved" "https://registry.npmjs.org/rlp/-/rlp-2.2.7.tgz" + "version" "2.2.7" + dependencies: + "bn.js" "^5.2.0" + +"rsa-pem-to-jwk@^1.1.3": + "integrity" "sha512-ZlVavEvTnD8Rzh/pdB8NH4VF5GNEtF6biGQcTtC4GKFMsbZR08oHtOYefbhCN+JnJIuMItiCDCMycdcMrw6blA==" + "resolved" "https://registry.npmjs.org/rsa-pem-to-jwk/-/rsa-pem-to-jwk-1.1.3.tgz" + "version" "1.1.3" + dependencies: + "object-assign" "^2.0.0" + "rsa-unpack" "0.0.6" + +"rsa-unpack@0.0.6": + "integrity" "sha512-HRrl8GHjjPziPFRDJPq/v5OxZ3IPdksV5h3cime/oHgcgM1k1toO5OdtzClgBqRf5dF6IgptOB0g/zFb0w5zQw==" + "resolved" "https://registry.npmjs.org/rsa-unpack/-/rsa-unpack-0.0.6.tgz" + "version" "0.0.6" + dependencies: + "optimist" "~0.3.5" + +"safe-buffer@^5.0.1", "safe-buffer@^5.1.0", "safe-buffer@^5.1.1", "safe-buffer@^5.1.2", "safe-buffer@^5.2.0", "safe-buffer@~5.2.0": + "integrity" "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + "resolved" "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" + "version" "5.2.1" + +"safe-buffer@~5.1.0", "safe-buffer@~5.1.1": + "integrity" "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "resolved" "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz" + "version" "5.1.2" + +"safer-buffer@^2.0.2", "safer-buffer@^2.1.0", "safer-buffer@~2.1.0": + "integrity" "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "resolved" "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz" + "version" "2.1.2" + +"scrypt-js@^3.0.0": + "integrity" "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" + "resolved" "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz" + "version" "3.0.1" + +"secp256k1@^3.6.2": + "integrity" "sha512-k5ke5avRZbtl9Tqx/SA7CbY3NF6Ro+Sj9cZxezFzuBlLDmyqPiL8hJJ+EmzD8Ig4LUDByHJ3/iPOVoRixs/hmw==" + "resolved" "https://registry.npmjs.org/secp256k1/-/secp256k1-3.8.0.tgz" + "version" "3.8.0" + dependencies: + "bindings" "^1.5.0" + "bip66" "^1.1.5" + "bn.js" "^4.11.8" + "create-hash" "^1.2.0" + "drbg.js" "^1.0.1" + "elliptic" "^6.5.2" + "nan" "^2.14.0" + "safe-buffer" "^5.1.2" + +"secp256k1@^4.0.1": + "integrity" "sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==" + "resolved" "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.3.tgz" + "version" "4.0.3" + dependencies: + "elliptic" "^6.5.4" + "node-addon-api" "^2.0.0" + "node-gyp-build" "^4.2.0" + +"semver@^7.0.0", "semver@7.3.5": + "integrity" "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==" + "resolved" "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz" + "version" "7.3.5" + dependencies: + "lru-cache" "^6.0.0" + +"setimmediate@^1.0.5": + "integrity" "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" + "resolved" "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz" + "version" "1.0.5" + +"sha.js@^2.4.0", "sha.js@^2.4.8": + "integrity" "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==" + "resolved" "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz" + "version" "2.4.11" + dependencies: + "inherits" "^2.0.1" + "safe-buffer" "^5.0.1" + +"shebang-command@^2.0.0": + "integrity" "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==" + "resolved" "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz" + "version" "2.0.0" + dependencies: + "shebang-regex" "^3.0.0" + +"shebang-regex@^3.0.0": + "integrity" "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + "resolved" "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz" + "version" "3.0.0" + +"side-channel@^1.0.4": + "integrity" "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==" + "resolved" "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz" + "version" "1.0.4" + dependencies: + "call-bind" "^1.0.0" + "get-intrinsic" "^1.0.2" + "object-inspect" "^1.9.0" + +"signal-exit@^3.0.2": + "integrity" "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + "resolved" "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" + "version" "3.0.7" + +"signed-varint@^2.0.1": + "integrity" "sha512-abgDPg1106vuZZOvw7cFwdCABddfJRz5akcCcchzTbhyhYnsG31y4AlZEgp315T7W3nQq5P4xeOm186ZiPVFzw==" + "resolved" "https://registry.npmjs.org/signed-varint/-/signed-varint-2.0.1.tgz" + "version" "2.0.1" + dependencies: + "varint" "~5.0.0" + +"split-ca@^1.0.0": + "integrity" "sha512-Q5thBSxp5t8WPTTJQS59LrGqOZqOsrhDGDVm8azCqIBjSBd7nd9o2PM+mDulQQkh8h//4U6hFZnc/mul8t5pWQ==" + "resolved" "https://registry.npmjs.org/split-ca/-/split-ca-1.0.1.tgz" + "version" "1.0.1" + +"split2@^3.1.0": + "integrity" "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==" + "resolved" "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz" + "version" "3.2.2" + dependencies: + "readable-stream" "^3.0.0" + +"sprintf-js@~1.0.2": + "integrity" "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" + "resolved" "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz" + "version" "1.0.3" + +"sshpk@^1.7.0": + "integrity" "sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==" + "resolved" "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz" + "version" "1.17.0" + dependencies: + "asn1" "~0.2.3" + "assert-plus" "^1.0.0" + "bcrypt-pbkdf" "^1.0.0" + "dashdash" "^1.12.0" + "ecc-jsbn" "~0.1.1" + "getpass" "^0.1.1" + "jsbn" "~0.1.0" + "safer-buffer" "^2.0.2" + "tweetnacl" "~0.14.0" + +"stable@~0.1.8": + "integrity" "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==" + "resolved" "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz" + "version" "0.1.8" + +"stream-to-pull-stream@^1.7.2": + "integrity" "sha512-6sNyqJpr5dIOQdgNy/xcDWwDuzAsAwVzhzrWlAPAQ7Lkjx/rv0wgvxEyKwTq6FmNd5rjTrELt/CLmaSw7crMGg==" + "resolved" "https://registry.npmjs.org/stream-to-pull-stream/-/stream-to-pull-stream-1.7.3.tgz" + "version" "1.7.3" + dependencies: + "looper" "^3.0.0" + "pull-stream" "^3.2.3" + +"string_decoder@^1.1.1", "string_decoder@^1.2.0": + "integrity" "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==" + "resolved" "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz" + "version" "1.3.0" + dependencies: + "safe-buffer" "~5.2.0" + +"string_decoder@~0.10.x": + "integrity" "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==" + "resolved" "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + "version" "0.10.31" + +"string_decoder@~1.1.1": + "integrity" "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==" + "resolved" "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz" + "version" "1.1.1" + dependencies: + "safe-buffer" "~5.1.0" + +"string-width@^2.1.1": + "integrity" "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==" + "resolved" "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz" + "version" "2.1.1" + dependencies: + "is-fullwidth-code-point" "^2.0.0" + "strip-ansi" "^4.0.0" + +"strip-ansi@^4.0.0": + "integrity" "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==" + "resolved" "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz" + "version" "4.0.0" + dependencies: + "ansi-regex" "^3.0.0" + +"strip-ansi@^6.0.0": + "integrity" "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==" + "resolved" "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz" + "version" "6.0.1" + dependencies: + "ansi-regex" "^5.0.1" + +"strip-final-newline@^2.0.0": + "integrity" "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" + "resolved" "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz" + "version" "2.0.0" + +"strip-hex-prefix@1.0.0": + "integrity" "sha512-q8d4ue7JGEiVcypji1bALTos+0pWtyGlivAWyPuTkHzuTCJqrK9sWxYQZUq6Nq3cuyv3bm734IhHvHtGGURU6A==" + "resolved" "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz" + "version" "1.0.0" + dependencies: + "is-hex-prefixed" "1.0.0" + +"supports-color@^5.3.0": + "integrity" "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==" + "resolved" "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz" + "version" "5.5.0" + dependencies: + "has-flag" "^3.0.0" + +"supports-color@^7.1.0": + "integrity" "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==" + "resolved" "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz" + "version" "7.2.0" + dependencies: + "has-flag" "^4.0.0" + +"sync-request@6.1.0": + "integrity" "sha512-8fjNkrNlNCrVc/av+Jn+xxqfCjYaBoHqCsDz6mt030UMxJGr+GSfCV1dQt2gRtlL63+VPidwDVLr7V2OcTSdRw==" + "resolved" "https://registry.npmjs.org/sync-request/-/sync-request-6.1.0.tgz" + "version" "6.1.0" + dependencies: + "http-response-object" "^3.0.1" + "sync-rpc" "^1.2.1" + "then-request" "^6.0.0" + +"sync-rpc@^1.2.1": + "integrity" "sha512-J8jTXuZzRlvU7HemDgHi3pGnh/rkoqR/OZSjhTyyZrEkkYQbk7Z33AXp37mkPfPpfdOuj7Ex3H/TJM1z48uPQw==" + "resolved" "https://registry.npmjs.org/sync-rpc/-/sync-rpc-1.3.6.tgz" + "version" "1.3.6" + dependencies: + "get-port" "^3.1.0" + +"tar-fs@~1.16.3": + "integrity" "sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw==" + "resolved" "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.3.tgz" + "version" "1.16.3" + dependencies: + "chownr" "^1.0.1" + "mkdirp" "^0.5.1" + "pump" "^1.0.0" + "tar-stream" "^1.1.2" + +"tar-stream@^1.1.2": + "integrity" "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==" + "resolved" "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz" + "version" "1.6.2" + dependencies: + "bl" "^1.0.0" + "buffer-alloc" "^1.2.0" + "end-of-stream" "^1.0.0" + "fs-constants" "^1.0.0" + "readable-stream" "^2.3.0" + "to-buffer" "^1.1.1" + "xtend" "^4.0.0" + +"tar-stream@^2.0.1": + "integrity" "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==" + "resolved" "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz" + "version" "2.2.0" + dependencies: + "bl" "^4.0.3" + "end-of-stream" "^1.4.1" + "fs-constants" "^1.0.0" + "inherits" "^2.0.3" + "readable-stream" "^3.1.1" + +"tar@^6.1.0": + "integrity" "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==" + "resolved" "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz" + "version" "6.1.11" + dependencies: + "chownr" "^2.0.0" + "fs-minipass" "^2.0.0" + "minipass" "^3.0.0" + "minizlib" "^2.1.1" + "mkdirp" "^1.0.3" + "yallist" "^4.0.0" + +"then-request@^6.0.0": + "integrity" "sha512-3ZBiG7JvP3wbDzA9iNY5zJQcHL4jn/0BWtXIkagfz7QgOL/LqjCEOBQuJNZfu0XYnv5JhKh+cDxCPM4ILrqruA==" + "resolved" "https://registry.npmjs.org/then-request/-/then-request-6.0.2.tgz" + "version" "6.0.2" + dependencies: + "@types/concat-stream" "^1.6.0" + "@types/form-data" "0.0.33" + "@types/node" "^8.0.0" + "@types/qs" "^6.2.31" + "caseless" "~0.12.0" + "concat-stream" "^1.6.0" + "form-data" "^2.2.0" + "http-basic" "^8.1.1" + "http-response-object" "^3.0.1" + "promise" "^8.0.0" + "qs" "^6.4.0" + +"through@>=2.2.7 <3": + "integrity" "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" + "resolved" "https://registry.npmjs.org/through/-/through-2.3.8.tgz" + "version" "2.3.8" + +"through2@^3.0.0", "through2@^3.0.1": + "integrity" "sha512-enaDQ4MUyP2W6ZyT6EsMzqBPZaM/avg8iuo+l2d3QCs0J+6RaqkHV/2/lOwDTueBHeJ/2LG9lrLW3d5rWPucuQ==" + "resolved" "https://registry.npmjs.org/through2/-/through2-3.0.2.tgz" + "version" "3.0.2" + dependencies: + "inherits" "^2.0.4" + "readable-stream" "2 || 3" + +"tmp-promise@3.0.2": + "integrity" "sha512-OyCLAKU1HzBjL6Ev3gxUeraJNlbNingmi8IrHHEsYH8LTmEuhvYfqvhn2F/je+mjf4N58UmZ96OMEy1JanSCpA==" + "resolved" "https://registry.npmjs.org/tmp-promise/-/tmp-promise-3.0.2.tgz" + "version" "3.0.2" + dependencies: + "tmp" "^0.2.0" + +"tmp@^0.2.0": + "integrity" "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==" + "resolved" "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz" + "version" "0.2.1" + dependencies: + "rimraf" "^3.0.0" + +"to-buffer@^1.1.1": + "integrity" "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" + "resolved" "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz" + "version" "1.1.1" + +"to-regex-range@^5.0.1": + "integrity" "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==" + "resolved" "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz" + "version" "5.0.1" + dependencies: + "is-number" "^7.0.0" + +"tough-cookie@~2.5.0": + "integrity" "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==" + "resolved" "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz" + "version" "2.5.0" + dependencies: + "psl" "^1.1.28" + "punycode" "^2.1.1" + +"tunnel-agent@^0.6.0": + "integrity" "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==" + "resolved" "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz" + "version" "0.6.0" + dependencies: + "safe-buffer" "^5.0.1" + +"tweetnacl@^0.14.3": + "integrity" "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" + "resolved" "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz" + "version" "0.14.5" + +"tweetnacl@^1.0.0": + "integrity" "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + "resolved" "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz" + "version" "1.0.3" + +"tweetnacl@~0.14.0": + "integrity" "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" + "resolved" "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz" + "version" "0.14.5" + +"typedarray@^0.0.6": + "integrity" "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + "resolved" "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" + "version" "0.0.6" + +"unique-by@^1.0.0": + "integrity" "sha512-rJRXK5V0zL6TiSzhoGNpJp5dr+TZBLoPJFC06rLn17Ug++7Aa0Qnve5v+skXeQxx6/sI7rBsSesa6MAcmFi8Ew==" + "resolved" "https://registry.npmjs.org/unique-by/-/unique-by-1.0.0.tgz" + "version" "1.0.0" + +"universalify@^1.0.0": + "integrity" "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==" + "resolved" "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz" + "version" "1.0.0" + +"universalify@^2.0.0": + "integrity" "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" + "resolved" "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz" + "version" "2.0.0" + +"uri-js@^4.2.2": + "integrity" "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==" + "resolved" "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz" + "version" "4.4.1" + dependencies: + "punycode" "^2.1.0" + +"ursa-optional@~0.10.0": + "integrity" "sha512-TKdwuLboBn7M34RcvVTuQyhvrA8gYKapuVdm0nBP0mnBc7oECOfUQZrY91cefL3/nm64ZyrejSRrhTVdX7NG/A==" + "resolved" "https://registry.npmjs.org/ursa-optional/-/ursa-optional-0.10.2.tgz" + "version" "0.10.2" + dependencies: + "bindings" "^1.5.0" + "nan" "^2.14.2" + +"utf8@3.0.0": + "integrity" "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==" + "resolved" "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz" + "version" "3.0.0" + +"util-deprecate@^1.0.1", "util-deprecate@~1.0.1": + "integrity" "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + "resolved" "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" + "version" "1.0.2" + +"uuid@^3.2.1", "uuid@^3.3.2": + "integrity" "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + "resolved" "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz" + "version" "3.4.0" + +"varint@^5.0.0", "varint@~5.0.0": + "integrity" "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" + "resolved" "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz" + "version" "5.0.2" + +"verror@1.10.0": + "integrity" "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==" + "resolved" "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz" + "version" "1.10.0" + dependencies: + "assert-plus" "^1.0.0" + "core-util-is" "1.0.2" + "extsprintf" "^1.2.0" + +"wcwidth@^1.0.1": + "integrity" "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==" + "resolved" "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz" + "version" "1.0.1" + dependencies: + "defaults" "^1.0.3" + +"web3-eth-abi@1.7.0": + "integrity" "sha512-heqR0bWxgCJwjWIhq2sGyNj9bwun5+Xox/LdZKe+WMyTSy0cXDXEAgv3XKNkXC4JqdDt/ZlbTEx4TWak4TRMSg==" + "resolved" "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.7.0.tgz" + "version" "1.7.0" + dependencies: + "@ethersproject/abi" "5.0.7" + "web3-utils" "1.7.0" + +"web3-utils@1.7.0": + "integrity" "sha512-O8Tl4Ky40Sp6pe89Olk2FsaUkgHyb5QAXuaKo38ms3CxZZ4d3rPGfjP9DNKGm5+IUgAZBNpF1VmlSmNCqfDI1w==" + "resolved" "https://registry.npmjs.org/web3-utils/-/web3-utils-1.7.0.tgz" + "version" "1.7.0" + dependencies: + "bn.js" "^4.11.9" + "ethereum-bloom-filters" "^1.0.6" + "ethereumjs-util" "^7.1.0" + "ethjs-unit" "0.1.6" + "number-to-bn" "1.7.0" + "randombytes" "^2.1.0" + "utf8" "3.0.0" + +"which@^2.0.0", "which@^2.0.1", "which@2.0.2": + "integrity" "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==" + "resolved" "https://registry.npmjs.org/which/-/which-2.0.2.tgz" + "version" "2.0.2" + dependencies: + "isexe" "^2.0.0" + +"wordwrap@~0.0.2": + "integrity" "sha512-1tMA907+V4QmxV7dbRvb4/8MaRALK6q9Abid3ndMYnbyo8piisCmeONVqVSXqQA3KaP4SLt5b7ud6E2sqP8TFw==" + "resolved" "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz" + "version" "0.0.3" + +"wrappy@1": + "integrity" "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + "resolved" "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" + "version" "1.0.2" + +"xtend@^4.0.0": + "integrity" "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" + "resolved" "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz" + "version" "4.0.2" + +"yallist@^3.0.2": + "integrity" "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + "resolved" "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz" + "version" "3.1.1" + +"yallist@^4.0.0": + "integrity" "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "resolved" "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz" + "version" "4.0.0" + +"yaml@^1.7.2", "yaml@1.9.2": + "integrity" "sha512-HPT7cGGI0DuRcsO51qC1j9O16Dh1mZ2bnXwsi0jrSpsLz0WxOLSLXfkABVl6bZO629py3CU+OMJtpNHDLB97kg==" + "resolved" "https://registry.npmjs.org/yaml/-/yaml-1.9.2.tgz" + "version" "1.9.2" + dependencies: + "@babel/runtime" "^7.9.2" + +"yargs-parser@^16.1.0": + "integrity" "sha512-H/V41UNZQPkUMIT5h5hiwg4QKIY1RPvoBV4XcjUbRM8Bk2oKqqyZ0DIEbTFZB0XjbtSPG8SAa/0DxCQmiRgzKg==" + "resolved" "https://registry.npmjs.org/yargs-parser/-/yargs-parser-16.1.0.tgz" + "version" "16.1.0" + dependencies: + "camelcase" "^5.0.0" + "decamelize" "^1.2.0" From f9653b2fe5ec08cfddbab0301b23f66719d62a23 Mon Sep 17 00:00:00 2001 From: Founder Date: Mon, 17 Apr 2023 20:56:05 +0800 Subject: [PATCH 2/5] Fix lint errors --- subgraphs/vela-exchange/src/entities/protocol.ts | 2 +- subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts | 2 +- subgraphs/vela-exchange/src/mappings/VaultUtils.ts | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/subgraphs/vela-exchange/src/entities/protocol.ts b/subgraphs/vela-exchange/src/entities/protocol.ts index 340ddebc15..2f98a340de 100644 --- a/subgraphs/vela-exchange/src/entities/protocol.ts +++ b/subgraphs/vela-exchange/src/entities/protocol.ts @@ -1,4 +1,4 @@ -import { BigDecimal, Bytes, ethereum, log } from "@graphprotocol/graph-ts"; +import { BigDecimal, Bytes, ethereum} from "@graphprotocol/graph-ts"; import { DerivPerpProtocol } from "../../generated/schema"; import { Versions } from "../versions"; import { EventType } from "./event"; diff --git a/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts b/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts index 841ea5bbf5..634589f5e3 100644 --- a/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts +++ b/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts @@ -1,4 +1,4 @@ -import { Address, BigInt, log } from "@graphprotocol/graph-ts"; +import { BigInt } from "@graphprotocol/graph-ts"; import { AddRewardInfo, ComplexRewarderPerSec, diff --git a/subgraphs/vela-exchange/src/mappings/VaultUtils.ts b/subgraphs/vela-exchange/src/mappings/VaultUtils.ts index 034d7a8f8d..0fa35b3414 100644 --- a/subgraphs/vela-exchange/src/mappings/VaultUtils.ts +++ b/subgraphs/vela-exchange/src/mappings/VaultUtils.ts @@ -4,7 +4,6 @@ import { BigInt, Bytes, ethereum, - log, } from "@graphprotocol/graph-ts"; import { IncreasePosition, From b1b4447948186e453aa650f2e2cd3bedca6abe6f Mon Sep 17 00:00:00 2001 From: Founder Date: Mon, 17 Apr 2023 21:00:21 +0800 Subject: [PATCH 3/5] Fix formatting errors --- subgraphs/vela-exchange/src/entities/protocol.ts | 2 +- subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/subgraphs/vela-exchange/src/entities/protocol.ts b/subgraphs/vela-exchange/src/entities/protocol.ts index 2f98a340de..3c13fa8597 100644 --- a/subgraphs/vela-exchange/src/entities/protocol.ts +++ b/subgraphs/vela-exchange/src/entities/protocol.ts @@ -1,4 +1,4 @@ -import { BigDecimal, Bytes, ethereum} from "@graphprotocol/graph-ts"; +import { BigDecimal, Bytes, ethereum } from "@graphprotocol/graph-ts"; import { DerivPerpProtocol } from "../../generated/schema"; import { Versions } from "../versions"; import { EventType } from "./event"; diff --git a/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts b/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts index 634589f5e3..9cd65ae170 100644 --- a/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts +++ b/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts @@ -7,9 +7,7 @@ import { getOrCreateToken, getOrCreateRewardToken } from "../entities/token"; import { updatePoolRewardToken } from "../entities/pool"; import { takeSnapshots } from "../entities/snapshots"; import { convertTokenToDecimal } from "../utils/numbers"; -import { - SECONDS_PER_DAY, -} from "../utils/constants"; +import { SECONDS_PER_DAY } from "../utils/constants"; export function handleAddRewardInfo(event: AddRewardInfo): void { takeSnapshots(event); From 8dfa1e80b0869c4e525b7e7614a4999d469d9a09 Mon Sep 17 00:00:00 2001 From: Founder Date: Fri, 21 Apr 2023 14:16:31 +0800 Subject: [PATCH 4/5] fixed price rounding --- subgraphs/vela-exchange/src/entities/pool.ts | 14 ++++---- .../vela-exchange/src/entities/position.ts | 23 ++++++------- .../vela-exchange/src/mappings/VaultUtils.ts | 33 ++++++++----------- .../vela-exchange/src/utils/constants.ts | 2 +- subgraphs/vela-exchange/src/utils/numbers.ts | 7 +++- 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/subgraphs/vela-exchange/src/entities/pool.ts b/subgraphs/vela-exchange/src/entities/pool.ts index cc1680573a..22fe6ece3f 100644 --- a/subgraphs/vela-exchange/src/entities/pool.ts +++ b/subgraphs/vela-exchange/src/entities/pool.ts @@ -44,9 +44,12 @@ import { VAULT_ADDRESS, USDC_ADDRESS_ARBITRUM, BIGDECIMAL_HUNDRED, - PRICE_PRECISION, } from "../utils/constants"; -import { convertTokenToDecimal, multiArraySort } from "../utils/numbers"; +import { + convertPriceToBigDecimal, + convertTokenToDecimal, + multiArraySort, +} from "../utils/numbers"; import { enumToPrefix } from "../utils/strings"; export function getOrCreateLiquidityPool(event: ethereum.Event): LiquidityPool { @@ -418,10 +421,9 @@ export function updatePoolTvl( event, Address.fromString(USDC_ADDRESS_ARBITRUM) ); - pool.totalValueLockedUSD = tryTotalUSDC.value - .div(PRICE_PRECISION) - .toBigDecimal() - .times(inputToken.lastPriceUSD!); + pool.totalValueLockedUSD = convertPriceToBigDecimal( + tryTotalUSDC.value + ).times(inputToken.lastPriceUSD!); } const tvlChangeUSD = pool.totalValueLockedUSD.minus(prevPoolTVL); diff --git a/subgraphs/vela-exchange/src/entities/position.ts b/subgraphs/vela-exchange/src/entities/position.ts index be76903730..72ab7cbb00 100644 --- a/subgraphs/vela-exchange/src/entities/position.ts +++ b/subgraphs/vela-exchange/src/entities/position.ts @@ -30,9 +30,12 @@ import { INT_ZERO, PositionSide, POSITION_VAULT_ADDRESS, - PRICE_PRECISION, } from "../utils/constants"; -import { bigDecimalToBigInt, exponentToBigDecimal } from "../utils/numbers"; +import { + bigDecimalToBigInt, + convertPriceToBigDecimal, + exponentToBigDecimal, +} from "../utils/numbers"; export function getUserPosition( event: ethereum.Event, @@ -159,7 +162,7 @@ export function updateUserPosition( entryFundingRate ); - const realisedPnlUSD = realisedPnl.div(PRICE_PRECISION).toBigDecimal(); + const realisedPnlUSD = convertPriceToBigDecimal(realisedPnl); switch (eventType) { case EventType.CollateralIn: position.collateralInCount += INT_ONE; @@ -194,14 +197,12 @@ export function updateUserPosition( posId ); if (!tryGetPosition.reverted) { - position.balanceUSD = tryGetPosition.value - .getValue0() - .size.div(PRICE_PRECISION) - .toBigDecimal(); - position.collateralBalanceUSD = tryGetPosition.value - .getValue0() - .collateral.div(PRICE_PRECISION) - .toBigDecimal(); + position.balanceUSD = convertPriceToBigDecimal( + tryGetPosition.value.getValue0().size + ); + position.collateralBalanceUSD = convertPriceToBigDecimal( + tryGetPosition.value.getValue0().collateral + ); const indexToken = getOrCreateToken(event, indexTokenAddress); if (indexToken.lastPriceUSD && indexToken.lastPriceUSD! > BIGDECIMAL_ZERO) { diff --git a/subgraphs/vela-exchange/src/mappings/VaultUtils.ts b/subgraphs/vela-exchange/src/mappings/VaultUtils.ts index 0fa35b3414..9af79fae01 100644 --- a/subgraphs/vela-exchange/src/mappings/VaultUtils.ts +++ b/subgraphs/vela-exchange/src/mappings/VaultUtils.ts @@ -51,12 +51,15 @@ import { INT_ONE, INT_ZERO, PositionSide, - PRICE_PRECISION, PROTOCOL_SIDE_REVENUE_PERCENT, STAKE_SIDE_REVENUE_PERCENT, USDC_ADDRESS_ARBITRUM, } from "../utils/constants"; -import { bigDecimalToBigInt, exponentToBigDecimal } from "../utils/numbers"; +import { + bigDecimalToBigInt, + convertPriceToBigDecimal, + exponentToBigDecimal, +} from "../utils/numbers"; import { LiquidityPool } from "../../generated/schema"; export function handleIncreasePosition(event: IncreasePosition): void { @@ -66,9 +69,9 @@ export function handleIncreasePosition(event: IncreasePosition): void { event.params.key, event.params.account, Address.fromString(USDC_ADDRESS_ARBITRUM), - event.params.posData[0].div(PRICE_PRECISION).toBigDecimal(), + convertPriceToBigDecimal(event.params.posData[0]), event.params.indexToken, - event.params.posData[1].div(PRICE_PRECISION).toBigDecimal(), + convertPriceToBigDecimal(event.params.posData[1]), event.params.posData[5], event.params.posData[6], event.params.isLong, @@ -85,9 +88,9 @@ export function handleDecreasePosition(event: DecreasePosition): void { event.params.key, event.params.account, Address.fromString(USDC_ADDRESS_ARBITRUM), - event.params.posData[0].div(PRICE_PRECISION).toBigDecimal(), + convertPriceToBigDecimal(event.params.posData[0]), event.params.indexToken, - event.params.posData[1].div(PRICE_PRECISION).toBigDecimal(), + convertPriceToBigDecimal(event.params.posData[1]), event.params.posData[5], event.params.posData[6], event.params.isLong, @@ -180,7 +183,7 @@ export function handleUpdatePositionEvent( updateTokenPrice( event, indexToken, - indexTokenPrice.div(PRICE_PRECISION).toBigDecimal() + convertPriceToBigDecimal(indexTokenPrice) ); const collateralToken = getOrCreateToken(event, collateralTokenAddress); let collateralTokenAmountDelta = BIGINT_ZERO; @@ -242,12 +245,7 @@ export function handleUpdatePositionEvent( eventType ); - increasePoolPremium( - event, - pool, - fee.div(PRICE_PRECISION).toBigDecimal(), - eventType - ); + increasePoolPremium(event, pool, convertPriceToBigDecimal(fee), eventType); increasePoolVolume( event, @@ -335,7 +333,7 @@ export function handleUpdatePositionEvent( indexTokenAddress, collateralTokenAmountDelta, collateralUSDDelta, - realisedPnl.div(PRICE_PRECISION).toBigDecimal(), + convertPriceToBigDecimal(realisedPnl), event.transaction.from, accountAddress, position @@ -378,12 +376,7 @@ function increaseCollectedFees( pool: LiquidityPool, feeUsd: BigInt ): void { - const totalFee = feeUsd.div(PRICE_PRECISION).toBigDecimal(); - - // log.error("IincreasePoolProtocolSideRevenue {}", [ - // totalFee.times(PROTOCOL_SIDE_REVENUE_PERCENT).toString(), - // ]); - + const totalFee = convertPriceToBigDecimal(feeUsd); increasePoolProtocolSideRevenue( event, pool, diff --git a/subgraphs/vela-exchange/src/utils/constants.ts b/subgraphs/vela-exchange/src/utils/constants.ts index 8976ce50df..221c6deaf0 100644 --- a/subgraphs/vela-exchange/src/utils/constants.ts +++ b/subgraphs/vela-exchange/src/utils/constants.ts @@ -182,7 +182,7 @@ export const VLP_ADDRESS = "0x4e0d4a5a5b4faf5c2ecc1c63c8d19bb0804a96f1"; export const USDC_ADDRESS_ARBITRUM = "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8"; export const PRICE_CACHING_BLOCKS = BigInt.fromI32(7000); -export const PRICE_PRECISION = BigInt.fromI32(10).pow(30); +export const PRICE_PRECISION = BigInt.fromI32(10).pow(30).toBigDecimal(); export const FUNDING_PRECISION = BigDecimal.fromString("1000000"); export const PROTOCOL_SIDE_REVENUE_PERCENT = BigDecimal.fromString("0.25"); export const STAKE_SIDE_REVENUE_PERCENT = BigDecimal.fromString("0.15"); diff --git a/subgraphs/vela-exchange/src/utils/numbers.ts b/subgraphs/vela-exchange/src/utils/numbers.ts index 7eff00af40..5075a3ddeb 100644 --- a/subgraphs/vela-exchange/src/utils/numbers.ts +++ b/subgraphs/vela-exchange/src/utils/numbers.ts @@ -1,5 +1,5 @@ import { BigDecimal, BigInt, Bytes } from "@graphprotocol/graph-ts"; -import { INT_ZERO } from "./constants"; +import { INT_ZERO, PRICE_PRECISION } from "./constants"; export function bigDecimalToBigInt(input: BigDecimal): BigInt { const str = input.truncate(0).toString(); @@ -28,6 +28,11 @@ export function exponentToBigDecimal(exp: i32): BigDecimal { return bd; } +// Converts BigInt prices to BigDecimal for contracts using PRICE_PRECISION +export function convertPriceToBigDecimal(value: BigInt): BigDecimal { + return value.toBigDecimal().div(PRICE_PRECISION); +} + export function calculateAverage(prices: BigDecimal[]): BigDecimal { let sum = BigDecimal.fromString("0"); for (let i = 0; i < prices.length; i++) { From 1f746b4b5029653acee568f36acc830ea81cd007 Mon Sep 17 00:00:00 2001 From: Founder Date: Fri, 21 Apr 2023 14:20:02 +0800 Subject: [PATCH 5/5] normalize TS filenames --- .../config/templates/vela.exchange.template.yaml | 6 +++--- .../{ComplexRewarderPerSec.ts => complexRewarderPerSec.ts} | 0 subgraphs/vela-exchange/src/mappings/{Vault.ts => vault.ts} | 0 .../src/mappings/{VaultUtils.ts => vaultUtils.ts} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename subgraphs/vela-exchange/src/mappings/{ComplexRewarderPerSec.ts => complexRewarderPerSec.ts} (100%) rename subgraphs/vela-exchange/src/mappings/{Vault.ts => vault.ts} (100%) rename subgraphs/vela-exchange/src/mappings/{VaultUtils.ts => vaultUtils.ts} (100%) diff --git a/subgraphs/vela-exchange/protocols/vela-exchange/config/templates/vela.exchange.template.yaml b/subgraphs/vela-exchange/protocols/vela-exchange/config/templates/vela.exchange.template.yaml index 11ad4afb42..f8b534e8f3 100644 --- a/subgraphs/vela-exchange/protocols/vela-exchange/config/templates/vela.exchange.template.yaml +++ b/subgraphs/vela-exchange/protocols/vela-exchange/config/templates/vela.exchange.template.yaml @@ -57,7 +57,7 @@ dataSources: handler: handleStake - event: Unstake(indexed address,address,uint256,uint256) handler: handleUnstake - file: ./src/mappings/Vault.ts + file: ./src/mappings/vault.ts - kind: ethereum name: VaultUtils @@ -121,7 +121,7 @@ dataSources: handler: handleClosePosition - event: LiquidatePosition(bytes32,int256,uint256,uint256) handler: handleLiquidatePosition - file: ./src/mappings/VaultUtils.ts + file: ./src/mappings/vaultUtils.ts - kind: ethereum/contract name: ComplexRewarderPerSec @@ -176,4 +176,4 @@ dataSources: eventHandlers: - event: AddRewardInfo(indexed uint256,indexed uint256,uint256,uint256) handler: handleAddRewardInfo - file: ./src/mappings/ComplexRewarderPerSec.ts + file: ./src/mappings/complexRewarderPerSec.ts diff --git a/subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts b/subgraphs/vela-exchange/src/mappings/complexRewarderPerSec.ts similarity index 100% rename from subgraphs/vela-exchange/src/mappings/ComplexRewarderPerSec.ts rename to subgraphs/vela-exchange/src/mappings/complexRewarderPerSec.ts diff --git a/subgraphs/vela-exchange/src/mappings/Vault.ts b/subgraphs/vela-exchange/src/mappings/vault.ts similarity index 100% rename from subgraphs/vela-exchange/src/mappings/Vault.ts rename to subgraphs/vela-exchange/src/mappings/vault.ts diff --git a/subgraphs/vela-exchange/src/mappings/VaultUtils.ts b/subgraphs/vela-exchange/src/mappings/vaultUtils.ts similarity index 100% rename from subgraphs/vela-exchange/src/mappings/VaultUtils.ts rename to subgraphs/vela-exchange/src/mappings/vaultUtils.ts