diff --git a/data/constants.js b/data/constants.js index 5384409..be7e8be 100644 --- a/data/constants.js +++ b/data/constants.js @@ -154,6 +154,7 @@ const ESTIMATED_APY_TYPES = { NOTIONAL: 'NOTIONAL', APE: 'APE', MESHSWAP: 'MESHSWAP', + IDLE_FINANCE_TRANCHE: 'IDLE_FINANCE_TRANCHE', } const COLLATERAL_TYPE = { @@ -192,6 +193,7 @@ const TRADING_APY_TYPES = { MSTABLE: 'MSTABLE', LOOKS: 'LOOKS', APE: 'APE', + IDLE_FINANCE_TRANCHE: 'IDLE_FINANCE_TRANCHE', } const POOL_TYPES = { diff --git a/data/icons/idletranche-wsteth.png b/data/icons/idletranche-wsteth.png new file mode 100644 index 0000000..3be1195 Binary files /dev/null and b/data/icons/idletranche-wsteth.png differ diff --git a/data/icons/wsteth.png b/data/icons/wsteth.png new file mode 100644 index 0000000..14c1e28 Binary files /dev/null and b/data/icons/wsteth.png differ diff --git a/data/mainnet/addresses.json b/data/mainnet/addresses.json index 343fdea..38cecb9 100644 --- a/data/mainnet/addresses.json +++ b/data/mainnet/addresses.json @@ -100,6 +100,7 @@ "cvxCRV": "0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7", "BASED_sUSD": "0xaAD22f5543FCDaA694B68f94Be177B561836AE57", "NOTE": "0xCFEAead4947f0705A14ec42aC3D44129E1Ef3eD5", + "WSTETH": "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", "UNI_LP_WETH_DPI": "0x4d5ef58aAc27d99935E5b6B4A6778ff292059991", "UNI_LP_WETH_USDT": "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852", @@ -1375,6 +1376,14 @@ "NewStrategy": "0x29951C181Dff1f5f7b4c71d4D77604158d058ad2", "NewPool": "0x973cFd9B6B5d98C6ff815e364D1F7f3C48C351be", "Miner": "0xB576491F1E6e5E62f1d8F26062Ee822B40B0E0d4" + }, + "wstETH": { + "Underlying": "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", + "NewVault": "0x13324dB39551A2Be0E39D74827fD5B47AcAE52Bb", + "NewStrategy": "0xB3C74E678e36359BB45908A90843F60E0f2523d1", + "NewPool": "0x0202865aCD69577cB28F173600d101799BD24e95", + "TrancheCDO": "0x34dCd573C5dE4672C8248cd12A99f875Ca112Ad8", + "LiquidityGauge": "0x675eC042325535F6e176638Dd2d4994F645502B9" } }, "BSC": { diff --git a/data/mainnet/pools.js b/data/mainnet/pools.js index 7d43d05..575a509 100644 --- a/data/mainnet/pools.js +++ b/data/mainnet/pools.js @@ -4,6 +4,42 @@ const addresses = require('./addresses.json') const strat30PercentFactor = '0.7' module.exports = [ + { + chain: CHAINS_ID.ETH_MAINNET, + id: 'wstETH', + type: POOL_TYPES.INCENTIVE, + contractAddress: addresses.V2.wstETH.NewPool, + collateralAddress: addresses.V2.wstETH.NewVault, + rewardAPY: [], + rewardTokens: [addresses.iFARM], + rewardTokenSymbols: ['iFARM'], + tradingApyFunction: { + type: TRADING_APY_TYPES.IDLE_FINANCE_TRANCHE, + params: [addresses.V2.wstETH.TrancheCDO], + }, + stakeAndDepositHelpMessage: ` +
+ `, + }, { chain: CHAINS_ID.ETH_MAINNET, id: 'convex_DOLA_FRAXBP', diff --git a/data/mainnet/tokens.js b/data/mainnet/tokens.js index 6aa5d5f..e844f2c 100644 --- a/data/mainnet/tokens.js +++ b/data/mainnet/tokens.js @@ -45,6 +45,37 @@ module.exports = { ], cmcRewardTokenSymbols: ['FARM', 'WETH'], }, + wstETH: { + isNew: true, + category: VAULT_CATEGORIES_IDS.IDLE, + chain: CHAINS_ID.ETH_MAINNET, + logoUrl: './icons/wsteth.png', + apyIconUrls: ['./icons/idle.png', './icons/ldo.png'], + apyTokenSymbols: ['IDLE', 'LDO'], + displayName: 'wstETH', + subLabel: 'Idle Finance Tranche', + tokenAddress: addresses.V2.wstETH.Underlying, + decimals: '18', + vaultAddress: addresses.V2.wstETH.NewVault, + priceFunction: { + type: GET_PRICE_TYPES.COINGECKO_CONTRACT, + params: [addresses.WSTETH], + }, + estimateApyFunctions: [ + { + type: ESTIMATED_APY_TYPES.IDLE_FINANCE_TRANCHE, + params: [ + addresses.V2.wstETH.TrancheCDO, + addresses.V2.wstETH.LiquidityGauge, + [addresses.LDO], + addresses.WSTETH, + true, + '0.85', + ], + }, + ], + cmcRewardTokenSymbols: ['iFARM', 'IDLE', 'LDO'], + }, USDD: { chain: CHAINS_ID.ETH_MAINNET, logoUrl: './icons/usdd.png', diff --git a/src/lib/web3/contracts/idle-cdo/contract.json b/src/lib/web3/contracts/idle-cdo/contract.json new file mode 100644 index 0000000..a0f1b38 --- /dev/null +++ b/src/lib/web3/contracts/idle-cdo/contract.json @@ -0,0 +1,649 @@ +{ + "abi": [ + { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, + { + "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": "address", "name": "account", "type": "address" } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "_ref", "type": "address" } + ], + "name": "Referral", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "account", "type": "address" } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "AAStaking", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "AATranche", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BBStaking", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BBTranche", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FULL_ALLOC", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_FEE", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ONE_TRANCHE_TOKEN", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_limit", "type": "uint256" }], + "name": "_setLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "allowAAWithdraw", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "allowBBWithdraw", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], + "name": "depositAA", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "internalType": "address", "name": "_referral", "type": "address" } + ], + "name": "depositAARef", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], + "name": "depositBB", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "internalType": "address", "name": "_referral", "type": "address" } + ], + "name": "depositBBRef", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "emergencyShutdown", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "fee", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeReceiver", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeSplit", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_tranche", "type": "address" }], + "name": "getApr", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getContractValue", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentAARatio", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_tranche", "type": "address" }], + "name": "getIdealApr", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getIncentiveTokens", + "outputs": [{ "internalType": "address[]", "name": "", "type": "address[]" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governanceRecoveryFund", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "guardian", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bool[]", "name": "_skipFlags", "type": "bool[]" }, + { "internalType": "bool[]", "name": "_skipReward", "type": "bool[]" }, + { "internalType": "uint256[]", "name": "_minAmount", "type": "uint256[]" }, + { "internalType": "uint256[]", "name": "_sellAmounts", "type": "uint256[]" }, + { "internalType": "bytes", "name": "_extraData", "type": "bytes" } + ], + "name": "harvest", + "outputs": [{ "internalType": "uint256[][]", "name": "_res", "type": "uint256[][]" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "idealRange", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "incentiveTokens", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_limit", "type": "uint256" }, + { "internalType": "address", "name": "_guardedToken", "type": "address" }, + { "internalType": "address", "name": "_governanceFund", "type": "address" }, + { "internalType": "address", "name": "_owner", "type": "address" }, + { "internalType": "address", "name": "_rebalancer", "type": "address" }, + { "internalType": "address", "name": "_strategy", "type": "address" }, + { "internalType": "uint256", "name": "_trancheAPRSplitRatio", "type": "uint256" }, + { "internalType": "uint256", "name": "_trancheIdealWeightRatio", "type": "uint256" }, + { "internalType": "address[]", "name": "_incentiveTokens", "type": "address[]" } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isAYSActive", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastNAVAA", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastNAVBB", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastStrategyPrice", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "limit", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "internalType": "bool", "name": "_revertIfNeeded", "type": "bool" } + ], + "name": "liquidate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "oneToken", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "priceAA", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "priceBB", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rebalancer", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "referral", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "releaseBlocksPeriod", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revertIfTooLow", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bool", "name": "_allowed", "type": "bool" }], + "name": "setAllowAAWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bool", "name": "_allowed", "type": "bool" }], + "name": "setAllowBBWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_fee", "type": "uint256" }], + "name": "setFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_feeReceiver", "type": "address" }], + "name": "setFeeReceiver", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_feeSplit", "type": "uint256" }], + "name": "setFeeSplit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_guardian", "type": "address" }], + "name": "setGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_idealRange", "type": "uint256" }], + "name": "setIdealRange", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address[]", "name": "_incentiveTokens", "type": "address[]" }], + "name": "setIncentiveTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bool", "name": "_active", "type": "bool" }], + "name": "setIsAYSActive", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bool", "name": "_isStkAAVEActive", "type": "bool" }], + "name": "setIsStkAAVEActive", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_rebalancer", "type": "address" }], + "name": "setRebalancer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_referral", "type": "address" }], + "name": "setReferral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_releaseBlocksPeriod", "type": "uint256" }], + "name": "setReleaseBlocksPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bool", "name": "_allowed", "type": "bool" }], + "name": "setRevertIfTooLow", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bool", "name": "_allowed", "type": "bool" }], + "name": "setSkipDefaultCheck", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_AAStaking", "type": "address" }, + { "internalType": "address", "name": "_BBStaking", "type": "address" } + ], + "name": "setStakingRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_strategy", "type": "address" }, + { "internalType": "address[]", "name": "_incentiveTokens", "type": "address[]" } + ], + "name": "setStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_trancheAPRSplitRatio", "type": "uint256" }], + "name": "setTrancheAPRSplitRatio", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_trancheIdealWeightRatio", "type": "uint256" } + ], + "name": "setTrancheIdealWeightRatio", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_unlentPerc", "type": "uint256" }], + "name": "setUnlentPerc", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "skipDefaultCheck", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "strategy", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "strategyToken", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "trancheAPRSplitRatio", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "trancheIdealWeightRatio", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_tranche", "type": "address" }], + "name": "tranchePrice", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_token", "type": "address" }, + { "internalType": "uint256", "name": "_value", "type": "uint256" } + ], + "name": "transferToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unclaimedFees", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unlentPerc", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_tranche", "type": "address" }], + "name": "virtualPrice", + "outputs": [{ "internalType": "uint256", "name": "_virtualPrice", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "weth", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], + "name": "withdrawAA", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], + "name": "withdrawBB", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + } + ] +} diff --git a/src/lib/web3/contracts/idle-cdo/methods.js b/src/lib/web3/contracts/idle-cdo/methods.js new file mode 100644 index 0000000..2cad826 --- /dev/null +++ b/src/lib/web3/contracts/idle-cdo/methods.js @@ -0,0 +1,13 @@ +const { countFunctionCall } = require('../..') + +const priceAA = instance => countFunctionCall(instance.methods.priceAA().call()) + +const getApr = (tranche, instance) => countFunctionCall(instance.methods.getApr(tranche).call()) + +const AATranche = instance => countFunctionCall(instance.methods.AATranche().call()) + +module.exports = { + getApr, + priceAA, + AATranche, +} diff --git a/src/lib/web3/contracts/idle-gauge-controller/contract.json b/src/lib/web3/contracts/idle-gauge-controller/contract.json new file mode 100644 index 0000000..01ab3f7 --- /dev/null +++ b/src/lib/web3/contracts/idle-gauge-controller/contract.json @@ -0,0 +1,424 @@ +{ + "address": { + "ropsten": "", + "mainnet": "0xaC69078141f76A1e257Ee889920d02Cc547d632f" + }, + "abi": [ + { + "name": "CommitOwnership", + "inputs": [{ "name": "admin", "type": "address", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "ApplyOwnership", + "inputs": [{ "name": "admin", "type": "address", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "AddType", + "inputs": [ + { "name": "name", "type": "string", "indexed": false }, + { "name": "type_id", "type": "int128", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewTypeWeight", + "inputs": [ + { "name": "type_id", "type": "int128", "indexed": false }, + { "name": "time", "type": "uint256", "indexed": false }, + { "name": "weight", "type": "uint256", "indexed": false }, + { "name": "total_weight", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewGaugeWeight", + "inputs": [ + { "name": "gauge_address", "type": "address", "indexed": false }, + { "name": "time", "type": "uint256", "indexed": false }, + { "name": "weight", "type": "uint256", "indexed": false }, + { "name": "total_weight", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "VoteForGauge", + "inputs": [ + { "name": "time", "type": "uint256", "indexed": false }, + { "name": "user", "type": "address", "indexed": false }, + { "name": "gauge_addr", "type": "address", "indexed": false }, + { "name": "weight", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "NewGauge", + "inputs": [ + { "name": "addr", "type": "address", "indexed": false }, + { "name": "gauge_type", "type": "int128", "indexed": false }, + { "name": "weight", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "stateMutability": "nonpayable", + "type": "constructor", + "inputs": [{ "name": "_voting_escrow", "type": "address" }], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "commit_transfer_ownership", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [], + "gas": 38895 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "apply_transfer_ownership", + "inputs": [], + "outputs": [], + "gas": 41034 + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauge_types", + "inputs": [{ "name": "_addr", "type": "address" }], + "outputs": [{ "name": "", "type": "int128" }], + "gas": 3014 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "add_gauge", + "inputs": [ + { "name": "addr", "type": "address" }, + { "name": "gauge_type", "type": "int128" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "add_gauge", + "inputs": [ + { "name": "addr", "type": "address" }, + { "name": "gauge_type", "type": "int128" }, + { "name": "weight", "type": "uint256" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "checkpoint", + "inputs": [], + "outputs": [], + "gas": 18271410417 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "checkpoint_gauge", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [], + "gas": 18325922441 + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauge_relative_weight", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauge_relative_weight", + "inputs": [ + { "name": "addr", "type": "address" }, + { "name": "time", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "gauge_relative_weight_write", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "gauge_relative_weight_write", + "inputs": [ + { "name": "addr", "type": "address" }, + { "name": "time", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "uint256" }] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "add_type", + "inputs": [{ "name": "_name", "type": "string" }], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "add_type", + "inputs": [ + { "name": "_name", "type": "string" }, + { "name": "weight", "type": "uint256" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "change_type_weight", + "inputs": [ + { "name": "type_id", "type": "int128" }, + { "name": "weight", "type": "uint256" } + ], + "outputs": [], + "gas": 36722675398 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "change_gauge_weight", + "inputs": [ + { "name": "addr", "type": "address" }, + { "name": "weight", "type": "uint256" } + ], + "outputs": [], + "gas": 36831772473 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "vote_for_gauge_weights", + "inputs": [ + { "name": "_gauge_addr", "type": "address" }, + { "name": "_user_weight", "type": "uint256" } + ], + "outputs": [], + "gas": 18380903247 + }, + { + "stateMutability": "view", + "type": "function", + "name": "get_gauge_weight", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 5290 + }, + { + "stateMutability": "view", + "type": "function", + "name": "get_type_weight", + "inputs": [{ "name": "type_id", "type": "int128" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 5331 + }, + { + "stateMutability": "view", + "type": "function", + "name": "get_total_weight", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 5020 + }, + { + "stateMutability": "view", + "type": "function", + "name": "get_weights_sum_per_type", + "inputs": [{ "name": "type_id", "type": "int128" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 5391 + }, + { + "stateMutability": "view", + "type": "function", + "name": "admin", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 2868 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_admin", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 2898 + }, + { + "stateMutability": "view", + "type": "function", + "name": "voting_escrow", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 2928 + }, + { + "stateMutability": "view", + "type": "function", + "name": "n_gauge_types", + "inputs": [], + "outputs": [{ "name": "", "type": "int128" }], + "gas": 2958 + }, + { + "stateMutability": "view", + "type": "function", + "name": "n_gauges", + "inputs": [], + "outputs": [{ "name": "", "type": "int128" }], + "gas": 2988 + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauge_type_names", + "inputs": [{ "name": "arg0", "type": "int128" }], + "outputs": [{ "name": "", "type": "string" }], + "gas": 13544 + }, + { + "stateMutability": "view", + "type": "function", + "name": "gauges", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "address" }], + "gas": 3093 + }, + { + "stateMutability": "view", + "type": "function", + "name": "vote_user_slopes", + "inputs": [ + { "name": "arg0", "type": "address" }, + { "name": "arg1", "type": "address" } + ], + "outputs": [ + { "name": "slope", "type": "uint256" }, + { "name": "power", "type": "uint256" }, + { "name": "end", "type": "uint256" } + ], + "gas": 8108 + }, + { + "stateMutability": "view", + "type": "function", + "name": "vote_user_power", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3323 + }, + { + "stateMutability": "view", + "type": "function", + "name": "last_user_vote", + "inputs": [ + { "name": "arg0", "type": "address" }, + { "name": "arg1", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3568 + }, + { + "stateMutability": "view", + "type": "function", + "name": "points_weight", + "inputs": [ + { "name": "arg0", "type": "address" }, + { "name": "arg1", "type": "uint256" } + ], + "outputs": [ + { "name": "bias", "type": "uint256" }, + { "name": "slope", "type": "uint256" } + ], + "gas": 5888 + }, + { + "stateMutability": "view", + "type": "function", + "name": "time_weight", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3413 + }, + { + "stateMutability": "view", + "type": "function", + "name": "points_sum", + "inputs": [ + { "name": "arg0", "type": "int128" }, + { "name": "arg1", "type": "uint256" } + ], + "outputs": [ + { "name": "bias", "type": "uint256" }, + { "name": "slope", "type": "uint256" } + ], + "gas": 6029 + }, + { + "stateMutability": "view", + "type": "function", + "name": "time_sum", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3303 + }, + { + "stateMutability": "view", + "type": "function", + "name": "points_total", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3403 + }, + { + "stateMutability": "view", + "type": "function", + "name": "time_total", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3318 + }, + { + "stateMutability": "view", + "type": "function", + "name": "points_type_weight", + "inputs": [ + { "name": "arg0", "type": "int128" }, + { "name": "arg1", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3759 + }, + { + "stateMutability": "view", + "type": "function", + "name": "time_type_weight", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3423 + } + ] +} diff --git a/src/lib/web3/contracts/idle-gauge-controller/methods.js b/src/lib/web3/contracts/idle-gauge-controller/methods.js new file mode 100644 index 0000000..7297701 --- /dev/null +++ b/src/lib/web3/contracts/idle-gauge-controller/methods.js @@ -0,0 +1,8 @@ +const { countFunctionCall } = require('../..') + +const gaugeRelativeWeight = (gauge, instance) => + countFunctionCall(instance.methods.gauge_relative_weight(gauge).call()) + +module.exports = { + gaugeRelativeWeight, +} diff --git a/src/lib/web3/contracts/idle-gauge-distributor/contract.json b/src/lib/web3/contracts/idle-gauge-distributor/contract.json new file mode 100644 index 0000000..d27cae2 --- /dev/null +++ b/src/lib/web3/contracts/idle-gauge-distributor/contract.json @@ -0,0 +1,230 @@ +{ + "address": { + "ropsten": "", + "mainnet": "0x1276A8ee84900bD8CcA6e9b3ccB99FF4771Fe329" + }, + "abi": [ + { + "inputs": [ + { "internalType": "contract IERC20", "name": "_idle", "type": "address" }, + { "internalType": "address", "name": "_treasury", "type": "address" }, + { "internalType": "address", "name": "_emergencyAdmin", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "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": "time", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "rate", "type": "uint256" } + ], + "name": "UpdateDistributionParameters", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldProxy", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newProxy", "type": "address" } + ], + "name": "UpdateDistributorProxy", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "rate", "type": "uint256" } + ], + "name": "UpdatePendingRate", + "type": "event" + }, + { + "inputs": [], + "name": "EPOCH_DURATION", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INITIAL_DISTRIBUTION_DELAY", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INITIAL_RATE", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ONE_WEEK", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "availableToDistribute", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "distribute", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "distributed", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "distributorProxy", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "emergencyAdmin", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], + "name": "emergencyWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "epochNumber", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "epochStartingDistributed", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "futureEpochTimeWrite", + "outputs": [{ "internalType": "uint256", "name": "_futureEpochTime", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "ratePerEpoch", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "proxy", "type": "address" }], + "name": "setDistributorProxy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "emergencyAdmin_", "type": "address" }], + "name": "setEmergencyAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "newRate", "type": "uint256" }], + "name": "setPendingRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "startEpochTime", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "startEpochTimeWrite", + "outputs": [{ "internalType": "uint256", "name": "_startEpochTime", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateDistributionParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] +} diff --git a/src/lib/web3/contracts/idle-gauge-distributor/methods.js b/src/lib/web3/contracts/idle-gauge-distributor/methods.js new file mode 100644 index 0000000..ac91077 --- /dev/null +++ b/src/lib/web3/contracts/idle-gauge-distributor/methods.js @@ -0,0 +1,7 @@ +const { countFunctionCall } = require('../..') + +const rate = instance => countFunctionCall(instance.methods.rate().call()) + +module.exports = { + rate, +} diff --git a/src/lib/web3/contracts/idle-liquidity-gauge/contract.json b/src/lib/web3/contracts/idle-liquidity-gauge/contract.json new file mode 100644 index 0000000..7e26b69 --- /dev/null +++ b/src/lib/web3/contracts/idle-liquidity-gauge/contract.json @@ -0,0 +1,556 @@ +{ + "abi": [ + { + "name": "Deposit", + "inputs": [ + { "name": "provider", "type": "address", "indexed": true }, + { "name": "value", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "Withdraw", + "inputs": [ + { "name": "provider", "type": "address", "indexed": true }, + { "name": "value", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateLiquidityLimit", + "inputs": [ + { "name": "user", "type": "address", "indexed": false }, + { "name": "original_balance", "type": "uint256", "indexed": false }, + { "name": "original_supply", "type": "uint256", "indexed": false }, + { "name": "working_balance", "type": "uint256", "indexed": false }, + { "name": "working_supply", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "CommitOwnership", + "inputs": [{ "name": "admin", "type": "address", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "ApplyOwnership", + "inputs": [{ "name": "admin", "type": "address", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "Transfer", + "inputs": [ + { "name": "_from", "type": "address", "indexed": true }, + { "name": "_to", "type": "address", "indexed": true }, + { "name": "_value", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "Approval", + "inputs": [ + { "name": "_owner", "type": "address", "indexed": true }, + { "name": "_spender", "type": "address", "indexed": true }, + { "name": "_value", "type": "uint256", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "stateMutability": "nonpayable", + "type": "constructor", + "inputs": [ + { "name": "_lp_token", "type": "address" }, + { "name": "_distributor_proxy", "type": "address" }, + { "name": "_admin", "type": "address" } + ], + "outputs": [] + }, + { + "stateMutability": "view", + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 288 + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_checkpoint", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4560 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "user_checkpoint", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "bool" }], + "gas": 3133382 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claimable_tokens", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3046449 + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_contract", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 2718 + }, + { + "stateMutability": "view", + "type": "function", + "name": "last_claim", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 2544 + }, + { + "stateMutability": "view", + "type": "function", + "name": "claimed_reward", + "inputs": [ + { "name": "_addr", "type": "address" }, + { "name": "_token", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3066 + }, + { + "stateMutability": "view", + "type": "function", + "name": "claimable_reward", + "inputs": [ + { "name": "_addr", "type": "address" }, + { "name": "_token", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3034 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claimable_reward_write", + "inputs": [ + { "name": "_addr", "type": "address" }, + { "name": "_token", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 1209922 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "set_rewards_receiver", + "inputs": [{ "name": "_receiver", "type": "address" }], + "outputs": [], + "gas": 35733 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_rewards", + "inputs": [], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_rewards", + "inputs": [{ "name": "_addr", "type": "address" }], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "claim_rewards", + "inputs": [ + { "name": "_addr", "type": "address" }, + { "name": "_receiver", "type": "address" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "kick", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [], + "gas": 3147973 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "deposit", + "inputs": [{ "name": "_value", "type": "uint256" }], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "deposit", + "inputs": [ + { "name": "_value", "type": "uint256" }, + { "name": "_addr", "type": "address" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "deposit", + "inputs": [ + { "name": "_value", "type": "uint256" }, + { "name": "_addr", "type": "address" }, + { "name": "_claim_rewards", "type": "bool" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "withdraw", + "inputs": [{ "name": "_value", "type": "uint256" }], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "withdraw", + "inputs": [ + { "name": "_value", "type": "uint256" }, + { "name": "_claim_rewards", "type": "bool" } + ], + "outputs": [] + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "transfer", + "inputs": [ + { "name": "_to", "type": "address" }, + { "name": "_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }], + "gas": 17167132 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "transferFrom", + "inputs": [ + { "name": "_from", "type": "address" }, + { "name": "_to", "type": "address" }, + { "name": "_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }], + "gas": 17205082 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "approve", + "inputs": [ + { "name": "_spender", "type": "address" }, + { "name": "_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }], + "gas": 38211 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "increaseAllowance", + "inputs": [ + { "name": "_spender", "type": "address" }, + { "name": "_added_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }], + "gas": 40755 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "decreaseAllowance", + "inputs": [ + { "name": "_spender", "type": "address" }, + { "name": "_subtracted_value", "type": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool" }], + "gas": 40779 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "set_rewards", + "inputs": [ + { "name": "_reward_contract", "type": "address" }, + { "name": "_sigs", "type": "bytes32" }, + { "name": "_reward_tokens", "type": "address[8]" } + ], + "outputs": [], + "gas": 2740447 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "set_killed", + "inputs": [{ "name": "_is_killed", "type": "bool" }], + "outputs": [], + "gas": 38145 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "commit_transfer_ownership", + "inputs": [{ "name": "addr", "type": "address" }], + "outputs": [], + "gas": 39525 + }, + { + "stateMutability": "nonpayable", + "type": "function", + "name": "accept_transfer_ownership", + "inputs": [], + "outputs": [], + "gas": 39470 + }, + { + "stateMutability": "view", + "type": "function", + "name": "distributor_proxy", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 3078 + }, + { + "stateMutability": "view", + "type": "function", + "name": "distributor", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 3108 + }, + { + "stateMutability": "view", + "type": "function", + "name": "lp_token", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 3138 + }, + { + "stateMutability": "view", + "type": "function", + "name": "controller", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 3168 + }, + { + "stateMutability": "view", + "type": "function", + "name": "voting_escrow", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 3198 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_epoch_time", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3228 + }, + { + "stateMutability": "view", + "type": "function", + "name": "balanceOf", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3473 + }, + { + "stateMutability": "view", + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3288 + }, + { + "stateMutability": "view", + "type": "function", + "name": "allowance", + "inputs": [ + { "name": "arg0", "type": "address" }, + { "name": "arg1", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3748 + }, + { + "stateMutability": "view", + "type": "function", + "name": "name", + "inputs": [], + "outputs": [{ "name": "", "type": "string" }], + "gas": 13578 + }, + { + "stateMutability": "view", + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [{ "name": "", "type": "string" }], + "gas": 11331 + }, + { + "stateMutability": "view", + "type": "function", + "name": "working_balances", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3623 + }, + { + "stateMutability": "view", + "type": "function", + "name": "working_supply", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3438 + }, + { + "stateMutability": "view", + "type": "function", + "name": "period", + "inputs": [], + "outputs": [{ "name": "", "type": "int128" }], + "gas": 3468 + }, + { + "stateMutability": "view", + "type": "function", + "name": "period_timestamp", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3543 + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_inv_supply", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3573 + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_inv_supply_of", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3773 + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_checkpoint_of", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3803 + }, + { + "stateMutability": "view", + "type": "function", + "name": "integrate_fraction", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3833 + }, + { + "stateMutability": "view", + "type": "function", + "name": "inflation_rate", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3648 + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_tokens", + "inputs": [{ "name": "arg0", "type": "uint256" }], + "outputs": [{ "name": "", "type": "address" }], + "gas": 3723 + }, + { + "stateMutability": "view", + "type": "function", + "name": "rewards_receiver", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "address" }], + "gas": 3923 + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_integral", + "inputs": [{ "name": "arg0", "type": "address" }], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 3953 + }, + { + "stateMutability": "view", + "type": "function", + "name": "reward_integral_for", + "inputs": [ + { "name": "arg0", "type": "address" }, + { "name": "arg1", "type": "address" } + ], + "outputs": [{ "name": "", "type": "uint256" }], + "gas": 4198 + }, + { + "stateMutability": "view", + "type": "function", + "name": "admin", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 3798 + }, + { + "stateMutability": "view", + "type": "function", + "name": "future_admin", + "inputs": [], + "outputs": [{ "name": "", "type": "address" }], + "gas": 3828 + }, + { + "stateMutability": "view", + "type": "function", + "name": "is_killed", + "inputs": [], + "outputs": [{ "name": "", "type": "bool" }], + "gas": 3858 + } + ] +} diff --git a/src/lib/web3/contracts/idle-liquidity-gauge/methods.js b/src/lib/web3/contracts/idle-liquidity-gauge/methods.js new file mode 100644 index 0000000..7ae70fa --- /dev/null +++ b/src/lib/web3/contracts/idle-liquidity-gauge/methods.js @@ -0,0 +1,9 @@ +const { countFunctionCall } = require('../..') + +const rewardContract = instance => countFunctionCall(instance.methods.reward_contract().call()) +const totalSupply = instance => countFunctionCall(instance.methods.totalSupply().call()) + +module.exports = { + rewardContract, + totalSupply, +} diff --git a/src/lib/web3/contracts/idle-multi-reward/contract.json b/src/lib/web3/contracts/idle-multi-reward/contract.json new file mode 100644 index 0000000..ef75494 --- /dev/null +++ b/src/lib/web3/contracts/idle-multi-reward/contract.json @@ -0,0 +1,365 @@ +{ + "abi": [ + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { "internalType": "address", "name": "_stakingToken", "type": "address" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldOwner", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnerNominated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "bool", "name": "isPaused", "type": "bool" }], + "name": "PauseChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "Recovered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "reward", "type": "uint256" } + ], + "name": "RewardAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "rewardsToken", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "reward", "type": "uint256" } + ], + "name": "RewardPaid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "newDuration", "type": "uint256" } + ], + "name": "RewardsDurationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "Staked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "Withdrawn", + "type": "event" + }, + { + "constant": false, + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardsToken", "type": "address" }, + { "internalType": "address", "name": "_rewardsDistributor", "type": "address" }, + { "internalType": "uint256", "name": "_rewardsDuration", "type": "uint256" } + ], + "name": "addReward", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" }, + { "internalType": "address", "name": "_rewardsToken", "type": "address" } + ], + "name": "earned", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "exit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "getReward", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "_rewardsToken", "type": "address" }], + "name": "getRewardForDuration", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "lastPauseTime", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "_rewardsToken", "type": "address" }], + "name": "lastTimeRewardApplicable", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "_owner", "type": "address" }], + "name": "nominateNewOwner", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "nominatedOwner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardsToken", "type": "address" }, + { "internalType": "uint256", "name": "reward", "type": "uint256" } + ], + "name": "notifyRewardAmount", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "paused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" }, + { "internalType": "uint256", "name": "tokenAmount", "type": "uint256" } + ], + "name": "recoverERC20", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "rewardData", + "outputs": [ + { "internalType": "address", "name": "rewardsDistributor", "type": "address" }, + { "internalType": "uint256", "name": "rewardsDuration", "type": "uint256" }, + { "internalType": "uint256", "name": "periodFinish", "type": "uint256" }, + { "internalType": "uint256", "name": "rewardRate", "type": "uint256" }, + { "internalType": "uint256", "name": "lastUpdateTime", "type": "uint256" }, + { "internalType": "uint256", "name": "rewardPerTokenStored", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "_rewardsToken", "type": "address" }], + "name": "rewardPerToken", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "rewardTokens", + "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": "rewards", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "bool", "name": "_paused", "type": "bool" }], + "name": "setPaused", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardsToken", "type": "address" }, + { "internalType": "address", "name": "_rewardsDistributor", "type": "address" } + ], + "name": "setRewardsDistributor", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardsToken", "type": "address" }, + { "internalType": "uint256", "name": "_rewardsDuration", "type": "uint256" } + ], + "name": "setRewardsDuration", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], + "name": "stake", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "stakingToken", + "outputs": [{ "internalType": "contract IERC20", "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": true, + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "userRewardPerTokenPaid", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], + "name": "withdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ] +} diff --git a/src/lib/web3/contracts/idle-multi-reward/methods.js b/src/lib/web3/contracts/idle-multi-reward/methods.js new file mode 100644 index 0000000..fd5f1e0 --- /dev/null +++ b/src/lib/web3/contracts/idle-multi-reward/methods.js @@ -0,0 +1,8 @@ +const { countFunctionCall } = require('../..') + +const rewardData = (rewardToken, instance) => + countFunctionCall(instance.methods.rewardData(rewardToken).call()) + +module.exports = { + rewardData, +} diff --git a/src/lib/web3/contracts/lido-wsteth/contract.json b/src/lib/web3/contracts/lido-wsteth/contract.json new file mode 100644 index 0000000..2df39c5 --- /dev/null +++ b/src/lib/web3/contracts/lido-wsteth/contract.json @@ -0,0 +1,207 @@ +{ + "address": { + "mainnet": "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0" + }, + "abi": [ + { + "inputs": [{ "internalType": "contract IStETH", "name": "_stETH", "type": "address" }], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "subtractedValue", "type": "uint256" } + ], + "name": "decreaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_wstETHAmount", "type": "uint256" }], + "name": "getStETHByWstETH", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_stETHAmount", "type": "uint256" }], + "name": "getWstETHByStETH", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "addedValue", "type": "uint256" } + ], + "name": "increaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], + "name": "nonces", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stETH", + "outputs": [{ "internalType": "contract IStETH", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stEthPerToken", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tokensPerStEth", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_wstETHAmount", "type": "uint256" }], + "name": "unwrap", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_stETHAmount", "type": "uint256" }], + "name": "wrap", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } + ] +} diff --git a/src/lib/web3/contracts/lido-wsteth/methods.js b/src/lib/web3/contracts/lido-wsteth/methods.js new file mode 100644 index 0000000..1d2b075 --- /dev/null +++ b/src/lib/web3/contracts/lido-wsteth/methods.js @@ -0,0 +1,5 @@ +const { countFunctionCall } = require('../..') + +const stEthPerToken = instance => countFunctionCall(instance.methods.stEthPerToken().call()) + +module.exports = { stEthPerToken } diff --git a/src/vaults/apys/implementations/idle-finance-tranche.js b/src/vaults/apys/implementations/idle-finance-tranche.js new file mode 100644 index 0000000..5cdcca7 --- /dev/null +++ b/src/vaults/apys/implementations/idle-finance-tranche.js @@ -0,0 +1,100 @@ +/* eslint-disable for-direction */ +const BigNumber = require('bignumber.js') +const { web3 } = require('../../../lib/web3') +const tokenAddresses = require('../../../lib/data/addresses.json') + +const controllerContract = require('../../../lib/web3/contracts/idle-gauge-controller/contract.json') +const distributorContract = require('../../../lib/web3/contracts/idle-gauge-distributor/contract.json') +const liquidityGaugeContract = require('../../../lib/web3/contracts/idle-liquidity-gauge/contract.json') +const multiRewardContract = require('../../../lib/web3/contracts/idle-multi-reward/contract.json') +const trancheCDOContract = require('../../../lib/web3/contracts/idle-cdo/contract.json') +const wstethContract = require('../../../lib/web3/contracts/lido-wsteth/contract.json') + +const { gaugeRelativeWeight } = require('../../../lib/web3/contracts/idle-gauge-controller/methods') +const { rate } = require('../../../lib/web3/contracts/idle-gauge-distributor/methods') +const { + rewardContract, + totalSupply, +} = require('../../../lib/web3/contracts/idle-liquidity-gauge/methods') +const { rewardData } = require('../../../lib/web3/contracts/idle-multi-reward/methods') +const { priceAA } = require('../../../lib/web3/contracts/idle-cdo/methods') +const { stEthPerToken } = require('../../../lib/web3/contracts/lido-wsteth/methods') + +const { getTokenPrice } = require('../../../prices') + +const ONE_YEAR = new BigNumber(3600 * 24 * 365) + +const getApy = async ( + trancheCDO, + liquidityGauge, + rewardTokens, + underlyingToken, + iswstETH, + reduction, +) => { + const controllerInstance = new web3.eth.Contract( + controllerContract.abi, + controllerContract.address.mainnet, + ) + const distributorInstance = new web3.eth.Contract( + distributorContract.abi, + distributorContract.address.mainnet, + ) + const liquidityGaugeInstance = new web3.eth.Contract(liquidityGaugeContract.abi, liquidityGauge) + const trancheCDOInstance = new web3.eth.Contract(trancheCDOContract.abi, trancheCDO) + + const weight = await gaugeRelativeWeight(liquidityGauge, controllerInstance) + const idleRate = await rate(distributorInstance) + const idleForGaugePerYear = new BigNumber(idleRate) + .multipliedBy(ONE_YEAR) + .multipliedBy(new BigNumber(weight)) + .dividedBy(new BigNumber(1e18)) // weight decimal + .dividedBy(new BigNumber(1e18)) // idle token decimal + const idlePrice = await getTokenPrice(tokenAddresses.IDLE) + const idleValuePerYear = new BigNumber(idlePrice).multipliedBy(idleForGaugePerYear) + + let rewardValuePerYear = new BigNumber(0) + if (rewardTokens.length > 0) { + const rewardContractAddr = await rewardContract(liquidityGaugeInstance) + const rewardInstance = new web3.eth.Contract(multiRewardContract.abi, rewardContractAddr) + + for (let i = 0; i < rewardTokens.length; i++) { + const data = await rewardData(rewardTokens[i], rewardInstance) + const tokenPrice = await getTokenPrice(rewardTokens[i]) + const value = new BigNumber(data.rewardRate) + .multipliedBy(new BigNumber(tokenPrice)) + .multipliedBy(ONE_YEAR) + .dividedBy(new BigNumber(1e18)) // token decimal + rewardValuePerYear = rewardValuePerYear.plus(value) + } + } + + const trancheSupply = await totalSupply(liquidityGaugeInstance) + const AATranchePrice = await priceAA(trancheCDOInstance) + let trancheBalancePerUnderlying = new BigNumber(1e18).dividedBy(new BigNumber(AATranchePrice)) + if (iswstETH) { + const wstETHInstance = new web3.eth.Contract(wstethContract.abi, wstethContract.address.mainnet) + const stethPerToken = await stEthPerToken(wstETHInstance) + trancheBalancePerUnderlying = trancheBalancePerUnderlying.multipliedBy( + new BigNumber(stethPerToken), + ) + } + + const underlyingPrice = await getTokenPrice(underlyingToken) + let apy = idleValuePerYear + .plus(rewardValuePerYear) + .multipliedBy(trancheBalancePerUnderlying) + .dividedBy(trancheSupply) + .dividedBy(underlyingPrice) + apy = apy.multipliedBy(new BigNumber(90)).dividedBy(new BigNumber(100)) //10% performance fee + + if (reduction) { + apy = apy.multipliedBy(reduction) + } + + return apy.multipliedBy(100).toFixed(2, 1) +} + +module.exports = { + getApy, +} diff --git a/src/vaults/trading-apys/implementations/idle-finance-tranche.js b/src/vaults/trading-apys/implementations/idle-finance-tranche.js new file mode 100644 index 0000000..d558a9a --- /dev/null +++ b/src/vaults/trading-apys/implementations/idle-finance-tranche.js @@ -0,0 +1,18 @@ +const BigNumber = require('bignumber.js') +const { web3 } = require('../../../lib/web3') +const trancheCDOContract = require('../../../lib/web3/contracts/idle-cdo/contract.json') +const { getApr, AATranche } = require('../../../lib/web3/contracts/idle-cdo/methods') + +const getTradingApy = async trancheCDO => { + const trancheCDOInstance = new web3.eth.Contract(trancheCDOContract.abi, trancheCDO) + const tranche = await AATranche(trancheCDOInstance) + let apr = new BigNumber(await getApr(tranche, trancheCDOInstance)) + apr = apr.dividedBy(new BigNumber(1e18)).dividedBy(100) + const apy = apr.dividedBy(12).plus(1).exponentiatedBy(12).minus(1) + + return apy.multipliedBy(100).toFixed(2, 1) +} + +module.exports = { + getTradingApy, +}