From 1ad268586d9bb7d61e1e58f0ab00f406c4e05ed3 Mon Sep 17 00:00:00 2001 From: getUnrekt <75529443+getunrekt@users.noreply.github.com> Date: Mon, 8 Apr 2024 14:00:23 +0800 Subject: [PATCH 01/73] add linea chain for acryptos protocol (#1259) * add kava chain to acryptos * add polygon chain to acryptos * add linea chain for acryptos protocol --- src/adaptors/acryptos/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/adaptors/acryptos/index.js b/src/adaptors/acryptos/index.js index f1b532c485..0a2fed5d53 100644 --- a/src/adaptors/acryptos/index.js +++ b/src/adaptors/acryptos/index.js @@ -18,6 +18,7 @@ const chainMapping = { 8453: 'base', 42161: 'arbitrum', 43114: 'avalanche', + 59144: 'linea', 1666600000: 'harmony', }; @@ -74,5 +75,5 @@ const main = async () => { module.exports = { timetravel: false, apy: main, - url: 'https://app-v2.acryptos.com/#/BSC/vaults/all', + url: 'https://app.acryptos.com/', }; From 45185410b0a8f9c50ad83d581314609b78289644 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Mon, 8 Apr 2024 10:15:26 +0400 Subject: [PATCH 02/73] solv-funds fix --- src/adaptors/solv-funds/index.js | 84 ++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 25 deletions(-) diff --git a/src/adaptors/solv-funds/index.js b/src/adaptors/solv-funds/index.js index 282d968392..4c902efef8 100644 --- a/src/adaptors/solv-funds/index.js +++ b/src/adaptors/solv-funds/index.js @@ -1,6 +1,8 @@ const { default: request, gql } = require('graphql-request'); const axios = require('axios'); +const utils = require('../utils'); + const chain = { 1: 'ethereum', 56: 'bsc', @@ -14,32 +16,34 @@ const chain = { const poolsQuery = gql` query Pools { - pools(filter:{ - poolStatus: "Active", - auditStatus: "Approved", - isUnlisted: false, - saleStatus: ["Upcoming","Fundraising","Active"] - }){ + pools( + filter: { + poolStatus: "Active" + auditStatus: "Approved" + isUnlisted: false + saleStatus: ["Upcoming", "Fundraising", "Active"] + } + ) { poolsInfo { id - productInfo{ + productInfo { name chainId - contractInfo{ + contractInfo { contractAddress } } - currencyInfo{ + currencyInfo { symbol currencyAddress decimals } issuerInfo { - accountInfo{ + accountInfo { username } } - poolOrderInfo{ + poolOrderInfo { poolId } aum @@ -50,23 +54,29 @@ const poolsQuery = gql` } `; -const headers = { 'Authorization': 'solv' } +const headers = { Authorization: 'solv' }; const poolsFunction = async () => { - const pools = (await request("https://sft-api.com/graphql", poolsQuery, null, headers)).pools; - const pricesArray = pools.poolsInfo.map((t) => `${chain[t.productInfo.chainId]}:${t.currencyInfo.currencyAddress}`); + const pools = ( + await request('https://sft-api.com/graphql', poolsQuery, null, headers) + ).pools; + const pricesArray = pools.poolsInfo.map( + (t) => `${chain[t.productInfo.chainId]}:${t.currencyInfo.currencyAddress}` + ); const prices = ( await axios.get(`https://coins.llama.fi/prices/current/${pricesArray}`) ).data.coins; const poolConfiguration = ( - await axios.get(`https://raw.githubusercontent.com/solv-finance-dev/slov-protocol-defillama/main/pools.json`) + await axios.get( + `https://raw.githubusercontent.com/solv-finance-dev/slov-protocol-defillama/main/pools.json` + ) ).data; let ustPool = []; for (const pool of pools.poolsInfo) { if (poolConfiguration.filterOut.indexOf(pool.poolOrderInfo.poolId) !== -1) { - continue + continue; } const marketContractQuery = gql` @@ -79,37 +89,61 @@ const poolsFunction = async () => { } `; - const marketContract = (await request("https://sft-api.com/graphql", marketContractQuery, null, headers)).marketContract; + const marketContract = ( + await request( + 'https://sft-api.com/graphql', + marketContractQuery, + null, + headers + ) + ).marketContract; let rewardApy = 0; let rewardTokens = []; JSON.parse(pool.additionalRewards).map(function (item, index) { - if (poolConfiguration.rewardTokenAddress[pool.productInfo.chainId]?.[item.symbol]) { - rewardTokens.push(poolConfiguration.rewardTokenAddress[pool.productInfo.chainId]?.[item.symbol]) + if ( + poolConfiguration.rewardTokenAddress[pool.productInfo.chainId]?.[ + item.symbol + ] + ) { + rewardTokens.push( + poolConfiguration.rewardTokenAddress[pool.productInfo.chainId]?.[ + item.symbol + ] + ); rewardApy += item.apy / 100; } - }) + }); ustPool.push({ - pool: `${pool.poolOrderInfo.poolId.toLowerCase()}-${chain[pool.productInfo.chainId]}`, + pool: `${pool.poolOrderInfo.poolId.toLowerCase()}-${ + chain[pool.productInfo.chainId] + }`, chain: chain[pool.productInfo.chainId], project: `solv-funds`, symbol: pool.currencyInfo.symbol, underlyingTokens: [pool.currencyInfo.currencyAddress], - tvlUsd: Number(pool.aum * prices[`${chain[pool.productInfo.chainId]}:${pool.currencyInfo.currencyAddress}`].price), + tvlUsd: Number( + pool.aum * + prices[ + `${chain[pool.productInfo.chainId]}:${ + pool.currencyInfo.currencyAddress + }` + ]?.price + ), apyBase: Number(pool.apy / 100) - Number(marketContract.defautFeeRate), apyReward: rewardApy, rewardTokens, url: `https://app.solv.finance/earn/open-fund/detail/${pool.id}`, poolMeta: pool.productInfo.name, - }) + }); } - return ustPool; + return ustPool.filter((i) => utils.keepFinite(i)); }; module.exports = { timetravel: false, apy: poolsFunction, url: 'https://app.solv.finance/', -}; \ No newline at end of file +}; From ef6026290d8cb38391fe2533f02d408d619fdfdf Mon Sep 17 00:00:00 2001 From: slasher125 Date: Mon, 8 Apr 2024 10:40:29 +0400 Subject: [PATCH 03/73] layerbank temp set apyreward on manta to 0 --- src/adaptors/layerbank/index.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/adaptors/layerbank/index.js b/src/adaptors/layerbank/index.js index 7d8991ac14..bb0ac93ece 100644 --- a/src/adaptors/layerbank/index.js +++ b/src/adaptors/layerbank/index.js @@ -6,11 +6,7 @@ const abiLABDistributor = require('./abiLABDistributor.json'); const abiLToken = require('./abiLToken.json'); const abiRateModelSlope = require('./abiRateModelSlope.json'); const abiPriceCalculator = require('./abiPriceCalculator.json'); - -const CORE = '0xB7A23Fc0b066051dE58B922dC1a08f33DF748bbf'; -const LABDistributor = '0x67c10B7b8eEFe92EB4DfdEeedd94263632E483b0'; -const LAB = '0x20a512dbdc0d006f46e6ca11329034eb3d18c997'; -const PriceCalculator = '0x38f4384B457F81A4895c93a7503c255eFd0746d2'; +const utils = require('../utils'); const CHAINS = { manta: { @@ -188,14 +184,17 @@ const apy = async (chain) => { await axios.get(`https://coins.llama.fi/prices/current/${priceKeys}`) ).data.coins; - const priceLAB = ( - await sdk.api.abi.call({ - target: PriceCalculator, - abi: abiPriceCalculator.find((m) => m.name === 'priceOf'), - params: [LAB], - chain, - }) - ).output; + const priceLAB = + chain !== 'manta' + ? ( + await sdk.api.abi.call({ + target: PriceCalculator, + abi: abiPriceCalculator.find((m) => m.name === 'priceOf'), + params: [LAB], + chain, + }) + ).output + : null; return allMarkets.map((p, i) => { const price = prices[`${chain}:${underlying[i]}`]?.price; @@ -249,7 +248,7 @@ const main = async () => { const pools = await Promise.all( Object.keys(CHAINS).map((chain) => apy(chain)) ); - return pools.flat(); + return pools.flat().filter((i) => utils.keepFinite(i)); }; module.exports = { From 43d7b43a547ef3e2b8a2902c5162e6d5e4827f06 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Mon, 8 Apr 2024 10:55:20 +0400 Subject: [PATCH 04/73] cellana fix --- src/adaptors/cellana-finance/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adaptors/cellana-finance/index.js b/src/adaptors/cellana-finance/index.js index 7ad28f66e8..77e48b5a77 100644 --- a/src/adaptors/cellana-finance/index.js +++ b/src/adaptors/cellana-finance/index.js @@ -92,7 +92,7 @@ async function main() { // res.push(rs[1]) })); - return [...res]; + return utils.removeDuplicates([...res]); } async function getCurrentVotes (poolAddress ) { From 2f04c24e6037960661adbcec1092f0d8ea86d907 Mon Sep 17 00:00:00 2001 From: Dzianis Ihnatovich Date: Tue, 9 Apr 2024 07:40:20 +0200 Subject: [PATCH 05/73] refactor(Toros): Apy calcs changes (#1261) --- src/adaptors/toros/index.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/adaptors/toros/index.js b/src/adaptors/toros/index.js index 77e0b4682d..f6a3d14afb 100644 --- a/src/adaptors/toros/index.js +++ b/src/adaptors/toros/index.js @@ -13,10 +13,6 @@ const YIELD_PRODUCTS_QUERY = gql` yieldProducts { address } - apyForTorosFunds { - fundAddress - monthly - } } `; @@ -39,6 +35,10 @@ const POOL_DATA_QUERY = gql` } symbol totalValue + apy { + monthly + weekly + } } } `; @@ -48,6 +48,12 @@ const formatValue = (value) => new BN(value).shiftedBy(-18).toNumber(); const getDaysSincePoolCreation = (blockTime) => Math.round((Date.now() / 1000 - +blockTime) / 86400); +const chooseApy = (apy, blockTime, metrics) => { + if (!apy) return calcApy(blockTime, metrics); + + return apy.weekly; +}; + // Fallback APY calculation simply based on pool's past performance const calcApy = (blockTime, metrics) => { const daysActive = getDaysSincePoolCreation(blockTime); @@ -65,16 +71,12 @@ const calcApy = (blockTime, metrics) => { const fetchTorosYieldProducts = async () => { try { const response = await request(DHEDGE_API_URL, YIELD_PRODUCTS_QUERY); - const apyData = response.apyForTorosFunds; const products = await Promise.all( response.yieldProducts.map(async ({ address }) => { const { fund } = await request(DHEDGE_API_URL, POOL_DATA_QUERY, { address, }); - const poolApyData = apyData.find( - ({ fundAddress }) => fundAddress === fund.address - ); - return { ...fund, apy: poolApyData?.monthly }; + return fund; }) ); return products; @@ -120,7 +122,7 @@ const listTorosYieldProducts = async () => { project: 'toros', symbol, tvlUsd: formatValue(totalValue), - apy: apy ?? calcApy(blockTime, performanceMetrics), + apy: chooseApy(apy, blockTime, performanceMetrics), rewardTokens: rewardIncentivisedPool && rewardData?.rewardToken ? [rewardData.rewardToken] @@ -128,7 +130,7 @@ const listTorosYieldProducts = async () => { underlyingTokens: fundComposition .filter(({ amount }) => amount !== '0') .map(({ tokenAddress }) => tokenAddress), - url: `https://toros.finance/pool/${address}`, + url: `https://toros.finance/vault/${address}`, }; } ); From 5a3f2c747cac05375f58747a7f368ec90ddee696 Mon Sep 17 00:00:00 2001 From: henrio123 Date: Tue, 9 Apr 2024 18:59:28 +0300 Subject: [PATCH 06/73] Sommelier- RYE Optimism Vault (#1263) * Sommelier: Add Turbo GHO * Edge case for apys * Sommelier: Add ETH Trend Growth vault * Add Turbo Steth * Add Turbo SOMM * Sommelier: Add Turbo EETH Vault * Sommelier: Add turbo steth 2 vault * Sommelier: Morpho Maxmimizer * Modify next minor version of vaults to handle new holding position logic * Add Turbo divETH & ETHx vaults * Sommelier Add Turbo eETH V2 * Stash changes for partial chain abstraction * Fix chain config issues * Holding postion chain abstraction * Finish abstracting away chains * Add real yield eth on arbitrum * RYUSD-ARB * Turbo-rsETH;Turbo-ezETH * RYE-opt --------- Co-authored-by: Phil Co-authored-by: Phil <30321052+philipjames44@users.noreply.github.com> --- src/adaptors/sommelier/config.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/adaptors/sommelier/config.js b/src/adaptors/sommelier/config.js index 2764d2164f..32ee8861bd 100644 --- a/src/adaptors/sommelier/config.js +++ b/src/adaptors/sommelier/config.js @@ -31,6 +31,9 @@ const turboezeth = '0x27500de405a3212d57177a789e30bb88b0adbec5'; const realYieldEth_arbitrum = '0xC47bB288178Ea40bF520a91826a3DEE9e0DbFA4C'; const realYieldUsd_arbitrum = '0x392B1E6905bb8449d26af701Cdea6Ff47bF6e5A8'; +// Optimism addresses +const realYieldEth_optimism = "0xC47bB288178Ea40bF520a91826a3DEE9e0DbFA4C" + // Rewards on ethereum are paid out in EVM SOMM const ethRewardTokens = ['0xa670d7237398238de01267472c6f13e5b8010fd1']; @@ -38,6 +41,10 @@ const ethRewardTokens = ['0xa670d7237398238de01267472c6f13e5b8010fd1']; // Rewards on arbitrum are paid out in axlSOMM const arbitrumRewardTokens = ['0x4e914bbDCDE0f455A8aC9d59d3bF739c46287Ed2']; + +// Rewards on optimism are paid out in axlSOMM +const optimismRewardTokens = ['0x4e914bbDCDE0f455A8aC9d59d3bF739c46287Ed2']; + // Map of Cellars -> Staking Pool const stakingPools = { ethereum: { @@ -80,6 +87,9 @@ const stakingPools = { + }, + optimism: { + [realYieldEth_optimism]: '0xd700D39be88fB6b54311f95cCA949C3f6835e236', }, }; @@ -517,6 +527,19 @@ const v2p6Pools = [ underlyingTokens: [], url: 'https://app.sommelier.finance/strategies/Turbo-ezETH/manage', }, + { + pool: `${realYieldEth_optimism}-optimism`, + chain: 'optimism', + project, + symbol: 'WETH-wstETH-cbETH-rETH', + poolMeta: 'RealYieldETH', + tvlUsd: 0, + apyBase: 0, + apyReward: 0, + rewardTokens: optimismRewardTokens, + underlyingTokens: [], + url: 'https://app.sommelier.finance/strategies/real-yield-eth-opt/manage', + }, ]; module.exports = { From 5b3aa2e8be08b75d31c771164d53c554971352d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Manojlovi=C4=87?= Date: Tue, 9 Apr 2024 18:01:08 +0200 Subject: [PATCH 07/73] Add UNO yield to Nostra Money Market (#1262) --- src/adaptors/nostra-money-market/index.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/adaptors/nostra-money-market/index.js b/src/adaptors/nostra-money-market/index.js index c4a1d7d6a7..e86d6cbf3a 100644 --- a/src/adaptors/nostra-money-market/index.js +++ b/src/adaptors/nostra-money-market/index.js @@ -127,14 +127,25 @@ const markets = { debtToken: '0x0292be6baee291a148006db984f200dbdb34b12fb2136c70bfe88649c12d934b', }, + UNO: { + address: + '0x0719b5092403233201aa822ce928bd4b551d0cdb071a724edd7dc5e5f57b7f34', + decimals: 18, + supplyTokens: [ + '0x1325caf7c91ee415b8df721fb952fa88486a0fc250063eafddd5d3c67867ce7', + '0x2a3a9d7bcecc6d3121e3b6180b73c7e8f4c5f81c35a90c8dd457a70a842b723', + '0x6757ef9960c5bc711d1ba7f7a3bff44a45ba9e28f2ac0cc63ee957e6cada8ea', + '0x7d717fb27c9856ea10068d864465a2a8f9f669f4f78013967de06149c09b9af', + ], + debtToken: + '0x4b036839a8769c04144cc47415c64b083a2b26e4a7daa53c07f6042a0d35792', + }, }; const starknetFoundationIncentivesEndpoint = 'https://kx58j6x5me.execute-api.us-east-1.amazonaws.com/starknet/fetchFile?file=qa_lending_strk_grant.json'; async function getTokenPrice(token) { - const underlyingToken = - token === markets.nstSTRK.address ? markets.STRK.address : token; - const networkTokenPair = `starknet:${underlyingToken}`; + const networkTokenPair = `starknet:${token}`; return ( await axios.get(`https://coins.llama.fi/prices/current/${networkTokenPair}`) ).data.coins[networkTokenPair].price; From de956b79412e1b811bd26acaa2266af7c67dab94 Mon Sep 17 00:00:00 2001 From: fredwes <6827305+fredwes@users.noreply.github.com> Date: Tue, 9 Apr 2024 22:50:39 -0700 Subject: [PATCH 08/73] Add Seamless ILM 7day APY (#1264) --- src/adaptors/seamless-protocol/index.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/adaptors/seamless-protocol/index.js b/src/adaptors/seamless-protocol/index.js index b60153c0eb..a9b51bda97 100644 --- a/src/adaptors/seamless-protocol/index.js +++ b/src/adaptors/seamless-protocol/index.js @@ -20,7 +20,7 @@ const chainUrlParam = { const ILMs = [ { address: '0x258730e23cF2f25887Cb962d32Bd10b878ea8a4e', - compoundingPeriods: 360, + compoundingPeriods: 1, }, ]; @@ -293,12 +293,14 @@ const getLpPrices = async (blockNumber, assets, decimals) => { const ilmApys = async () => { const latestBlock = await sdk.api.util.getLatestBlock(chain); - const prevBlock = await sdk.api.util.lookupBlock( + const prevBlock1Day = await sdk.api.util.lookupBlock( latestBlock.timestamp - SECONDS_PER_DAY, { chain } ); - - const timeWindow = latestBlock.timestamp - prevBlock.timestamp; + const prevBlock7Day = await sdk.api.util.lookupBlock( + latestBlock.timestamp - (7 * SECONDS_PER_DAY), + { chain } + ); const assets = ( await sdk.api.abi.multiCall({ @@ -337,7 +339,8 @@ const ilmApys = async () => { assets, decimals ); - const prevBlockPrices = await getLpPrices(prevBlock.number, assets, decimals); + const prevBlock1DayPrices = await getLpPrices(prevBlock1Day.number, assets, decimals); + const prevBlock7DayPrices = await getLpPrices(prevBlock7Day.number, assets, decimals); const pools = ILMs.map(({ address, compoundingPeriods }, i) => { return { @@ -348,8 +351,14 @@ const ilmApys = async () => { tvlUsd: Number(ethers.utils.formatUnits(tvlsUSD[i], USD_DECIMALS)), apyBase: calculateApy( latestBlockPrices[i], - prevBlockPrices[i], - timeWindow, + prevBlock1DayPrices[i], + latestBlock.timestamp - prevBlock1Day.timestamp, + compoundingPeriods + ), + apyBase7d: calculateApy( + latestBlockPrices[i], + prevBlock7DayPrices[i], + latestBlock.timestamp - prevBlock7Day.timestamp, compoundingPeriods ), underlyingTokens: [assets[i].underlying || assets[i].collateral], From 577f98fa3ccb979b22d14e6cbd12ec454b27d5a3 Mon Sep 17 00:00:00 2001 From: EPETE-EPETE <89405534+EPETE-EPETE@users.noreply.github.com> Date: Wed, 10 Apr 2024 01:55:00 -0400 Subject: [PATCH 09/73] change vaults endpoint to include CLM (#1265) --- src/adaptors/beefy/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adaptors/beefy/index.js b/src/adaptors/beefy/index.js index ad65508e33..0305c87754 100644 --- a/src/adaptors/beefy/index.js +++ b/src/adaptors/beefy/index.js @@ -3,7 +3,7 @@ const utils = require('../utils'); const url = 'https://api.beefy.finance'; const urlApy = `${url}/apy`; const urlTvl = `${url}/tvl`; -const urlMeta = `${url}/vaults`; +const urlMeta = `${url}/harvestable-vaults`; const networkMapping = { 1: 'ethereum', From 6039ce9820ba92a4d48f59e8649423cd925e0be2 Mon Sep 17 00:00:00 2001 From: Eren Jaegar <88328748+erenjaegar77@users.noreply.github.com> Date: Thu, 11 Apr 2024 03:57:23 -0300 Subject: [PATCH 10/73] improve beefy adapter (#1266) --- src/adaptors/beefy/index.js | 169 +++++++++++++++++++++--------------- 1 file changed, 101 insertions(+), 68 deletions(-) diff --git a/src/adaptors/beefy/index.js b/src/adaptors/beefy/index.js index 0305c87754..2a33258d1f 100644 --- a/src/adaptors/beefy/index.js +++ b/src/adaptors/beefy/index.js @@ -1,104 +1,137 @@ -const utils = require('../utils'); +const { + formatChain, + formatSymbol, + getData, + removeDuplicates +} = require('../utils'); const url = 'https://api.beefy.finance'; const urlApy = `${url}/apy`; const urlTvl = `${url}/tvl`; -const urlMeta = `${url}/harvestable-vaults`; +const urlVaults = `${url}/harvestable-vaults`; +const urlGovVaults = `${url}/gov-vaults`; +const urlAddressbook = `${url}/tokens`; const networkMapping = { 1: 'ethereum', 10: 'optimism', - 43114: 'avalanche', - 1666600000: 'harmony', - 42220: 'celo', - 42161: 'arbitrum', - 1285: 'moonriver', - 1088: 'metis', - 250: 'fantom', - 137: 'polygon', - 128: 'heco', - 122: 'fuse', - 56: 'binance', 25: 'cronos', + 56: 'bsc', + 100: 'gnosis', + 122: 'fuse', + 128: 'heco', + 137: 'polygon', + 250: 'fantom', + 252: 'fraxtal', + 324: 'zksync', + 1088: 'metis', + 1101: 'polygon_zkevm', 1284: 'moonbeam', + 1285: 'moonriver', + 2222: 'kava', + 5000: 'mantle', + 7700: 'canto', + 8453: 'base', + 42161: 'arbitrum', + 42220: 'celo', 42262: 'oasis', + 43114: 'avalanche', + 59144: 'linea', 1313161554: 'aurora', - 8453: 'base', -}; - -// hardcode bifi token addresses per chain -const bifiMapping = { - 1: '0x5870700f1272a1AdbB87C3140bD770880a95e55D', - 10: '0x4E720DD3Ac5CFe1e1fbDE4935f386Bb1C66F4642', - 43114: '0xd6070ae98b8069de6B494332d1A1a81B6179D960', - 1666600000: '0x6ab6d61428fde76768d7b45d8bfeec19c6ef91a8', - 42220: '0x639A647fbe20b6c8ac19E48E2de44ea792c62c5C', - 42161: '0x99C409E5f62E4bd2AC142f17caFb6810B8F0BAAE', - 1285: '0x173fd7434B8B50dF08e3298f173487ebDB35FD14', - 1088: '0xe6801928061CDbE32AC5AD0634427E140EFd05F9', - 250: '0xd6070ae98b8069de6b494332d1a1a81b6179d960', - 137: '0xFbdd194376de19a88118e84E279b977f165d01b8', - 128: '0x765277eebeca2e31912c9946eae1021199b39c61', - 122: '0x2bF9b864cdc97b08B6D79ad4663e71B8aB65c45c', - 56: '0xCa3F508B8e4Dd382eE878A314789373D80A5190A', - 25: '0xe6801928061CDbE32AC5AD0634427E140EFd05F9', - 1284: '0x595c8481c48894771CE8FaDE54ac6Bf59093F9E8', - 42262: '0x65e66a61D0a8F1e686C2D6083ad611a10D84D97A', - 1313161554: '0x218c3c3D49d0E7B37aff0D8bB079de36Ae61A4c0', - 8453: '0xb4aa172f1Cf73cCC41290A8477F72CFB2ded46dd', + 1666600000: 'harmony' }; const main = async () => { - const [apy, tvl, meta] = await Promise.all( - [urlApy, urlTvl, urlMeta].map((u) => utils.getData(u)) + const [apys, tvlsByChain, vaults, govVaults, tokens] = await Promise.all( + [urlApy, urlTvl, urlVaults, urlGovVaults, urlAddressbook].map((u) => + getData(u) + ) ); - let data = []; - for (const chain of Object.keys(networkMapping)) { - const poolData = tvl[chain]; - for (const pool of Object.keys(poolData)) { - if (apy[pool] === undefined) { + const data = []; + for (const [chainId, tvls] of Object.entries(tvlsByChain)) { + const llamaChain = networkMapping[chainId]; + if (!llamaChain) { + // console.debug(`Skipping chain ${chainId}, not in networkMapping`); + continue; + } + + for (const [vaultId, tvl] of Object.entries(tvls)) { + let vault = vaults.find((v) => v.id === vaultId); + if (vault === undefined) { + vault = govVaults.find((v) => v.id === vaultId); + } + + if (vault === undefined) { + // console.debug(`Skipping vault ${vaultId}, no vault data`); + continue; + } + + if (tvl === undefined || tvl === null) { + // console.debug(`Skipping vault ${vaultId}, no TVL data`); continue; } - const poolMeta = meta.find((m) => m?.id === pool); - const platformId = poolMeta?.platformId; - const poolId = - poolMeta === undefined - ? bifiMapping[chain] - : poolMeta.earnedTokenAddress; + const apy = apys[vaultId] || 0; + + const { + assets, + platformId, + depositTokenAddresses, + earnContractAddress, + chain, + type, + tokenAddress + } = vault; - const isActive = poolMeta === undefined || poolMeta.status == 'active'; + const tokenSymbols = []; + const tokenAddresses = []; - if (!poolId) continue; + for (const assetId of assets) { + const token = tokens[chain]?.[assetId]; + if (token) { + const { address, symbol } = token; + if (address) { + tokenAddresses.push( + address === 'native' + ? '0x0000000000000000000000000000000000000000' + : address + ); + } + if (symbol) { + tokenSymbols.push(symbol); + } + } else { + // fallback to assetId if token not found + tokenSymbols.push(assetId); + } + } const underlyingTokens = - !!poolMeta && poolMeta.assets.length === 1 && poolMeta.tokenAddress - ? [poolMeta.tokenAddress] - : undefined; + tokenAddresses.length === 0 && assets.length === 1 + ? [tokenAddress] + : type === 'cowcentrated' + ? depositTokenAddresses + : tokenAddresses; data.push({ - pool: `${poolId}-${networkMapping[chain]}`.toLowerCase(), - chain: utils.formatChain(networkMapping[chain]), + pool: `${earnContractAddress}-${llamaChain}`.toLowerCase(), + chain: formatChain(llamaChain), project: 'beefy', - symbol: - poolMeta === undefined - ? 'BIFI' - : utils.formatSymbol(poolMeta?.assets.join('-')), - tvlUsd: poolData[pool], - apy: isActive ? apy[pool] * 100 : 0, - poolMeta: - platformId === undefined ? null : utils.formatChain(platformId), - underlyingTokens, + symbol: formatSymbol(tokenSymbols.join('-')), + tvlUsd: tvl, + apy: apy * 100, + poolMeta: formatChain(platformId), + underlyingTokens }); } } - return utils.removeDuplicates(data); + return removeDuplicates(data); }; module.exports = { timetravel: false, apy: main, - url: 'https://app.beefy.com/', -}; + url: 'https://app.beefy.com/' +}; \ No newline at end of file From 92280d69a153c1139ebb262de40a284a7bd5dadf Mon Sep 17 00:00:00 2001 From: halfdoctor Date: Thu, 11 Apr 2024 07:59:48 +0100 Subject: [PATCH 11/73] SONNE Finance on Base chain reward APR non propogation error fixed. (#1268) --- src/adaptors/sonne-finance/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adaptors/sonne-finance/index.js b/src/adaptors/sonne-finance/index.js index 57823e884a..c020c68189 100644 --- a/src/adaptors/sonne-finance/index.js +++ b/src/adaptors/sonne-finance/index.js @@ -172,7 +172,7 @@ const lendingApy = async (chain) => { chain ); - const SONNE = CHAINS[chain].SONNE; + const SONNE = CHAINS.optimism.SONNE; const prices = await getPrices( underlyingTokens From c60a25c036557e7de6d4fdba028ea1a3fe624db1 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Thu, 11 Apr 2024 19:00:05 +0400 Subject: [PATCH 12/73] notional add back arbitrum pools --- src/adaptors/notional-v3/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adaptors/notional-v3/index.js b/src/adaptors/notional-v3/index.js index 0312f35945..6e90cea7a2 100644 --- a/src/adaptors/notional-v3/index.js +++ b/src/adaptors/notional-v3/index.js @@ -10,8 +10,8 @@ const API = (chain) => const NOTE_Mainnet = '0xCFEAead4947f0705A14ec42aC3D44129E1Ef3eD5'; const SUBGRAPHS = { - // arbitrum: - // 'https://api.studio.thegraph.com/query/36749/notional-v3-arbitrum/version/latest', + arbitrum: + 'https://api.studio.thegraph.com/query/36749/notional-v3-arbitrum/version/latest', ethereum: 'https://api.studio.thegraph.com/query/36749/notional-v3-mainnet/version/latest', }; From cfe48f9f60bbbd1de328af0b78490c28080a04ec Mon Sep 17 00:00:00 2001 From: Alik Mikhaylov <92106180+Parzival11l@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:04:39 +0300 Subject: [PATCH 13/73] feat(adaptors): adds liquidswap farms (#1269) * feat(index/api/constants/utils) creates * fix(constants) update uniqueFarmKey * fix(constants) deployed pool address update --- src/adaptors/liquidswap/api.js | 68 ++++++++++ src/adaptors/liquidswap/constants.js | 87 +++++++++++++ src/adaptors/liquidswap/index.js | 179 +++++++++++++++++++++++++++ src/adaptors/liquidswap/utils.js | 93 ++++++++++++++ 4 files changed, 427 insertions(+) create mode 100644 src/adaptors/liquidswap/api.js create mode 100644 src/adaptors/liquidswap/constants.js create mode 100644 src/adaptors/liquidswap/index.js create mode 100644 src/adaptors/liquidswap/utils.js diff --git a/src/adaptors/liquidswap/api.js b/src/adaptors/liquidswap/api.js new file mode 100644 index 0000000000..b76f0ca9b5 --- /dev/null +++ b/src/adaptors/liquidswap/api.js @@ -0,0 +1,68 @@ +const utils = require('../utils'); +const { + getPoolTotalLPUrl, + getFarmResourceUrl, + getPoolResourceUrl, +} = require('./utils'); + +async function fetchPoolTotalMintedLP(coinX, coinY, curve, resourceAccount) { + const response = await utils.getData( + getPoolTotalLPUrl(coinX, coinY, curve, resourceAccount) + ); + + return BigInt(response.data.supply.vec[0].integer.vec[0].value); +} + +async function fetchFarmPoolData( + deployedAddress, + coinX, + coinY, + curve, + reward, + resourceAccount +) { + const response = await utils.getData( + getFarmResourceUrl( + deployedAddress, + coinX, + coinY, + curve, + reward, + resourceAccount + ) + ); + + return { + rewardPerSecond: BigInt(response.data.reward_per_sec), + stakeCoins: BigInt(response.data.stake_coins.value), + totalBoosted: BigInt(response.data.total_boosted), + }; +} + +async function fetchLiquidityPoolData( + coinX, + coinY, + curve, + resourceAccount, + moduleAccount +) { + const response = await utils.getData( + getPoolResourceUrl(coinX, coinY, curve, resourceAccount, moduleAccount) + ); + + return { + coinXReserves: BigInt(response.data.coin_x_reserve.value), + coinYReserves: BigInt(response.data.coin_y_reserve.value), + }; +} + +async function getAPRsFromSentio() { + return await utils.getData('https://api.liquidswap.com/sentio/apr') +} + +module.exports = { + fetchFarmPoolData, + fetchLiquidityPoolData, + fetchPoolTotalMintedLP, + getAPRsFromSentio, +}; diff --git a/src/adaptors/liquidswap/constants.js b/src/adaptors/liquidswap/constants.js new file mode 100644 index 0000000000..a47de76927 --- /dev/null +++ b/src/adaptors/liquidswap/constants.js @@ -0,0 +1,87 @@ +const LP_DECIMALS = 6; +const LP_STAKING_ACCOUNT = + '0xb247ddeee87e848315caf9a33b8e4c71ac53db888cb88143d62d2370cca0ead2'; + +const RESOURCES_ACCOUNT_0_5 = + '0x61d2c22a6cb7831bee0f48363b0eec92369357aece0d1142062f7d5d85c7bef8'; +const MODULE_ACCOUNT_0_5 = + '0x163df34fccbf003ce219d3f1d9e70d140b60622cb9dd47599c25fb2f797ba6e'; + +const NODE_URL = 'https://fullnode.mainnet.aptoslabs.com/v1'; +const APTOS_TOKEN = '0x1::aptos_coin::AptosCoin'; +const AMNIS_ST_APT = + '0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a::stapt_token::StakedApt'; +const LZ_USDC = + '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC'; +const UNCORRELATED_CURVE = + '0x163df34fccbf003ce219d3f1d9e70d140b60622cb9dd47599c25fb2f797ba6e::curves::Uncorrelated'; +const APTOS_COINGECKO_ID = 'aptos'; +const AMNIS_ST_APT_COINGECKO_ID = 'amnis-staked-aptos-coin'; +const LZ_USDC_COINGECKO_ID = 'usd-coin'; + +const APT_AMNIS_STAPT_FARM = { + deployedAddress: '0xe5d1cbab351261717d7b44787596033c691e4dd80cc3dede9a8682a6ec52214f', + coinX: { + type: APTOS_TOKEN, + decimals: 8, + coinGeckoId: APTOS_COINGECKO_ID, + symbol: 'APT', + }, + coinY: { + type: AMNIS_ST_APT, + decimals: 8, + coinGeckoId: AMNIS_ST_APT_COINGECKO_ID, + symbol: 'amStApt', + }, + curve: UNCORRELATED_CURVE, + rewardTokenInfo: { + type: APTOS_TOKEN, + decimals: 8, + coinGeckoId: APTOS_COINGECKO_ID, + symbol: 'APT', + }, + resourceAccount: RESOURCES_ACCOUNT_0_5, + moduleAccount: MODULE_ACCOUNT_0_5, + uniqueFarmKey: '0xe5d1cbab351261717d7b44787596033c691e4dd80cc3dede9a8682a6ec52214f-APT-amStApt-UNCORRELATED' +}; + +const USDC_AMNIS_STAPT_FARM = { + deployedAddress: '0x07abf560d050c0249a610f9b78513dd8253b85dd14b9e7bedb86f8c6bb96cf64', + coinX: { + type: LZ_USDC, + decimals: 6, + coinGeckoId: LZ_USDC_COINGECKO_ID, + symbol: 'zUSDC', + }, + coinY: { + type: AMNIS_ST_APT, + decimals: 8, + coinGeckoId: AMNIS_ST_APT_COINGECKO_ID, + symbol: 'amStApt', + }, + curve: UNCORRELATED_CURVE, + rewardTokenInfo: { + type: APTOS_TOKEN, + decimals: 8, + coinGeckoId: APTOS_COINGECKO_ID, + symbol: 'APT', + }, + resourceAccount: RESOURCES_ACCOUNT_0_5, + moduleAccount: MODULE_ACCOUNT_0_5, + uniqueFarmKey: '0x07abf560d050c0249a610f9b78513dd8253b85dd14b9e7bedb86f8c6bb96cf64-zUSDC-amStApt-UNCORRELATED' +}; + +const FARMS = [APT_AMNIS_STAPT_FARM, USDC_AMNIS_STAPT_FARM]; + +const WEEK_SEC = 7 * 24 * 60 * 60; + +module.exports = { + LP_DECIMALS, + LP_STAKING_ACCOUNT, + RESOURCES_ACCOUNT_0_5, + NODE_URL, + FARMS, + USDC_AMNIS_STAPT_FARM, + APT_AMNIS_STAPT_FARM, + WEEK_SEC, +}; diff --git a/src/adaptors/liquidswap/index.js b/src/adaptors/liquidswap/index.js new file mode 100644 index 0000000000..c157fb51a4 --- /dev/null +++ b/src/adaptors/liquidswap/index.js @@ -0,0 +1,179 @@ +const { BigNumber } = require('bignumber.js'); +const utils = require('../utils'); +const { FARMS, NODE_URL, LP_DECIMALS, WEEK_SEC } = require('./constants'); +const { + getUSDEquivalent, + getPoolTotalLPUrl, + decimalsMultiplier, + getFarmResourceUrl, + getAmountWithDecimal, + calcOutputBurnLiquidity, + calcRewardPerWeekPerOneLp, +} = require('./utils'); +const { + fetchFarmPoolData, + fetchLiquidityPoolData, + fetchPoolTotalMintedLP, + getAPRsFromSentio, +} = require('./api'); + +async function getAPRandTVL(farmPool) { + // calc ARP + const decimalsReward = decimalsMultiplier( + farmPool.rewardTokenInfo.decimals + ).toNumber(); + + const farmData = await fetchFarmPoolData( + farmPool.deployedAddress, + farmPool.coinX.type, + farmPool.coinY.type, + farmPool.curve, + farmPool.rewardTokenInfo.type, + farmPool.resourceAccount + ); + + const rewardPerWeekPerOneLP = calcRewardPerWeekPerOneLp( + farmData, + farmPool.rewardTokenInfo + ); + + const liquidityPoolData = await fetchLiquidityPoolData( + farmPool.coinX.type, + farmPool.coinY.type, + farmPool.curve, + farmPool.resourceAccount, + farmPool.moduleAccount + ); + + const liquidityPoolTotalMintedLPValue = await fetchPoolTotalMintedLP( + farmPool.coinX.type, + farmPool.coinY.type, + farmPool.curve, + farmPool.resourceAccount + ); + + const poolTokensPrices = await utils.getPrices([ + `coingecko:${farmPool.rewardTokenInfo.coinGeckoId}`, + `coingecko:${farmPool.coinX.coinGeckoId}`, + `coingecko:${farmPool.coinY.coinGeckoId}`, + ]); + + const rewardTokenPriceValue = + poolTokensPrices.pricesByAddress[farmPool.rewardTokenInfo.coinGeckoId]; + + const rewardPerWeekHumanReadable = getAmountWithDecimal( + rewardPerWeekPerOneLP, + farmPool.rewardTokenInfo.decimals + ); + + const rewardPerWeekInUSD = getUSDEquivalent( + rewardPerWeekHumanReadable, + rewardTokenPriceValue + ); + + const oneLPHumanReadableValue = decimalsMultiplier(LP_DECIMALS).toNumber(); + + const afterBurnOneLpValue = calcOutputBurnLiquidity({ + xReserve: liquidityPoolData.coinXReserves, + yReserve: liquidityPoolData.coinYReserves, + lpSupply: liquidityPoolTotalMintedLPValue, + toBurn: oneLPHumanReadableValue, + }); + + const oneLpXRateHumanReadableAPR = getAmountWithDecimal( + afterBurnOneLpValue.x, + farmPool.coinX.decimals + ); + + const oneLpYRateHumanReadableAPR = getAmountWithDecimal( + afterBurnOneLpValue.y, + farmPool.coinY.decimals + ); + + const oneLpXRateInUSD = getUSDEquivalent( + oneLpXRateHumanReadableAPR, + poolTokensPrices.pricesByAddress[farmPool.coinX.coinGeckoId] + ); + + const oneLpYRateInUSD = getUSDEquivalent( + oneLpYRateHumanReadableAPR, + poolTokensPrices.pricesByAddress[farmPool.coinY.coinGeckoId] + ); + + const oneLpInUSD = oneLpXRateInUSD + oneLpYRateInUSD; + + const APR = ((rewardPerWeekInUSD / oneLpInUSD) * 100 * 365) / 7; + + // calc TVL + const TVLCalculationData = calcOutputBurnLiquidity({ + xReserve: liquidityPoolData.coinXReserves, + yReserve: liquidityPoolData.coinYReserves, + lpSupply: liquidityPoolTotalMintedLPValue, + toBurn: farmData.stakeCoins, + }); + + const oneLpXRateHumanReadableTVL = getAmountWithDecimal( + TVLCalculationData.x, + farmPool.coinX.decimals + ); + + const oneLpYRateHumanReadableTVL = getAmountWithDecimal( + TVLCalculationData.y, + farmPool.coinY.decimals + ); + + const oneLpXRateInUSDTVL = getUSDEquivalent( + oneLpXRateHumanReadableTVL, + poolTokensPrices.pricesByAddress[farmPool.coinX.coinGeckoId] + ); + + const oneLpYRateInUSDTVL = getUSDEquivalent( + oneLpYRateHumanReadableTVL, + poolTokensPrices.pricesByAddress[farmPool.coinY.coinGeckoId] + ); + + const TVL = oneLpXRateInUSDTVL + oneLpYRateInUSDTVL; + + return { + apr: APR, + tvl: TVL, + }; +} + +async function main() { + const pools = []; + + for (let farmPool of FARMS) { + const farmPoolInfo = await getAPRandTVL(farmPool); + const { deployedAddress, coinX, coinY, curve, uniqueFarmKey, } = farmPool; + + const aprs = await getAPRsFromSentio(); + + const aprBase = aprs.data.find((el) => ( + (el.alias.pair === `${coinX.symbol}-${coinY.symbol}` || + el.alias.pair === `${coinY.symbol}-${coinX.symbol}`) && + (el.alias.ver === 'v0.5') && + (el.alias.curve === 'Uncorrelated') + ) + ).apr + + const apy = (farmPoolInfo.apr + aprBase) + + pools.push({ + pool: uniqueFarmKey, + chain: utils.formatChain('aptos'), + project: 'liquidswap', + symbol: `${coinX.symbol}-${coinY.symbol}`, + tvlUsd: farmPoolInfo.tvl, + apy, + }); + } + + return pools; +} + +module.exports = { + timetravel: false, + apy: main, + url: 'https://farms.liquidswap.com/#/stakes', +}; diff --git a/src/adaptors/liquidswap/utils.js b/src/adaptors/liquidswap/utils.js new file mode 100644 index 0000000000..73c17cff07 --- /dev/null +++ b/src/adaptors/liquidswap/utils.js @@ -0,0 +1,93 @@ +const { + FARMS, + NODE_URL, + LP_STAKING_ACCOUNT, + LP_DECIMALS, + WEEK_SEC, +} = require('./constants'); +const { BigNumber } = require('bignumber.js'); + +function getFarmResourceUrl( + deploymentAddress, + coinXType, + coinYType, + curveType, + rewardType, + resourceAccount +) { + return `${NODE_URL}/accounts/${deploymentAddress}/resource/${LP_STAKING_ACCOUNT}::stake::StakePool<${resourceAccount}::lp_coin::LP<${coinXType},${coinYType},${curveType}>,${rewardType}>`; +} + +function getPoolResourceUrl( + coinXType, + coinYType, + curveType, + resourceAccount, + moduleAccount +) { + return `${NODE_URL}/accounts/${resourceAccount}/resource/${moduleAccount}::liquidity_pool::LiquidityPool<${coinXType},${coinYType},${curveType}>`; +} + +function getPoolTotalLPUrl(coinXType, coinYType, curveType, resourceAccount) { + return `${NODE_URL}/accounts/${resourceAccount}/resource/0x1::coin::CoinInfo<${resourceAccount}::lp_coin::LP<${coinXType},${coinYType},${curveType}>>`; +} + +function calcOutputBurnLiquidity({ xReserve, yReserve, lpSupply, toBurn }) { + const xReturn = BigNumber(toBurn).multipliedBy(xReserve).dividedBy(lpSupply); + const yReturn = BigNumber(toBurn).multipliedBy(yReserve).dividedBy(lpSupply); + + if (xReturn.isEqualTo(0) || yReturn.isEqualTo(0)) { + return undefined; + } + + return { + x: Math.trunc(xReturn.toNumber()), + y: Math.trunc(yReturn.toNumber()), + }; +} + +function getAmountWithDecimal(amount, decimal) { + if (amount === undefined) return; + + return +BigNumber(amount) + .dividedBy(decimalsMultiplier(decimal)) + .toFixed(decimal); +} + +function decimalsMultiplier(decimals) { + return BigNumber(10).exponentiatedBy(BigNumber(decimals).absoluteValue()); +} + +function calcRewardPerWeekPerOneLp(farmData, rewardToken) { + const decimalsReward = decimalsMultiplier(rewardToken.decimals).toNumber(); + + const decimalsLP = decimalsMultiplier(LP_DECIMALS).toNumber(); + const numerator = BigNumber(farmData.rewardPerSecond).multipliedBy(WEEK_SEC); + const denominator = BigNumber(farmData.stakeCoins) + .plus(farmData.totalBoosted) + .plus(decimalsLP); + + const estimation = BigNumber(numerator).dividedBy(denominator); + const normalizer = BigNumber(decimalsLP).dividedBy(decimalsReward); + const rewardPerWeekOnLp = estimation + .multipliedBy(normalizer) + .multipliedBy(decimalsReward); + + return rewardPerWeekOnLp.toNumber(); +} + +function getUSDEquivalent(coinAmount, usdRate) { + if (!coinAmount || !usdRate) return 0; + return BigNumber(coinAmount).multipliedBy(BigNumber(usdRate)).toNumber(); +} + +module.exports = { + getUSDEquivalent, + getPoolTotalLPUrl, + decimalsMultiplier, + getFarmResourceUrl, + getPoolResourceUrl, + getAmountWithDecimal, + calcOutputBurnLiquidity, + calcRewardPerWeekPerOneLp, +}; From 25da060d5bea7f9737223e09e003fe25dbeb2165 Mon Sep 17 00:00:00 2001 From: 0xngmi <0xngmi@protonmail.com> Date: Sat, 13 Apr 2024 02:51:37 +0100 Subject: [PATCH 14/73] add sfrax --- src/adaptors/frax/index.js | 12 +++++++++++- src/adaptors/helpers/erc4626.js | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/adaptors/helpers/erc4626.js diff --git a/src/adaptors/frax/index.js b/src/adaptors/frax/index.js index 8ca42ace4d..ac3392fb33 100644 --- a/src/adaptors/frax/index.js +++ b/src/adaptors/frax/index.js @@ -4,6 +4,7 @@ const utils = require('../utils'); const { farmAbi, pairAbi } = require('./abi'); const { vstFraxStaking } = require('./vstFraxStaking'); +const { getERC4626Info } = require('../helpers/erc4626'); const FRAXSWAP_POOLS_URL = 'https://api.frax.finance/v2/fraxswap/pools'; const STAKING_URL = 'https://api.frax.finance/v1/pools'; @@ -20,7 +21,15 @@ const STAKING_CONTRACTS = { 'Fraxswap FRAX/SYN': '0xE8453a2e8E97cba69365A1d727Fde3768b18d814', }; -const apy = async () => { +const apy = async (timestamp) => { + const sfrax = await getERC4626Info("0xA663B02CF0a4b149d2aD41910CB81e23e1c41c32", "ethereum", timestamp) + const sfraxvault = { + ...sfrax, + project: 'frax', + symbol: `sFRAX`, + tvlUsd: sfrax.tvl/1e18, + underlyingTokens: ["0x853d955acef822db058eb8505911ed77f175b99e"], + }; const { pools: fxswapData } = await utils.getData(FRAXSWAP_POOLS_URL); const stakingData = await utils .getData(STAKING_URL) @@ -85,6 +94,7 @@ const apy = async () => { return fraxSwapRes .concat(stakingRes) .concat(vstFraxStakingRes) + .concat([sfraxvault]) .filter(Boolean); }; diff --git a/src/adaptors/helpers/erc4626.js b/src/adaptors/helpers/erc4626.js new file mode 100644 index 0000000000..f38e8bfa6a --- /dev/null +++ b/src/adaptors/helpers/erc4626.js @@ -0,0 +1,34 @@ +const sdk = require('@defillama/sdk4'); +const utils = require('../utils'); + +const DAY = 24*3600 + +async function getERC4626Info(address, chain, timestamp = Math.floor(Date.now()/1e3), { + assetUnit = "100000000000000000", + totalAssetsAbi = "uint:totalAssets", + convertToAssetsAbi = "function convertToAssets(uint256 shares) external view returns (uint256)" +}={}){ + const [blockNow, blockYesterday] = await Promise.all([timestamp, timestamp - DAY].map(time=>utils.getData(`https://coins.llama.fi/block/${chain}/${time}`).then(r=>r.height))) + const [tvl, priceNow, priceYesterday] = await Promise.all([ + sdk.api.abi.call({ + target: address, block: blockNow, abi:totalAssetsAbi + }), + sdk.api.abi.call({ + target: address, block: blockNow, abi:convertToAssetsAbi, params: [assetUnit] + }), + sdk.api.abi.call({ + target: address, block: blockYesterday, abi:convertToAssetsAbi, params: [assetUnit] + }), + ]) + const apy = (priceNow.output/priceYesterday.output)**365 * 100 - 100 + return { + pool: address, + chain: utils.formatChain(chain), + tvl: tvl.output, + apyBase: apy, + } +} + +module.exports = { + getERC4626Info +} \ No newline at end of file From 6cb2d56263cc18bbf3d1ad4565b4a4a289f00dcf Mon Sep 17 00:00:00 2001 From: 0xngmi <0xngmi@protonmail.com> Date: Sat, 13 Apr 2024 02:56:11 +0100 Subject: [PATCH 15/73] fix --- src/adaptors/helpers/erc4626.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adaptors/helpers/erc4626.js b/src/adaptors/helpers/erc4626.js index f38e8bfa6a..eddbf8f15b 100644 --- a/src/adaptors/helpers/erc4626.js +++ b/src/adaptors/helpers/erc4626.js @@ -1,4 +1,4 @@ -const sdk = require('@defillama/sdk4'); +const sdk = require('@defillama/sdk5'); const utils = require('../utils'); const DAY = 24*3600 From 8b6308092e72887f8ddefb2a7f804817495e5fb3 Mon Sep 17 00:00:00 2001 From: Carlos Alvarez <76534971+carlosalv098@users.noreply.github.com> Date: Sat, 13 Apr 2024 01:15:48 -0600 Subject: [PATCH 16/73] add all money markets (#1270) --- src/adaptors/hatom-lending/index.js | 14 ++++++++++---- src/adaptors/hatom-lending/utils/data.js | 5 +++-- src/adaptors/hatom-lending/utils/math.js | 2 +- src/adaptors/hatom-lending/utils/queries.js | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/adaptors/hatom-lending/index.js b/src/adaptors/hatom-lending/index.js index a9b2fdf066..1dd7e9de37 100644 --- a/src/adaptors/hatom-lending/index.js +++ b/src/adaptors/hatom-lending/index.js @@ -4,10 +4,16 @@ const { calcRewardsAPY } = require('./utils/math.js'); const { getMoneyMarkets, getTokenPrices, getExchangeRates, getRewardsBatches, getBoostedRewards, getBoostedColateralMap } = require('./utils/data.js'); const MARKETS = [ - { symbol: "USDC", address: "erd1qqqqqqqqqqqqqpgqkrgsvct7hfx7ru30mfzk3uy6pxzxn6jj78ss84aldu" }, - { symbol: 'WBTC', address: "erd1qqqqqqqqqqqqqpgqg47t8v5nwzvdxgf6g5jkxleuplu8y4f678ssfcg5gy" }, - { symbol: "WETH", address: "erd1qqqqqqqqqqqqqpgq8h8upp38fe9p4ny9ecvsett0usu2ep7978ssypgmrs" }, - { symbol: "USDT", address: "erd1qqqqqqqqqqqqqpgqvxn0cl35r74tlw2a8d794v795jrzfxyf78sstg8pjr" } + { symbol: 'EGLD', address: 'erd1qqqqqqqqqqqqqpgq35qkf34a8svu4r2zmfzuztmeltqclapv78ss5jleq3' }, + { symbol: 'SEGLD', address: 'erd1qqqqqqqqqqqqqpgqxmn4jlazsjp6gnec95423egatwcdfcjm78ss5q550k' }, + { symbol: 'WBTC', address: 'erd1qqqqqqqqqqqqqpgqg47t8v5nwzvdxgf6g5jkxleuplu8y4f678ssfcg5gy' }, + { symbol: 'WETH', address: 'erd1qqqqqqqqqqqqqpgq8h8upp38fe9p4ny9ecvsett0usu2ep7978ssypgmrs' }, + { symbol: 'USDC', address: 'erd1qqqqqqqqqqqqqpgqkrgsvct7hfx7ru30mfzk3uy6pxzxn6jj78ss84aldu' }, + { symbol: 'USDT', address: 'erd1qqqqqqqqqqqqqpgqvxn0cl35r74tlw2a8d794v795jrzfxyf78sstg8pjr' }, + { symbol: 'UTK', address: 'erd1qqqqqqqqqqqqqpgqta0tv8d5pjzmwzshrtw62n4nww9kxtl278ssspxpxu' }, + { symbol: 'HTM', address: 'erd1qqqqqqqqqqqqqpgqxerzmkr80xc0qwa8vvm5ug9h8e2y7jgsqk2svevje0' }, + { symbol: 'WTAO', address: 'erd1qqqqqqqqqqqqqpgqz9pvuz22qvqxfqpk6r3rluj0u2can55c78ssgcqs00' }, + { symbol: 'SWTAO', address: 'erd1qqqqqqqqqqqqqpgq7sspywe6e2ehy7dn5dz00ved3aa450mv78ssllmln6'}, ] const apy = async () => { diff --git a/src/adaptors/hatom-lending/utils/data.js b/src/adaptors/hatom-lending/utils/data.js index 8ca79ca16e..9aff8644dc 100644 --- a/src/adaptors/hatom-lending/utils/data.js +++ b/src/adaptors/hatom-lending/utils/data.js @@ -2,10 +2,11 @@ const BigNumber = require('bignumber.js'); const { default: axios } = require('axios'); const { request } = require('graphql-request'); -const { queryPrices, queryMoneyMarkets, queryRewards } = require('./queries') +const { queryPrices, queryMoneyMarkets, queryRewards } = require('./queries'); const { calcLiquidStakingExchangeRate, calcSimulateExchangeRate } = require('./math'); const API_URL = 'https://mainnet-api.hatom.com/graphql'; +const WAD = '1000000000000000000'; async function getMoneyMarkets() { const response = await request(API_URL, queryMoneyMarkets, {}); @@ -56,7 +57,7 @@ async function getTokenPrices() { if (tokenItem.symbol == 'EGLD') { dailyPriceInEgld = '1'; } else if (tokenItem.symbol == 'SEGLD') { - dailyPriceInEgld = new BigNumber(1).multipliedBy(liquidStakingExchangeRate).dividedBy(BigNumber.WAD).toString(); + dailyPriceInEgld = new BigNumber(1).multipliedBy(liquidStakingExchangeRate).dividedBy(WAD); } else { dailyPriceInEgld = priceEgld; } diff --git a/src/adaptors/hatom-lending/utils/math.js b/src/adaptors/hatom-lending/utils/math.js index 654585ec60..3e825db68d 100644 --- a/src/adaptors/hatom-lending/utils/math.js +++ b/src/adaptors/hatom-lending/utils/math.js @@ -80,7 +80,7 @@ const calcLiquidStakingExchangeRate = (cashReserve, totalShares) => { } return new BigNumber(cashReserve) - .multipliedBy(`1e18`) + .multipliedBy('1e18') .dividedBy(totalShares) .toFixed(0, BigNumber.ROUND_DOWN); }; diff --git a/src/adaptors/hatom-lending/utils/queries.js b/src/adaptors/hatom-lending/utils/queries.js index f3fa2a6db1..2bbf6c391d 100644 --- a/src/adaptors/hatom-lending/utils/queries.js +++ b/src/adaptors/hatom-lending/utils/queries.js @@ -64,7 +64,7 @@ query QueryRewards { underlying{ symbol } - } + } rewardsToken{ symbol decimals From e36d5ad233195cbf0d81b20ab25968de2235b70d Mon Sep 17 00:00:00 2001 From: slasher125 Date: Sun, 14 Apr 2024 21:49:21 +0400 Subject: [PATCH 17/73] meta pool add 7day apy --- src/adaptors/meta-pool-eth/index.js | 31 ++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/adaptors/meta-pool-eth/index.js b/src/adaptors/meta-pool-eth/index.js index 9eadf0d058..5183d6f78c 100644 --- a/src/adaptors/meta-pool-eth/index.js +++ b/src/adaptors/meta-pool-eth/index.js @@ -7,28 +7,44 @@ const token = '0x48AFbBd342F64EF8a9Ab1C143719b63C2AD81710'; const weth = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; const apy = async () => { - const timestamp1dayAgo = Math.floor(Date.now() / 1000) - 86400; - const duration = 1; // day + const now = Math.floor(Date.now() / 1000); + const timestamp1dayAgo = now - 86400; + const timestamp7dayAgo = now - 86400 * 7; const block1dayAgo = ( await axios.get(`https://coins.llama.fi/block/ethereum/${timestamp1dayAgo}`) ).data.height; + const block7dayAgo = ( + await axios.get(`https://coins.llama.fi/block/ethereum/${timestamp7dayAgo}`) + ).data.height; + + const amount = 1000000000000000000n; + const exchangeRates = await Promise.all([ sdk.api.abi.call({ target: token, abi: abi.find((m) => m.name === 'convertToAssets'), - params: [1000000000000000000n], + params: [amount], }), sdk.api.abi.call({ target: token, abi: abi.find((m) => m.name === 'convertToAssets'), - params: [1000000000000000000n], + params: [amount], block: block1dayAgo, }), + sdk.api.abi.call({ + target: token, + abi: abi.find((m) => m.name === 'convertToAssets'), + params: [amount], + block: block7dayAgo, + }), ]); - const apr = - ((exchangeRates[0].output - exchangeRates[1].output) / 1e18 / duration) * + const apyBase = + ((exchangeRates[0].output - exchangeRates[1].output) / 1e18) * 365 * 100; + + const apyBase7d = + ((exchangeRates[0].output - exchangeRates[2].output) / 1e18 / 7) * 365 * 100; @@ -52,7 +68,8 @@ const apy = async () => { chain: 'ethereum', symbol: 'mpETH', tvlUsd: totalSupply * ethPrice, - apyBase: apr, + apyBase, + apyBase7d, underlyingTokens: [weth], }, ]; From 87c86b1eaeacff74f3a2821afa339ccb6decfddf Mon Sep 17 00:00:00 2001 From: Philippe <2307365+philippe-git@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:52:23 +0200 Subject: [PATCH 18/73] Add factory-twocrypto to curve config (#1272) --- src/adaptors/curve-dex/config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/adaptors/curve-dex/config.js b/src/adaptors/curve-dex/config.js index 57a6158f87..4f213c1365 100644 --- a/src/adaptors/curve-dex/config.js +++ b/src/adaptors/curve-dex/config.js @@ -20,6 +20,7 @@ REGISTRY_TYPES = [ 'factory-crypto', 'optimism', 'factory-crvusd', + 'factory-twocrypto', 'factory-tricrypto', 'factory-stable-ng', ]; From a9f5d168572693ae6b3a6f74a683cf22314a4829 Mon Sep 17 00:00:00 2001 From: take3315 <114322307+take3315@users.noreply.github.com> Date: Tue, 16 Apr 2024 23:17:22 +0800 Subject: [PATCH 19/73] Add factory-twocrypto to convex (#1273) Newest Curve registry (https://api.curve.fi/v1/documentation/#/Misc/get_getPlatforms) --- src/adaptors/convex-finance/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/adaptors/convex-finance/index.js b/src/adaptors/convex-finance/index.js index 84f0a89cc7..58499f7c56 100755 --- a/src/adaptors/convex-finance/index.js +++ b/src/adaptors/convex-finance/index.js @@ -47,6 +47,7 @@ const main = async () => { 'factory-crvusd', 'factory-tricrypto', 'factory-stable-ng', + 'factory-twocrypto', ].map((registry) => utils.getData(`https://api.curve.fi/api/getPools/ethereum/${registry}`) ) From c829d422b73b7d84e2fb0de75ff61aed9be8eed5 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Wed, 17 Apr 2024 11:54:38 +0400 Subject: [PATCH 20/73] remove agave usdt pool --- src/utils/exclude.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/exclude.js b/src/utils/exclude.js index 0f9332399a..fd9b9f5ddc 100644 --- a/src/utils/exclude.js +++ b/src/utils/exclude.js @@ -456,6 +456,7 @@ const excludePools = [ '0xe24563774dd4050e28e3c63567b2918495367626-avalanche', '0x42c02c24caaf42a27dd95c790073a4ea3118ea48', '0x4aE5CE819e7D678b07E8D0f483d351E2c8e8B8D3', + '0x5b4ef67c63d091083ec4d30cfc4ac685ef051046-xdai', ]; const boundaries = { From b389eb5358e0621b8e5f53215685a6264038be06 Mon Sep 17 00:00:00 2001 From: 0x_danr Date: Thu, 18 Apr 2024 01:49:57 -0400 Subject: [PATCH 21/73] Feat: Add Base Pools to GammaSwap (#1267) * pools yield information for gammaswap * annualize yield, fix BN to decimal conversion, format USDC bridged symbol from USDC to USDC.e * adding url per pool * added borrow apy * adding IGammaPool ABI to get poolViewer from weth/usdc gammapool in arbitrum, to use in all other calls * removing unused imports * add base pools query and filter out odd decimal pools --------- Co-authored-by: Kalesberg --- src/adaptors/gammaswap/index.js | 74 ++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/src/adaptors/gammaswap/index.js b/src/adaptors/gammaswap/index.js index 7fd8b929a1..418370e89c 100644 --- a/src/adaptors/gammaswap/index.js +++ b/src/adaptors/gammaswap/index.js @@ -1,4 +1,4 @@ -const sdk = require('@defillama/sdk'); +const sdk = require('@defillama/sdk5'); const { gql, request } = require('graphql-request'); const { BigNumber, utils: etherUtils } = require('ethers'); const utils = require('../utils'); @@ -28,25 +28,47 @@ function borrowApy(snapshot, poolInfo) { return borrowYield * (secondsOfDay / timeDiff) * 365 * 100; } -function formatSymbols(symbols, addresses) { - if(addresses[0] == "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8") { - symbols[0] = "USDC.e"; - } - if(addresses[1] == "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8") { - symbols[1] = "USDC.e"; +function formatSymbols(chainName, symbols, addresses) { + if(chainName == "arbitrum") { + if(addresses[0] == "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8") { + symbols[0] = "USDC.e"; + } + if(addresses[1] == "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8") { + symbols[1] = "USDC.e"; + } } return symbols.join("-"); } async function apy() { - const poolAddr = '0x63c531ffed7e17f8adca4ed490837838f6fa1b66'; + const chainInfo = [ + { + chainName: "arbitrum", + endpoint: "https://api.thegraph.com/subgraphs/name/gammaswap/gammaswap-v1-arbitrum", + refPoolAddr: "0x63c531ffed7e17f8adca4ed490837838f6fa1b66", + }, + { + chainName: "base", + endpoint: "https://api.studio.thegraph.com/query/49518/gammaswap-v1-base/version/latest", + refPoolAddr: "0xcd4257699b48d4791e77116d0e6a3bd48ad9567f", + } + ] + + let pools = []; + for(let i = 0; i < chainInfo.length; i++) { + const _pools = await apyPerChain(chainInfo[i].chainName, chainInfo[i].refPoolAddr, chainInfo[i].endpoint) + pools = pools.concat(_pools); + } + return pools; +} + +async function apyPerChain(chainName, refPoolAddr, endpoint) { const { output: poolViewer } = await sdk.api.abi.call( { - target: poolAddr, + target: refPoolAddr, abi: IGammaPoolABI[0], - chain: 'arbitrum' + chain: chainName }); - const endpoint = 'https://api.thegraph.com/subgraphs/name/gammaswap/gammaswap-v1-arbitrum'; const query = gql` { gammaPoolTracers { @@ -73,19 +95,31 @@ async function apy() { target: poolViewer, params: pool })), - chain: 'arbitrum', + chain: chainName, permitFailure: true, }); - return pools.map((pool, i) => ({ + let _latestPoolsData = latestPoolsData.filter(function(pool) { + return (Number(pool.output.decimals[0]) + Number(pool.output.decimals[1])) % 2 == 0; + }); + + const _pools = pools.filter(function(pool, i) { + return (Number(latestPoolsData[i].output.decimals[0]) + Number(latestPoolsData[i].output.decimals[1])) % 2 == 0; + }); + + const _gammaPoolTracers = gammaPoolTracers.filter(function(tracer, i) { + return (Number(latestPoolsData[i].output.decimals[0]) + Number(latestPoolsData[i].output.decimals[1])) % 2 == 0; + }); + + return _pools.map((pool, i) => ({ pool, - chain: utils.formatChain('arbitrum'), - project: 'gammaswap', - symbol: formatSymbols(latestPoolsData[i].output.symbols,latestPoolsData[i].output.tokens), - tvlUsd: Number(gammaPoolTracers[i].lastDailyData.pool.tvlUSD), - apyBase: supplyApy(gammaPoolTracers[i].lastDailyData, latestPoolsData[i].output), - apyBaseBorrow: borrowApy(gammaPoolTracers[i].lastDailyData, latestPoolsData[i].output), - underlyingTokens: latestPoolsData[i].output.tokens, + chain: utils.formatChain(chainName), + project: "gammaswap", + symbol: formatSymbols(chainName, _latestPoolsData[i].output.symbols,_latestPoolsData[i].output.tokens), + tvlUsd: Number(_gammaPoolTracers[i].lastDailyData.pool.tvlUSD), + apyBase: supplyApy(_gammaPoolTracers[i].lastDailyData, _latestPoolsData[i].output), + apyBaseBorrow: borrowApy(_gammaPoolTracers[i].lastDailyData, _latestPoolsData[i].output), + underlyingTokens: _latestPoolsData[i].output.tokens, url: `https://app.gammaswap.com/earn/${pool}`, })); } From 3e276230518b6e65aa65e3f69d8458a2a5c8d89f Mon Sep 17 00:00:00 2001 From: Deantoshi <141426562+Deantoshi@users.noreply.github.com> Date: Fri, 19 Apr 2024 02:31:59 -0400 Subject: [PATCH 22/73] added ironclad-finance (#1275) * added ironclad-finance * Updated sdk import to @defillama/sdk5 --------- Co-authored-by: Daniel_Dean --- .../ironclad-finance/abiLendingPool.js | 692 ++++++++++++++++++ .../abiProtocolDataProvider.js | 148 ++++ src/adaptors/ironclad-finance/index.js | 138 ++++ 3 files changed, 978 insertions(+) create mode 100644 src/adaptors/ironclad-finance/abiLendingPool.js create mode 100644 src/adaptors/ironclad-finance/abiProtocolDataProvider.js create mode 100644 src/adaptors/ironclad-finance/index.js diff --git a/src/adaptors/ironclad-finance/abiLendingPool.js b/src/adaptors/ironclad-finance/abiLendingPool.js new file mode 100644 index 0000000000..ddf300738e --- /dev/null +++ b/src/adaptors/ironclad-finance/abiLendingPool.js @@ -0,0 +1,692 @@ +module.exports = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'borrowRateMode', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'borrowRate', + type: 'uint256', + }, + { + indexed: true, + internalType: 'uint16', + name: 'referral', + type: 'uint16', + }, + ], + name: 'Borrow', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: true, + internalType: 'uint16', + name: 'referral', + type: 'uint16', + }, + ], + name: 'Deposit', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'target', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'initiator', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'premium', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + ], + name: 'FlashLoan', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'collateralAsset', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'debtAsset', + type: 'address', + }, + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'debtToCover', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'liquidatedCollateralAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'address', + name: 'liquidator', + type: 'address', + }, + { + indexed: false, + internalType: 'bool', + name: 'receiveAToken', + type: 'bool', + }, + ], + name: 'LiquidationCall', + type: 'event', + }, + { anonymous: false, inputs: [], name: 'Paused', type: 'event' }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + ], + name: 'RebalanceStableBorrowRate', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { + indexed: true, + internalType: 'address', + name: 'repayer', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Repay', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'liquidityRate', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'stableBorrowRate', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'variableBorrowRate', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'liquidityIndex', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'variableBorrowIndex', + type: 'uint256', + }, + ], + name: 'ReserveDataUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + ], + name: 'ReserveUsedAsCollateralDisabled', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + ], + name: 'ReserveUsedAsCollateralEnabled', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'rateMode', + type: 'uint256', + }, + ], + name: 'Swap', + type: 'event', + }, + { anonymous: false, inputs: [], name: 'Unpaused', type: 'event' }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Withdraw', + type: 'event', + }, + { + inputs: [], + name: 'FLASHLOAN_PREMIUM_TOTAL', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'LENDINGPOOL_REVISION', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_NUMBER_RESERVES', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'interestRateMode', type: 'uint256' }, + { internalType: 'uint16', name: 'referralCode', type: 'uint16' }, + { internalType: 'address', name: 'onBehalfOf', type: 'address' }, + ], + name: 'borrow', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'address', name: 'onBehalfOf', type: 'address' }, + { internalType: 'uint16', name: 'referralCode', type: 'uint16' }, + ], + name: 'deposit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'address', name: 'from', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'balanceFromBefore', type: 'uint256' }, + { internalType: 'uint256', name: 'balanceToBefore', type: 'uint256' }, + ], + name: 'finalizeTransfer', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'receiverAddress', type: 'address' }, + { internalType: 'address[]', name: 'assets', type: 'address[]' }, + { internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' }, + { internalType: 'uint256[]', name: 'modes', type: 'uint256[]' }, + { internalType: 'address', name: 'onBehalfOf', type: 'address' }, + { internalType: 'bytes', name: 'params', type: 'bytes' }, + { internalType: 'uint16', name: 'referralCode', type: 'uint16' }, + ], + name: 'flashLoan', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'getAddressesProvider', + outputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'asset', type: 'address' }], + name: 'getConfiguration', + outputs: [ + { + components: [ + { internalType: 'uint256', name: 'data', type: 'uint256' }, + ], + internalType: 'struct DataTypes.ReserveConfigurationMap', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'asset', type: 'address' }], + name: 'getReserveData', + outputs: [ + { + components: [ + { + components: [ + { internalType: 'uint256', name: 'data', type: 'uint256' }, + ], + internalType: 'struct DataTypes.ReserveConfigurationMap', + name: 'configuration', + type: 'tuple', + }, + { internalType: 'uint128', name: 'liquidityIndex', type: 'uint128' }, + { + internalType: 'uint128', + name: 'variableBorrowIndex', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'currentLiquidityRate', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'currentVariableBorrowRate', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'currentStableBorrowRate', + type: 'uint128', + }, + { + internalType: 'uint40', + name: 'lastUpdateTimestamp', + type: 'uint40', + }, + { internalType: 'address', name: 'aTokenAddress', type: 'address' }, + { + internalType: 'address', + name: 'stableDebtTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'variableDebtTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'interestRateStrategyAddress', + type: 'address', + }, + { internalType: 'uint8', name: 'id', type: 'uint8' }, + ], + internalType: 'struct DataTypes.ReserveData', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'asset', type: 'address' }], + name: 'getReserveNormalizedIncome', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'asset', type: 'address' }], + name: 'getReserveNormalizedVariableDebt', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getReservesList', + outputs: [{ internalType: 'address[]', name: '', type: 'address[]' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'user', type: 'address' }], + name: 'getUserAccountData', + outputs: [ + { internalType: 'uint256', name: 'totalCollateralETH', type: 'uint256' }, + { internalType: 'uint256', name: 'totalDebtETH', type: 'uint256' }, + { internalType: 'uint256', name: 'availableBorrowsETH', type: 'uint256' }, + { + internalType: 'uint256', + name: 'currentLiquidationThreshold', + type: 'uint256', + }, + { internalType: 'uint256', name: 'ltv', type: 'uint256' }, + { internalType: 'uint256', name: 'healthFactor', type: 'uint256' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'user', type: 'address' }], + name: 'getUserConfiguration', + outputs: [ + { + components: [ + { internalType: 'uint256', name: 'data', type: 'uint256' }, + ], + internalType: 'struct DataTypes.UserConfigurationMap', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'address', name: 'aTokenAddress', type: 'address' }, + { internalType: 'address', name: 'stableDebtAddress', type: 'address' }, + { internalType: 'address', name: 'variableDebtAddress', type: 'address' }, + { + internalType: 'address', + name: 'interestRateStrategyAddress', + type: 'address', + }, + ], + name: 'initReserve', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: 'provider', + type: 'address', + }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'collateralAsset', type: 'address' }, + { internalType: 'address', name: 'debtAsset', type: 'address' }, + { internalType: 'address', name: 'user', type: 'address' }, + { internalType: 'uint256', name: 'debtToCover', type: 'uint256' }, + { internalType: 'bool', name: 'receiveAToken', type: 'bool' }, + ], + name: 'liquidationCall', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'paused', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'address', name: 'user', type: 'address' }, + ], + name: 'rebalanceStableBorrowRate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'rateMode', type: 'uint256' }, + { internalType: 'address', name: 'onBehalfOf', type: 'address' }, + ], + name: 'repay', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'configuration', type: 'uint256' }, + ], + name: 'setConfiguration', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bool', name: 'val', type: 'bool' }], + name: 'setPause', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'address', name: 'rateStrategyAddress', type: 'address' }, + ], + name: 'setReserveInterestRateStrategyAddress', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'bool', name: 'useAsCollateral', type: 'bool' }, + ], + name: 'setUserUseReserveAsCollateral', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'rateMode', type: 'uint256' }, + ], + name: 'swapBorrowRateMode', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'address', name: 'to', type: 'address' }, + ], + name: 'withdraw', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + ]; + \ No newline at end of file diff --git a/src/adaptors/ironclad-finance/abiProtocolDataProvider.js b/src/adaptors/ironclad-finance/abiProtocolDataProvider.js new file mode 100644 index 0000000000..1c698fcae2 --- /dev/null +++ b/src/adaptors/ironclad-finance/abiProtocolDataProvider.js @@ -0,0 +1,148 @@ +module.exports = [ + { + inputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: 'addressesProvider', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + name: 'ADDRESSES_PROVIDER', + outputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getAllATokens', + outputs: [ + { + components: [ + { internalType: 'string', name: 'symbol', type: 'string' }, + { internalType: 'address', name: 'tokenAddress', type: 'address' }, + ], + internalType: 'struct AaveProtocolDataProvider.TokenData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getAllReservesTokens', + outputs: [ + { + components: [ + { internalType: 'string', name: 'symbol', type: 'string' }, + { internalType: 'address', name: 'tokenAddress', type: 'address' }, + ], + internalType: 'struct AaveProtocolDataProvider.TokenData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'asset', type: 'address' }], + name: 'getReserveConfigurationData', + outputs: [ + { internalType: 'uint256', name: 'decimals', type: 'uint256' }, + { internalType: 'uint256', name: 'ltv', type: 'uint256' }, + { + internalType: 'uint256', + name: 'liquidationThreshold', + type: 'uint256', + }, + { internalType: 'uint256', name: 'liquidationBonus', type: 'uint256' }, + { internalType: 'uint256', name: 'reserveFactor', type: 'uint256' }, + { internalType: 'bool', name: 'usageAsCollateralEnabled', type: 'bool' }, + { internalType: 'bool', name: 'borrowingEnabled', type: 'bool' }, + { internalType: 'bool', name: 'stableBorrowRateEnabled', type: 'bool' }, + { internalType: 'bool', name: 'isActive', type: 'bool' }, + { internalType: 'bool', name: 'isFrozen', type: 'bool' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'asset', type: 'address' }], + name: 'getReserveData', + outputs: [ + { internalType: 'uint256', name: 'availableLiquidity', type: 'uint256' }, + { internalType: 'uint256', name: 'totalStableDebt', type: 'uint256' }, + { internalType: 'uint256', name: 'totalVariableDebt', type: 'uint256' }, + { internalType: 'uint256', name: 'liquidityRate', type: 'uint256' }, + { internalType: 'uint256', name: 'variableBorrowRate', type: 'uint256' }, + { internalType: 'uint256', name: 'stableBorrowRate', type: 'uint256' }, + { + internalType: 'uint256', + name: 'averageStableBorrowRate', + type: 'uint256', + }, + { internalType: 'uint256', name: 'liquidityIndex', type: 'uint256' }, + { internalType: 'uint256', name: 'variableBorrowIndex', type: 'uint256' }, + { internalType: 'uint40', name: 'lastUpdateTimestamp', type: 'uint40' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'asset', type: 'address' }], + name: 'getReserveTokensAddresses', + outputs: [ + { internalType: 'address', name: 'aTokenAddress', type: 'address' }, + { + internalType: 'address', + name: 'stableDebtTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'variableDebtTokenAddress', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'address', name: 'user', type: 'address' }, + ], + name: 'getUserReserveData', + outputs: [ + { + internalType: 'uint256', + name: 'currentATokenBalance', + type: 'uint256', + }, + { internalType: 'uint256', name: 'currentStableDebt', type: 'uint256' }, + { internalType: 'uint256', name: 'currentVariableDebt', type: 'uint256' }, + { internalType: 'uint256', name: 'principalStableDebt', type: 'uint256' }, + { internalType: 'uint256', name: 'scaledVariableDebt', type: 'uint256' }, + { internalType: 'uint256', name: 'stableBorrowRate', type: 'uint256' }, + { internalType: 'uint256', name: 'liquidityRate', type: 'uint256' }, + { internalType: 'uint40', name: 'stableRateLastUpdated', type: 'uint40' }, + { internalType: 'bool', name: 'usageAsCollateralEnabled', type: 'bool' }, + ], + stateMutability: 'view', + type: 'function', + }, + ]; + \ No newline at end of file diff --git a/src/adaptors/ironclad-finance/index.js b/src/adaptors/ironclad-finance/index.js new file mode 100644 index 0000000000..b0f95080a4 --- /dev/null +++ b/src/adaptors/ironclad-finance/index.js @@ -0,0 +1,138 @@ +const ethers = require('ethers'); +const { JsonRpcProvider } = require('ethers'); +const sdk = require('@defillama/sdk5'); +const axios = require('axios'); +const abiLendingPool = require('./abiLendingPool'); +const abiProtocolDataProvider = require('./abiProtocolDataProvider'); + +const utils = require('../utils'); + +const chains = { + mode: { + LendingPool: '0xB702cE183b4E1Faa574834715E5D4a6378D0eEd3', + ProtocolDataProvider: '0x29563f73De731Ae555093deb795ba4D1E584e42E', + url: 'mode', + }, +}; + +const getApy = async () => { + const pools = await Promise.all( + Object.keys(chains).map(async (chain) => { + const addresses = chains[chain]; + const sdkChain = chain; + + const reservesList = ( + await sdk.api.abi.call({ + target: addresses.LendingPool, + abi: abiLendingPool.find((m) => m.name === 'getReservesList'), + chain: sdkChain, + }) + ).output; + + const reserveData = ( + await sdk.api.abi.multiCall({ + calls: reservesList.map((i) => ({ + target: addresses.LendingPool, + params: [i], + })), + abi: abiLendingPool.find((m) => m.name === 'getReserveData'), + chain: sdkChain, + }) + ).output.map((o) => o.output); + + const [liquidityRes, decimalsRes, symbolsRes] = await Promise.all( + ['erc20:balanceOf', 'erc20:decimals', 'erc20:symbol'].map((method) => + sdk.api.abi.multiCall({ + abi: method, + calls: reservesList.map((t, i) => ({ + target: t, + params: + method === 'erc20:balanceOf' + ? reserveData[i].aTokenAddress + : null, + })), + chain: sdkChain, + }) + ) + ); + + const liquidity = liquidityRes.output.map((o) => o.output); + const decimals = decimalsRes.output.map((o) => o.output); + let symbols = symbolsRes.output.map((o) => o.output); + // maker symbol is null + const mkrIdx = symbols.findIndex((s) => s === null); + symbols[mkrIdx] = 'MKR'; + + const totalBorrow = ( + await sdk.api.abi.multiCall({ + abi: 'erc20:totalSupply', + calls: reserveData.map((p) => ({ + target: p.variableDebtTokenAddress, + })), + chain: sdkChain, + }) + ).output.map((o) => o.output); + + const reserveConfigurationData = ( + await sdk.api.abi.multiCall({ + calls: reservesList.map((t) => ({ + target: addresses.ProtocolDataProvider, + params: t, + })), + chain: sdkChain, + abi: abiProtocolDataProvider.find( + (n) => n.name === 'getReserveConfigurationData' + ), + }) + ).output.map((o) => o.output); + + const pricesArray = reservesList.map((t) => `${sdkChain}:${t}`); + const prices = ( + await axios.get(`https://coins.llama.fi/prices/current/${pricesArray}`) + ).data.coins; + + return reservesList.map((t, i) => { + const config = reserveConfigurationData[i]; + if (!config.isActive) return null; + + const price = prices[`${sdkChain}:${t}`]?.price; + + const tvlUsd = (liquidity[i] / 10 ** decimals[i]) * price; + const totalBorrowUsd = (totalBorrow[i] / 10 ** decimals[i]) * price; + const totalSupplyUsd = tvlUsd + totalBorrowUsd; + + const apyBase = reserveData[i].currentLiquidityRate / 1e25; + const apyBaseBorrow = reserveData[i].currentVariableBorrowRate / 1e25; + + const ltv = config.ltv / 1e4; + const borrowable = config.borrowingEnabled; + const frozen = config.isFrozen; + const poolSymbol = symbols[i].toLowerCase() + const url = `https://app.ironclad.finance/markets/${poolSymbol}`; + + return { + pool: `${reserveData[i].aTokenAddress}-${chain}`.toLowerCase(), + symbol: symbols[i], + project: 'ironclad-finance', + chain, + tvlUsd, + apyBase, + underlyingTokens: [t], + url, + // borrow fields + totalSupplyUsd, + totalBorrowUsd, + apyBaseBorrow, + ltv, + borrowable, + poolMeta: frozen ? 'frozen' : null, + }; + }); + }) + ); + return pools.flat().filter((p) => utils.keepFinite(p)); +}; + +module.exports = { + apy: getApy, +}; From b5a6adb48d6b340e58763b121dc64d15426aae12 Mon Sep 17 00:00:00 2001 From: utwang Date: Fri, 19 Apr 2024 15:39:07 +0900 Subject: [PATCH 23/73] Update vaults & calculation APR (#1276) --- src/adaptors/orange-finance/index.ts | 166 +++++++++-------- src/adaptors/orange-finance/price.ts | 28 +++ src/adaptors/orange-finance/query.ts | 103 +++++++++++ src/adaptors/orange-finance/strykeFee.ts | 226 +++++++++++++++++++++++ src/adaptors/orange-finance/v1.ts | 97 ++++++++++ 5 files changed, 541 insertions(+), 79 deletions(-) create mode 100644 src/adaptors/orange-finance/price.ts create mode 100644 src/adaptors/orange-finance/query.ts create mode 100644 src/adaptors/orange-finance/strykeFee.ts create mode 100644 src/adaptors/orange-finance/v1.ts diff --git a/src/adaptors/orange-finance/index.ts b/src/adaptors/orange-finance/index.ts index 5b884d6c3b..f3fdd09603 100644 --- a/src/adaptors/orange-finance/index.ts +++ b/src/adaptors/orange-finance/index.ts @@ -1,97 +1,105 @@ const utils = require('../utils'); -const { v1VaultAbi } = require('./abi'); -const Web3 = require('web3'); -const dayjs = require('dayjs'); -const duration =require('dayjs/plugin/duration') -const { compact, isEmpty, last } = require('lodash'); +const { calculateAPR } = require('./strykeFee'); +const BigNumber = require('bignumber.js'); +const { chain } = require('lodash'); +const { request } = require('graphql-request'); -dayjs.extend(duration) +const orangeGraphUrl = + 'https://subgraph.satsuma-prod.com/1563a78cd0f9/pao-tech/orange-finance/api'; +const strykeGraphUrl = + 'https://api.0xgraph.xyz/subgraphs/name/dopex-v2-clamm-public'; -const RPC_URL = 'https://arb1.arbitrum.io/rpc' -const APR_BASE_DAYS = 30 -const V1_VAULTS = [ - { - name: 'ETH-USDC.e', - address: '0xB9c5425084671221d7D5A547dBf1Bdcec26C8B7d', - yieldStart: 1689033600000, - showApy: true, - } -] -const web3 = new Web3(RPC_URL); +const { + getStrykeVaultListQuery, + getUniV3PoolListQuery, + getStrykeLpPositionsListQuery, + getDailyStrikeEarningsListQuery, +} = require('./query'); -const getAprFromActionEvents = async (address, yieldStart, block) => { - const v1Contract = new web3.eth.Contract(v1VaultAbi, address); +const vaultList = ['0xe1B68841E764Cc31be1Eb1e59d156a4ED1217c2C']; - const events = await v1Contract.getPastEvents('Action', { - filter: {actionType: [0]}, - fromBlock: block - }) +async function getPools() { + const dataOrange = await request(orangeGraphUrl, getStrykeVaultListQuery); - const tokenValueList = await Promise.all(events.map(async (event) => { - const block = await web3.eth.getBlock(event.blockNumber) - const blockTime = dayjs.unix(block.timestamp) + const strykeVaults = + dataOrange?.dopexVaults.filter((vault) => { + return vaultList + .map((address) => address.toLowerCase()) + .includes(vault.id.toLowerCase()); + }) ?? []; - if (blockTime.valueOf() < yieldStart) { - return null - } - const totalAssets = event.returnValues.totalAssets - const totalSupply = event.returnValues.totalSupply - const tokenValue = totalSupply !== 0 ? totalAssets / totalSupply : 0 - return { - timestamp: blockTime.valueOf(), - tokenValue, - } - })) + const dataUni = await request(orangeGraphUrl, getUniV3PoolListQuery, { + poolIds: chain(strykeVaults).map((vault) => vault.pool).uniq().value(), + }); - const tokenValues = compact(tokenValueList) - const lastSnapshot = last(tokenValues) - const lastSnapshotTime = lastSnapshot?.timestamp ?? yieldStart - const yearDays = dayjs.duration(1, 'years').asDays() + const dataStryke1 = await request( + strykeGraphUrl, + getStrykeLpPositionsListQuery, + { vaultIds: strykeVaults.map((vault) => vault.id) } + ); - if (tokenValues.length >= APR_BASE_DAYS) { - const baseSnapshot = tokenValues[tokenValues.length - APR_BASE_DAYS] - const gainValue = lastSnapshot.tokenValue - baseSnapshot.tokenValue - return (gainValue / baseSnapshot.tokenValue) * 100 * (yearDays / APR_BASE_DAYS) - } else { - const period = dayjs.duration(lastSnapshotTime - yieldStart, 'milliseconds').asDays() - return lastSnapshot.tokenValue * (yearDays / period) - } -} + const tokenIds = dataStryke1?.lppositions.map(lpPosition => lpPosition.strike.id) ?? [] + + const dataStryke2 = await request( + strykeGraphUrl, + getDailyStrikeEarningsListQuery, + { tokenIds, tokenIdsCount: tokenIds.length } + ); -const getApy = async () => { - const totalDepositList = await Promise.all( - ['totalAssets', 'decimals', 'token0'].map((method) => - utils.makeMulticall( - v1VaultAbi.find(({ name }) => name === method), - V1_VAULTS.map(({ address }) => address), - 'arbitrum' + const strikeEarningsDict = chain(dataStryke1?.lppositions ?? []) + .map(lpPosition => { + const donation = dataStryke2?.dailyDonations.find( + d => d.strike.id === lpPosition.strike.id ) - ) - ) + const compound = dataStryke2?.dailyFeeCompounds.find(c => c.id === donation?.id) + return { + sqrtPriceX96: donation?.sqrtPriceX96, + donation: donation?.donation, + compound: compound?.compound, + strike: lpPosition?.strike, + pool: lpPosition.pool, + shares: lpPosition.shares, + user: lpPosition.user, + handler: lpPosition.handler, + } + }) + .groupBy('user') + .value() - const startTimestamp = dayjs().subtract(APR_BASE_DAYS + 5, 'days').unix() - const blocks = await utils.getBlocksByTime([startTimestamp], 'arbitrum') + const ethPriceUSD = new BigNumber(dataUni.bundle.ethPriceUSD) - const res = await Promise.all(V1_VAULTS.map(async ({ name, address, yieldStart, showApy }, idx) => { - const apyBase = showApy ? await getAprFromActionEvents(address, yieldStart, blocks[0]) : 0 - const pool = { - pool: address, - chain: utils.formatChain('arbitrum'), - project: 'orange-finance', - symbol: name, - tvlUsd: Number(totalDepositList[0][idx]) / (10 ** totalDepositList[1][idx]), - apyBase, - underlyingTokens: [totalDepositList[2][idx]], - poolMeta: 'v1', - } - return pool - })) + const statsList = chain(strykeVaults) + .map(vault => { + const dopexStrikeEarnings = strikeEarningsDict[vault.id] + const pool = dataUni?.pools.find(pool => pool.id === vault?.pool) + if (!vault || !pool) { + return + } + const stats = calculateAPR(dopexStrikeEarnings, vault, pool, ethPriceUSD) + return { stats, vault, pool } + }) + .compact() + .map(vaultStats => { + const symbol = vaultStats.vault.isTokenPairReversed + ? `${vaultStats.pool.token1.symbol}-${vaultStats.pool.token0.symbol}` + : `${vaultStats.pool.token0.symbol}-${vaultStats.pool.token1.symbol}` + return { + pool: vaultStats.vault.id, + chain: utils.formatChain('arbitrum'), + project: 'orange-finance', + symbol, + apyBase: vaultStats.stats.dopexApr.toNumber() * 100, + tvlUsd: vaultStats.stats.tvl.toNumber(), + poolMeta: 'LPDfi' + } + }) + .value() - return res + return statsList } module.exports = { timetravel: false, - apy: getApy, - url: 'https://alpha.orangefinance.io', -}; + apy: getPools, + url: 'https://app.orangefinance.io', +}; \ No newline at end of file diff --git a/src/adaptors/orange-finance/price.ts b/src/adaptors/orange-finance/price.ts new file mode 100644 index 0000000000..97d8727f2e --- /dev/null +++ b/src/adaptors/orange-finance/price.ts @@ -0,0 +1,28 @@ +const { SqrtPriceMath } = require('@uniswap/v3-sdk'); +const JSBI = require('jsbi') + +const getAmountsForLiquidity = ( + sqrtRatioX96: typeof JSBI, + sqrtRatioAX96: typeof JSBI, + sqrtRatioBX96: typeof JSBI, + liquidity: typeof JSBI +): { amount0: typeof JSBI; amount1: typeof JSBI } => { + if (JSBI.greaterThan(sqrtRatioAX96, sqrtRatioBX96)) { + ;[sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96] + } + + let amount0 = JSBI.BigInt(0) + let amount1 = JSBI.BigInt(0) + + if (JSBI.lessThanOrEqual(sqrtRatioX96, sqrtRatioAX96)) { + amount0 = SqrtPriceMath.getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, liquidity, false) + } else if (JSBI.lessThan(sqrtRatioX96, sqrtRatioBX96)) { + amount0 = SqrtPriceMath.getAmount0Delta(sqrtRatioX96, sqrtRatioBX96, liquidity, false) + amount1 = SqrtPriceMath.getAmount1Delta(sqrtRatioAX96, sqrtRatioX96, liquidity, false) + } else { + amount1 = SqrtPriceMath.getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, liquidity, false) + } + return { amount0, amount1 } +} + +module.exports = { getAmountsForLiquidity } \ No newline at end of file diff --git a/src/adaptors/orange-finance/query.ts b/src/adaptors/orange-finance/query.ts new file mode 100644 index 0000000000..953a3065a2 --- /dev/null +++ b/src/adaptors/orange-finance/query.ts @@ -0,0 +1,103 @@ +const { gql } = require('graphql-request'); + +const getStrykeVaultListQuery = gql` + query getStrykeVaultList { + dopexVaults(orderBy: totalSupply, orderDirection: desc) { + id + totalAssets + totalSupply + decimals + yieldStart + isTokenPairReversed + depositCap + pool + } + } +` + +const getUniV3PoolListQuery = gql` + query getUniV3PoolListQuery($poolIds: [ID!]!) { + pools(where: { id_in: $poolIds }) { + id + tick + sqrtPrice + token0 { + id + name + symbol + decimals + derivedETH + } + token1 { + id + name + symbol + decimals + derivedETH + } + token0Price + token1Price + } + bundle(id: "1") { + ethPriceUSD + id + } + } +` + +const getStrykeLpPositionsListQuery = gql` + query getStrykeLpPositionsList($vaultIds: [String!]!) { + lppositions(where: { user_in: $vaultIds, shares_gt: "0" }) { + id + pool + shares + initialLiquidity + user + handler + strike { + id + pool + tickLower + tickUpper + totalLiquidity + usedLiquidity + totalShares + } + } + } +` + +const getDailyStrikeEarningsListQuery = gql` + query getDailyStrikeEarningsList($tokenIds: [ID!]!, $tokenIdsCount: Int!) { + dailyDonations( + where: { strike_: { id_in: $tokenIds } } + orderBy: start + orderDirection: desc + first: $tokenIdsCount + ) { + id + donation + sqrtPriceX96 + start + strike { + id + } + } + dailyFeeCompounds( + where: { strike_: { id_in: $tokenIds } } + orderBy: start + orderDirection: desc + first: $tokenIdsCount + ) { + id + compound + sqrtPriceX96 + start + strike { + id + } + } + } +` + +module.exports = { getStrykeVaultListQuery, getUniV3PoolListQuery, getStrykeLpPositionsListQuery, getDailyStrikeEarningsListQuery} \ No newline at end of file diff --git a/src/adaptors/orange-finance/strykeFee.ts b/src/adaptors/orange-finance/strykeFee.ts new file mode 100644 index 0000000000..65c61564c0 --- /dev/null +++ b/src/adaptors/orange-finance/strykeFee.ts @@ -0,0 +1,226 @@ +const BigNumber = require('bignumber.js'); +const { TickMath } = require('@uniswap/v3-sdk') +const JSBI = require('jsbi') +const { getAmountsForLiquidity } = require('./price') + +export type DopexStrikeEarningPerVault = { + sqrtPriceX96?: string + compound?: string + donation?: string + strike: { + id: string + pool: string + tickLower: number + tickUpper: number + totalLiquidity: string + totalShares: string + } + pool: string + shares: string + user: string + handler: string +} + +type Token = { + id: string + decimals: string + derivedETH: string +} +type Pool = { + id: string + token0Price: string + token1Price: string + token0: Token + token1: Token +} + +type Vault = { + id: string + totalAssets: string + totalSupply: string + decimals: string + isTokenPairReversed: boolean +} + +const calculateAPR = ( + earningList: DopexStrikeEarningPerVault[], + vault: Vault, + pool: Pool, + ethPriceUSD: typeof BigNumber +) => { + const strikeEarningAmounts = getStrikeEarningAmounts(earningList) + + const result = strikeEarningAmounts.map(earn => { + const { + amount0ETH: feeAmount0ETH, + amount1ETH: feeAmount1ETH, + totalAmountETH: feeTotalAmountETH, + totalAmountUSD: feeTotalAmountUSD, + } = convertAmountToETH( + earn.fee.amount0, + earn.fee.amount1, + pool.token0, + pool.token1, + ethPriceUSD + ) + const { + amount0ETH: premiumAmount0ETH, + amount1ETH: premiumAmount1ETH, + totalAmountETH: premiumTotalAmountETH, + totalAmountUSD: premiumTotalAmountUSD, + } = convertAmountToETH( + earn.premium.amount0, + earn.premium.amount1, + pool.token0, + pool.token1, + ethPriceUSD + ) + const { + amount0: orangeAmount0, + amount1: orangeAmount1, + totalAmountETH: orangeTotalAmountETH, + totalAmountUSD: orangeTotalAmountUSD, + } = convertAmountToETH( + earn.orange.amount0, + earn.orange.amount1, + pool.token0, + pool.token1, + ethPriceUSD + ) + + const feeAPR = feeTotalAmountETH + .multipliedBy(earn.rate) + .dividedBy(orangeTotalAmountETH) + .multipliedBy(365) + + const premiumAPR = premiumTotalAmountETH + .multipliedBy(earn.rate) + .dividedBy(orangeTotalAmountETH) + .multipliedBy(365) + + return { + id: earn.tokenId, + feeAmount0ETH, + feeAmount1ETH, + feeTotalAmountETH, + feeTotalAmountETHOfOrangeShare: feeTotalAmountETH.multipliedBy(earn.rate), + premiumAmount0ETH, + premiumAmount1ETH, + premiumTotalAmountETH, + premiumTotalAmountETHOfOrangeShare: premiumTotalAmountETH.multipliedBy(earn.rate), + orangeAmount0, + orangeAmount1, + orangeTotalAmountETH, + feeAPR, + premiumAPR, + rate: earn.rate, + } + }) + const baseToken = vault.isTokenPairReversed ? pool.token1 : pool.token0 + const tvl = new BigNumber(vault.totalAssets) + .dividedBy(10 ** Number(baseToken.decimals)) + .times(baseToken.derivedETH) + .times(ethPriceUSD) + + const res = result.reduce( + (acc, sp) => { + acc.fee = acc.fee.plus(sp.feeTotalAmountETHOfOrangeShare) + acc.premium = acc.premium.plus(sp.premiumTotalAmountETHOfOrangeShare) + acc.orange = acc.orange.plus(sp.orangeTotalAmountETH) + return acc + }, + { fee: new BigNumber(0), premium: new BigNumber(0), orange: new BigNumber(0) } + ) + + return { + vaultId: vault.id, + fee: res.fee, + premium: res.premium, + orange: res.orange, + dopexApr: !res.orange.isZero() + ? res.fee.plus(res.premium).dividedBy(res.orange).multipliedBy(365) + : new BigNumber(0), + strikePremimFee: result, + tvl, + } +} + +const getStrikeEarningAmounts = (earningList: DopexStrikeEarningPerVault[]) => { + if (!earningList) return [] + + return earningList.map(earning => { + if (!earning.strike || !earning.sqrtPriceX96 || !earning.donation || !earning.compound) { + return { + tokenId: earning.strike.id, + fee: { amount0: JSBI.BigInt(0), amount1: JSBI.BigInt(0) }, + premium: { amount0: JSBI.BigInt(0), amount1: JSBI.BigInt(0) }, + orange: { amount0: JSBI.BigInt(0), amount1: JSBI.BigInt(0) }, + rate: new BigNumber(0), + } + } + const sqrtPriceX96 = JSBI.BigInt(earning.sqrtPriceX96) + const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(earning.strike.tickLower) + const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(earning.strike.tickUpper) + const donations = JSBI.BigInt(earning.donation) + const compouds = JSBI.BigInt(earning.compound) + const premiumAmounts = getAmountsForLiquidity( + sqrtPriceX96, + sqrtRatioAX96, + sqrtRatioBX96, + donations + ) + const feeAmounts = getAmountsForLiquidity(sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, compouds) + + const totalLiquidity = new BigNumber(earning.strike.totalLiquidity.toString()) + const shares = new BigNumber(earning.shares.toString() ?? 0) + const totalShares = new BigNumber(earning.strike.totalShares.toString()) + const orangeShareRate = + shares.isZero() || totalShares.isZero() ? new BigNumber(0) : shares.dividedBy(totalShares) + const orangeLiquidity = totalLiquidity.multipliedBy(orangeShareRate).toFixed(0) + + const orangeAmounts = getAmountsForLiquidity( + sqrtPriceX96, + sqrtRatioAX96, + sqrtRatioBX96, + JSBI.BigInt(Number(orangeLiquidity)) + ) + + return { + tokenId: earning.strike.id, + fee: feeAmounts, + premium: premiumAmounts, + orange: orangeAmounts, + rate: shares.dividedBy(totalShares), + } + }) +} + +const convertAmountToETH = ( + amount0: typeof JSBI, + amount1: typeof JSBI, + token0: Token, + token1: Token, + ethPriceUSD: typeof BigNumber +) => { + const token0Decimal = 10 ** Number(token0.decimals) + const token1Decimal = 10 ** Number(token1.decimals) + + const decimalizeAmount0 = new BigNumber(amount0.toString()).div(token0Decimal) + const decimalizeAmount1 = new BigNumber(amount1.toString()).div(token1Decimal) + + const amount0ETH = decimalizeAmount0.times(token0.derivedETH) + const amount1ETH = decimalizeAmount1.times(token1.derivedETH) + const totalAmountETH = amount0ETH.plus(amount1ETH) + const totalAmountUSD = totalAmountETH.times(ethPriceUSD) + + return { + amount0: decimalizeAmount0, + amount1: decimalizeAmount1, + amount0ETH, + amount1ETH, + totalAmountETH, + totalAmountUSD, + } +} + +module.exports = { calculateAPR, getStrikeEarningAmounts } \ No newline at end of file diff --git a/src/adaptors/orange-finance/v1.ts b/src/adaptors/orange-finance/v1.ts new file mode 100644 index 0000000000..5b884d6c3b --- /dev/null +++ b/src/adaptors/orange-finance/v1.ts @@ -0,0 +1,97 @@ +const utils = require('../utils'); +const { v1VaultAbi } = require('./abi'); +const Web3 = require('web3'); +const dayjs = require('dayjs'); +const duration =require('dayjs/plugin/duration') +const { compact, isEmpty, last } = require('lodash'); + +dayjs.extend(duration) + +const RPC_URL = 'https://arb1.arbitrum.io/rpc' +const APR_BASE_DAYS = 30 +const V1_VAULTS = [ + { + name: 'ETH-USDC.e', + address: '0xB9c5425084671221d7D5A547dBf1Bdcec26C8B7d', + yieldStart: 1689033600000, + showApy: true, + } +] +const web3 = new Web3(RPC_URL); + +const getAprFromActionEvents = async (address, yieldStart, block) => { + const v1Contract = new web3.eth.Contract(v1VaultAbi, address); + + const events = await v1Contract.getPastEvents('Action', { + filter: {actionType: [0]}, + fromBlock: block + }) + + const tokenValueList = await Promise.all(events.map(async (event) => { + const block = await web3.eth.getBlock(event.blockNumber) + const blockTime = dayjs.unix(block.timestamp) + + if (blockTime.valueOf() < yieldStart) { + return null + } + const totalAssets = event.returnValues.totalAssets + const totalSupply = event.returnValues.totalSupply + const tokenValue = totalSupply !== 0 ? totalAssets / totalSupply : 0 + return { + timestamp: blockTime.valueOf(), + tokenValue, + } + })) + + const tokenValues = compact(tokenValueList) + const lastSnapshot = last(tokenValues) + const lastSnapshotTime = lastSnapshot?.timestamp ?? yieldStart + const yearDays = dayjs.duration(1, 'years').asDays() + + if (tokenValues.length >= APR_BASE_DAYS) { + const baseSnapshot = tokenValues[tokenValues.length - APR_BASE_DAYS] + const gainValue = lastSnapshot.tokenValue - baseSnapshot.tokenValue + return (gainValue / baseSnapshot.tokenValue) * 100 * (yearDays / APR_BASE_DAYS) + } else { + const period = dayjs.duration(lastSnapshotTime - yieldStart, 'milliseconds').asDays() + return lastSnapshot.tokenValue * (yearDays / period) + } +} + +const getApy = async () => { + const totalDepositList = await Promise.all( + ['totalAssets', 'decimals', 'token0'].map((method) => + utils.makeMulticall( + v1VaultAbi.find(({ name }) => name === method), + V1_VAULTS.map(({ address }) => address), + 'arbitrum' + ) + ) + ) + + const startTimestamp = dayjs().subtract(APR_BASE_DAYS + 5, 'days').unix() + const blocks = await utils.getBlocksByTime([startTimestamp], 'arbitrum') + + const res = await Promise.all(V1_VAULTS.map(async ({ name, address, yieldStart, showApy }, idx) => { + const apyBase = showApy ? await getAprFromActionEvents(address, yieldStart, blocks[0]) : 0 + const pool = { + pool: address, + chain: utils.formatChain('arbitrum'), + project: 'orange-finance', + symbol: name, + tvlUsd: Number(totalDepositList[0][idx]) / (10 ** totalDepositList[1][idx]), + apyBase, + underlyingTokens: [totalDepositList[2][idx]], + poolMeta: 'v1', + } + return pool + })) + + return res +} + +module.exports = { + timetravel: false, + apy: getApy, + url: 'https://alpha.orangefinance.io', +}; From 89c9ee19cea51eb1c972ed25278cd69350194364 Mon Sep 17 00:00:00 2001 From: Sindermann <163030670+Sindermann@users.noreply.github.com> Date: Mon, 22 Apr 2024 07:09:57 +0100 Subject: [PATCH 24/73] feat: updated to include wombat LPs (#1277) --- src/adaptors/yield-yak-aggregator/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/adaptors/yield-yak-aggregator/index.js b/src/adaptors/yield-yak-aggregator/index.js index 53bc3c914a..9fc7d09b7b 100644 --- a/src/adaptors/yield-yak-aggregator/index.js +++ b/src/adaptors/yield-yak-aggregator/index.js @@ -73,10 +73,17 @@ const main = async () => { (farm.totalDeposits / farm.lpToken.supply); } } else { - const tokenSymbol = farm.depositToken.address.toLowerCase(); - const tokenName = farm.name.toLowerCase(); - const tokenPrice = - pricesByAddress[tokenSymbol] || pricesBySymbol[tokenName]; + let tokenPrice = 0; + + if (farm.platform == 'wombat') { + const tokenSymbol = farm.depositToken.underlying[0].toLowerCase(); + tokenPrice = pricesByAddress[tokenSymbol]; + } else { + const tokenSymbol = farm.depositToken.address.toLowerCase(); + const tokenName = farm.name.toLowerCase(); + tokenPrice = + pricesByAddress[tokenSymbol] || pricesBySymbol[tokenName]; + } if (farm.depositToken.stablecoin) tvlUsd = Number(farm.totalDeposits); else if (tokenPrice) tvlUsd = tokenPrice * Number(farm.totalDeposits); From 6981f57fdf89ad67efa8583cef4390d441587643 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Mon, 22 Apr 2024 11:02:13 +0400 Subject: [PATCH 25/73] upgrade sdk --- package-lock.json | 8 ++++---- package.json | 2 +- src/adaptors/package-lock.json | 8 ++++---- src/adaptors/package.json | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index f652d61da5..0877ca5f8b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@balancer-labs/sdk": "^1.1.5", "@defillama/sdk": "^2.3.126", - "@defillama/sdk5": "npm:@defillama/sdk@^5.0.37", + "@defillama/sdk5": "npm:@defillama/sdk@^5.0.53", "@types/jest": "^28.1.6", "@uniswap/sdk-core": "^3.0.1", "@uniswap/smart-order-router": "^2.8.0", @@ -1715,9 +1715,9 @@ }, "node_modules/@defillama/sdk5": { "name": "@defillama/sdk", - "version": "5.0.37", - "resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-5.0.37.tgz", - "integrity": "sha512-V+3bpkkU5fiHVDwcerk+aqozxYrPJ9aunNb4KbXO4CSB9YmCA23QJn+3EEP9e5iikjVmnlFCeIOVViMB86LkYQ==", + "version": "5.0.53", + "resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-5.0.53.tgz", + "integrity": "sha512-FhrgVni9TNEdOHV+7NHHTvfzHCkejI/1dG6Jj4TlK3vIGEgsgIlFxZzXImhnXf2SBxBMKvye9WF95Sk5RO6riQ==", "dependencies": { "@aws-sdk/client-s3": "^3.400.0", "@supercharge/promise-pool": "^2.1.0", diff --git a/package.json b/package.json index b46669835e..f2507b93cd 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "dependencies": { "@balancer-labs/sdk": "^1.1.5", "@defillama/sdk": "^2.3.126", - "@defillama/sdk5": "npm:@defillama/sdk@^5.0.37", + "@defillama/sdk5": "npm:@defillama/sdk@^5.0.53", "@types/jest": "^28.1.6", "@uniswap/sdk-core": "^3.0.1", "@uniswap/smart-order-router": "^2.8.0", diff --git a/src/adaptors/package-lock.json b/src/adaptors/package-lock.json index 8ca75a3906..1d75f9ccf4 100644 --- a/src/adaptors/package-lock.json +++ b/src/adaptors/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@balancer-labs/sdk": "^1.1.5", "@defillama/sdk": "^2.3.126", - "@defillama/sdk5": "npm:@defillama/sdk@^5.0.37", + "@defillama/sdk5": "npm:@defillama/sdk@^5.0.53", "@types/jest": "^28.1.6", "@uniswap/sdk-core": "^3.0.1", "@uniswap/smart-order-router": "^2.8.0", @@ -1419,9 +1419,9 @@ }, "node_modules/@defillama/sdk5": { "name": "@defillama/sdk", - "version": "5.0.37", - "resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-5.0.37.tgz", - "integrity": "sha512-V+3bpkkU5fiHVDwcerk+aqozxYrPJ9aunNb4KbXO4CSB9YmCA23QJn+3EEP9e5iikjVmnlFCeIOVViMB86LkYQ==", + "version": "5.0.53", + "resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-5.0.53.tgz", + "integrity": "sha512-FhrgVni9TNEdOHV+7NHHTvfzHCkejI/1dG6Jj4TlK3vIGEgsgIlFxZzXImhnXf2SBxBMKvye9WF95Sk5RO6riQ==", "dependencies": { "@aws-sdk/client-s3": "^3.400.0", "@supercharge/promise-pool": "^2.1.0", diff --git a/src/adaptors/package.json b/src/adaptors/package.json index 28c8e58acf..087985bebe 100644 --- a/src/adaptors/package.json +++ b/src/adaptors/package.json @@ -9,7 +9,7 @@ "dependencies": { "@balancer-labs/sdk": "^1.1.5", "@defillama/sdk": "^2.3.126", - "@defillama/sdk5": "npm:@defillama/sdk@^5.0.37", + "@defillama/sdk5": "npm:@defillama/sdk@^5.0.53", "@types/jest": "^28.1.6", "@uniswap/sdk-core": "^3.0.1", "@uniswap/smart-order-router": "^2.8.0", From 7b6829bef03d0ae7d2eaf3baa6191a4afac32865 Mon Sep 17 00:00:00 2001 From: fungify <87287926+fungify@users.noreply.github.com> Date: Mon, 22 Apr 2024 03:09:53 -0400 Subject: [PATCH 26/73] Adding Fungify APY adapter (#1258) * initial comit * added basic functions * added most of adapter functionality * polishing * changed tvl to market size and added borrow apy * removed unused line * updated abi * updated package.json * updated package-lock * undo package changes * package update * various fixes --------- Co-authored-by: Ava Clementine Co-authored-by: CleanPegasus --- src/adaptors/fungify/abi.json | 126 +++++++++++++++++++ src/adaptors/fungify/index.js | 221 ++++++++++++++++++++++++++++++++++ 2 files changed, 347 insertions(+) create mode 100644 src/adaptors/fungify/abi.json create mode 100644 src/adaptors/fungify/index.js diff --git a/src/adaptors/fungify/abi.json b/src/adaptors/fungify/abi.json new file mode 100644 index 0000000000..60cb9a0676 --- /dev/null +++ b/src/adaptors/fungify/abi.json @@ -0,0 +1,126 @@ +{ + "getAllMarkets": "function getAllMarkets() view returns (address[])", + "cTokenMetadataAll": { + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenMetadataAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "compSupplySpeed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "compBorrowSpeed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCap", + "type": "uint256" + }, + { + "internalType": "enum CTokenStorage.MarketType", + "name": "marketType", + "type": "uint8" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + "balanceOf": "function balanceOf(address) view returns (uint256)", + "totalSupply": "function totalSupply() view returns (uint256)", + "exchangeRateStored": "function exchangeRateStored() view returns (uint256)", + "underlying": "function underlying() view returns (address)", + "symbol": "function symbol() view returns (string)", + "interestMarket": "function interestMarket() view returns (address)", + "interestRateModel": "function interestRateModel() view returns (address)", + "blocksPerYear": "function blocksPerYear() view returns (uint256)", + "getUnderlyingPrice": "function getUnderlyingPrice(address) view returns (uint256)", + "getCash": "function getCash() view returns (uint256)", + "totalReserves": "function totalReserves() view returns (uint256)", + "totalBorrows": "function totalBorrows() view returns (uint256)" +} \ No newline at end of file diff --git a/src/adaptors/fungify/index.js b/src/adaptors/fungify/index.js new file mode 100644 index 0000000000..468eb7674d --- /dev/null +++ b/src/adaptors/fungify/index.js @@ -0,0 +1,221 @@ +const utils = require('../utils'); +const sdk = require("@defillama/sdk5"); +const ABI = require("./abi.json"); + +const CHAIN = "ethereum"; +const COMPTROLLER = "0xf9c70750bF615dE83fE7FF62D30C7faACD8f8Ba0"; +const LENS = "0x2C4A503Bce0805C357D961e45b55BEEE073188E7"; +const PRICE_ORACLE = "0x9b960808875000AC17dfAE13B72BBDF69DF6e7A7"; +const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; +const SCALE = 1e18 + +// Fetch all Markets from comptroller +async function getAllMarkets() { + const cTokenMarkets = (await sdk.api.abi.call({ + target: COMPTROLLER, + params: [], + abi: ABI['getAllMarkets'], + chain: CHAIN + })).output; + return cTokenMarkets +} + +// Fetch metdata for all markets +async function getCtokenMetadata(markets) { + const cTokenMetadatas = (await sdk.api.abi.call({ + target: LENS, + params: [markets], + abi: ABI['cTokenMetadataAll'], + chain: CHAIN + })).output; + return cTokenMetadatas +} + +// Fetches balance of an asset for a given address +async function getBalance(assetAddress, subjectAddress) { + const underlyingBalance = (await sdk.api.abi.call({ + target: assetAddress, + params: [subjectAddress], + abi: ABI["balanceOf"], + chain: CHAIN + })).output; + return underlyingBalance +} + +// Fetches the cash of a cToken +async function getTotalCash(cTokenAddress) { + const totalCash = (await sdk.api.abi.call({ + target: cTokenAddress, + params: [], + abi: ABI["getCash"], + chain: CHAIN + })).output; + return totalCash +} + +// Fetches the total reserves of a cToken +async function getTotalReserves(cTokenAddress) { + const totalReserves = (await sdk.api.abi.call({ + target: cTokenAddress, + params: [], + abi: ABI["totalReserves"], + chain: CHAIN + })).output; + return totalReserves +} + +// Fetches the total borrows of a cToken +async function getTotalBorrows(cTokenAddress) { + const totalBorrows = (await sdk.api.abi.call({ + target: cTokenAddress, + params: [], + abi: ABI["totalBorrows"], + chain: CHAIN + })).output; + return totalBorrows +} + +// Fetches the cToken to underlying exchange rate of the asset +async function getExchangeRate(cTokenAddress) { + const exchangeRate = (await sdk.api.abi.call({ + target: cTokenAddress, + params: [], + abi: ABI["exchangeRateStored"], + chain: CHAIN + })).output; + return exchangeRate +} + + +// Gets the underlying asset of a cToken +async function getUnderlyingAsset(cTokenAddress) { + const underlyingAddress = (await sdk.api.abi.call({ + target: cTokenAddress, + params: [], + abi: ABI["underlying"], + chain: CHAIN + })).output; + return underlyingAddress +} + +// Gets the symbol of the market token +async function getSymbol(cTokenAddress) { + const symbol = (await sdk.api.abi.call({ + target: cTokenAddress, + params: [], + abi: ABI["symbol"], + chain: CHAIN + })).output; + return symbol +} + +// Gets the interestMarket for cErc721s +async function getInterestMarket() { + const interestMarket = (await sdk.api.abi.call({ + target: COMPTROLLER, + params: [], + abi: ABI["interestMarket"], + chain: CHAIN + })).output; + return interestMarket +} + +// Gets the interestRateModel (used for blocksPerYear) +async function getInterestRateModel(cTokenAddress) { + const interestRateModel = (await sdk.api.abi.call({ + target: cTokenAddress, + params: [], + abi: ABI["interestRateModel"], + chain: CHAIN + })).output; + return interestRateModel +} + +// Gets the blockPerYear for apys +async function getBlocksPerYear(interestRateModel) { + const blocksPerYear = (await sdk.api.abi.call({ + target: interestRateModel, + params: [], + abi: ABI["blocksPerYear"], + chain: CHAIN + })).output; + return blocksPerYear +} + +async function getUnderlyingPrice(cTokenAddress) { + const underlyingPrice = (await sdk.api.abi.call({ + target: PRICE_ORACLE, + params: [cTokenAddress], + abi: ABI['getUnderlyingPrice'], + chain: CHAIN + })).output; + return underlyingPrice +} + +// Creates a pool dictionary of the proper format +async function poolStruct(poolIdentifier, chain, symbol, tvlUsd, totalBorrowsUsd, totalSuppliesUsd, apy, underlyingTokens, apyBorrow, ltv) { + return { + pool: poolIdentifier, // unique identifier for the pool in the form of: `${ReceivedTokenAddress}-${chain}`.toLowerCase() + chain: chain, // chain where the pool is (needs to match the `name` field in here https://api.llama.fi/chains) + project: "fungify", // protocol (using the slug again) + symbol: symbol, // symbol of the tokens in pool, can be a single symbol if pool is single-sided or multiple symbols (eg: USDT-ETH) if it's an LP + tvlUsd: tvlUsd, // number representing current USD free liquidity in pool + totalBorrowUsd: totalBorrowsUsd, // number representing current USD borrows in pool + totalSupplyUsd: totalSuppliesUsd, // number representing current USD supplies in pool + apyBase: apy, // APY from pool fees/supplying in % + underlyingTokens: underlyingTokens, // Array of underlying token addresses from a pool, eg here USDT address on ethereum // Array; + url: "https://app.fungify.it/pools", // URL for app + apyBaseBorrow: apyBorrow, // Borrow APR + ltv: ltv // Collateral Factor + } +} + +// Fetches the apy for all markets +async function poolsAPY() { + + const markets = await getAllMarkets(); + const cTokenMetadatas = await getCtokenMetadata(markets); + const interestMarket = await getInterestMarket(); + const interestToken = await getUnderlyingAsset(interestMarket); + let pools = []; + + // Iterates through each market's metadata calculating the APY + for(const cTokenMetaData of cTokenMetadatas) { + + const cTokenAddress = cTokenMetaData.cToken; + const symbol = await getSymbol(cTokenAddress); + if (symbol.includes("_NB")) continue; // Excludes no borrow markets since they will always have 0% APY + + let underlyingAsset = cTokenMetaData.underlyingAssetAddress; + const marketType = cTokenMetaData.marketType; + + const interestRateModel = await getInterestRateModel(cTokenAddress); + const supplyRatePerBlock = cTokenMetaData.supplyRatePerBlock; + const borrowRatePerBlock = cTokenMetaData.borrowRatePerBlock; + const blocksPerYear = await getBlocksPerYear(interestRateModel); + const apy = supplyRatePerBlock * blocksPerYear / SCALE * 100; + const apyBorrow = borrowRatePerBlock * blocksPerYear / SCALE * 100; + + const ltv = cTokenMetaData.collateralFactorMantissa / SCALE; + const underlyingPrice = await getUnderlyingPrice(cTokenAddress) + const poolIdentifier = `${cTokenAddress}-${CHAIN}`.toLowerCase(); + + const totalCash = Number(await getTotalCash(cTokenAddress)); + const totalBorrows = Number(await getTotalBorrows(cTokenAddress)); + const totalReserves = Number(await getTotalReserves(cTokenAddress)); + + const tvlUsd = (totalCash - totalReserves) * underlyingPrice / SCALE / SCALE; + const totalBorrowsUsd = totalBorrows * underlyingPrice / SCALE / SCALE; + const totalSuppliesUsd = (totalCash + totalBorrows - totalReserves) * underlyingPrice / SCALE / SCALE; + + let poolInfo = await poolStruct(poolIdentifier, CHAIN, symbol, tvlUsd, totalBorrowsUsd, totalSuppliesUsd, apy, [underlyingAsset], apyBorrow, ltv); + pools.push(poolInfo); + } + return pools; +} + +module.exports = { + timetravel: false, + apy: poolsAPY, + url: 'https://app.fungify.it/pools', +}; \ No newline at end of file From 4ce24e7376685c466ecdd8cb658b95c5a50b444e Mon Sep 17 00:00:00 2001 From: slasher125 Date: Mon, 22 Apr 2024 11:19:59 +0400 Subject: [PATCH 27/73] baseswap change subgraph --- src/adaptors/basex/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adaptors/basex/index.js b/src/adaptors/basex/index.js index 3b2b740774..2f9eab0e80 100644 --- a/src/adaptors/basex/index.js +++ b/src/adaptors/basex/index.js @@ -7,7 +7,7 @@ const { EstimatedFees } = require('./estimateFee'); const { checkStablecoin } = require('../../handlers/triggerEnrichment'); const { boundaries } = require('../../utils/exclude'); -const url = 'https://api.thegraph.com/subgraphs/name/harleen-m/basex'; +const url = 'https://api.thegraph.com/subgraphs/name/baseswapfi/v3-base'; const query = gql` { From 937ac52bde0e0e099109d108af24e52e614aca9f Mon Sep 17 00:00:00 2001 From: slasher125 Date: Mon, 22 Apr 2024 11:24:20 +0400 Subject: [PATCH 28/73] clip finance fix --- src/adaptors/clip-finance/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adaptors/clip-finance/index.js b/src/adaptors/clip-finance/index.js index 1b0ad90431..c8f089526a 100644 --- a/src/adaptors/clip-finance/index.js +++ b/src/adaptors/clip-finance/index.js @@ -29,7 +29,7 @@ const config = { }; const getUrl = (chain, from) => - `https://stats-kixqx.ondigitalocean.app/apy?from=${from}&chain=${chain}`; + `https://stats-kixqx.ondigitalocean.app/daily-apy?from=${from}&chain=${chain}`; const pairsToObj = (pairs) => pairs.reduce((acc, [el1, el2]) => ({ ...acc, [el1]: el2 }), {}); From 3607bc0ad49a87085f241484c9eeaf1a6f2ece1c Mon Sep 17 00:00:00 2001 From: slasher125 Date: Mon, 22 Apr 2024 11:43:45 +0400 Subject: [PATCH 29/73] fraxlend remove apyrewardborrow --- src/adaptors/fraxlend/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/adaptors/fraxlend/index.js b/src/adaptors/fraxlend/index.js index ce03175c91..7278624a55 100644 --- a/src/adaptors/fraxlend/index.js +++ b/src/adaptors/fraxlend/index.js @@ -284,7 +284,7 @@ const main = async () => { .div(BIG_10.pow(18)) .multipliedBy(100); - const apyRewardBorrow = apyBaseBorrow + const apyBase = apyBaseBorrow .multipliedBy(new BigNumber(totalBorrows[index].amount)) .div(new BigNumber(totalAssets[index].amount)); return { @@ -292,11 +292,10 @@ const main = async () => { project: 'fraxlend', symbol: underlyingCollaterals[index], chain: 'ethereum', - apyBase: apyRewardBorrow.toNumber(), + apyBase: apyBase.toNumber(), tvlUsd: tvlUsd.toNumber(), // borrow fields apyBaseBorrow: apyBaseBorrow.toNumber(), - apyRewardBorrow: apyRewardBorrow.toNumber(), totalSupplyUsd: tvlUsd.toNumber(), totalBorrowUsd: totalBorrowUsd.toNumber(), debtCeilingUsd: debtCeilingUsd.toNumber(), From a0dfe1333755b493458812473ca30295a558f81d Mon Sep 17 00:00:00 2001 From: slasher125 Date: Tue, 23 Apr 2024 10:37:38 +0400 Subject: [PATCH 30/73] abracadabra rename --- .../abis/BaseStargateLPStrategy.json | 0 .../{abracadabra => abracadabra-spell}/abis/BentoBoxV1.json | 0 .../{abracadabra => abracadabra-spell}/abis/CauldronV2.json | 0 .../{abracadabra => abracadabra-spell}/abis/ERC4626.json | 0 .../{abracadabra => abracadabra-spell}/abis/FeeCollectable.json | 0 .../{abracadabra => abracadabra-spell}/abis/GlpManager.json | 0 .../abis/InterestStrategy.json | 0 .../abis/MagicGlpHarvestor.json | 0 .../{abracadabra => abracadabra-spell}/abis/MarketLens.json | 0 .../abis/MultiRewardsStaking.json | 0 .../{abracadabra => abracadabra-spell}/abis/RewardTracker.json | 0 .../{abracadabra => abracadabra-spell}/abis/Sorbettiere.json | 0 .../{abracadabra => abracadabra-spell}/abis/UniswapV2Pair.json | 0 src/adaptors/{abracadabra => abracadabra-spell}/cauldrons.js | 2 +- src/adaptors/{abracadabra => abracadabra-spell}/farms.js | 2 +- src/adaptors/{abracadabra => abracadabra-spell}/index.js | 0 src/adaptors/{abracadabra => abracadabra-spell}/magic-glp.js | 2 +- .../{abracadabra => abracadabra-spell}/multi-reward-farms.js | 2 +- 18 files changed, 4 insertions(+), 4 deletions(-) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/BaseStargateLPStrategy.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/BentoBoxV1.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/CauldronV2.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/ERC4626.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/FeeCollectable.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/GlpManager.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/InterestStrategy.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/MagicGlpHarvestor.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/MarketLens.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/MultiRewardsStaking.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/RewardTracker.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/Sorbettiere.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/abis/UniswapV2Pair.json (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/cauldrons.js (99%) rename src/adaptors/{abracadabra => abracadabra-spell}/farms.js (99%) rename src/adaptors/{abracadabra => abracadabra-spell}/index.js (100%) rename src/adaptors/{abracadabra => abracadabra-spell}/magic-glp.js (99%) rename src/adaptors/{abracadabra => abracadabra-spell}/multi-reward-farms.js (99%) diff --git a/src/adaptors/abracadabra/abis/BaseStargateLPStrategy.json b/src/adaptors/abracadabra-spell/abis/BaseStargateLPStrategy.json similarity index 100% rename from src/adaptors/abracadabra/abis/BaseStargateLPStrategy.json rename to src/adaptors/abracadabra-spell/abis/BaseStargateLPStrategy.json diff --git a/src/adaptors/abracadabra/abis/BentoBoxV1.json b/src/adaptors/abracadabra-spell/abis/BentoBoxV1.json similarity index 100% rename from src/adaptors/abracadabra/abis/BentoBoxV1.json rename to src/adaptors/abracadabra-spell/abis/BentoBoxV1.json diff --git a/src/adaptors/abracadabra/abis/CauldronV2.json b/src/adaptors/abracadabra-spell/abis/CauldronV2.json similarity index 100% rename from src/adaptors/abracadabra/abis/CauldronV2.json rename to src/adaptors/abracadabra-spell/abis/CauldronV2.json diff --git a/src/adaptors/abracadabra/abis/ERC4626.json b/src/adaptors/abracadabra-spell/abis/ERC4626.json similarity index 100% rename from src/adaptors/abracadabra/abis/ERC4626.json rename to src/adaptors/abracadabra-spell/abis/ERC4626.json diff --git a/src/adaptors/abracadabra/abis/FeeCollectable.json b/src/adaptors/abracadabra-spell/abis/FeeCollectable.json similarity index 100% rename from src/adaptors/abracadabra/abis/FeeCollectable.json rename to src/adaptors/abracadabra-spell/abis/FeeCollectable.json diff --git a/src/adaptors/abracadabra/abis/GlpManager.json b/src/adaptors/abracadabra-spell/abis/GlpManager.json similarity index 100% rename from src/adaptors/abracadabra/abis/GlpManager.json rename to src/adaptors/abracadabra-spell/abis/GlpManager.json diff --git a/src/adaptors/abracadabra/abis/InterestStrategy.json b/src/adaptors/abracadabra-spell/abis/InterestStrategy.json similarity index 100% rename from src/adaptors/abracadabra/abis/InterestStrategy.json rename to src/adaptors/abracadabra-spell/abis/InterestStrategy.json diff --git a/src/adaptors/abracadabra/abis/MagicGlpHarvestor.json b/src/adaptors/abracadabra-spell/abis/MagicGlpHarvestor.json similarity index 100% rename from src/adaptors/abracadabra/abis/MagicGlpHarvestor.json rename to src/adaptors/abracadabra-spell/abis/MagicGlpHarvestor.json diff --git a/src/adaptors/abracadabra/abis/MarketLens.json b/src/adaptors/abracadabra-spell/abis/MarketLens.json similarity index 100% rename from src/adaptors/abracadabra/abis/MarketLens.json rename to src/adaptors/abracadabra-spell/abis/MarketLens.json diff --git a/src/adaptors/abracadabra/abis/MultiRewardsStaking.json b/src/adaptors/abracadabra-spell/abis/MultiRewardsStaking.json similarity index 100% rename from src/adaptors/abracadabra/abis/MultiRewardsStaking.json rename to src/adaptors/abracadabra-spell/abis/MultiRewardsStaking.json diff --git a/src/adaptors/abracadabra/abis/RewardTracker.json b/src/adaptors/abracadabra-spell/abis/RewardTracker.json similarity index 100% rename from src/adaptors/abracadabra/abis/RewardTracker.json rename to src/adaptors/abracadabra-spell/abis/RewardTracker.json diff --git a/src/adaptors/abracadabra/abis/Sorbettiere.json b/src/adaptors/abracadabra-spell/abis/Sorbettiere.json similarity index 100% rename from src/adaptors/abracadabra/abis/Sorbettiere.json rename to src/adaptors/abracadabra-spell/abis/Sorbettiere.json diff --git a/src/adaptors/abracadabra/abis/UniswapV2Pair.json b/src/adaptors/abracadabra-spell/abis/UniswapV2Pair.json similarity index 100% rename from src/adaptors/abracadabra/abis/UniswapV2Pair.json rename to src/adaptors/abracadabra-spell/abis/UniswapV2Pair.json diff --git a/src/adaptors/abracadabra/cauldrons.js b/src/adaptors/abracadabra-spell/cauldrons.js similarity index 99% rename from src/adaptors/abracadabra/cauldrons.js rename to src/adaptors/abracadabra-spell/cauldrons.js index 3e3e98d48a..58594b48a4 100644 --- a/src/adaptors/abracadabra/cauldrons.js +++ b/src/adaptors/abracadabra-spell/cauldrons.js @@ -719,7 +719,7 @@ const getApy = async () => { return { ...marketInfoToPool(chain, marketInfo, collateral, pricesObj), - project: 'abracadabra', + project: 'abracadabra-spell', }; }) ); diff --git a/src/adaptors/abracadabra/farms.js b/src/adaptors/abracadabra-spell/farms.js similarity index 99% rename from src/adaptors/abracadabra/farms.js rename to src/adaptors/abracadabra-spell/farms.js index f647dcbdf8..d0a08687a5 100644 --- a/src/adaptors/abracadabra/farms.js +++ b/src/adaptors/abracadabra-spell/farms.js @@ -240,7 +240,7 @@ const getApy = async () => { return { pool: `${pool.stakingToken}-abracadabra`, chain: utils.formatChain(chain), - project: 'abracadabra', + project: 'abracadabra-spell', tvlUsd, symbol, apyReward, diff --git a/src/adaptors/abracadabra/index.js b/src/adaptors/abracadabra-spell/index.js similarity index 100% rename from src/adaptors/abracadabra/index.js rename to src/adaptors/abracadabra-spell/index.js diff --git a/src/adaptors/abracadabra/magic-glp.js b/src/adaptors/abracadabra-spell/magic-glp.js similarity index 99% rename from src/adaptors/abracadabra/magic-glp.js rename to src/adaptors/abracadabra-spell/magic-glp.js index c3b858abc1..b157cec8c8 100644 --- a/src/adaptors/abracadabra/magic-glp.js +++ b/src/adaptors/abracadabra-spell/magic-glp.js @@ -219,7 +219,7 @@ const getApy = async () => { return { pool: `${magicGlpAddress}-magicglp-${chain}`, chain: utils.formatChain(chain), - project: 'abracadabra', + project: 'abracadabra-spell', symbol: utils.formatSymbol('magicGLP'), tvlUsd: (magicGlpTotalAssets[chain] / 10 ** glp.decimals) * glpPrice[chain], diff --git a/src/adaptors/abracadabra/multi-reward-farms.js b/src/adaptors/abracadabra-spell/multi-reward-farms.js similarity index 99% rename from src/adaptors/abracadabra/multi-reward-farms.js rename to src/adaptors/abracadabra-spell/multi-reward-farms.js index c4a09bb5b6..921de755cb 100644 --- a/src/adaptors/abracadabra/multi-reward-farms.js +++ b/src/adaptors/abracadabra-spell/multi-reward-farms.js @@ -74,7 +74,7 @@ const getApy = async () => { return { pool: `${address}-${chain}`, chain: utils.formatChain(chain), - project: 'abracadabra', + project: 'abracadabra-spell', tvlUsd: Number(tvlUsdChainFarms[address.toLowerCase()]), symbol: symbol ?? utils.formatSymbol(symbols[stakingToken.toLowerCase()].output), apyBase: stakingTokenYieldPool.apyBase, From 4fa5c52051d9b65e4c139ab10bbcbd6d6413a168 Mon Sep 17 00:00:00 2001 From: Benny Date: Wed, 24 Apr 2024 02:05:51 +1000 Subject: [PATCH 31/73] Track Curve lending markets (#1278) * Track curve lending markets * Rename to curve-llamalend * Remove curve-lending --- src/adaptors/curve-llamalend/index.js | 76 +++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/adaptors/curve-llamalend/index.js diff --git a/src/adaptors/curve-llamalend/index.js b/src/adaptors/curve-llamalend/index.js new file mode 100644 index 0000000000..cb24f842d9 --- /dev/null +++ b/src/adaptors/curve-llamalend/index.js @@ -0,0 +1,76 @@ +const utils = require('../utils'); + +const getLendingPoolData = async () => { + try { + const response = await utils.getData('https://api.curve.fi/v1/getLendingVaults/all'); + if (response.success) { + return response.data.lendingVaultData.map(vault =>({ + pool: vault.address + '-' + vault.blockchainId, + chain: utils.formatChain(vault.blockchainId), + project: 'curve-llamalend', + symbol: vault.assets.borrowed.symbol + '-' + vault.assets.collateral.symbol, + tvlUsd: vault.usdTotal, + underlyingTokens: [vault.assets.collateral.address], + url: vault.lendingVaultUrls.deposit, + apyBase: vault.rates.lendApyPcent, + apyBaseBorrow: vault.rates.borrowApyPcent, + totalSupplyUsd: vault.totalSupplied.usdTotal + })) + } else { + console.error('Failed to fetch lending pool data'); + return []; + } + } catch (error) { + console.error('Error fetching lending pool data:', error); + return []; + } +}; + +const getGaugesData = async () => { + try { + const response = await utils.getData('https://api.curve.fi/v1/getAllGauges'); + if (response.success) { + const gaugesByAddress = {}; + Object.entries(response.data).forEach(([key, gauge]) => { + if (gauge.lendingVaultAddress) { + gaugesByAddress[gauge.lendingVaultAddress.toLowerCase()] = { + crvApy: gauge.gaugeCrvApy ? gauge.gaugeCrvApy[0] : null, + rewardTokens: gauge.gaugeCrvApy ? ['0xD533a949740bb3306d119CC777fa900bA034cd52'] : null + }; + } + }); + return gaugesByAddress; + } else { + console.error('Failed to fetch gauges data'); + return {}; + } + } catch (error) { + console.error('Error fetching gauges data:', error); + return {}; + } +}; + +const fullLendingPoolDataWithGauges = async () => { + const [lendingPools, gaugesByAddress] = await Promise.all([ + getLendingPoolData(), + getGaugesData() + ]); + + return lendingPools.map(pool => { + const gaugeInfo = gaugesByAddress[pool.pool.split('-')[0].toLowerCase()] || {}; + return { + ...pool, + apyReward: gaugeInfo.crvApy, + rewardTokens: gaugeInfo.rewardTokens + }; + }); +}; + +const main = async () => { + return await fullLendingPoolDataWithGauges(); +}; + + +module.exports = { + apy: main, +}; From 63d3daa7adc7ecc5d9476111afdde818f4387653 Mon Sep 17 00:00:00 2001 From: ruhum <90156563+0xruhum@users.noreply.github.com> Date: Tue, 23 Apr 2024 19:06:36 +0300 Subject: [PATCH 32/73] feat: add primeETH yield (#1279) * feat: add primeETH yield * fix: use on-chain calls for tvl --- src/adaptors/prime-staked-eth/index.js | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/adaptors/prime-staked-eth/index.js diff --git a/src/adaptors/prime-staked-eth/index.js b/src/adaptors/prime-staked-eth/index.js new file mode 100644 index 0000000000..01920c7e7b --- /dev/null +++ b/src/adaptors/prime-staked-eth/index.js @@ -0,0 +1,48 @@ +const sdk = require("@defillama/sdk5"); +const axios = require('axios'); + +const utils = require("../utils.js"); + +const PRIME_ETH = "0x6ef3D766Dfe02Dc4bF04aAe9122EB9A0Ded25615"; +const LRT_ORACLE = "0xA755c18CD2376ee238daA5Ce88AcF17Ea74C1c32"; + +const apy = async () => { + const totalSupply = await sdk.api.abi.call({ + abi: 'uint:totalSupply', + target: PRIME_ETH + }); + // primeETH/ETH price + const primeEthPrice = await sdk.api.abi.call({ + abi: 'uint:primeETHPrice', + target: LRT_ORACLE, + }); + const priceData = await utils.getData( + 'https://coins.llama.fi/prices/current/coingecko:ethereum?searchWidth=4h' + ); + const ethPrice = priceData.coins['coingecko:ethereum'].price; + const tvlUsd = totalSupply.output * primeEthPrice.output / 1e36 * ethPrice; + + + const { data } = await axios.get("https://api.originprotocol.com/api/v2/primestaked"); + + const primeStaked = { + pool: "0x6ef3D766Dfe02Dc4bF04aAe9122EB9A0Ded25615-ethereum".toLowerCase(), + chain: "Ethereum", + project: "prime-staked-eth", + symbol: "primeETH", + apy: data.apy, + tvlUsd, + underlyingTokens: [ + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + "0x0000000000000000000000000000000000000000", + "0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3", + ] + } + + return [primeStaked]; +}; +module.exports = { + timetravel: false, + apy, + url: "https://www.primestaked.com", +} \ No newline at end of file From 5ea020efeec122539632d9d310a4aad5ad815471 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Wed, 24 Apr 2024 12:21:15 +0400 Subject: [PATCH 33/73] abra fix --- src/adaptors/abracadabra-spell/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/adaptors/abracadabra-spell/index.js b/src/adaptors/abracadabra-spell/index.js index 248490d589..7ae9bc5e73 100644 --- a/src/adaptors/abracadabra-spell/index.js +++ b/src/adaptors/abracadabra-spell/index.js @@ -2,15 +2,19 @@ const cauldrons = require('./cauldrons'); const multiRewardFarms = require('./multi-reward-farms'); const farms = require('./farms'); const magicGlp = require('./magic-glp'); +const utils = require('../utils'); -const getApy = async () => - [ +const getApy = async () => { + const pools = [ ...(await cauldrons()), ...(await farms()), ...(await magicGlp()), ...(await multiRewardFarms()), ].map((i) => ({ ...i, pool: i.pool.toLowerCase() })); + return utils.removeDuplicates(pools); +}; + module.exports = { timetravel: false, apy: getApy, From dbc6db674411135ea28850382629afeb15c1c060 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Wed, 24 Apr 2024 20:01:37 +0400 Subject: [PATCH 34/73] blast futures rename --- src/adaptors/{blast-futures => bfx-(blast-futures)}/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/adaptors/{blast-futures => bfx-(blast-futures)}/index.js (96%) diff --git a/src/adaptors/blast-futures/index.js b/src/adaptors/bfx-(blast-futures)/index.js similarity index 96% rename from src/adaptors/blast-futures/index.js rename to src/adaptors/bfx-(blast-futures)/index.js index a5818bbaad..2839636651 100644 --- a/src/adaptors/blast-futures/index.js +++ b/src/adaptors/bfx-(blast-futures)/index.js @@ -27,7 +27,7 @@ const getApy = async () => { return pools.map((p) => ({ chain: utils.formatChain(CHAIN), - project: 'blast-futures', + project: 'bfx-(blast-futures)', pool: 'Dynamic AMM LP', symbol: 'USDB', tvlUsd: tvlValue * Number(p.share_price), From 730ac00369cc9dc6c0ff3fdbacf4d3987f137904 Mon Sep 17 00:00:00 2001 From: "Web3.World" <165679484+web3world@users.noreply.github.com> Date: Thu, 25 Apr 2024 18:09:29 +0700 Subject: [PATCH 35/73] feat: added yield-server adapter for web3world project (#1281) * feat: added yield-server adapter for web3world project * fix: now apy calculates according to the annual period * fix: handling of the case with infinite apy --- src/adaptors/web3.world/index.js | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/adaptors/web3.world/index.js diff --git a/src/adaptors/web3.world/index.js b/src/adaptors/web3.world/index.js new file mode 100644 index 0000000000..c3e2a916de --- /dev/null +++ b/src/adaptors/web3.world/index.js @@ -0,0 +1,73 @@ +const { default: BigNumber } = require('bignumber.js'); +const utils = require('../utils'); + + +const getPoolStats = async () => { + return await utils.getData( + "https://api.web3.world/v2/pools", + { + limit: 1000, + offset: 0, + ordering: "tvldescending", + whiteListUri: "https://static.web3.world/assets/manifest.json", + } + ); +}; + +const getFarmingPoolStats = async () => { + return await utils.getData( + "https://farming.web3.world/v2/gauges", + { + additionalTokenRoots: [], + limit: 1000, + offset: 0, + showLowBalance: false, + whitelistUri: "https://static.web3.world/assets/manifest.json" + } + ); +}; + +const calcApy = (fee7d, tvl) => { + const apy = BigNumber(fee7d).div(7).times(365).div(tvl).div(365).plus(1).pow(365).minus(1); + if (apy.isNaN() || !apy.isFinite()) return 0 + return apy.times(100).toNumber() +} + +const fetch = async () => { + const poolsStats = await getPoolStats(); + const farmingPoolsStats = await getFarmingPoolStats(); + const result = [] + poolsStats.pools.forEach((pool) => { + result.push({ + pool: pool.meta.poolAddress, + chain: utils.formatChain('venom'), + project: 'web3.world', + symbol: pool.meta.currencies.join('-'), + tvlUsd: Number(pool.tvl), + underlyingTokens: pool.meta.currencyAddresses, + apy: calcApy(pool.fee7d, pool.tvl), + url: "https://web3.world/pools/" + pool.meta.poolAddress + }) + }) + farmingPoolsStats.gauges.forEach((pool) => { + result.push({ + pool: pool.address, + chain: utils.formatChain('venom'), + project: 'web3.world', + symbol: pool.poolTokens.map(({ tokenSymbol }) => tokenSymbol).join('-'), + tvlUsd: Number(pool.tvl), + rewardTokens: pool.rewardTokens.map(({ tokenRoot }) => tokenRoot), + underlyingTokens: pool.poolTokens.map(({ tokenRoot }) => tokenRoot), + apy: Number(pool.minApr), + url: "https://web3.world/farming/" + pool.address + }) + }) + + return result; +}; + +module.exports = { + timetravel: false, + apy: fetch, + url: 'https://web3.world', +}; From 43d5d942c97263f305368ec49adbff8774ea56b8 Mon Sep 17 00:00:00 2001 From: Georgi Popov Date: Thu, 25 Apr 2024 17:01:05 +0300 Subject: [PATCH 36/73] Created return-finance adapter (#1282) --- .../return-finance/abiAAVEAvalanche.json | 1138 ++++++++++++ .../return-finance/abiAAVEPolygon.json | 1138 ++++++++++++ .../return-finance/abiCompoundV3Base.json | 1120 ++++++++++++ src/adaptors/return-finance/abiConvex.json | 1528 +++++++++++++++++ src/adaptors/return-finance/abiMakerDAO.json | 1200 +++++++++++++ src/adaptors/return-finance/index.js | 78 + 6 files changed, 6202 insertions(+) create mode 100644 src/adaptors/return-finance/abiAAVEAvalanche.json create mode 100644 src/adaptors/return-finance/abiAAVEPolygon.json create mode 100644 src/adaptors/return-finance/abiCompoundV3Base.json create mode 100644 src/adaptors/return-finance/abiConvex.json create mode 100644 src/adaptors/return-finance/abiMakerDAO.json create mode 100644 src/adaptors/return-finance/index.js diff --git a/src/adaptors/return-finance/abiAAVEAvalanche.json b/src/adaptors/return-finance/abiAAVEAvalanche.json new file mode 100644 index 0000000000..c69983fb45 --- /dev/null +++ b/src/adaptors/return-finance/abiAAVEAvalanche.json @@ -0,0 +1,1138 @@ +[ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_usdc", + "type": "address" + }, + { + "internalType": "address", + "name": "_aaveV3Pool", + "type": "address" + }, + { + "internalType": "address", + "name": "_aEthUSDC", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxDeposit", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxMint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxRedeem", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxWithdraw", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "MathOverflowedMulDiv", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrongAddress", + "type": "address" + } + ], + "name": "NotInWhitelist", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "UnableToSweep", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "whitelistedAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + } + ], + "name": "AddressWhitelisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "PoolDonation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "totalUsdc", + "type": "uint256" + } + ], + "name": "RescueFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "SweepFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [], + "name": "aEthUSDC", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "aaveV3Pool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "asset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "callExternalContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "convertToAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "convertToShares", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "destination", + "type": "address" + } + ], + "name": "rescueFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "sweepFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "updatedAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + } + ], + "name": "toggleWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "usdc", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "whitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/src/adaptors/return-finance/abiAAVEPolygon.json b/src/adaptors/return-finance/abiAAVEPolygon.json new file mode 100644 index 0000000000..c69983fb45 --- /dev/null +++ b/src/adaptors/return-finance/abiAAVEPolygon.json @@ -0,0 +1,1138 @@ +[ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_usdc", + "type": "address" + }, + { + "internalType": "address", + "name": "_aaveV3Pool", + "type": "address" + }, + { + "internalType": "address", + "name": "_aEthUSDC", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxDeposit", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxMint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxRedeem", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxWithdraw", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "MathOverflowedMulDiv", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrongAddress", + "type": "address" + } + ], + "name": "NotInWhitelist", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "UnableToSweep", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "whitelistedAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + } + ], + "name": "AddressWhitelisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "PoolDonation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "totalUsdc", + "type": "uint256" + } + ], + "name": "RescueFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "SweepFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [], + "name": "aEthUSDC", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "aaveV3Pool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "asset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "callExternalContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "convertToAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "convertToShares", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "destination", + "type": "address" + } + ], + "name": "rescueFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "sweepFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "updatedAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + } + ], + "name": "toggleWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "usdc", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "whitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/src/adaptors/return-finance/abiCompoundV3Base.json b/src/adaptors/return-finance/abiCompoundV3Base.json new file mode 100644 index 0000000000..f769159525 --- /dev/null +++ b/src/adaptors/return-finance/abiCompoundV3Base.json @@ -0,0 +1,1120 @@ +[ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_usdc", + "type": "address" + }, + { + "internalType": "address", + "name": "_cUSDCv3", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxDeposit", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxMint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxRedeem", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxWithdraw", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "MathOverflowedMulDiv", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrongAddress", + "type": "address" + } + ], + "name": "NotInWhitelist", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "UnableToSweep", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "whitelistedAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + } + ], + "name": "AddressWhitelisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "PoolDonation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "totalUsdc", + "type": "uint256" + } + ], + "name": "RescueFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "SweepFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "asset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cUSDCv3", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "callExternalContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "convertToAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "convertToShares", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "destination", + "type": "address" + } + ], + "name": "rescueFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "sweepFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "updatedAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + } + ], + "name": "toggleWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "usdc", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "whitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/src/adaptors/return-finance/abiConvex.json b/src/adaptors/return-finance/abiConvex.json new file mode 100644 index 0000000000..48182a1899 --- /dev/null +++ b/src/adaptors/return-finance/abiConvex.json @@ -0,0 +1,1528 @@ +[ + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20", + "name": "usdc", + "type": "address" + }, + { + "internalType": "address", + "name": "cvx", + "type": "address" + }, + { + "internalType": "address", + "name": "crv", + "type": "address" + }, + { + "internalType": "address", + "name": "curveLpToken", + "type": "address" + }, + { + "internalType": "address", + "name": "curveDepositZap", + "type": "address" + }, + { + "internalType": "address", + "name": "convexBooster", + "type": "address" + }, + { + "internalType": "address", + "name": "convexRewards", + "type": "address" + }, + { + "internalType": "address", + "name": "convexHandler", + "type": "address" + }, + { + "internalType": "uint256", + "name": "convexPoolId", + "type": "uint256" + }, + { + "internalType": "uint24", + "name": "uniswapFee", + "type": "uint24" + }, + { + "internalType": "address", + "name": "uniswapV3Router", + "type": "address" + }, + { + "internalType": "address", + "name": "chainlinkDataFeedCVXUSD", + "type": "address" + }, + { + "internalType": "address", + "name": "chainlinkDataFeedCRVUSD", + "type": "address" + } + ], + "internalType": "struct IReturnFinanceConvexUSDCVault.Config", + "name": "config", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "ChainlinkIncompleteRound", + "type": "error" + }, + { + "inputs": [], + "name": "ChainlinkPriceZero", + "type": "error" + }, + { + "inputs": [], + "name": "ChainlinkStalePrice", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxDeposit", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxMint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxRedeem", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxWithdraw", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "MathOverflowedMulDiv", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrongAddress", + "type": "address" + } + ], + "name": "NotInWhitelist", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "UnableToSweep", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "whitelistedAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + } + ], + "name": "AddressWhitelisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "HarvestRewards", + "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": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "PoolDonation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "totalUsdc", + "type": "uint256" + } + ], + "name": "RescueFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "crvRewards", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "cvxRewards", + "type": "uint256" + } + ], + "name": "RescueRewards", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "harvest", + "type": "bool" + } + ], + "name": "SetHarvestRewards", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newSlippage", + "type": "uint256" + } + ], + "name": "SlippageUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint24", + "name": "newSwapFee", + "type": "uint24" + } + ], + "name": "SwapFeeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "SweepFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "asset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "callExternalContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "chainlinkDataFeedCRVUSD", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "chainlinkDataFeedCVXUSD", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "convertToAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "convertToShares", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "convexBooster", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "convexHandler", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "convexPoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "convexRewards", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "crv", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "crvPriceUSD", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "curveDepositZap", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "curveLpToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cvx", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cvxPriceUSD", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "earnedCRV", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "earnedCVX", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "harvestAndDepositRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "harvestAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "harvestRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "harvestAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "destination", + "type": "address" + } + ], + "name": "rescueFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "destination", + "type": "address" + } + ], + "name": "rescueRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stakedLpInConvex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "sweepFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "updatedAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + } + ], + "name": "toggleWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "uniswapFee", + "outputs": [ + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "uniswapV3Router", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint24", + "name": "newSwapFee", + "type": "uint24" + } + ], + "name": "updateSwapFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "usdc", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "whitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/src/adaptors/return-finance/abiMakerDAO.json b/src/adaptors/return-finance/abiMakerDAO.json new file mode 100644 index 0000000000..f8e0930987 --- /dev/null +++ b/src/adaptors/return-finance/abiMakerDAO.json @@ -0,0 +1,1200 @@ +[ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_usdc", + "type": "address" + }, + { + "internalType": "address", + "name": "_dai", + "type": "address" + }, + { + "internalType": "address", + "name": "_sDai", + "type": "address" + }, + { + "internalType": "address", + "name": "_uniswapV3Router", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_slippage", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxDeposit", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxMint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxRedeem", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ERC4626ExceededMaxWithdraw", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "MathOverflowedMulDiv", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrongAddress", + "type": "address" + } + ], + "name": "NotInWhitelist", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "UnableToSweep", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "whitelistedAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + } + ], + "name": "AddressWhitelisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "PoolDonation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "totalDai", + "type": "uint256" + } + ], + "name": "RescueFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newSlippage", + "type": "uint256" + } + ], + "name": "SlippageUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "SweepFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "asset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "callExternalContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "convertToAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "convertToShares", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "dai", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewMint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "destination", + "type": "address" + } + ], + "name": "rescueFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sDai", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newSlippage", + "type": "uint256" + } + ], + "name": "setSlippage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "slippage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "sweepFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "updatedAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + } + ], + "name": "toggleWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "uniswapV3Router", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "usdc", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "whitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/src/adaptors/return-finance/index.js b/src/adaptors/return-finance/index.js new file mode 100644 index 0000000000..95ceeaf905 --- /dev/null +++ b/src/adaptors/return-finance/index.js @@ -0,0 +1,78 @@ +const sdk = require('@defillama/sdk5'); +const utils = require('../utils'); + +const abiAAVEPolygon = require('./abiAAVEPolygon.json'); +const abiAAVEAvalanche = require('./abiAAVEAvalanche.json'); +const abiCompoundV3Base = require('./abiCompoundV3Base.json'); +const abiMakerDAO = require('./abiMakerDAO.json'); +const abiConvex = require('./abiConvex.json'); + +const getPoolData = async ({ contract, abi, chain }) => { + const { output: tvlUsd } = await sdk.api.abi.call({ + target: contract, + abi: abi.find((m) => m.name === 'totalAssets'), + chain, + }); + + const poolsData = await utils.getData( + 'https://api.return.finance//api/our-pools' + ); + + const currentPool = poolsData.pools.find((pool) => { + const incomingChainParam = chain === 'avax' ? 'avalanche' : chain; + + return ( + pool.networkName.toLowerCase() === incomingChainParam && + pool.returnContractAddress === contract + ); + }); + + return { + pool: `${contract}-${chain}`, + chain, + project: 'return-finance', + symbol: 'USDC', + tvlUsd: tvlUsd / 1000000, + apyBase: currentPool?.apy, + }; +}; + +const getApy = async () => { + const aavePolygon = await getPoolData({ + contract: '0x3B6385493a1d4603809dDbaE647200eF8baA53F5', + abi: abiAAVEPolygon, + chain: 'polygon', + }); + + const aaveAvalanche = await getPoolData({ + contract: '0x3B6385493a1d4603809dDbaE647200eF8baA53F5', + abi: abiAAVEAvalanche, + chain: 'avax', + }); + + const compoundV3Base = await getPoolData({ + contract: '0x3B6385493a1d4603809dDbaE647200eF8baA53F5', + abi: abiCompoundV3Base, + chain: 'base', + }); + + const makerDao = await getPoolData({ + contract: '0x201254227f9fE57296C257397Be6c617389a8cCb', + abi: abiMakerDAO, + chain: 'ethereum', + }); + + const convexFinance = await getPoolData({ + contract: '0xFD360A096E4a4c3C424fc3aCd85da8010D0Db9a5', + abi: abiConvex, + chain: 'ethereum', + }); + + return [aavePolygon, aaveAvalanche, compoundV3Base, makerDao, convexFinance]; +}; + +module.exports = { + timetravel: false, + apy: getApy, + url: 'https://return.finance', +}; From 44e980c62d0d205b9597bccb3fa98b39188ec1e5 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Fri, 26 Apr 2024 10:52:24 +0400 Subject: [PATCH 37/73] aerdrome rename --- src/adaptors/{aerodrome => aerodrome-v1}/abiGauge.json | 0 src/adaptors/{aerodrome => aerodrome-v1}/abiPool.json | 0 src/adaptors/{aerodrome => aerodrome-v1}/abiPoolsFactory.json | 0 src/adaptors/{aerodrome => aerodrome-v1}/abiVoter.json | 0 src/adaptors/{aerodrome => aerodrome-v1}/index.js | 2 +- 5 files changed, 1 insertion(+), 1 deletion(-) rename src/adaptors/{aerodrome => aerodrome-v1}/abiGauge.json (100%) rename src/adaptors/{aerodrome => aerodrome-v1}/abiPool.json (100%) rename src/adaptors/{aerodrome => aerodrome-v1}/abiPoolsFactory.json (100%) rename src/adaptors/{aerodrome => aerodrome-v1}/abiVoter.json (100%) rename src/adaptors/{aerodrome => aerodrome-v1}/index.js (99%) diff --git a/src/adaptors/aerodrome/abiGauge.json b/src/adaptors/aerodrome-v1/abiGauge.json similarity index 100% rename from src/adaptors/aerodrome/abiGauge.json rename to src/adaptors/aerodrome-v1/abiGauge.json diff --git a/src/adaptors/aerodrome/abiPool.json b/src/adaptors/aerodrome-v1/abiPool.json similarity index 100% rename from src/adaptors/aerodrome/abiPool.json rename to src/adaptors/aerodrome-v1/abiPool.json diff --git a/src/adaptors/aerodrome/abiPoolsFactory.json b/src/adaptors/aerodrome-v1/abiPoolsFactory.json similarity index 100% rename from src/adaptors/aerodrome/abiPoolsFactory.json rename to src/adaptors/aerodrome-v1/abiPoolsFactory.json diff --git a/src/adaptors/aerodrome/abiVoter.json b/src/adaptors/aerodrome-v1/abiVoter.json similarity index 100% rename from src/adaptors/aerodrome/abiVoter.json rename to src/adaptors/aerodrome-v1/abiVoter.json diff --git a/src/adaptors/aerodrome/index.js b/src/adaptors/aerodrome-v1/index.js similarity index 99% rename from src/adaptors/aerodrome/index.js rename to src/adaptors/aerodrome-v1/index.js index 7fa9da762e..673dd0632b 100644 --- a/src/adaptors/aerodrome/index.js +++ b/src/adaptors/aerodrome-v1/index.js @@ -137,7 +137,7 @@ const getApy = async () => { return { pool: p, chain: utils.formatChain('base'), - project: 'aerodrome', + project: 'aerodrome-v1', symbol: utils.formatSymbol(s.split('-')[1]), tvlUsd, apyReward, From 32e6535220559a4b22e7526a87601988ce7122dd Mon Sep 17 00:00:00 2001 From: slasher125 Date: Fri, 26 Apr 2024 11:09:11 +0400 Subject: [PATCH 38/73] sommelier temp disable turbosomm, is breaking adapter --- src/adaptors/sommelier/config.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/adaptors/sommelier/config.js b/src/adaptors/sommelier/config.js index 32ee8861bd..6edcd52315 100644 --- a/src/adaptors/sommelier/config.js +++ b/src/adaptors/sommelier/config.js @@ -368,19 +368,19 @@ const v2p5Pools = [ underlyingTokens: [], url: 'https://app.sommelier.finance/strategies/ETH-Trend-Growth', }, - { - pool: `${turbosomm}-ethereum`, - chain: 'ethereum', - project, - symbol: 'SOMM-WETH', - poolMeta: 'TurboSOMM', - tvlUsd: 0, - apyBase: 0, - apyReward: 0, - rewardTokens: ethRewardTokens, - underlyingTokens: [], - url: 'https://app.sommelier.finance/strategies/Turbo-SOMM', - }, + // { + // pool: `${turbosomm}-ethereum`, + // chain: 'ethereum', + // project, + // symbol: 'SOMM-WETH', + // poolMeta: 'TurboSOMM', + // tvlUsd: 0, + // apyBase: 0, + // apyReward: 0, + // rewardTokens: ethRewardTokens, + // underlyingTokens: [], + // url: 'https://app.sommelier.finance/strategies/Turbo-SOMM', + // }, { pool: `${turboeeth}-ethereum`, chain: 'ethereum', From e9000f41a98af623fff937e2037d5672f71b2513 Mon Sep 17 00:00:00 2001 From: Weaver <105595435+WeaverSphere@users.noreply.github.com> Date: Mon, 29 Apr 2024 10:10:57 +0300 Subject: [PATCH 39/73] feat: dyson compounder pools (#1283) --- src/adaptors/dyson/index.js | 126 ++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 src/adaptors/dyson/index.js diff --git a/src/adaptors/dyson/index.js b/src/adaptors/dyson/index.js new file mode 100644 index 0000000000..b67b569ef7 --- /dev/null +++ b/src/adaptors/dyson/index.js @@ -0,0 +1,126 @@ +const { + formatChain, + formatSymbol, + getData, + removeDuplicates, +} = require('../utils'); + +const vaultsURL = `https://api2.dyson.money/vaults/compounders`; +const appURL = 'https://app.dyson.money/all' + +const dysonToLlama = { + polygon: 'polygon', + arbitrum: 'arbitrum', + optimism: 'optimism', + kava: 'kava', + avalanche: 'avalanche', + base: 'base', +}; + +const main = async () => { + try { + const vaults = await getData(vaultsURL); + + const formatted = vaults + .map((vault) => { + try { + /** check if vault is valid */ + if (!vault) { + console.debug(`empty vault`); + return null; + } + + // deconstruct vault object + const { + id, + address: vaultAddress, + underlying, + platform, + composition, + network: dysonNetwork, + metrics, + } = vault; + + /** + * NETWORK + */ + const network = dysonToLlama[dysonNetwork]; + if (!network) { + const networkOptions = Object.keys(dysonToLlama).join(', '); + console.debug( + `Ignore vault ${id}, not valid network. Current options ${networkOptions}` + ); + return null; + } + + /** + * UNDERLYING + */ + const underlyingTokens = underlying + .sort((a, b) => a.index - b.index) + .map((token) => token.address); + + /** check if underlying tokens are valid */ + if (!underlyingTokens || underlyingTokens.length === 0) { + console.debug(`Ignore vault ${id}, no underlying tokens`); + } + + /** + * SYMBOL + */ + const symbols = composition + .sort((a, b) => a.index - b.index) + .map((token) => token.symbol); + + /** check if symbols are valid */ + if (!symbols || symbols.length === 0) { + console.debug(`Ignore vault ${id}, no symbols`); + } + + /** + * TVL & APY + */ + // deconstruct metrics object + const { tvl: tvlMetric, rewardRate: rewardRateMetric } = metrics; + + // format tvl & apy + const tvlUsd = Number(tvlMetric.vault.USDBalance); + const apy = Number(rewardRateMetric.rewardRate) * 100; // apy post performance fees + + /** check if TVL & APY is valid */ + if (!tvlUsd || !apy) { + console.debug(`Ignore vault ${id}, no TVL or apy`); + return null; + } + + return { + pool: `${vaultAddress}-${network}`.toLowerCase(), + chain: formatChain(network), + project: 'dyson', + symbol: formatSymbol(symbols.join('-')), + tvlUsd, + apy, + poolMeta: formatChain(platform), // provide base platform + underlyingTokens, + url: `${appURL}?id=${encodeURIComponent(id)}` // replace special characters with browser safe characted for exceptions like: USD+,USDC+, etc. + }; + } catch (e) { + console.debug(e); + return null; + } + }) + // remove any failed vaults + .filter((vault) => vault !== null); + + return removeDuplicates(formatted); + } catch (e) { + console.error(e); + return []; + } +}; + +module.exports = { + timetravel: false, + apy: main, + url: 'https://app.dyson.money/all', +}; From 6f8e1a594c2055b550c37e43e6739957e0a5e41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20Ayd=C4=B1nl=C4=B1k?= <46279260+waliair@users.noreply.github.com> Date: Mon, 29 Apr 2024 10:12:08 +0300 Subject: [PATCH 40/73] feat: add hercules dex v3 data (#1284) --- src/adaptors/hercules-v3/index.js | 101 ++++++++++++++++++++++++++++++ src/adaptors/utils.js | 1 + 2 files changed, 102 insertions(+) create mode 100644 src/adaptors/hercules-v3/index.js diff --git a/src/adaptors/hercules-v3/index.js b/src/adaptors/hercules-v3/index.js new file mode 100644 index 0000000000..4f2cfe7cb7 --- /dev/null +++ b/src/adaptors/hercules-v3/index.js @@ -0,0 +1,101 @@ +const { request, gql } = require('graphql-request'); +const sdk = require('@defillama/sdk'); +const axios = require('axios'); + +const utils = require('../utils'); + +const url ='https://metisapi.0xgraph.xyz/subgraphs/name/cryptoalgebra/analytics'; + +const query = gql` + { + pools(first: 1000 orderBy: totalValueLockedUSD orderDirection: desc block: {number: }) { + id + volumeUSD + token0 { + symbol + id + } + token1 { + id + symbol + } + reserve0: totalValueLockedToken0 + reserve1: totalValueLockedToken1 + feeOtZ + feeZtO + + } + } +`; + +const queryPrior = gql` + { + pools(first: 1000 orderBy: totalValueLockedUSD orderDirection: desc block: {number: }) { + id + volumeUSD + } + } +`; + +const topLvl = async (chainString, timestamp, url) => { + const [block, blockPrior] = await utils.getBlocks(chainString, timestamp, [ + url, + ]); + + const [_, blockPrior7d] = await utils.getBlocks( + chainString, + timestamp, + [url], + 604800 + ); + + let data = (await request(url, query.replace('', block))).pools; + + // pull 24h offset data to calculate fees from swap volume + const dataPrior = ( + await request(url, queryPrior.replace('', blockPrior)) + ).pools; + + // 7d offset + const dataPrior7d = ( + await request(url, queryPrior.replace('', blockPrior7d)) + ).pools; + + data = await utils.tvl(data, chainString); + + data = data.map((p) => ({ + ...p, + feeTier: (Number(p.feeOtZ) + Number(p.feeZtO)) / 2, + })); + data = data.map((el) => utils.apy(el, dataPrior, dataPrior7d, 'v3')); + + data = data.map((p) => { + const symbol = utils.formatSymbol(`${p.token0.symbol}-${p.token1.symbol}`); + return { + pool: p.id, + chain: utils.formatChain(chainString), + project: 'hercules-v3', + symbol, + tvlUsd: p.totalValueLockedUSD, + apyBase: p.apy1d, + apyBase7d: p.apy7d, + underlyingTokens: [p.token0.id, p.token1.id], + volumeUsd1d: p.volumeUSD1d, + volumeUsd7d: p.volumeUSD7d, + url: `https://app.hercules.exchange/pools/${p.id}`, + }; + }); + + return data; +}; + +const main = async (timestamp = null) => { + console.log(timestamp); + const data = await Promise.all([topLvl('metis', timestamp, url)]); + return data.flat().filter((p) => utils.keepFinite(p)); +}; + +module.exports = { + timetravel: true, + apy: main, +}; diff --git a/src/adaptors/utils.js b/src/adaptors/utils.js index ba8196bcd8..894373939d 100755 --- a/src/adaptors/utils.js +++ b/src/adaptors/utils.js @@ -96,6 +96,7 @@ const getLatestBlockSubgraph = async (url) => { url.includes('babydoge/faas') || url.includes('kybernetwork/kyberswap-elastic-cronos') || url.includes('kybernetwork/kyberswap-elastic-matic') || + url.includes('metisapi.0xgraph.xyz/subgraphs/name') || url.includes( 'https://subgraph.satsuma-prod.com/09c9cf3574cc/orbital-apes/v3-subgraph/api' ) || From c5b181be21d357d67b2e201f0bb9ce558a6068ed Mon Sep 17 00:00:00 2001 From: "Web3.World" <165679484+web3world@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:17:36 +0700 Subject: [PATCH 41/73] feat: apy has been clarified (#1286) --- src/adaptors/web3.world/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adaptors/web3.world/index.js b/src/adaptors/web3.world/index.js index c3e2a916de..78fc5993e9 100644 --- a/src/adaptors/web3.world/index.js +++ b/src/adaptors/web3.world/index.js @@ -45,7 +45,7 @@ const fetch = async () => { symbol: pool.meta.currencies.join('-'), tvlUsd: Number(pool.tvl), underlyingTokens: pool.meta.currencyAddresses, - apy: calcApy(pool.fee7d, pool.tvl), + apyBase: calcApy(pool.fee7d, pool.tvl), url: "https://web3.world/pools/" + pool.meta.poolAddress }) }) @@ -58,7 +58,7 @@ const fetch = async () => { tvlUsd: Number(pool.tvl), rewardTokens: pool.rewardTokens.map(({ tokenRoot }) => tokenRoot), underlyingTokens: pool.poolTokens.map(({ tokenRoot }) => tokenRoot), - apy: Number(pool.minApr), + apyBase: Number(pool.minApr), url: "https://web3.world/farming/" + pool.address }) }) From caf01a2a79164cb2161d19c251b8b92c91f95e74 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Mon, 29 Apr 2024 12:24:15 +0400 Subject: [PATCH 42/73] camelot fix --- src/adaptors/camelot-v3/index.js | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/adaptors/camelot-v3/index.js b/src/adaptors/camelot-v3/index.js index cd29f05fdd..8be8d9578e 100644 --- a/src/adaptors/camelot-v3/index.js +++ b/src/adaptors/camelot-v3/index.js @@ -15,10 +15,12 @@ const query = gql` token0 { symbol id + decimals } token1 { id symbol + decimals } reserve0: totalValueLockedToken0 reserve1: totalValueLockedToken1 @@ -62,6 +64,39 @@ const topLvl = async (chainString, timestamp, url) => { await request(url, queryPrior.replace('', blockPrior7d)) ).pools; + // subgraph resever values are completely wrong + const balanceCalls = []; + for (const pool of data) { + balanceCalls.push({ + target: pool.token0.id, + params: pool.id, + }); + balanceCalls.push({ + target: pool.token1.id, + params: pool.id, + }); + } + + const tokenBalances = await sdk.api.abi.multiCall({ + abi: 'erc20:balanceOf', + calls: balanceCalls, + chain: chainString, + permitFailure: true, + }); + + data = data.map((p) => { + const x = tokenBalances.output.filter((i) => i.input.params[0] === p.id); + return { + ...p, + reserve0: + x.find((i) => i.input.target === p.token0.id).output / + `1e${p.token0.decimals}`, + reserve1: + x.find((i) => i.input.target === p.token1.id).output / + `1e${p.token1.decimals}`, + }; + }); + data = await utils.tvl(data, chainString); data = data.map((p) => ({ From 05f8a943016f558379a26de6a8d5378d50581fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20Ayd=C4=B1nl=C4=B1k?= <46279260+waliair@users.noreply.github.com> Date: Mon, 29 Apr 2024 11:51:53 +0300 Subject: [PATCH 43/73] feat: update hercules-v3 balanceCalls (#1288) --- src/adaptors/hercules-v3/index.js | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/adaptors/hercules-v3/index.js b/src/adaptors/hercules-v3/index.js index 4f2cfe7cb7..1c6b112eb4 100644 --- a/src/adaptors/hercules-v3/index.js +++ b/src/adaptors/hercules-v3/index.js @@ -14,10 +14,12 @@ const query = gql` token0 { symbol id + decimals } token1 { id symbol + decimals } reserve0: totalValueLockedToken0 reserve1: totalValueLockedToken1 @@ -61,6 +63,38 @@ const topLvl = async (chainString, timestamp, url) => { await request(url, queryPrior.replace('', blockPrior7d)) ).pools; + const balanceCalls = []; + for (const pool of data) { + balanceCalls.push({ + target: pool.token0.id, + params: pool.id, + }); + balanceCalls.push({ + target: pool.token1.id, + params: pool.id, + }); + } + + const tokenBalances = await sdk.api.abi.multiCall({ + abi: 'erc20:balanceOf', + calls: balanceCalls, + chain: chainString, + permitFailure: true, + }); + + data = data.map((p) => { + const x = tokenBalances.output.filter((i) => i.input.params[0] === p.id); + return { + ...p, + reserve0: + x.find((i) => i.input.target === p.token0.id).output / + `1e${p.token0.decimals}`, + reserve1: + x.find((i) => i.input.target === p.token1.id).output / + `1e${p.token1.decimals}`, + }; + }); + data = await utils.tvl(data, chainString); data = data.map((p) => ({ From 5b0cbface50eaa1003ae4c1994a90a4ba0651ce3 Mon Sep 17 00:00:00 2001 From: Hayden Shively <17186559+haydenshively@users.noreply.github.com> Date: Tue, 30 Apr 2024 01:36:15 -0500 Subject: [PATCH 44/73] feat: add aloe data (#1285) * feat: add aloe data * Multiply APYs by 100 --- src/adaptors/aloe-capital/index.js | 189 +++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 src/adaptors/aloe-capital/index.js diff --git a/src/adaptors/aloe-capital/index.js b/src/adaptors/aloe-capital/index.js new file mode 100644 index 0000000000..975faa8bc0 --- /dev/null +++ b/src/adaptors/aloe-capital/index.js @@ -0,0 +1,189 @@ +const sdk = require('@defillama/sdk5'); +const { secondsInYear } = require('date-fns'); +const ethers = require('ethers'); +const { default: BigNumber } = require('bignumber.js'); +const utils = require('../utils'); +const superagent = require('superagent'); +const { rewardTokens } = require('../sommelier/config'); + +const config = { + ethereum: { fromBlock: 18782116 }, + optimism: { fromBlock: 113464669 }, + base: { fromBlock: 7869252 }, + arbitrum: { fromBlock: 159919891 }, +}; + +const ALOE_II_MAX_LEVERAGE = 1 / 200; +const ALOE_II_LIQUIDATION_INCENTIVE = 1 / 20; + +function computeLTV(iv, nSigma) { + const ltv = + 1 / + ((1 + ALOE_II_MAX_LEVERAGE + ALOE_II_LIQUIDATION_INCENTIVE) * + Math.exp(iv * nSigma)); + return Math.max(0.1, Math.min(ltv, 0.9)); +} + +async function getLTVs(chain, factory, volatilityOracle, uniswapPools) { + const parameters = await sdk.api2.abi.multiCall({ + calls: uniswapPools.map((uniswapPool) => ({ + target: factory, + params: [uniswapPool], + })), + abi: 'function getParameters(address uniswapPool) view returns (uint208 ante,uint8 nSigma,uint8 manipulationThresholdDivisor,uint32 pausedUntilTime)', + chain, + }); + + const consults = await sdk.api2.abi.multiCall({ + calls: uniswapPools.map((uniswapPool) => ({ + target: volatilityOracle, + params: [uniswapPool, '0x100000000'], + })), + abi: 'function consult(address pool,uint40 seed) view returns (uint56 metric,uint160 sqrtMeanPriceX96,uint256 iv)', + chain, + }); + + return parameters.map((p, i) => + computeLTV(Number(consults[i].iv) / 1e12, Number(p.nSigma) / 10) + ); +} + +async function getPrices(chain, addresses) { + const priceKeys = [...new Set(addresses)].map( + (address) => `${chain}:${address}` + ); + return ( + await superagent.get( + `https://coins.llama.fi/prices/current/${priceKeys + .join(',') + .toLowerCase()}` + ) + ).body.coins; +} + +async function getPoolsFor(chain) { + const { + factory = '0x000000009efdB26b970bCc0085E126C9dfc16ee8', + volatilityOracle = '0x0000000030d51e39a2dDDb5Db50F9d74a289DFc3', + lenderLens = '0x1f36838Ac6e3922dD26f1222d75af86185f2b798', + fromBlock, + } = config[chain]; + + const currentBlock = await sdk.api.util.getLatestBlock(chain); + + const iface = new ethers.utils.Interface([ + 'event CreateMarket(address indexed pool, address lender0, address lender1)', + ]); + const createMarketEvents = ( + await sdk.api2.util.getLogs({ + target: factory, + topic: '', + fromBlock, + toBlock: currentBlock.number, + keys: [], + topics: [iface.getEventTopic('CreateMarket')], + chain, + }) + ).output + .filter((ev) => !ev.removed) + .map((ev) => iface.parseLog(ev).args); + + const lenders = createMarketEvents.flatMap((ev, idx) => [ + { address: ev.lender0, peer: ev.lender1, peerIdx: idx * 2 + 1 }, + { address: ev.lender1, peer: ev.lender0, peerIdx: idx * 2 }, + ]); + + const uniswapPools = createMarketEvents.map((ev) => ev.pool); + const ltvs = await getLTVs(chain, factory, volatilityOracle, uniswapPools); + + const basics = await sdk.api2.abi.multiCall({ + calls: lenders.map((lender) => ({ + target: lenderLens, + params: [lender.address], + })), + abi: 'function readBasics(address lender) view returns (address asset,uint256 interestRate,uint256 utilization,uint256 inventory,uint256 totalBorrows,uint256 totalSupply,uint8 reserveFactor,uint64 rewardsRate)', + chain, + }); + + const prices = await getPrices( + chain, + basics.map((info) => info.asset) + ); + + return basics + .map((info, i) => { + const reserveFraction = 1 / info.reserveFactor; + const userFraction = 1 - reserveFraction; + + const aprBaseBorrow = new BigNumber(info.interestRate).times( + secondsInYear + ); + const aprBaseLend = aprBaseBorrow + .times(info.utilization) + .times(userFraction) + .div('1e18'); + + const apyBaseBorrow = + utils.aprToApy( + aprBaseBorrow.div('1e7').toNumber() / 1e3, + secondsInYear + ) / 100; + const apyBaseLend = + utils.aprToApy(aprBaseLend.div('1e7').toNumber() / 1e3, secondsInYear) / + 100; + + const priceKey = `${chain}:${info.asset}`.toLowerCase(); + if (!(priceKey in prices)) { + return undefined; + } + const { decimals = 18, symbol, price } = prices[priceKey]; + + const totalSupply = + new BigNumber(info.inventory) + .times('1e8') + .div(`1e${decimals}`) + .toNumber() / 1e8; + const totalBorrow = + new BigNumber(info.totalBorrows) + .times('1e8') + .div(`1e${decimals}`) + .toNumber() / 1e8; + const tvl = totalSupply - totalBorrow; + + const lender = lenders[i]; + const peerAssetAddress = basics[lender.peerIdx].asset; + const peerPriceKey = `${chain}:${peerAssetAddress}`.toLowerCase(); + const { symbol: peerSymbol } = + peerPriceKey in prices + ? prices[peerPriceKey] + : { symbol: peerAssetAddress }; + + return { + pool: `${lender.address}-${chain}`.toLowerCase(), + chain, + project: 'aloe-capital', + symbol: symbol.toUpperCase(), + tvlUsd: tvl * price, + apyBase: apyBaseLend * 100, + underlyingTokens: [info.asset], + poolMeta: `${peerSymbol.toUpperCase()}-pool`, + apyBaseBorrow: apyBaseBorrow * 100, + totalSupplyUsd: totalSupply * price, + totalBorrowUsd: totalBorrow * price, + ltv: ltvs[Math.floor(i / 2)], + }; + }) + .filter((pool) => pool !== undefined); +} + +async function apy() { + return (await Promise.all( + Object.keys(config).map((chain) => getPoolsFor(chain)) + )).flat(); +} + +module.exports = { + apy, + timetravel: false, + url: 'https://app.aloe.capital/markets', +}; From 178fdde9af30a844367fde9c41fecdfa78c42916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20Ayd=C4=B1nl=C4=B1k?= <46279260+waliair@users.noreply.github.com> Date: Tue, 30 Apr 2024 09:38:53 +0300 Subject: [PATCH 45/73] hercules v2 data (#1289) * feat: update hercules-v3 balanceCalls * feat: add herculesDEX v2 data --- src/adaptors/hercules-v2/factory.js | 348 ++++++++ src/adaptors/hercules-v2/index.js | 239 +++++ src/adaptors/hercules-v2/lp.js | 626 ++++++++++++++ src/adaptors/hercules-v2/masterchef.js | 318 +++++++ src/adaptors/hercules-v2/stakingPosition.js | 909 ++++++++++++++++++++ 5 files changed, 2440 insertions(+) create mode 100644 src/adaptors/hercules-v2/factory.js create mode 100644 src/adaptors/hercules-v2/index.js create mode 100644 src/adaptors/hercules-v2/lp.js create mode 100644 src/adaptors/hercules-v2/masterchef.js create mode 100644 src/adaptors/hercules-v2/stakingPosition.js diff --git a/src/adaptors/hercules-v2/factory.js b/src/adaptors/hercules-v2/factory.js new file mode 100644 index 0000000000..3ba1439aae --- /dev/null +++ b/src/adaptors/hercules-v2/factory.js @@ -0,0 +1,348 @@ +module.exports = [ + { + inputs: [{ internalType: 'address', name: 'feeTo_', type: 'address' }], + payable: false, + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'prevOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'FeePercentOwnershipTransferred', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'prevFeeTo', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newFeeTo', + type: 'address', + }, + ], + name: 'FeeToTransferred', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'prevOwnerFeeShare', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'ownerFeeShare', + type: 'uint256', + }, + ], + name: 'OwnerFeeShareUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'prevOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + 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: 'length', + type: 'uint256', + }, + ], + name: 'PairCreated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'referrer', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'prevReferrerFeeShare', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'referrerFeeShare', + type: 'uint256', + }, + ], + name: 'ReferrerFeeShareUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'prevOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'SetStableOwnershipTransferred', + type: 'event', + }, + { + constant: true, + inputs: [], + name: 'OWNER_FEE_SHARE_MAX', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'REFERER_FEE_SHARE_MAX', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + 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: 'feeInfo', + outputs: [ + { internalType: 'uint256', name: '_ownerFeeShare', type: 'uint256' }, + { internalType: 'address', name: '_feeTo', type: 'address' }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'feePercentOwner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'feeTo', + 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: true, + inputs: [], + name: 'owner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'ownerFeeShare', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'referrersFeeShare', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { internalType: 'address', name: '_feePercentOwner', type: 'address' }, + ], + name: 'setFeePercentOwner', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + 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: '_owner', type: 'address' }], + name: 'setOwner', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { internalType: 'uint256', name: 'newOwnerFeeShare', type: 'uint256' }, + ], + name: 'setOwnerFeeShare', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { internalType: 'address', name: 'referrer', type: 'address' }, + { internalType: 'uint256', name: 'referrerFeeShare', type: 'uint256' }, + ], + name: 'setReferrerFeeShare', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { internalType: 'address', name: '_setStableOwner', type: 'address' }, + ], + name: 'setSetStableOwner', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'setStableOwner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, +]; diff --git a/src/adaptors/hercules-v2/index.js b/src/adaptors/hercules-v2/index.js new file mode 100644 index 0000000000..618c8d4795 --- /dev/null +++ b/src/adaptors/hercules-v2/index.js @@ -0,0 +1,239 @@ +const { request, gql } = require('graphql-request'); +const sdk = require('@defillama/sdk'); +const masterchefAbi = require('./masterchef'); +const stakingPositionAbi = require('./stakingPosition'); +const factoryAbi = require('./factory'); +const lp = require('./lp'); +const lpAbi = require('./lp'); +const axios = require('axios'); + +const masterchef = '0x438718E30B6395c4a0B5622490CC3DC9B1B8ba3d'; +const factory = '0xF38E7c7f8eA779e8A193B61f9155E6650CbAE095'; +const TORCH = '0xbB1676046C36BCd2F6fD08d8f60672c7087d9aDF'; + +const utils = require('../utils'); + +const url = 'https://metisapi.0xgraph.xyz/subgraphs/name/amm-subgraph-andromeda/'; + +const query = gql` + { + pairs(first: 1000 orderBy: trackedReserveETH orderDirection: desc block: {number: }) { + id + volumeUSD + reserve0 + reserve1 + token0 { + id + symbol + } + token1 { + id + symbol + } + } + } +`; + +const queryPrior = gql` + { + pairs(first: 1000 orderBy: trackedReserveETH orderDirection: desc block: {number: }) { + id + volumeUSD + } + } +`; + +const topLvl = async (chainString, timestamp, url) => { + // --- fee tier + const allPairsLength = ( + await sdk.api.abi.call({ + target: factory, + abi: factoryAbi.find((m) => m.name === 'allPairsLength'), + chain: chainString, + }) + ).output; + + const allPairs = ( + await sdk.api.abi.multiCall({ + calls: [...Array(Number(allPairsLength)).keys()].map((i) => ({ + target: factory, + params: [i], + })), + abi: factoryAbi.find((m) => m.name === 'allPairs'), + chain: chainString, + }) + ).output.map((o) => o.output); + + const token0FeePercent = ( + await sdk.api.abi.multiCall({ + calls: allPairs.map((i) => ({ + target: i, + })), + abi: lpAbi.find((m) => m.name === 'token0FeePercent'), + chain: chainString, + }) + ).output.map((o) => o.output); + + const token1FeePercent = ( + await sdk.api.abi.multiCall({ + calls: allPairs.map((i) => ({ + target: i, + })), + abi: lpAbi.find((m) => m.name === 'token1FeePercent'), + chain: chainString, + }) + ).output.map((o) => o.output); + + // --- rewards + const poolsLength = ( + await sdk.api.abi.call({ + target: masterchef, + abi: masterchefAbi.find((m) => m.name === 'poolsLength'), + chain: chainString, + }) + ).output; + + const pools = ( + await sdk.api.abi.multiCall({ + calls: [...Array(Number(poolsLength)).keys()].map((i) => ({ + target: masterchef, + params: [i], + })), + abi: masterchefAbi.find((m) => m.name === 'getPoolAddressByIndex'), + chain: chainString, + }) + ).output.map((o) => o.output); + + let poolInfo = ( + await sdk.api.abi.multiCall({ + calls: pools.map((i) => ({ + target: i, + })), + abi: stakingPositionAbi.find((m) => m.name === 'getPoolInfo'), + chain: chainString, + }) + ).output.map((o) => o.output); + + const lpTokens = poolInfo.map((p) => p.lpToken); + const totalSupply = ( + await sdk.api.abi.multiCall({ + calls: lpTokens.map((i) => ({ + target: i, + })), + abi: lp.find((m) => m.name === 'totalSupply'), + chain: chainString, + }) + ).output.map((o) => o.output); + + poolInfo = poolInfo.map((p, i) => ({ ...p, totalSupply: totalSupply[i] })); + + const totalAllocPoint = ( + await sdk.api.abi.call({ + target: masterchef, + abi: masterchefAbi.find((m) => m.name === 'totalAllocPoint'), + chain: chainString, + }) + ).output; + + const torchPerSec = + ( + await sdk.api.abi.call({ + target: masterchef, + abi: masterchefAbi.find((m) => m.name === 'emissionRate'), + chain: chainString, + }) + ).output / 1e18; + + const priceKey = `metis:${TORCH}`; + const torchPrice = ( + await axios.get(`https://coins.llama.fi/prices/current/${priceKey}`) + ).data.coins[priceKey]?.price; + + const torchPerYearUsd = torchPerSec * 86400 * 365 * torchPrice; + + const [block, blockPrior] = await utils.getBlocks(chainString, timestamp, [ + url, + ]); + + const [_, blockPrior7d] = await utils.getBlocks( + chainString, + timestamp, + [url], + 604800 + ); + + let data = (await request(url, query.replace('', block))).pairs; + + // pull 24h offset data to calculate fees from swap volume + const dataPrior = ( + await request(url, queryPrior.replace('', blockPrior)) + ).pairs; + + // 7d offset + const dataPrior7d = ( + await request(url, queryPrior.replace('', blockPrior7d)) + ).pairs; + + // calculate tvl + data = await utils.tvl(data, chainString); + + // add fee tier + data = data.map((p) => { + const idx = allPairs.findIndex( + (i) => i.toLowerCase() === p.id.toLowerCase() + ); + const feeAvg = + ((Number(token0FeePercent[idx]) + Number(token1FeePercent[idx])) / 2) * + 10; + return { ...p, feeTier: feeAvg }; + }); + + // calculate apy + data = data.map((el) => utils.apy(el, dataPrior, dataPrior7d, 'v3')); + + // build pool objects + data = data.map((p) => { + const pi = poolInfo.find( + (pi) => pi.lpToken.toLowerCase() === p.id?.toLowerCase() + ); + + const farmReserveRatio = pi?.lpSupplyWithMultiplier / pi?.totalSupply; + + const apyReward = + (((pi?.allocPoint / totalAllocPoint) * torchPerYearUsd) / + (p.totalValueLockedUSD * farmReserveRatio)) * + 100; + + // rewards are 20% in liquid torch and 80% in non-transferable xtorch (which can be used to boost though) + // gonna report 20% torch only + + const symbol = utils.formatSymbol(`${p.token0.symbol}-${p.token1.symbol}`); + return { + pool: p.id, + chain: utils.formatChain(chainString), + project: 'hercules-v2', + symbol, + tvlUsd: p.totalValueLockedUSD, + apyBase: p.apy1d, + apyBase7d: p.apy7d, + apyReward: apyReward * 0.2, + underlyingTokens: [p.token0.id, p.token1.id], + rewardTokens: apyReward > 0 ? [TORCH] : [], + volumeUsd1d: p.volumeUSD1d, + volumeUsd7d: p.volumeUSD7d, + }; + }); + + return data; +}; + +const main = async (timestamp = null) => { + const data = await Promise.all([topLvl('metis', timestamp, url)]); + return data.flat().filter((p) => utils.keepFinite(p)); +}; + +module.exports = { + timetravel: true, + apy: main, + url: 'https://app.hercules.exchange/liquidity', +}; diff --git a/src/adaptors/hercules-v2/lp.js b/src/adaptors/hercules-v2/lp.js new file mode 100644 index 0000000000..65d0d5cb14 --- /dev/null +++ b/src/adaptors/hercules-v2/lp.js @@ -0,0 +1,626 @@ +module.exports = [ + { + 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: 'token', + type: 'address', + }, + { indexed: false, internalType: 'address', name: 'to', type: 'address' }, + ], + name: 'DrainWrongToken', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint16', + name: 'token0FeePercent', + type: 'uint16', + }, + { + indexed: false, + internalType: 'uint16', + name: 'token1FeePercent', + type: 'uint16', + }, + ], + name: 'FeePercentUpdated', + 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: [], name: 'SetPairTypeImmutable', type: 'event' }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bool', + name: 'prevStableSwap', + type: 'bool', + }, + { + indexed: false, + internalType: 'bool', + name: 'stableSwap', + type: 'bool', + }, + ], + name: 'SetStableSwap', + type: 'event', + }, + { anonymous: false, inputs: [], name: 'Skim', 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: 'FEE_DENOMINATOR', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'MAX_FEE_PERCENT', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + 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: false, + inputs: [ + { internalType: 'address', name: 'token', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + ], + name: 'drainWrongToken', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'factory', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { internalType: 'uint256', name: 'amountIn', type: 'uint256' }, + { internalType: 'address', name: 'tokenIn', type: 'address' }, + ], + name: 'getAmountOut', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + 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: 'uint16', name: '_token0FeePercent', type: 'uint16' }, + { internalType: 'uint16', name: '_token1FeePercent', type: 'uint16' }, + ], + 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: 'initialized', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + payable: false, + stateMutability: 'view', + 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: true, + inputs: [], + name: 'pairTypeImmutable', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + 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: 'precisionMultiplier0', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'precisionMultiplier1', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { internalType: 'uint16', name: 'newToken0FeePercent', type: 'uint16' }, + { internalType: 'uint16', name: 'newToken1FeePercent', type: 'uint16' }, + ], + name: 'setFeePercent', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'setPairTypeImmutable', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { internalType: 'bool', name: 'stable', type: 'bool' }, + { internalType: 'uint112', name: 'expectedReserve0', type: 'uint112' }, + { internalType: 'uint112', name: 'expectedReserve1', type: 'uint112' }, + ], + name: 'setStableSwap', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [{ internalType: 'address', name: 'to', type: 'address' }], + name: 'skim', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'stableSwap', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + payable: false, + stateMutability: 'view', + 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: 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' }, + { internalType: 'address', name: 'referrer', type: 'address' }, + ], + 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: 'token0FeePercent', + outputs: [{ internalType: 'uint16', name: '', type: 'uint16' }], + 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: 'token1FeePercent', + outputs: [{ internalType: 'uint16', name: '', type: 'uint16' }], + 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/src/adaptors/hercules-v2/masterchef.js b/src/adaptors/hercules-v2/masterchef.js new file mode 100644 index 0000000000..3ba12d541a --- /dev/null +++ b/src/adaptors/hercules-v2/masterchef.js @@ -0,0 +1,318 @@ +module.exports = [ + { + inputs: [ + { + internalType: 'contract IGrailTokenV2', + name: 'grailToken_', + type: 'address', + }, + { internalType: 'uint256', name: 'startTime_', type: 'uint256' }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'poolAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'ClaimRewards', + 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: 'poolAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'allocPoint', + type: 'uint256', + }, + ], + name: 'PoolAdded', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'poolAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'allocPoint', + type: 'uint256', + }, + ], + name: 'PoolSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'poolAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'reserve', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'lastRewardTime', + type: 'uint256', + }, + ], + name: 'PoolUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bool', + name: 'emergencyUnlock', + type: 'bool', + }, + ], + name: 'SetEmergencyUnlock', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'previousYieldBooster', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'newYieldBooster', + type: 'address', + }, + ], + name: 'SetYieldBooster', + type: 'event', + }, + { + inputs: [], + name: 'activePoolsLength', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'contract INFTPool', name: 'nftPool', type: 'address' }, + { internalType: 'uint256', name: 'allocPoint', type: 'uint256' }, + { internalType: 'bool', name: 'withUpdate', type: 'bool' }, + ], + name: 'add', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'claimRewards', + outputs: [ + { internalType: 'uint256', name: 'rewardsAmount', type: 'uint256' }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'emergencyUnlock', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'emissionRate', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'index', type: 'uint256' }], + name: 'getActivePoolAddressByIndex', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'index', type: 'uint256' }], + name: 'getPoolAddressByIndex', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'poolAddress_', type: 'address' }, + ], + name: 'getPoolInfo', + outputs: [ + { internalType: 'address', name: 'poolAddress', type: 'address' }, + { internalType: 'uint256', name: 'allocPoint', type: 'uint256' }, + { internalType: 'uint256', name: 'lastRewardTime', type: 'uint256' }, + { internalType: 'uint256', name: 'reserve', type: 'uint256' }, + { internalType: 'uint256', name: 'poolEmissionRate', type: 'uint256' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'grailToken', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'massUpdatePools', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'poolsLength', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'poolAddress', type: 'address' }, + { internalType: 'uint256', name: 'allocPoint', type: 'uint256' }, + { internalType: 'bool', name: 'withUpdate', type: 'bool' }, + ], + name: 'set', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bool', name: 'emergencyUnlock_', type: 'bool' }], + name: 'setEmergencyUnlock', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract IYieldBooster', + name: 'yieldBooster_', + type: 'address', + }, + ], + name: 'setYieldBooster', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'startTime', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalAllocPoint', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'nftPool', type: 'address' }], + name: 'updatePool', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'yieldBooster', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, +]; diff --git a/src/adaptors/hercules-v2/stakingPosition.js b/src/adaptors/hercules-v2/stakingPosition.js new file mode 100644 index 0000000000..afdc34f103 --- /dev/null +++ b/src/adaptors/hercules-v2/stakingPosition.js @@ -0,0 +1,909 @@ +module.exports = [ + { inputs: [], stateMutability: 'nonpayable', type: 'constructor' }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'AddToPosition', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'approved', + type: 'address', + }, + { + indexed: true, + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'operator', + type: 'address', + }, + { indexed: false, internalType: 'bool', name: 'approved', type: 'bool' }, + ], + name: 'ApprovalForAll', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'lockDuration', + type: 'uint256', + }, + ], + name: 'CreatePosition', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'EmergencyWithdraw', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + { indexed: false, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'pending', + type: 'uint256', + }, + ], + name: 'HarvestPosition', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'lockDuration', + type: 'uint256', + }, + ], + name: 'LockPosition', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { + indexed: false, + internalType: 'uint256[]', + name: 'tokenIds', + type: 'uint256[]', + }, + ], + name: 'MergePositions', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'lastRewardTime', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'accRewardsPerShare', + type: 'uint256', + }, + ], + name: 'PoolUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'boostPoints', + type: 'uint256', + }, + ], + name: 'SetBoost', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'maxGlobalMultiplier', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'maxBoostMultiplier', + type: 'uint256', + }, + ], + name: 'SetBoostMultiplierSettings', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bool', + name: 'emergencyUnlock', + type: 'bool', + }, + ], + name: 'SetEmergencyUnlock', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'maxLockDuration', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'maxLockMultiplier', + type: 'uint256', + }, + ], + name: 'SetLockMultiplierSettings', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'operator', + type: 'address', + }, + ], + name: 'SetOperator', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'operator', + type: 'address', + }, + { indexed: false, internalType: 'bool', name: 'isAdded', type: 'bool' }, + ], + name: 'SetUnlockOperator', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'xGrailRewardsShare', + type: 'uint256', + }, + ], + name: 'SetXGrailRewardsShare', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'splitAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'newTokenId', + type: 'uint256', + }, + ], + name: 'SplitPosition', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'from', type: 'address' }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: true, + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'tokenId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'WithdrawFromPosition', + type: 'event', + }, + { + inputs: [], + name: 'MAX_BOOST_MULTIPLIER_LIMIT', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_GLOBAL_MULTIPLIER_LIMIT', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_LOCK_MULTIPLIER_LIMIT', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + { internalType: 'uint256', name: 'amountToAdd', type: 'uint256' }, + ], + name: 'addToPosition', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + ], + name: 'approve', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'owner', type: 'address' }], + name: 'balanceOf', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'baseURI', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'boost', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'lockDuration', type: 'uint256' }, + ], + name: 'createPosition', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'emergencyUnlock', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }], + name: 'emergencyWithdraw', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }], + name: 'exists', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'factory', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }], + name: 'getApproved', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'boostPoints', type: 'uint256' }, + ], + name: 'getMultiplierByBoostPoints', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'lockDuration', type: 'uint256' }, + ], + name: 'getMultiplierByLockDuration', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getMultiplierSettings', + outputs: [ + { internalType: 'uint256', name: 'maxGlobalMultiplier', type: 'uint256' }, + { internalType: 'uint256', name: 'maxLockDuration', type: 'uint256' }, + { internalType: 'uint256', name: 'maxLockMultiplier', type: 'uint256' }, + { internalType: 'uint256', name: 'maxBoostMultiplier', type: 'uint256' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getPoolInfo', + outputs: [ + { internalType: 'address', name: 'lpToken', type: 'address' }, + { internalType: 'address', name: 'grailToken', type: 'address' }, + { internalType: 'address', name: 'xGrailToken', type: 'address' }, + { internalType: 'uint256', name: 'lastRewardTime', type: 'uint256' }, + { internalType: 'uint256', name: 'accRewardsPerShare', type: 'uint256' }, + { internalType: 'uint256', name: 'lpSupply', type: 'uint256' }, + { + internalType: 'uint256', + name: 'lpSupplyWithMultiplier', + type: 'uint256', + }, + { internalType: 'uint256', name: 'allocPoint', type: 'uint256' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }], + name: 'getStakingPosition', + outputs: [ + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { + internalType: 'uint256', + name: 'amountWithMultiplier', + type: 'uint256', + }, + { internalType: 'uint256', name: 'startLockTime', type: 'uint256' }, + { internalType: 'uint256', name: 'lockDuration', type: 'uint256' }, + { internalType: 'uint256', name: 'lockMultiplier', type: 'uint256' }, + { internalType: 'uint256', name: 'rewardDebt', type: 'uint256' }, + { internalType: 'uint256', name: 'boostPoints', type: 'uint256' }, + { internalType: 'uint256', name: 'totalMultiplier', type: 'uint256' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }], + name: 'harvestPosition', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + { internalType: 'address', name: 'to', type: 'address' }, + ], + name: 'harvestPositionTo', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256[]', name: 'tokenIds', type: 'uint256[]' }, + { internalType: 'address', name: 'to', type: 'address' }, + ], + name: 'harvestPositionsTo', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'hasDeposits', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract ICamelotMaster', + name: 'master_', + type: 'address', + }, + { internalType: 'contract IERC20', name: 'grailToken', type: 'address' }, + { + internalType: 'contract IXGrailToken', + name: 'xGrailToken', + type: 'address', + }, + { internalType: 'contract IERC20', name: 'lpToken', type: 'address' }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'initialized', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'owner', type: 'address' }, + { internalType: 'address', name: 'operator', type: 'address' }, + ], + name: 'isApprovedForAll', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '_operator', type: 'address' }], + name: 'isUnlockOperator', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'isUnlocked', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'lastTokenId', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + { internalType: 'uint256', name: 'lockDuration', type: 'uint256' }, + ], + name: 'lockPosition', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'master', + outputs: [ + { internalType: 'contract ICamelotMaster', name: '', type: 'address' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256[]', name: 'tokenIds', type: 'uint256[]' }, + { internalType: 'uint256', name: 'lockDuration', type: 'uint256' }, + ], + name: 'mergePositions', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'operator', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }], + name: 'ownerOf', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }], + name: 'pendingRewards', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }], + name: 'renewLockPosition', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'from', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + ], + name: 'safeTransferFrom', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'from', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + { internalType: 'bytes', name: '_data', type: 'bytes' }, + ], + name: 'safeTransferFrom', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'operator', type: 'address' }, + { internalType: 'bool', name: 'approved', type: 'bool' }, + ], + name: 'setApprovalForAll', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'maxGlobalMultiplier', type: 'uint256' }, + { internalType: 'uint256', name: 'maxBoostMultiplier', type: 'uint256' }, + ], + name: 'setBoostMultiplierSettings', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bool', name: 'emergencyUnlock_', type: 'bool' }], + name: 'setEmergencyUnlock', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'maxLockDuration', type: 'uint256' }, + { internalType: 'uint256', name: 'maxLockMultiplier', type: 'uint256' }, + ], + name: 'setLockMultiplierSettings', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'operator_', type: 'address' }], + name: 'setOperator', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '_operator', type: 'address' }, + { internalType: 'bool', name: 'add', type: 'bool' }, + ], + name: 'setUnlockOperator', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'xGrailRewardsShare_', type: 'uint256' }, + ], + name: 'setXGrailRewardsShare', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + { internalType: 'uint256', name: 'splitAmount', type: 'uint256' }, + ], + name: 'splitPosition', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes4', name: 'interfaceId', type: 'bytes4' }], + name: 'supportsInterface', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'index', type: 'uint256' }], + name: 'tokenByIndex', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'owner', type: 'address' }, + { internalType: 'uint256', name: 'index', type: 'uint256' }, + ], + name: 'tokenOfOwnerByIndex', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }], + name: 'tokenURI', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'from', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + ], + name: 'transferFrom', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'unboost', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'index', type: 'uint256' }], + name: 'unlockOperator', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'unlockOperatorsLength', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'updatePool', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'tokenId', type: 'uint256' }, + { internalType: 'uint256', name: 'amountToWithdraw', type: 'uint256' }, + ], + name: 'withdrawFromPosition', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'xGrailRewardsShare', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'yieldBooster', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, +]; From bd8bdf83bd811c0f574f99329f028af775c8b53b Mon Sep 17 00:00:00 2001 From: 0xIvan <83612730+0xIvan@users.noreply.github.com> Date: Tue, 30 Apr 2024 19:22:43 +0400 Subject: [PATCH 46/73] Jones DAO - jUSDC V2 (#1290) * Add jAura * Add stip farm apr * Remove unused * Fix key name * Change sdk version * Update with new jusdc * Add suffix --- src/adaptors/jones-dao/index.js | 67 +++++++++++++++------------------ 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/src/adaptors/jones-dao/index.js b/src/adaptors/jones-dao/index.js index acc604735c..390c2932da 100644 --- a/src/adaptors/jones-dao/index.js +++ b/src/adaptors/jones-dao/index.js @@ -9,46 +9,32 @@ const auraStrategy = '0x7629fc134e5a7feBEf6340438D96881C8D121f2c'; const glp = '0x1aDDD80E6039594eE970E5872D247bf0414C8903'; const glpTracker = '0x13C6Bed5Aa16823Aba5bBA691CAeC63788b19D9d'; const glpStrategy = '0x64ECc55a4F5D61ead9B966bcB59D777593afBd6f'; -const usdc = '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8'; -const uvrt = '0xa485a0bc44988B95245D5F20497CCaFF58a73E99'; -const uvrtTracker = '0xEB23C7e19DB72F9a728fD64E1CAA459E457cfaca'; +const bridgedUsdc = '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8'; +const usdc = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831'; const arbitrum = '0x912CE59144191C1204E64559FE8253a0e49E6548'; +const jusdcUnderlyingVault = '0xB0BDE111812EAC913b392D80D51966eC977bE3A2'; const SECONDS_PER_YEAR = 31556952; // 0.97% see https://docs.jonesdao.io/jones-dao/features/incentives const JUSDC_RETENTION = 0.97 / 100; const JGLP_RETENTION = 3 / 100; -async function getLeveragedVaultsTvl(token, address) { - const collateralBalance = await sdk.api.abi.call({ - abi: 'erc20:balanceOf', - target: token, - params: [address], - chain: 'arbitrum', - }); - - const key = `arbitrum:${token}`; - const priceUsd = await utils - .getData(`https://coins.llama.fi/prices/current/${key}`) - .then((res) => res.coins[key].price); - - const tvl = (Number(collateralBalance.output) / 1e18) * priceUsd; - - return tvl; -} - async function pools() { const [ + prices, auraLeftoverStrategy, auraLocked, - prices, jauraApyRes, jusdcApy, jglpApy, - jusdcTvl, - jglpTvl, - stipFarms, + jusdcCollateralBalance, + jglpCollateralBalance, ] = await Promise.all([ + utils.getPrices([ + `ethereum:${aura}`, + `arbitrum:${glp}`, + `arbitrum:${usdc}`, + ]), sdk.api.erc20 .balanceOf({ target: aura, @@ -62,7 +48,6 @@ async function pools() { params: auraStrategy, }) .then((result) => result.output[0]), - utils.getPrices([`ethereum:${aura}`, `arbitrum:${arbitrum}`]), utils.getData('https://api.jonesdao.io/api/v1/jones/apy-wjaura'), utils .getData('https://api.jonesdao.io/api/v1/jones/apy-jusdc') @@ -70,14 +55,27 @@ async function pools() { utils .getData('https://api.jonesdao.io/api/v1/jones/apy-jglp') .then((res) => res.jglpApy), - getLeveragedVaultsTvl(uvrt, uvrtTracker), - getLeveragedVaultsTvl(glp, glpStrategy), - utils - .getData('https://app.jonesdao.io/api/stip-farms') - .then((res) => res.farms), + sdk.api.abi.call({ + abi: 'uint256:totalAssets', + target: jusdcUnderlyingVault, + chain: 'arbitrum', + }), + sdk.api.abi.call({ + abi: 'erc20:balanceOf', + target: glp, + params: [glpStrategy], + chain: 'arbitrum', + }), ]); - const { aura: auraPrice, arb: arbPrice } = prices.pricesBySymbol; + const { + aura: auraPrice, + fsglp: glpPrice, + usdc: usdcPrice, + } = prices.pricesBySymbol; + + const jglpTvl = (Number(jglpCollateralBalance.output) / 1e18) * glpPrice; + const jusdcTvl = (Number(jusdcCollateralBalance.output) / 1e6) * usdcPrice; const jAuraTvl = (Number(auraLocked) / 1e18 + Number(auraLeftoverStrategy) / 1e18) * @@ -92,11 +90,10 @@ async function pools() { tvlUsd: jAuraTvl, apyBase: jauraApyRes.jauraApy * (1 - JGLP_RETENTION), apyBaseInception: jauraApyRes.jauraApyInception, - apyReward: stipFarms[2].apr, }; const jUsdcPool = { - pool: `${uvrtTracker}-arbitrum`.toLowerCase(), + pool: `${jusdcUnderlyingVault}-arbitrum-jones-dao`.toLowerCase(), // TODO update chain: 'Arbitrum', project: 'jones-dao', symbol: 'jUSDC', @@ -105,7 +102,6 @@ async function pools() { apyBase: jusdcApy.week * (1 - JUSDC_RETENTION), apyBaseInception: jusdcApy.full, poolMeta: '1day lock', - apyReward: stipFarms[1].apr, }; const jGlpPool = { @@ -117,7 +113,6 @@ async function pools() { tvlUsd: jglpTvl, apyBase: jglpApy.week * (1 - JGLP_RETENTION), apyBaseInception: jglpApy.full, - apyReward: stipFarms[0].apr, }; return [jUsdcPool, jGlpPool, jAuraPool]; From 57bcc6a42e506dbd358fbbfee745ebf012791dab Mon Sep 17 00:00:00 2001 From: mvp1983 <103922338+mvp1983@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:23:09 +0300 Subject: [PATCH 47/73] Add new chain (#1291) Co-authored-by: Valerii --- src/adaptors/clip-finance/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/adaptors/clip-finance/index.js b/src/adaptors/clip-finance/index.js index c8f089526a..2abce01333 100644 --- a/src/adaptors/clip-finance/index.js +++ b/src/adaptors/clip-finance/index.js @@ -7,6 +7,7 @@ const sdk = require('@defillama/sdk5'); const CHAINS = { bsc: 'bsc', linea: 'linea', + base : 'base' }; const config = { @@ -26,6 +27,14 @@ const config = { '0xA219439258ca9da29E9Cc4cE5596924745e12B93', ], }, + [CHAINS.base]: { + vaultAddress: '0x03A074D130144FcE6883F7EA3884C0a783d85Fb3', + symbol: 'USDbC-USDС', + underlyingTokens: [ + '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA', + '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', + ], + } }; const getUrl = (chain, from) => @@ -46,7 +55,7 @@ const getApy = async () => { ); let apy = 0; - if (apyResponse.data.status === 'apy_calculated') { + if (apyResponse.data.status === 'multistrategy_vault_apy_calculated') { apy = Number(apyResponse.data.data.apy); } @@ -126,4 +135,4 @@ const abis = { stateMutability: 'view', type: 'function', }, -}; +}; \ No newline at end of file From b610d9bc41c256a769884164b547f636b392c804 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Thu, 2 May 2024 11:02:16 +0400 Subject: [PATCH 48/73] aloe rename --- src/adaptors/{aloe-capital => aloe}/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename src/adaptors/{aloe-capital => aloe}/index.js (97%) diff --git a/src/adaptors/aloe-capital/index.js b/src/adaptors/aloe/index.js similarity index 97% rename from src/adaptors/aloe-capital/index.js rename to src/adaptors/aloe/index.js index 975faa8bc0..4890d7fd1c 100644 --- a/src/adaptors/aloe-capital/index.js +++ b/src/adaptors/aloe/index.js @@ -161,7 +161,7 @@ async function getPoolsFor(chain) { return { pool: `${lender.address}-${chain}`.toLowerCase(), chain, - project: 'aloe-capital', + project: 'aloe', symbol: symbol.toUpperCase(), tvlUsd: tvl * price, apyBase: apyBaseLend * 100, @@ -177,9 +177,9 @@ async function getPoolsFor(chain) { } async function apy() { - return (await Promise.all( - Object.keys(config).map((chain) => getPoolsFor(chain)) - )).flat(); + return ( + await Promise.all(Object.keys(config).map((chain) => getPoolsFor(chain))) + ).flat(); } module.exports = { From 544038bacee7fcebed4c1f5ed69953f0d5c9a71d Mon Sep 17 00:00:00 2001 From: slasher125 Date: Fri, 3 May 2024 10:37:36 +0400 Subject: [PATCH 49/73] reserve rename --- src/adaptors/{reserve => reserve-protocol}/abi.js | 0 src/adaptors/{reserve => reserve-protocol}/index.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/adaptors/{reserve => reserve-protocol}/abi.js (100%) rename src/adaptors/{reserve => reserve-protocol}/index.js (99%) diff --git a/src/adaptors/reserve/abi.js b/src/adaptors/reserve-protocol/abi.js similarity index 100% rename from src/adaptors/reserve/abi.js rename to src/adaptors/reserve-protocol/abi.js diff --git a/src/adaptors/reserve/index.js b/src/adaptors/reserve-protocol/index.js similarity index 99% rename from src/adaptors/reserve/index.js rename to src/adaptors/reserve-protocol/index.js index dc8e0afc92..c64557611c 100644 --- a/src/adaptors/reserve/index.js +++ b/src/adaptors/reserve-protocol/index.js @@ -173,7 +173,7 @@ const apyChain = async (chainProps) => { return { pool: rtoken.id, chain: chainName, - project: 'reserve', + project: 'reserve-protocol', symbol: rtoken.token?.symbol, tvlUsd: rtokenTvl(rtoken), apyBase: From 4818af85026e7bfbd2c922869c4188fb30d17935 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Fri, 3 May 2024 10:39:38 +0400 Subject: [PATCH 50/73] phuture fix --- src/adaptors/phuture/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adaptors/phuture/index.ts b/src/adaptors/phuture/index.ts index d04f128d83..5510ba67f9 100644 --- a/src/adaptors/phuture/index.ts +++ b/src/adaptors/phuture/index.ts @@ -1,4 +1,4 @@ -const sdk = require('@defillama/sdk'); +const sdk = require('@defillama/sdk5'); const axios = require('axios'); const utils = require('../utils'); From 87e0cee6839173dbe87270db622de55ca4510df4 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Fri, 3 May 2024 10:55:28 +0400 Subject: [PATCH 51/73] extra finane add try catch --- src/adaptors/extra-finance/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/adaptors/extra-finance/index.js b/src/adaptors/extra-finance/index.js index ec24c2ec4e..330e52604c 100644 --- a/src/adaptors/extra-finance/index.js +++ b/src/adaptors/extra-finance/index.js @@ -147,7 +147,11 @@ async function getPoolsData() { } for (const chain of Object.keys(subgraphUrls)) { - await getPoolsByChain(chain) + try { + await getPoolsByChain(chain); + } catch (err) { + console.log(err); + } } return pools.filter((p) => utils.keepFinite(p)); From e415996df43030f798872d983eb6fd850fe57cfa Mon Sep 17 00:00:00 2001 From: slasher125 Date: Fri, 3 May 2024 11:05:27 +0400 Subject: [PATCH 52/73] predy-v5 fix --- src/adaptors/predy-v5/helpers.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/adaptors/predy-v5/helpers.js b/src/adaptors/predy-v5/helpers.js index 1fbf1215e4..11f983ae11 100644 --- a/src/adaptors/predy-v5/helpers.js +++ b/src/adaptors/predy-v5/helpers.js @@ -1,24 +1,29 @@ const { default: BigNumber } = require('bignumber.js'); -const ONE = (new BigNumber(10)).pow(18) +const ONE = new BigNumber(10).pow(18); function calculateInterestRate(params, ur) { if (ur < 0) { - throw new Error('utilization ratio must be positive value.') + throw new Error('utilization ratio must be positive value.'); } - let ir = new BigNumber(params.baseRate) + let ir = new BigNumber(params.baseRate); - if (ur.lte(params.kinkRate)) { - ir = ir.plus(ur.times(params.slope1).div(ONE)) - } else { - ir = ir.plus(params.kinkRate.times(params.slope1).div(ONE)) - ir = ir.plus(params.slope2.times(ur.minus(params.kinkRate)).div(ONE)) + try { + if (ur.lte(params.kinkRate)) { + ir = ir.plus(ur.times(params.slope1).div(ONE)); + } else { + ir = ir.plus(params.kinkRate.times(params.slope1).div(ONE)); + ir = ir.plus(params.slope2.times(ur.minus(params.kinkRate)).div(ONE)); + } + } catch (err) { + console.log(err); + return ir; } - return ir + return ir; } module.exports = { - calculateInterestRate -} + calculateInterestRate, +}; From 0fc53cea73cbe2db8f6e69d0a857acfbf6a02677 Mon Sep 17 00:00:00 2001 From: "Web3.World" <165679484+web3world@users.noreply.github.com> Date: Fri, 3 May 2024 16:58:41 +0700 Subject: [PATCH 53/73] feat: venomstake yield adapter has been added (#1292) --- src/adaptors/venomstake/index.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/adaptors/venomstake/index.js diff --git a/src/adaptors/venomstake/index.js b/src/adaptors/venomstake/index.js new file mode 100644 index 0000000000..d527dc5f54 --- /dev/null +++ b/src/adaptors/venomstake/index.js @@ -0,0 +1,26 @@ +const { default: BigNumber } = require('bignumber.js'); +const utils = require('../utils'); + +const fetch = async () => { + const [{ data }, { price }] = await Promise.all([ + utils.getData('https://api.venomstake.com/v1/strategies/main'), + utils.getData('https://api.web3.world/v1/currencies/0:77d36848bb159fa485628bc38dc37eadb74befa514395e09910f601b841f749e', {}), + ]); + + return [{ + pool: 'be424d43-ccb6-4a2e-8064-222150b69aa0', + chain: utils.formatChain('venom'), + project: 'venomstake', + symbol: 'VENOM', + tvlUsd: BigNumber(data.tvl).div(1e9).multipliedBy(price).toNumber(), + rewardTokens: ['0:77d36848bb159fa485628bc38dc37eadb74befa514395e09910f601b841f749e'], + underlyingTokens: ['0:77d36848bb159fa485628bc38dc37eadb74befa514395e09910f601b841f749e'], + apyBase: BigNumber(data.apy).multipliedBy(100).toNumber() + }]; +}; + +module.exports = { + timetravel: false, + apy: fetch, + url: 'https://venomstake.com/', +}; From a739ea0b87beb3da98f289b227776fa1d1ec4995 Mon Sep 17 00:00:00 2001 From: Hayden Shively <17186559+haydenshively@users.noreply.github.com> Date: Fri, 3 May 2024 05:02:07 -0500 Subject: [PATCH 54/73] Add Linea pools to Aloe adaptor (#1293) --- src/adaptors/aloe/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/adaptors/aloe/index.js b/src/adaptors/aloe/index.js index 4890d7fd1c..f43f4cf0f8 100644 --- a/src/adaptors/aloe/index.js +++ b/src/adaptors/aloe/index.js @@ -11,6 +11,12 @@ const config = { optimism: { fromBlock: 113464669 }, base: { fromBlock: 7869252 }, arbitrum: { fromBlock: 159919891 }, + linea: { + factory: '0x00000000333288eBA83426245D144B966Fd7e82E', + volatilityOracle: '0x00000000570385b76719a95Fdf27B9c7fB5Ff299', + lenderLens: '0xFc39498Edd3E18d5296E6584847f2580ad0e770B', + fromBlock: 3982456, + }, }; const ALOE_II_MAX_LEVERAGE = 1 / 200; From 8f2a2bc6b3a4931d431d87307631595150e31e2a Mon Sep 17 00:00:00 2001 From: Alexander Ponomarev Date: Fri, 3 May 2024 14:05:40 +0400 Subject: [PATCH 55/73] feat: add line (#1287) * feat: add line * fix: tvl in USD now * fix: rename * fix: rename func * fix: rename func * fix: rename * fixes * fix * fix: decimals * fix decimals & name --- .../line-token/abi/equilibrePairAbi.js | 152 +++++++++ src/adaptors/line-token/abi/lineAbi.js | 300 ++++++++++++++++++ src/adaptors/line-token/abi/oracleAbi.js | 15 + src/adaptors/line-token/config.js | 5 + src/adaptors/line-token/index.js | 66 ++++ .../utils/fetchPriceFromCoingecko.js | 13 + src/adaptors/line-token/utils/getAllPools.js | 31 ++ .../line-token/utils/getCurrentLinePrice.js | 22 ++ src/adaptors/line-token/utils/getDecimals.js | 15 + .../line-token/utils/getInterestRate.js | 15 + .../utils/getPoolTokenPriceInUSD.js | 58 ++++ src/adaptors/line-token/utils/getSymbol.js | 15 + src/adaptors/line-token/utils/getTotalDebt.js | 15 + src/adaptors/line-token/utils/index.js | 17 + 14 files changed, 739 insertions(+) create mode 100644 src/adaptors/line-token/abi/equilibrePairAbi.js create mode 100644 src/adaptors/line-token/abi/lineAbi.js create mode 100644 src/adaptors/line-token/abi/oracleAbi.js create mode 100644 src/adaptors/line-token/config.js create mode 100644 src/adaptors/line-token/index.js create mode 100644 src/adaptors/line-token/utils/fetchPriceFromCoingecko.js create mode 100644 src/adaptors/line-token/utils/getAllPools.js create mode 100644 src/adaptors/line-token/utils/getCurrentLinePrice.js create mode 100644 src/adaptors/line-token/utils/getDecimals.js create mode 100644 src/adaptors/line-token/utils/getInterestRate.js create mode 100644 src/adaptors/line-token/utils/getPoolTokenPriceInUSD.js create mode 100644 src/adaptors/line-token/utils/getSymbol.js create mode 100644 src/adaptors/line-token/utils/getTotalDebt.js create mode 100644 src/adaptors/line-token/utils/index.js diff --git a/src/adaptors/line-token/abi/equilibrePairAbi.js b/src/adaptors/line-token/abi/equilibrePairAbi.js new file mode 100644 index 0000000000..7f3ab1871f --- /dev/null +++ b/src/adaptors/line-token/abi/equilibrePairAbi.js @@ -0,0 +1,152 @@ +module.exports = [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "_reserve0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_reserve1", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_blockTimestampLast", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "reserve0", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "reserve1", + "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": "token0", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token1", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tokens", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, +] \ No newline at end of file diff --git a/src/adaptors/line-token/abi/lineAbi.js b/src/adaptors/line-token/abi/lineAbi.js new file mode 100644 index 0000000000..5a8383bf06 --- /dev/null +++ b/src/adaptors/line-token/abi/lineAbi.js @@ -0,0 +1,300 @@ +module.exports = [ + { + "inputs": [], + "name": "collateral_token_address", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllPools", + "outputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "reward_share10000", + "type": "uint16" + }, + { + "internalType": "uint256", + "name": "last_total_reward", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "total_pool_reward_per_token", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "total_staked_in_pool", + "type": "uint256" + } + ], + "internalType": "struct Staking.Pool", + "name": "pool", + "type": "tuple" + }, + { + "internalType": "address", + "name": "pool_address", + "type": "address" + } + ], + "internalType": "struct Staking.PoolInfo[]", + "name": "all_pools", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "interest_rate10000", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "pool_addresses", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pools", + "outputs": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "reward_share10000", + "type": "uint16" + }, + { + "internalType": "uint256", + "name": "last_total_reward", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "total_pool_reward_per_token", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "total_staked_in_pool", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "total_debt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "total_interest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "total_reward_share10000", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "new_origination_fee10000", + "type": "uint256" + } + ], + "name": "setOriginationFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "new_interest_rate10000", + "type": "uint256" + } + ], + "name": "setInterestRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "collateral_amount", + "type": "uint256" + } + ], + "name": "borrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentInterestMultiplier", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalReward", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/adaptors/line-token/abi/oracleAbi.js b/src/adaptors/line-token/abi/oracleAbi.js new file mode 100644 index 0000000000..c53b28e5fc --- /dev/null +++ b/src/adaptors/line-token/abi/oracleAbi.js @@ -0,0 +1,15 @@ +module.exports = [ + { + "inputs": [], + "name": "getCurrentPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, +] \ No newline at end of file diff --git a/src/adaptors/line-token/config.js b/src/adaptors/line-token/config.js new file mode 100644 index 0000000000..4e03794788 --- /dev/null +++ b/src/adaptors/line-token/config.js @@ -0,0 +1,5 @@ +module.exports.LINE_CONTRACT_ADDRESS = '0x31f8d38df6514b6cc3C360ACE3a2EFA7496214f6'; +module.exports.CHAIN = 'kava'; +module.exports.PROJECT = 'line-token'; +module.exports.COLLATERAL_TOKEN_CONTRACT_ADDRESS = '0x0b93109d05Ef330acD2c75148891cc61D20C3EF1'; + diff --git a/src/adaptors/line-token/index.js b/src/adaptors/line-token/index.js new file mode 100644 index 0000000000..72c69aa2e2 --- /dev/null +++ b/src/adaptors/line-token/index.js @@ -0,0 +1,66 @@ +const sdk = require('@defillama/sdk'); +const BigNumber = require('bignumber.js'); + +const utils = require('../utils'); + +const { LINE_CONTRACT_ADDRESS, CHAIN, PROJECT, COLLATERAL_TOKEN_CONTRACT_ADDRESS } = require('./config'); +const { getCurrentLinePrice, getAllPools, getTotalDebt, getInterestRate, getPoolTokenPriceInUSD, fetchPriceFromCoingecko, getSymbol, getDecimals } = require('./utils'); + +const COMMON_DATA = { + chain: CHAIN, + project: PROJECT, + rewardTokens: [LINE_CONTRACT_ADDRESS], +}; + +const apy = async () => { + const pools = await getAllPools(); + const linePriceInCollateralToken = await getCurrentLinePrice(); + const collateralTokenPriceInUSD = await fetchPriceFromCoingecko(COLLATERAL_TOKEN_CONTRACT_ADDRESS); + const lineTokenPriceInUSD = BigNumber(linePriceInCollateralToken).multipliedBy(collateralTokenPriceInUSD).dividedBy(10 ** 18).toNumber(); + const collateralDecimals = await getDecimals(COLLATERAL_TOKEN_CONTRACT_ADDRESS); + const lineDecimals = await getDecimals(LINE_CONTRACT_ADDRESS); + + const totalDebt = await getTotalDebt(); + const interestRate = await getInterestRate(); + + const totalRewardPerYear = BigNumber(interestRate).multipliedBy(totalDebt).dividedBy("10000").dividedBy(10 ** lineDecimals).toNumber(); + + const results = []; + + for (const pool of pools) { + const { reward_share10000, total_staked_in_pool, poolContractAddress } = pool; + const poolTokenDecimals = await getDecimals(poolContractAddress); + + const totalStakedInPool = BigNumber(total_staked_in_pool).dividedBy(10 ** poolTokenDecimals).toNumber(); + + const poolRewardPerYear = totalRewardPerYear * (reward_share10000 / 1e4); + + const stakedTokenPriceInUSD = await getPoolTokenPriceInUSD(poolContractAddress, lineTokenPriceInUSD); + + if (!Number(collateralTokenPriceInUSD) || !Number(stakedTokenPriceInUSD)) continue; + + const poolRewardPerYearInUSD = poolRewardPerYear * lineTokenPriceInUSD; + + const apy = poolRewardPerYearInUSD / (totalStakedInPool * stakedTokenPriceInUSD) + + const tvlUsd = totalStakedInPool * stakedTokenPriceInUSD; + const symbol = await getSymbol(poolContractAddress); + + results.push({ + apy, + tvlUsd, + ...COMMON_DATA, + pool: `${poolContractAddress}-${CHAIN}`.toLowerCase(), + symbol: utils.formatSymbol(symbol), + }); + }; + + return results; +}; + + +module.exports = { + timetravel: false, + url: 'https://linetoken.org/staking/all', + apy +}; \ No newline at end of file diff --git a/src/adaptors/line-token/utils/fetchPriceFromCoingecko.js b/src/adaptors/line-token/utils/fetchPriceFromCoingecko.js new file mode 100644 index 0000000000..4ec37aff24 --- /dev/null +++ b/src/adaptors/line-token/utils/fetchPriceFromCoingecko.js @@ -0,0 +1,13 @@ +const utils = require('../../utils'); + +module.exports = async function fetchPriceFromCoingecko(tokenAddress) { + try { + const data = await utils.getData( + `https://api.coingecko.com/api/v3/coins/kava/contract/${tokenAddress.toLowerCase()}` + ); + + return data?.market_data?.current_price?.usd || 0; + } catch { + return 0; + } +} \ No newline at end of file diff --git a/src/adaptors/line-token/utils/getAllPools.js b/src/adaptors/line-token/utils/getAllPools.js new file mode 100644 index 0000000000..7bc58a8005 --- /dev/null +++ b/src/adaptors/line-token/utils/getAllPools.js @@ -0,0 +1,31 @@ +const sdk = require('@defillama/sdk'); + +const lineAbi = require("../abi/lineAbi"); +const { LINE_CONTRACT_ADDRESS, CHAIN } = require('../config'); + +module.exports = async function getAllPools() { + return ( + await sdk.api.abi.call({ + target: LINE_CONTRACT_ADDRESS, + abi: lineAbi.find((m) => m.name === 'getAllPools'), + chain: CHAIN, + }) + ).output.map(([ + [ + exists, + reward_share10000, + last_total_reward, + total_pool_reward_per_token, + total_staked_in_pool + ], + poolContractAddress, + + ]) => ({ + exists, + reward_share10000, + last_total_reward, + total_pool_reward_per_token, + total_staked_in_pool, + poolContractAddress, + })); +} \ No newline at end of file diff --git a/src/adaptors/line-token/utils/getCurrentLinePrice.js b/src/adaptors/line-token/utils/getCurrentLinePrice.js new file mode 100644 index 0000000000..e9e540a6be --- /dev/null +++ b/src/adaptors/line-token/utils/getCurrentLinePrice.js @@ -0,0 +1,22 @@ +const sdk = require('@defillama/sdk'); + +const oracleAbi = require("../abi/oracleAbi"); +const lineAbi = require("../abi/lineAbi"); + +const { LINE_CONTRACT_ADDRESS, CHAIN } = require("../config"); + +module.exports = async function getCurrentLinePrice() { + return ( + await sdk.api.abi.call({ + target: LINE_CONTRACT_ADDRESS, + abi: lineAbi.find((m) => m.name === 'oracle'), + chain: CHAIN, + }).then(({ output: oracle }) => { + return sdk.api.abi.call({ + target: oracle, + abi: oracleAbi.find((m) => m.name === 'getCurrentPrice'), + chain: CHAIN, + }) + }) + ).output; +} diff --git a/src/adaptors/line-token/utils/getDecimals.js b/src/adaptors/line-token/utils/getDecimals.js new file mode 100644 index 0000000000..9e90416fca --- /dev/null +++ b/src/adaptors/line-token/utils/getDecimals.js @@ -0,0 +1,15 @@ +const sdk = require('@defillama/sdk'); + +const { CHAIN } = require("../config"); + + +module.exports = async function getDecimals(target) { + return ( + await sdk.api.abi.call({ + target, + abi: 'erc20:decimals', + chain: CHAIN, + }) + ).output; + +} diff --git a/src/adaptors/line-token/utils/getInterestRate.js b/src/adaptors/line-token/utils/getInterestRate.js new file mode 100644 index 0000000000..633cf0fcd8 --- /dev/null +++ b/src/adaptors/line-token/utils/getInterestRate.js @@ -0,0 +1,15 @@ +const sdk = require('@defillama/sdk'); + +const { LINE_CONTRACT_ADDRESS, CHAIN } = require("../config"); + +const lineAbi = require('../abi/lineAbi'); + +module.exports = async function getInterestRate() { + return ( + await sdk.api.abi.call({ + target: LINE_CONTRACT_ADDRESS, + abi: lineAbi.find((m) => m.name === 'interest_rate10000'), + chain: CHAIN, + }) + ).output; +} diff --git a/src/adaptors/line-token/utils/getPoolTokenPriceInUSD.js b/src/adaptors/line-token/utils/getPoolTokenPriceInUSD.js new file mode 100644 index 0000000000..6934fbb412 --- /dev/null +++ b/src/adaptors/line-token/utils/getPoolTokenPriceInUSD.js @@ -0,0 +1,58 @@ +const sdk = require('@defillama/sdk'); +const BigNumber = require('bignumber.js'); + +const { LINE_CONTRACT_ADDRESS, CHAIN } = require("../config"); + +const LineAbi = require('../abi/lineAbi'); +const equilibrePairAbi = require('../abi/equilibrePairAbi'); +const { getData } = require('../../utils'); +const fetchPriceFromCoingecko = require('./fetchPriceFromCoingecko'); +const getDecimals = require('./getDecimals'); + +module.exports = async function getPoolTokenPriceInUSD(tokenAddress, lineTokenPriceInUSD) { + + const tokens = await sdk.api.abi.call({ + target: tokenAddress, + abi: equilibrePairAbi.find((m) => m.name === 'tokens'), + chain: CHAIN, + }).then((res) => res.output).catch(() => false); + + if (tokens) { // it's a equilibre pool + const totalSupplyGetter = sdk.api.abi.call({ + target: tokenAddress, + abi: equilibrePairAbi.find((m) => m.name === 'totalSupply'), + chain: CHAIN, + }).then(data => data.output) + + const reservesGetter = sdk.api.abi.call({ + target: tokenAddress, + abi: equilibrePairAbi.find((m) => m.name === 'getReserves'), + chain: CHAIN, + }).then(data => data.output) + + const [totalSupplyInPennies, reserves, poolTokenDecimals, token0Decimals] = await Promise.all([ + totalSupplyGetter, + reservesGetter, + getDecimals(tokenAddress), + getDecimals(tokens[0]) + ]); + + const price0 = tokens[0] !== LINE_CONTRACT_ADDRESS ? await fetchPriceFromCoingecko(tokens[0]) : lineTokenPriceInUSD; + let lpPriceInUSD = 0; + + if (totalSupplyInPennies) { + const reserve0 = BigNumber(reserves[0]).dividedBy(10 ** token0Decimals).toNumber(); + const totalSupply = BigNumber(totalSupplyInPennies).dividedBy(10 ** poolTokenDecimals).toNumber(); + + lpPriceInUSD = (reserve0 * 2 * price0) / totalSupply; + } + + return lpPriceInUSD; + } else { // it's a token + if (tokenAddress === LINE_CONTRACT_ADDRESS) { + return String(lineTokenPriceInUSD); + } else { + return await fetchPriceFromCoingecko(tokenAddress).then(price => String(price)).catch(() => 0); + } + } +} \ No newline at end of file diff --git a/src/adaptors/line-token/utils/getSymbol.js b/src/adaptors/line-token/utils/getSymbol.js new file mode 100644 index 0000000000..c5fe5a99f6 --- /dev/null +++ b/src/adaptors/line-token/utils/getSymbol.js @@ -0,0 +1,15 @@ +const sdk = require('@defillama/sdk'); + +const { CHAIN } = require("../config"); + + +module.exports = async function getSymbol(target) { + return ( + await sdk.api.abi.call({ + target, + abi: 'erc20:symbol', + chain: CHAIN, + }) + ).output; + +} \ No newline at end of file diff --git a/src/adaptors/line-token/utils/getTotalDebt.js b/src/adaptors/line-token/utils/getTotalDebt.js new file mode 100644 index 0000000000..b679d1b4ca --- /dev/null +++ b/src/adaptors/line-token/utils/getTotalDebt.js @@ -0,0 +1,15 @@ +const sdk = require('@defillama/sdk'); + +const { LINE_CONTRACT_ADDRESS, CHAIN } = require("../config"); + +const LineAbi = require('../abi/lineAbi'); + +module.exports = async function getTotalDebt() { + return ( + await sdk.api.abi.call({ + target: LINE_CONTRACT_ADDRESS, + abi: LineAbi.find((m) => m.name === 'total_debt'), + chain: CHAIN, + }) + ).output; +} \ No newline at end of file diff --git a/src/adaptors/line-token/utils/index.js b/src/adaptors/line-token/utils/index.js new file mode 100644 index 0000000000..be012f5a42 --- /dev/null +++ b/src/adaptors/line-token/utils/index.js @@ -0,0 +1,17 @@ +const getCurrentLinePrice = require('./getCurrentLinePrice'); +const getAllPools = require('./getAllPools'); +const getTotalDebt = require('./getTotalDebt'); +const getInterestRate = require('./getInterestRate'); +const getPoolTokenPriceInUSD = require('./getPoolTokenPriceInUSD'); +const fetchPriceFromCoingecko = require('./fetchPriceFromCoingecko'); +const getSymbol = require('./getSymbol'); +const getDecimals = require('./getDecimals'); + +module.exports.getCurrentLinePrice = getCurrentLinePrice; +module.exports.getAllPools = getAllPools; +module.exports.getTotalDebt = getTotalDebt; +module.exports.getInterestRate = getInterestRate; +module.exports.getPoolTokenPriceInUSD = getPoolTokenPriceInUSD; +module.exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko; +module.exports.getSymbol = getSymbol; +module.exports.getDecimals = getDecimals; \ No newline at end of file From d0d7c6609f000ed8eba557f8c87c9f0e323c719a Mon Sep 17 00:00:00 2001 From: slasher125 Date: Sun, 5 May 2024 23:35:05 +0400 Subject: [PATCH 56/73] remove pool --- src/utils/exclude.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/exclude.js b/src/utils/exclude.js index fd9b9f5ddc..cbf06d0cfc 100644 --- a/src/utils/exclude.js +++ b/src/utils/exclude.js @@ -457,6 +457,7 @@ const excludePools = [ '0x42c02c24caaf42a27dd95c790073a4ea3118ea48', '0x4aE5CE819e7D678b07E8D0f483d351E2c8e8B8D3', '0x5b4ef67c63d091083ec4d30cfc4ac685ef051046-xdai', + '0x659110d07923e2c3fcb9d3c9e66b0a1605e7ce71-astar', ]; const boundaries = { From a5c3bbfb30e51c5aabb53bad9c60ca01cfca1a2e Mon Sep 17 00:00:00 2001 From: Alejandro <84141043+0xDro@users.noreply.github.com> Date: Sun, 5 May 2024 12:36:44 -0700 Subject: [PATCH 57/73] add stream finance eth vaults (#1280) * add stream finance eth vaults * use onchain data * change symbol --- src/adaptors/stream-finance/abiVault.json | 1244 +++++++++++++++++++++ src/adaptors/stream-finance/index.js | 132 +++ 2 files changed, 1376 insertions(+) create mode 100644 src/adaptors/stream-finance/abiVault.json create mode 100644 src/adaptors/stream-finance/index.js diff --git a/src/adaptors/stream-finance/abiVault.json b/src/adaptors/stream-finance/abiVault.json new file mode 100644 index 0000000000..0befdcf215 --- /dev/null +++ b/src/adaptors/stream-finance/abiVault.json @@ -0,0 +1,1244 @@ + [ + { + "inputs": [ + { + "internalType": "address", + "name": "_weth", + "type": "address" + }, + { + "internalType": "address", + "name": "_keeper", + "type": "address" + }, + { + "internalType": "string", + "name": "_tokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "_tokenSymbol", + "type": "string" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + }, + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint56", + "name": "minimumSupply", + "type": "uint56" + }, + { + "internalType": "uint104", + "name": "cap", + "type": "uint104" + } + ], + "internalType": "struct Vault.VaultParams", + "name": "_vaultParams", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [], + "name": "ReentrancyGuardReentrantCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldCap", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCap", + "type": "uint256" + } + ], + "name": "CapSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "round", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "round", + "type": "uint256" + } + ], + "name": "InitiateWithdraw", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "round", + "type": "uint256" + } + ], + "name": "InstantWithdraw", + "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": "uint256", + "name": "share", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "round", + "type": "uint256" + } + ], + "name": "Redeem", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [], + "name": "WETH", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "accountVaultBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "canDeposit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "completeWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "currentQueuedWithdrawShares", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "depositETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "creditor", + "type": "address" + } + ], + "name": "depositETHFor", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "creditor", + "type": "address" + } + ], + "name": "depositFor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "depositReceipts", + "outputs": [ + { + "internalType": "uint16", + "name": "round", + "type": "uint16" + }, + { + "internalType": "uint104", + "name": "amount", + "type": "uint104" + }, + { + "internalType": "uint128", + "name": "unredeemedShares", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "currentBalance", + "type": "uint256" + } + ], + "name": "getCurrQueuedWithdrawAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "numShares", + "type": "uint256" + } + ], + "name": "initiateWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isPublic", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "keeper", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastQueuedWithdrawAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxRedeem", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "merkleRoot", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pricePerShare", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "privateDeposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "privateDepositETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "numShares", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "currentBalance", + "type": "uint256" + } + ], + "name": "rollToNextRound", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "round", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "roundPricePerShare", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newCap", + "type": "uint256" + } + ], + "name": "setCap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_merkleRoot", + "type": "bytes32" + } + ], + "name": "setMerkleRoot", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newKeeper", + "type": "address" + } + ], + "name": "setNewKeeper", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_isPublic", + "type": "bool" + } + ], + "name": "setPublic", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + }, + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint56", + "name": "minimumSupply", + "type": "uint56" + }, + { + "internalType": "uint104", + "name": "cap", + "type": "uint104" + } + ], + "internalType": "struct Vault.VaultParams", + "name": "newVaultParams", + "type": "tuple" + } + ], + "name": "setVaultParams", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "shareBalances", + "outputs": [ + { + "internalType": "uint256", + "name": "heldByAccount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "heldByVault", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "shares", + "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": "totalBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalPending", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vaultParams", + "outputs": [ + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + }, + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint56", + "name": "minimumSupply", + "type": "uint56" + }, + { + "internalType": "uint104", + "name": "cap", + "type": "uint104" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vaultState", + "outputs": [ + { + "internalType": "uint16", + "name": "round", + "type": "uint16" + }, + { + "internalType": "uint104", + "name": "lockedAmount", + "type": "uint104" + }, + { + "internalType": "uint104", + "name": "lastLockedAmount", + "type": "uint104" + }, + { + "internalType": "uint128", + "name": "totalPending", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "queuedWithdrawShares", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "withdrawInstantly", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "withdrawals", + "outputs": [ + { + "internalType": "uint16", + "name": "round", + "type": "uint16" + }, + { + "internalType": "uint128", + "name": "shares", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ] \ No newline at end of file diff --git a/src/adaptors/stream-finance/index.js b/src/adaptors/stream-finance/index.js new file mode 100644 index 0000000000..51603b6a58 --- /dev/null +++ b/src/adaptors/stream-finance/index.js @@ -0,0 +1,132 @@ +const utils = require('../utils'); +const axios = require('axios'); +const sdk = require('@defillama/sdk5'); +const vaultABI = require('./abiVault.json'); + +const eth_USDC = "0xf3b466F09ef476E311Ce275407Cfb09a8D8De3a7" +const eth_BTC = "0x6efa12b38038A6249B7aBdd5a047D211fB0aD48E" +const eth_ETH = "0x2a2f84e9AfE7b39146CDaF068b06b84EE23892c2" +const arb_USDC = "0xC36E1dd932dd95737bb8895B4B88A01b7d37e871" +const arb_BTC = "0x9aB1D3c233CF7f0f57F4F5e1A297bC5F8ab71dA6" +const arb_ETH = "0x3Ea6319268201f5346B570a91435A61a6ce3fbaD" +const base_USDC = "0xCACf1C081A421D51aE5E142aD6cA1504c8D89dab" +const base_ETH = "0x5398CC5265BCDf23A4d72f08A51Af42b6CA8f2e5" +const avax_USDC = "0xCd89b930eE05d962146a15567a1ec8a23E89700C" + +const vaults = { + "LevUSDC" : { + "ethereum": eth_USDC, + "arbitrum": arb_USDC, + "avax": avax_USDC, + "base": base_USDC + }, + "HodlwBTC" : { + "ethereum": eth_BTC, + "arbitrum": arb_BTC + }, + "HodlwETH": { + "ethereum": eth_ETH, + "arbitrum": arb_ETH, + "base": base_ETH + + } +} + +const mapToUnderlying = (vault) => { + if (vault === "LEVUSDC") { + return "USDC"; + } + if (vault === "HODLWBTC") { + return "wBTC"; + } + if (vault === "HODLWETH") { + return "wETH"; + } +} + + + + +const getTokenPrice = async (priceKey, amount, decimals) => { + const price = ( + await axios.get(`https://coins.llama.fi/prices/current/${priceKey}`) + ).data.coins[priceKey].price; + + return Number(price) * amount / 10 ** decimals; +}; + +const getVaultState = async (vaultAddy, chain) => { + + const vaultState = await sdk.api.abi.call({ + abi: vaultABI.find((m) => m.name === "vaultState"), + target: vaultAddy, + chain: chain, + }); + + return vaultState.output +} + +const getVaultParams = async (vaultAddy, chain) => { + + const vaultParams = await sdk.api.abi.call({ + abi: vaultABI.find((m) => m.name === "vaultParams"), + target: vaultAddy, + chain: chain, + }); + + return vaultParams.output + } + +const getAPY = async (vaultAddy, chain) => { + const currRound = (await getVaultState(vaultAddy, chain))[0]; + const prevPricePerShare = (await sdk.api.abi.call({ + abi: vaultABI.find((m) => m.name === "roundPricePerShare"), + target: vaultAddy, + chain: chain, + params: [currRound - 2], + })).output; + + const currPricePerShare = (await sdk.api.abi.call({ + abi: vaultABI.find((m) => m.name === "roundPricePerShare"), + target: vaultAddy, + chain: chain, + params: [currRound - 1], + })).output; + + const apy = (currPricePerShare - prevPricePerShare) / prevPricePerShare * 100 * 52; + return apy; +} + + +const main = async () => { + // const data = await utils.getData('https://api.streamprotocol.money/vaults'); + const pools = []; + + for (const entry of Object.keys(vaults)) { + for (const chain of Object.keys(vaults[entry])) { + + const vaultParams = await getVaultParams(vaults[entry][chain], chain); + pools.push({ + pool: `${vaults[entry][chain]}-${chain}`, + chain: utils.formatChain(chain), + project: 'stream-finance', + symbol: mapToUnderlying(utils.formatSymbol(entry)), + tvlUsd: await getTokenPrice(`${chain}:${vaultParams[1]}`, Number((await getVaultState(vaults[entry][chain], chain))[1]), vaultParams[0]), + apy: await getAPY(vaults[entry][chain], chain), + poolMeta: utils.formatSymbol(entry) + }); + } + + } + + return pools.filter((pool) => { + return utils.keepFinite(pool); + }); + +} + +module.exports = { + timetravel: false, + apy: main, + url: 'https://app.streamprotocol.money', +}; From b27492246c7a8fc5825921bfdb571c1ede348826 Mon Sep 17 00:00:00 2001 From: CronosLabsDev <106642922+CronosLabsDev@users.noreply.github.com> Date: Mon, 6 May 2024 01:48:28 -0400 Subject: [PATCH 58/73] add orby network APY data (#1295) --- src/adaptors/orby-network/index.js | 133 +++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 src/adaptors/orby-network/index.js diff --git a/src/adaptors/orby-network/index.js b/src/adaptors/orby-network/index.js new file mode 100644 index 0000000000..c26c75052b --- /dev/null +++ b/src/adaptors/orby-network/index.js @@ -0,0 +1,133 @@ +const sdk = require('@defillama/sdk'); +const superagent = require('superagent'); +const { request, gql } = require('graphql-request'); +const TROVE_MANAGER_ADDRESS = '0x7A47cF15a1fCbAd09c66077d1D021430eed7AC65'; +const USC_ADDRESS = '0xD42E078ceA2bE8D03cd9dFEcC1f0d28915Edea78'; +const SUBGRAPH_URL = 'https://graph.cronoslabs.com/subgraphs/name/orby/orby'; +const URL = 'https://api.crypto.com/pos/v1/public/get-conversion-rate'; + +const query = gql` + query { + global(id: "only") { + currentSystemState { + price + } + } + } +`; + +const req = { + id: 1, + method: 'ptivate/get-conversion-rate', + params: { + instrument_name: 'CDCETH', + }, +}; + +const ABIS = { + getEntireSystemColl: { + inputs: [], + name: 'getEntireSystemColl', + outputs: [ + { + internalType: 'uint256', + name: 'entireSystemColl', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + getMCR: { + inputs: [], + name: 'MCR', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + getBorrowFee: { + inputs: [], + name: 'getBorrowingRateWithDecay', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, +}; +const main = async () => { + const troveEthTvl = ( + await sdk.api.abi.call({ + target: TROVE_MANAGER_ADDRESS, + abi: ABIS.getEntireSystemColl, + chain: 'cronos', + }) + ).output; + + const mcr = ( + await sdk.api.abi.call({ + target: TROVE_MANAGER_ADDRESS, + abi: ABIS.getMCR, + chain: 'cronos', + }) + ).output; + + const uscTotalSupply = ( + await sdk.api.abi.call({ + target: USC_ADDRESS, + abi: 'erc20:totalSupply', + chain: 'cronos', + }) + ).output; + + const borrowFee = ( + await sdk.api.abi.call({ + target: TROVE_MANAGER_ADDRESS, + abi: ABIS.getBorrowFee, + chain: 'cronos', + }) + ).output; + + const key = `cronos:${USC_ADDRESS}`.toLowerCase(); + const prices = ( + await superagent.get(`https://coins.llama.fi/prices/current/${key}`) + ).body.coins; + + const conversionRate = (await superagent.post(URL, req)).body.result + .conversion_rate; + + const totalSupplyUsd = (Number(uscTotalSupply) / 1e18) * prices[key].price; + + const { global } = await request(SUBGRAPH_URL, query); + + return [ + { + pool: TROVE_MANAGER_ADDRESS, + project: 'orby-network', + symbol: 'CDCETH', + chain: 'cronos', + apyBase: Number(conversionRate) - 1, + apyReward: 0, + tvlUsd: + (Number(troveEthTvl) / 1e18) * Number(global.currentSystemState.price), + apyBaseBorrow: Number(borrowFee / 1e18) * 100, + apyRewardBorrow: 0, + totalSupplyUsd: + (Number(troveEthTvl) / 1e18) * Number(global.currentSystemState.price), + totalBorrowUsd: totalSupplyUsd, + ltv: 1 / (mcr / 1e18), + mintedCoin: 'USC', + underlyingTokens: ['0x7a7c9db510aB29A2FC362a4c34260BEcB5cE3446'], + }, + ]; +}; + +module.exports = { + timetravel: false, + apy: main, + url: 'https://orby.network/', +}; From c0c50005415d4d175f728003d72f95a26bac33c5 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Mon, 6 May 2024 12:57:01 +0400 Subject: [PATCH 59/73] swell swap api --- src/adaptors/swell-liquid-staking/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adaptors/swell-liquid-staking/index.js b/src/adaptors/swell-liquid-staking/index.js index 5993c46b51..213614a4d2 100644 --- a/src/adaptors/swell-liquid-staking/index.js +++ b/src/adaptors/swell-liquid-staking/index.js @@ -4,7 +4,7 @@ const sdk = require('@defillama/sdk5'); const abi = require('./abi.json'); const apr = 'https://v3.svc.swellnetwork.io/swell.v3.StatsService/All'; -const apr7d = 'https://v3.svc.swellnetwork.io/api/tokens/sweth/apr'; +const apr7d = 'https://v3-public.svc.swellnetwork.io/api/tokens/sweth/apr'; const swETH = '0xf951E335afb289353dc249e82926178EaC7DEd78'; const apy = async () => { @@ -31,7 +31,7 @@ const apy = async () => { const tvlUsd = totalSupply * rate * ethPrice; - const apyBase = (await axios.post(apr, {})).data.stakingAprPercent; + // const apyBase = (await axios.post(apr, {})).data.stakingAprPercent; const apyBase7d = (await axios.get(apr7d)).data; return [ From 4d3ff6cb4dd7116789c1f9f50814c34842c7d4ef Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 6 May 2024 19:07:48 +0200 Subject: [PATCH 60/73] :sparkles: implement stkGHO yield (#1298) --- src/adaptors/aave-v3/abi.js | 3 +- src/adaptors/aave-v3/index.js | 65 ++++++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/adaptors/aave-v3/abi.js b/src/adaptors/aave-v3/abi.js index 7b084cacd8..42fd722b87 100644 --- a/src/adaptors/aave-v3/abi.js +++ b/src/adaptors/aave-v3/abi.js @@ -1,3 +1,4 @@ module.exports = { - aTokenAbi: [{"inputs":[{"internalType":"contract IPool","name":"pool","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"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"BalanceTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balanceIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"underlyingAsset","type":"address"},{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"address","name":"treasury","type":"address"},{"indexed":false,"internalType":"address","name":"incentivesController","type":"address"},{"indexed":false,"internalType":"uint8","name":"aTokenDecimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"aTokenName","type":"string"},{"indexed":false,"internalType":"string","name":"aTokenSymbol","type":"string"},{"indexed":false,"internalType":"bytes","name":"params","type":"bytes"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"onBehalfOf","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balanceIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"Mint","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":"ATOKEN_REVISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EIP712_REVISION","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POOL","outputs":[{"internalType":"contract IPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RESERVE_TREASURY_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNDERLYING_ASSET_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"receiverOfUnderlying","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getIncentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getPreviousIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getScaledUserBalanceAndSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"handleRepayment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPool","name":"initializingPool","type":"address"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"address","name":"underlyingAsset","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"incentivesController","type":"address"},{"internalType":"uint8","name":"aTokenDecimals","type":"uint8"},{"internalType":"string","name":"aTokenName","type":"string"},{"internalType":"string","name":"aTokenSymbol","type":"string"},{"internalType":"bytes","name":"params","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"mintToTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"scaledBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"scaledTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IAaveIncentivesController","name":"controller","type":"address"}],"name":"setIncentivesController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferOnLiquidation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferUnderlyingTo","outputs":[],"stateMutability":"nonpayable","type":"function"}] + aTokenAbi: [{"inputs":[{"internalType":"contract IPool","name":"pool","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"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"BalanceTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balanceIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"underlyingAsset","type":"address"},{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"address","name":"treasury","type":"address"},{"indexed":false,"internalType":"address","name":"incentivesController","type":"address"},{"indexed":false,"internalType":"uint8","name":"aTokenDecimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"aTokenName","type":"string"},{"indexed":false,"internalType":"string","name":"aTokenSymbol","type":"string"},{"indexed":false,"internalType":"bytes","name":"params","type":"bytes"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"onBehalfOf","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balanceIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"Mint","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":"ATOKEN_REVISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EIP712_REVISION","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POOL","outputs":[{"internalType":"contract IPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RESERVE_TREASURY_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNDERLYING_ASSET_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"receiverOfUnderlying","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getIncentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getPreviousIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getScaledUserBalanceAndSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"handleRepayment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPool","name":"initializingPool","type":"address"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"address","name":"underlyingAsset","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"incentivesController","type":"address"},{"internalType":"uint8","name":"aTokenDecimals","type":"uint8"},{"internalType":"string","name":"aTokenName","type":"string"},{"internalType":"string","name":"aTokenSymbol","type":"string"},{"internalType":"bytes","name":"params","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"mintToTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"scaledBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"scaledTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IAaveIncentivesController","name":"controller","type":"address"}],"name":"setIncentivesController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferOnLiquidation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferUnderlyingTo","outputs":[],"stateMutability":"nonpayable","type":"function"}], + aaveStakedTokenDataProviderAbi: [{"inputs":[{"internalType":"address","name":"stkAave","type":"address"},{"internalType":"address","name":"ethUsdPriceFeed","type":"address"},{"internalType":"address","name":"aaveUsdPriceFeed","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AAVE_USD_PRICE_FEED","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETH_USD_PRICE_FEED","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STAKED_AAVE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"stakedAsset","type":"address"},{"internalType":"address","name":"oracle","type":"address"}],"name":"getStakedAssetData","outputs":[{"components":[{"internalType":"uint256","name":"stakedTokenTotalSupply","type":"uint256"},{"internalType":"uint256","name":"stakedTokenTotalRedeemableAmount","type":"uint256"},{"internalType":"uint256","name":"stakeCooldownSeconds","type":"uint256"},{"internalType":"uint256","name":"stakeUnstakeWindow","type":"uint256"},{"internalType":"uint256","name":"stakedTokenPriceUsd","type":"uint256"},{"internalType":"uint256","name":"rewardTokenPriceUsd","type":"uint256"},{"internalType":"uint256","name":"stakeApy","type":"uint256"},{"internalType":"uint128","name":"distributionPerSecond","type":"uint128"},{"internalType":"bool","name":"inPostSlashingPeriod","type":"bool"},{"internalType":"uint256","name":"distributionEnd","type":"uint256"},{"internalType":"uint256","name":"maxSlashablePercentage","type":"uint256"}],"internalType":"struct IStakedTokenDataProvider.StakedTokenData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"stakedAssets","type":"address[]"},{"internalType":"address[]","name":"oracles","type":"address[]"}],"name":"getStakedAssetDataBatch","outputs":[{"components":[{"internalType":"uint256","name":"stakedTokenTotalSupply","type":"uint256"},{"internalType":"uint256","name":"stakedTokenTotalRedeemableAmount","type":"uint256"},{"internalType":"uint256","name":"stakeCooldownSeconds","type":"uint256"},{"internalType":"uint256","name":"stakeUnstakeWindow","type":"uint256"},{"internalType":"uint256","name":"stakedTokenPriceUsd","type":"uint256"},{"internalType":"uint256","name":"rewardTokenPriceUsd","type":"uint256"},{"internalType":"uint256","name":"stakeApy","type":"uint256"},{"internalType":"uint128","name":"distributionPerSecond","type":"uint128"},{"internalType":"bool","name":"inPostSlashingPeriod","type":"bool"},{"internalType":"uint256","name":"distributionEnd","type":"uint256"},{"internalType":"uint256","name":"maxSlashablePercentage","type":"uint256"}],"internalType":"struct IStakedTokenDataProvider.StakedTokenData[]","name":"","type":"tuple[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"stakedAsset","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"getStakedUserData","outputs":[{"components":[{"internalType":"uint256","name":"stakedTokenTotalSupply","type":"uint256"},{"internalType":"uint256","name":"stakedTokenTotalRedeemableAmount","type":"uint256"},{"internalType":"uint256","name":"stakeCooldownSeconds","type":"uint256"},{"internalType":"uint256","name":"stakeUnstakeWindow","type":"uint256"},{"internalType":"uint256","name":"stakedTokenPriceUsd","type":"uint256"},{"internalType":"uint256","name":"rewardTokenPriceUsd","type":"uint256"},{"internalType":"uint256","name":"stakeApy","type":"uint256"},{"internalType":"uint128","name":"distributionPerSecond","type":"uint128"},{"internalType":"bool","name":"inPostSlashingPeriod","type":"bool"},{"internalType":"uint256","name":"distributionEnd","type":"uint256"},{"internalType":"uint256","name":"maxSlashablePercentage","type":"uint256"}],"internalType":"struct IStakedTokenDataProvider.StakedTokenData","name":"","type":"tuple"},{"components":[{"internalType":"uint256","name":"stakedTokenUserBalance","type":"uint256"},{"internalType":"uint256","name":"stakedTokenRedeemableAmount","type":"uint256"},{"internalType":"uint256","name":"underlyingTokenUserBalance","type":"uint256"},{"internalType":"uint256","name":"rewardsToClaim","type":"uint256"},{"internalType":"uint40","name":"userCooldownTimestamp","type":"uint40"},{"internalType":"uint216","name":"userCooldownAmount","type":"uint216"}],"internalType":"struct IStakedTokenDataProvider.StakedTokenUserData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"stakedAssets","type":"address[]"},{"internalType":"address[]","name":"oracles","type":"address[]"},{"internalType":"address","name":"user","type":"address"}],"name":"getStakedUserDataBatch","outputs":[{"components":[{"internalType":"uint256","name":"stakedTokenTotalSupply","type":"uint256"},{"internalType":"uint256","name":"stakedTokenTotalRedeemableAmount","type":"uint256"},{"internalType":"uint256","name":"stakeCooldownSeconds","type":"uint256"},{"internalType":"uint256","name":"stakeUnstakeWindow","type":"uint256"},{"internalType":"uint256","name":"stakedTokenPriceUsd","type":"uint256"},{"internalType":"uint256","name":"rewardTokenPriceUsd","type":"uint256"},{"internalType":"uint256","name":"stakeApy","type":"uint256"},{"internalType":"uint128","name":"distributionPerSecond","type":"uint128"},{"internalType":"bool","name":"inPostSlashingPeriod","type":"bool"},{"internalType":"uint256","name":"distributionEnd","type":"uint256"},{"internalType":"uint256","name":"maxSlashablePercentage","type":"uint256"}],"internalType":"struct IStakedTokenDataProvider.StakedTokenData[]","name":"","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"stakedTokenUserBalance","type":"uint256"},{"internalType":"uint256","name":"stakedTokenRedeemableAmount","type":"uint256"},{"internalType":"uint256","name":"underlyingTokenUserBalance","type":"uint256"},{"internalType":"uint256","name":"rewardsToClaim","type":"uint256"},{"internalType":"uint40","name":"userCooldownTimestamp","type":"uint40"},{"internalType":"uint216","name":"userCooldownAmount","type":"uint216"}],"internalType":"struct IStakedTokenDataProvider.StakedTokenUserData[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"}] } \ No newline at end of file diff --git a/src/adaptors/aave-v3/index.js b/src/adaptors/aave-v3/index.js index 411ddfd92b..6dd218a70a 100755 --- a/src/adaptors/aave-v3/index.js +++ b/src/adaptors/aave-v3/index.js @@ -3,7 +3,7 @@ const { request, gql } = require('graphql-request'); const sdk = require('@defillama/sdk5'); const utils = require('../utils'); -const { aTokenAbi } = require('./abi'); +const { aTokenAbi, aaveStakedTokenDataProviderAbi } = require('./abi'); const poolAbi = require('./poolAbi'); const SECONDS_PER_YEAR = 31536000; @@ -135,6 +135,66 @@ const queryMetis = gql` } `; +const stkGho = async () => { + const convertStakedTokenApy = (rawApy) => { + const rawApyStringified = rawApy.toString(); + const lastTwoDigits = rawApyStringified.slice(-2); + const remainingDigits = rawApyStringified.slice(0, -2); + const result = `${remainingDigits}.${lastTwoDigits}`; + return Number(result); + }; + + const STKGHO = '0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d'; + const stkGhoTokenOracle = '0x3f12643d3f6f874d39c2a4c9f2cd6f2dbac877fc'; + const aaveStakedTokenDataProviderAddress = + '0xb12e82DF057BF16ecFa89D7D089dc7E5C1Dc057B'; + + const stkghoData = ( + await sdk.api.abi.call({ + target: aaveStakedTokenDataProviderAddress, + abi: aaveStakedTokenDataProviderAbi.find( + (m) => m.name === 'getStakedAssetData' + ), + params: [STKGHO, stkGhoTokenOracle], + chain: 'ethereum', + }) + ).output; + + const stkghoNativeApyRaw = stkghoData[6]; // 6th index of the tuple is the APY + const stkghoNativeApy = convertStakedTokenApy(stkghoNativeApyRaw); + + const stkghoMeritApy = ( + await superagent.get('https://apps.aavechan.com/api/merit/aprs') + ).body.currentAPR.actionsAPR.stkgho; + + const stkghoApy = stkghoNativeApy + stkghoMeritApy; + + const stkghoSupply = + ( + await sdk.api.abi.call({ + target: STKGHO, + abi: 'erc20:totalSupply', + }) + ).output / 1e18; + + const ghoPrice = ( + await superagent.get( + `https://coins.llama.fi/prices/current/ethereum:${GHO}` + ) + ).body.coins[`ethereum:${GHO}`].price; + + const pool = { + pool: `${STKGHO}-ethereum`.toLowerCase(), + chain: 'Ethereum', + project: 'aave-v3', + symbol: 'GHO', + tvlUsd: stkghoSupply * ghoPrice, + apy: stkghoApy, + }; + + return pool; +}; + const ethV3Pools = async () => { const AaveProtocolDataProviderV3Mainnet = '0x7B4EB56E7CD4b454BA8ff71E4518426369a138a3'; @@ -398,9 +458,12 @@ const apy = async () => { const ethPools = await ethV3Pools(); + const stkghoPool = await stkGho(); + return pools .flat() .concat(ethPools) + .concat([stkghoPool]) .filter((p) => utils.keepFinite(p)); }; From 429545f3d16aa8bec013036ef0264f150546654c Mon Sep 17 00:00:00 2001 From: slasher125 Date: Tue, 7 May 2024 17:25:37 +0400 Subject: [PATCH 61/73] aave v3 test --- src/adaptors/aave-v3/index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/adaptors/aave-v3/index.js b/src/adaptors/aave-v3/index.js index 6dd218a70a..d33a158dde 100755 --- a/src/adaptors/aave-v3/index.js +++ b/src/adaptors/aave-v3/index.js @@ -458,13 +458,15 @@ const apy = async () => { const ethPools = await ethV3Pools(); - const stkghoPool = await stkGho(); - - return pools - .flat() - .concat(ethPools) - .concat([stkghoPool]) - .filter((p) => utils.keepFinite(p)); + // const stkghoPool = await stkGho(); + + return ( + pools + .flat() + .concat(ethPools) + // .concat([stkghoPool]) + .filter((p) => utils.keepFinite(p)) + ); }; module.exports = { From 7ebdb67353118404a5b0c597e804a010942979f3 Mon Sep 17 00:00:00 2001 From: ruhum <90156563+0xruhum@users.noreply.github.com> Date: Tue, 7 May 2024 16:27:42 +0300 Subject: [PATCH 62/73] feat: add rsETH yield (#1300) --- src/adaptors/kelp-dao/index.js | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/adaptors/kelp-dao/index.js diff --git a/src/adaptors/kelp-dao/index.js b/src/adaptors/kelp-dao/index.js new file mode 100644 index 0000000000..99876bcf4d --- /dev/null +++ b/src/adaptors/kelp-dao/index.js @@ -0,0 +1,54 @@ +const sdk = require('@defillama/sdk5'); + +const utils = require('../utils'); + +async function getTokenPrice(chain, token) { + const data = await utils.getData( + `https://coins.llama.fi/prices/current/${chain}:${token}` + ); + return data.coins[`${chain}:${token}`]?.price; +} + +const rsETH = '0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7'; +const DEPOSIT_POOL = "0x036676389e48133B63a802f8635AD39E752D375D"; +const apy = async () => { + const apy = (await utils.getData('https://universe.kelpdao.xyz/rseth/apy')).value; + const config = (await sdk.api.abi.call({ abi: 'address:lrtConfig', target: DEPOSIT_POOL })).output; + const tokens = (await sdk.api.abi.call({ abi: 'address[]:getSupportedAssetList', target: config })).output; + + let tvlUsd = 0; + for (let token of tokens) { + const balance = (await sdk.api.abi.call({ + abi: 'function getTotalAssetDeposits(address) external view returns (uint)', + params: [token], + target: DEPOSIT_POOL, + })).output; + + let decimals = 18; + if (token !== "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE") { + decimals = (await sdk.api.abi.call({ + abi: 'erc20:decimals', + target: token, + })).output; + } + + const tokenPrice = await getTokenPrice("ethereum", token); + tvlUsd += balance * tokenPrice / 10 ** decimals; + } + + return [{ + pool: `${rsETH}-ethereum`.toLowerCase(), + chain: "Ethereum", + project: "kelp-dao", + symbol: "rsETH", + underlyingTokens: tokens, + tvlUsd, + apy, + }]; +}; + +module.exports = { + timetravel: false, + apy, + url: 'https://kelpdao.xyz/' +} \ No newline at end of file From 0733ed86042407f53dd69420916e8bc34aca6a06 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Tue, 7 May 2024 17:33:35 +0400 Subject: [PATCH 63/73] aave v3 fix --- src/adaptors/aave-v3/index.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/adaptors/aave-v3/index.js b/src/adaptors/aave-v3/index.js index d33a158dde..113a7523c5 100755 --- a/src/adaptors/aave-v3/index.js +++ b/src/adaptors/aave-v3/index.js @@ -190,6 +190,7 @@ const stkGho = async () => { symbol: 'GHO', tvlUsd: stkghoSupply * ghoPrice, apy: stkghoApy, + url: 'https://app.aave.com/staking', }; return pool; @@ -458,15 +459,13 @@ const apy = async () => { const ethPools = await ethV3Pools(); - // const stkghoPool = await stkGho(); + const stkghoPool = await stkGho(); - return ( - pools - .flat() - .concat(ethPools) - // .concat([stkghoPool]) - .filter((p) => utils.keepFinite(p)) - ); + return pools + .flat() + .concat(ethPools) + .concat([stkghoPool]) + .filter((p) => utils.keepFinite(p)); }; module.exports = { From 0009991cf56b4db55b1b769dc9f4aed2d0996978 Mon Sep 17 00:00:00 2001 From: Dashan McCain Date: Tue, 7 May 2024 06:37:55 -0700 Subject: [PATCH 64/73] Add Ion Protocol Market APYs (#1297) * add: ion-protocol yield adapter * fix: remove log statements --- src/adaptors/ion-protocol/index.js | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/adaptors/ion-protocol/index.js diff --git a/src/adaptors/ion-protocol/index.js b/src/adaptors/ion-protocol/index.js new file mode 100644 index 0000000000..9f891cdc3e --- /dev/null +++ b/src/adaptors/ion-protocol/index.js @@ -0,0 +1,83 @@ +const utils = require('../utils'); +const sdk = require('@defillama/sdk5'); + +const ionAbi = { + usd: 'int256:latestAnswer', + debt: 'uint256:debt', + lenderExchangeRate: 'uint256:stEthPerToken', + totalSupply: 'uint256:totalSupply', + marketBorrowRate: + 'function getCurrentBorrowRate(uint8 ilkIndex) external view returns (uint256 borrowRate, uint256 reserveFactor)', +}; + +const marketApy = async () => { + const markets = await utils.getData( + 'https://ion-backend.vercel.app/v1/bigbrother/markets' + ); + let pools = []; + for (let market of markets) { + const debt = await sdk.api.abi.call({ + target: market.ionPool, + abi: ionAbi.debt, + chain: 'ethereum', + }); + const totalSupply = await sdk.api.abi.call({ + target: market.ionPool, + abi: ionAbi.totalSupply, + chain: 'ethereum', + }); + const usdExchangeRate = await sdk.api.abi.call({ + target: '0xCfE54B5cD566aB89272946F602D76Ea879CAb4a8', // chainlink stEth/USD + abi: ionAbi.usd, + chain: 'ethereum', + }); + const lenderAssetExchangeRate = await sdk.api.abi.call({ + target: market.lenderAssetAddress, + abi: ionAbi.lenderExchangeRate, + chain: 'ethereum', + }); + const borrowRate = await sdk.api.abi.call({ + target: market.ionPool, + abi: ionAbi.marketBorrowRate, + params: 0, + chain: 'ethereum', + }); + const totalSupplyUsd = + (totalSupply.output / 1e18) * + (lenderAssetExchangeRate.output / 1e18) * + (usdExchangeRate.output / 1e8); + const totalBorrowUsd = + (debt.output / 1e45) * + (lenderAssetExchangeRate.output / 1e18) * + (usdExchangeRate.output / 1e8); + const ltv = debt.output / 1e45 / (totalSupply.output / 1e18); + const borrowRateYearly = (borrowRate.output.borrowRate / 1e27) ** 31536000; + const marketApy = (borrowRateYearly - 1) * ltv * 100; + + const pool = { + pool: market.ionPool, + chain: 'ethereum', + project: 'ion-protocol', + symbol: market.collateralAssetName + '-' + market.lenderAssetName, + tvlUsd: totalSupplyUsd - totalBorrowUsd, + apyBase: marketApy, + underlyingTokens: [market.lenderAssetAddress], + totalSupplyUsd: totalSupplyUsd, + totalBorrowUsd: totalBorrowUsd, + ltv: ltv, + }; + pools.push(pool); + } + return pools; +}; + +const apy = async () => { + const pools = await marketApy(); + return pools; +}; + +module.exports = { + timetravel: false, + apy, + url: 'https://www.app.ionprotocol.io/', +}; From 5cc5dc24c1b88f93f42d9305bc9aada1b3c1d855 Mon Sep 17 00:00:00 2001 From: LeeRyanj <138840879+LeeRyanj@users.noreply.github.com> Date: Wed, 8 May 2024 13:52:56 +0800 Subject: [PATCH 65/73] Create index.js (#1299) * Create index.js add kiloex yield * Update index.js * Update index.js --- src/adaptors/kiloex/index.js | 94 ++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/adaptors/kiloex/index.js diff --git a/src/adaptors/kiloex/index.js b/src/adaptors/kiloex/index.js new file mode 100644 index 0000000000..b85368d9cf --- /dev/null +++ b/src/adaptors/kiloex/index.js @@ -0,0 +1,94 @@ +const axios = require('axios'); +const sdk = require('@defillama/sdk5'); + +const utils = require('../utils'); + +const chains = { + op_bnb: { + USDT: '0x9e5aac1ba1a2e6aed6b32689dfcf62a509ca96f3', + decimals: 18, + kUSDT: '0xA2E2F3726DF754C1848C8fd1CbeA6aAFF84FC5B2', + apyEndpoint: 'https://opapi.kiloex.io/common/queryKiloNewVaultApyHistory' + }, + manta: { + USDT: '0xf417F5A458eC102B90352F697D6e2Ac3A3d2851f', + decimals: 6, + kUSDT: '0xA2E2F3726DF754C1848C8fd1CbeA6aAFF84FC5B2', + apyEndpoint: 'https://mantaapi.kiloex.io/common/queryKiloNewVaultApyHistory', + STONE: '0xEc901DA9c68E90798BbBb74c11406A32A70652C3' + }, + bsc: { + USDT: '0x55d398326f99059fF775485246999027B3197955', + decimals: 18, + kUSDT: '0x1c3f35F7883fc4Ea8C4BCA1507144DC6087ad0fb', + apyEndpoint: 'https://api.kiloex.io/common/queryKiloNewVaultApyHistory' + } +}; + +const getApy = async () => { + const pools = await Promise.all( + Object.keys(chains).map(async (chain) => { + const y = chains[chain]; + const aprArray = (await axios.get(y.apyEndpoint)).data; + const apr = aprArray[aprArray.length - 1]; + + const balance = + ( + await sdk.api.abi.call({ + target: y.USDT, + abi: 'erc20:balanceOf', + params: [y.kUSDT], + chain, + }) + ).output / 10**y.decimals; + + + let results = [] + results.push({ + chain, + project: 'kiloex', + pool: y.USDT, + symbol: 'USDT', + tvlUsd: balance, + apyBase: apr.apy * 100, + underlyingTokens: [y.USDT], + }); + if (chain === 'manta') { + const stoneBalance = + ( + await sdk.api.abi.call({ + target: y.STONE, + abi: 'erc20:balanceOf', + params: ['0x471C5e8Cc0fEC9aeeb7ABA6697105fD6aaaDFf99'], + chain, + }) + ).output / 1e18; + + const priceKey = `manta:${y.STONE}`; + const price = ( + await axios.get(`https://coins.llama.fi/prices/current/${priceKey}`) + ).data.coins[priceKey].price; + + const stoneApy = (await axios.get('https://mantaapi.kiloex.io/sidevault/info')).data.data.apy; + + results.push({ + chain, + project: 'kiloex', + pool: y.STONE, + symbol: 'STONE', + tvlUsd: stoneBalance * price, + apyBase: Number(stoneApy) * 100, + underlyingTokens: [y.STONE], + }); + } + return results; + }) + ); + + return pools.flat(); +}; + +module.exports = { + apy: getApy, + url: 'https://app.kiloex.io/trade/vault', +}; From 56a094f6c9e5bb92fcc30dbd297c6d3913dc68fd Mon Sep 17 00:00:00 2001 From: slasher125 Date: Wed, 8 May 2024 10:48:04 +0400 Subject: [PATCH 66/73] update exclusion --- src/utils/exclude.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/exclude.js b/src/utils/exclude.js index cbf06d0cfc..8968343d66 100644 --- a/src/utils/exclude.js +++ b/src/utils/exclude.js @@ -89,6 +89,8 @@ const excludeAdaptors = [ 'wise-lending', 'nudes', 'pickle', + 'mycelium-perpetual-swaps', + 'lyra-v1', ]; const excludePools = [ From 79d3ff300065832883b5ccafba6303821fc8f65e Mon Sep 17 00:00:00 2001 From: slasher125 Date: Wed, 8 May 2024 10:51:37 +0400 Subject: [PATCH 67/73] vendor fix --- src/adaptors/vendor-v2/index.js | 104 +++++++++++++++++--------------- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/src/adaptors/vendor-v2/index.js b/src/adaptors/vendor-v2/index.js index c46724513b..2c865c09b2 100644 --- a/src/adaptors/vendor-v2/index.js +++ b/src/adaptors/vendor-v2/index.js @@ -171,61 +171,65 @@ const getPools = async () => { query: networkConfig.query, type: networkConfig.type, }); - const network = networkConfig.network.toLowerCase(); - for (const pool of Object.entries(response.data)[0][1]) { - const { - lendTokenSymbol, - colTokenSymbol, - lendTokenDecimals, - colTokenDecimals, - } = await getGenericTokenInfo([pool.lendToken, pool.colToken], network); - const [lendTokenPriceInfo, colTokenPriceInfo] = await getTokenPriceInfo( - [pool.lendToken, pool.colToken], - network - ); - const availableLiquidity = await getAvailableLiquidity( - pool.id, - lendTokenPriceInfo, - lendTokenDecimals, - network - ); - const { totalBorrowedUsd, totalSuppliedUsd, lendFee } = - await getSuppliedAndBorrowedUsd( - pool, + try { + const network = networkConfig.network.toLowerCase(); + for (const pool of Object.entries(response.data)[0][1]) { + const { + lendTokenSymbol, + colTokenSymbol, lendTokenDecimals, colTokenDecimals, + } = await getGenericTokenInfo([pool.lendToken, pool.colToken], network); + const [lendTokenPriceInfo, colTokenPriceInfo] = await getTokenPriceInfo( + [pool.lendToken, pool.colToken], + network + ); + const availableLiquidity = await getAvailableLiquidity( + pool.id, lendTokenPriceInfo, + lendTokenDecimals, network ); - const loanToValue = getLoanToValue( - lendTokenPriceInfo, - colTokenPriceInfo, - pool, - lendFee - ); - const poolObj = { - pool: pool.id, - chain: networkConfig.network, - project: 'vendor-v2', - ltv: loanToValue, - underlyingTokens: [pool.lendToken, pool.colToken], - symbol: lendTokenSymbol, - tvlUsd: availableLiquidity, - totalBorrowUsd: totalBorrowedUsd, - totalSupplyUsd: totalSuppliedUsd, - apyBase: 0, - apyBaseBorrow: - pool.feeType == 1 - ? ((31536000 / - (Number(pool.expiry) - new Date().getTime() / 1000)) * - pool.startRate) / - 10000 - : pool.startRate / 10000, - poolMeta: `Due ${new Date(pool.expiry * 1000) - .toUTCString() - .slice(5, -13)}, ${colTokenSymbol} collateral`, - }; - pools.push(poolObj); + const { totalBorrowedUsd, totalSuppliedUsd, lendFee } = + await getSuppliedAndBorrowedUsd( + pool, + lendTokenDecimals, + colTokenDecimals, + lendTokenPriceInfo, + network + ); + const loanToValue = getLoanToValue( + lendTokenPriceInfo, + colTokenPriceInfo, + pool, + lendFee + ); + const poolObj = { + pool: pool.id, + chain: networkConfig.network, + project: 'vendor-v2', + ltv: loanToValue, + underlyingTokens: [pool.lendToken, pool.colToken], + symbol: lendTokenSymbol, + tvlUsd: availableLiquidity, + totalBorrowUsd: totalBorrowedUsd, + totalSupplyUsd: totalSuppliedUsd, + apyBase: 0, + apyBaseBorrow: + pool.feeType == 1 + ? ((31536000 / + (Number(pool.expiry) - new Date().getTime() / 1000)) * + pool.startRate) / + 10000 + : pool.startRate / 10000, + poolMeta: `Due ${new Date(pool.expiry * 1000) + .toUTCString() + .slice(5, -13)}, ${colTokenSymbol} collateral`, + }; + pools.push(poolObj); + } + } catch (err) { + console.log(err); } } return pools; From 9f5d7a0460010b6ba93ae7316e05480cc7f057b3 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Wed, 8 May 2024 10:58:41 +0400 Subject: [PATCH 68/73] update exclusion --- src/utils/exclude.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/exclude.js b/src/utils/exclude.js index 8968343d66..e098678501 100644 --- a/src/utils/exclude.js +++ b/src/utils/exclude.js @@ -91,6 +91,7 @@ const excludeAdaptors = [ 'pickle', 'mycelium-perpetual-swaps', 'lyra-v1', + 'reflexer', ]; const excludePools = [ From c253d0b0cb9c8ce9ab754cf2354e49cbff9be4e7 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Wed, 8 May 2024 11:14:18 +0400 Subject: [PATCH 69/73] paladin fix --- src/adaptors/paladin-dullahan/index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/adaptors/paladin-dullahan/index.js b/src/adaptors/paladin-dullahan/index.js index 2739fbd941..2a20f6fba7 100644 --- a/src/adaptors/paladin-dullahan/index.js +++ b/src/adaptors/paladin-dullahan/index.js @@ -1,6 +1,6 @@ const ethers = require('ethers'); const abi = require('./abi'); -const sdk = require('@defillama/sdk'); +const sdk = require('@defillama/sdk5'); const superagent = require('superagent'); /////////////////////////// Constants /////////////////////////// @@ -75,7 +75,8 @@ const getDefiLLamaPools = async (project, chain) => { const pools = (await superagent.get('https://yields.llama.fi/pools')).body .data; return pools.filter( - (pool) => pool.project === project && pool.chain === chain + (pool) => + pool.project === project && pool.chain === chain && pool.underlyingTokens ); }; @@ -191,10 +192,7 @@ const maxApy = async () => { target: DISCOUNT_CALCULATOR_MODULE, abi: abi['calculateDiscountRate'], chain: 'ethereum', - params: [ - ethers.utils.parseEther('50'), - ethers.utils.parseEther('100000'), - ], + params: [50000000000000000000n, 100000000000000000000000n], }) ).output; const fee = ( From bd2c23fd718675a33f6ca7cb0d330e391d13a9e8 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Wed, 8 May 2024 12:10:39 +0400 Subject: [PATCH 70/73] synthetix v3 usdc pool --- src/adaptors/synthetix-v3/index.js | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/adaptors/synthetix-v3/index.js diff --git a/src/adaptors/synthetix-v3/index.js b/src/adaptors/synthetix-v3/index.js new file mode 100644 index 0000000000..ea7144c8d3 --- /dev/null +++ b/src/adaptors/synthetix-v3/index.js @@ -0,0 +1,46 @@ +const axios = require('axios'); + +const sdk = require('@defillama/sdk5'); + +const USDC = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'; +const SNX = '0x22e6966B799c4D5B13BE962E1D117b56327FDa66'; +const USDC_POOL = '0x32C222A9A159782aFD7529c87FA34b96CA72C696'; + +const apy = async () => { + const apr = (await axios.get('https://api.synthetix.io/v3/base/sc-pool-apy')) + .data; + + const deposits = + ( + await sdk.api.abi.call({ + target: USDC, + abi: 'erc20:balanceOf', + chain: 'base', + params: [USDC_POOL], + }) + ).output / 1e6; + + const key = `base:${USDC}`; + const price = ( + await axios.get(`https://coins.llama.fi/prices/current/${key}`) + ).data.coins[key].price; + + return [ + { + pool: USDC_POOL, + symbol: 'USDC', + project: 'synthetix-v3', + chain: 'Base', + tvlUsd: deposits * price, + apyBase: apr.aprPnl * 100, + apyReward: apr.aprRewards * 100, + rewardTokens: [USDC, SNX], + underlyingTokens: [USDC], + }, + ]; +}; + +module.exports = { + apy, + url: 'https://liquidity.synthetix.eth.limo/', +}; From ffdbcc0609a6b556837c84352a350e26fb3f370b Mon Sep 17 00:00:00 2001 From: Karman <130730603+KarmanMax@users.noreply.github.com> Date: Wed, 8 May 2024 21:52:34 +0800 Subject: [PATCH 71/73] update extra finance adapter (#1302) --- .../extra-finance/abis/veloPairsSugarV2.json | 1071 +++++++++++------ src/adaptors/extra-finance/contract.js | 10 +- 2 files changed, 739 insertions(+), 342 deletions(-) diff --git a/src/adaptors/extra-finance/abis/veloPairsSugarV2.json b/src/adaptors/extra-finance/abis/veloPairsSugarV2.json index 37149bb244..ff98d3e90b 100644 --- a/src/adaptors/extra-finance/abis/veloPairsSugarV2.json +++ b/src/adaptors/extra-finance/abis/veloPairsSugarV2.json @@ -1,337 +1,736 @@ [ - { - "stateMutability": "nonpayable", - "type": "constructor", - "inputs": [ - { "name": "_voter", "type": "address" }, - { "name": "_registry", "type": "address" }, - { "name": "_v1_voter", "type": "address" }, - { "name": "_convertor", "type": "address" } - ], - "outputs": [] - }, - { - "stateMutability": "view", - "type": "function", - "name": "toMigrate", - "inputs": [{ "name": "_account", "type": "address" }], - "outputs": [ - { - "name": "", - "type": "tuple[]", - "components": [ - { "name": "lp", "type": "address" }, - { "name": "symbol", "type": "string" }, - { "name": "decimals", "type": "uint8" }, - { "name": "stable", "type": "bool" }, - { "name": "total_supply", "type": "uint256" }, - { "name": "token0", "type": "address" }, - { "name": "reserve0", "type": "uint256" }, - { "name": "claimable0", "type": "uint256" }, - { "name": "token1", "type": "address" }, - { "name": "reserve1", "type": "uint256" }, - { "name": "claimable1", "type": "uint256" }, - { "name": "gauge", "type": "address" }, - { "name": "gauge_total_supply", "type": "uint256" }, - { "name": "gauge_alive", "type": "bool" }, - { "name": "fee", "type": "address" }, - { "name": "bribe", "type": "address" }, - { "name": "factory", "type": "address" }, - { "name": "emissions", "type": "uint256" }, - { "name": "emissions_token", "type": "address" }, - { "name": "account_balance", "type": "uint256" }, - { "name": "account_earned", "type": "uint256" }, - { "name": "account_staked", "type": "uint256" }, - { "name": "pool_fee", "type": "uint256" } - ] - } - ] - }, - { - "stateMutability": "view", - "type": "function", - "name": "forSwaps", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "tuple[]", - "components": [ - { "name": "lp", "type": "address" }, - { "name": "stable", "type": "bool" }, - { "name": "token0", "type": "address" }, - { "name": "token1", "type": "address" }, - { "name": "factory", "type": "address" } - ] - } - ] - }, - { - "stateMutability": "view", - "type": "function", - "name": "tokens", - "inputs": [ - { "name": "_limit", "type": "uint256" }, - { "name": "_offset", "type": "uint256" }, - { "name": "_account", "type": "address" } - ], - "outputs": [ - { - "name": "", - "type": "tuple[]", - "components": [ - { "name": "token_address", "type": "address" }, - { "name": "symbol", "type": "string" }, - { "name": "decimals", "type": "uint8" }, - { "name": "account_balance", "type": "uint256" }, - { "name": "listed", "type": "bool" } - ] - } - ] - }, - { - "stateMutability": "view", - "type": "function", - "name": "all", - "inputs": [ - { "name": "_limit", "type": "uint256" }, - { "name": "_offset", "type": "uint256" }, - { "name": "_account", "type": "address" } - ], - "outputs": [ - { - "name": "", - "type": "tuple[]", - "components": [ - { "name": "lp", "type": "address" }, - { "name": "symbol", "type": "string" }, - { "name": "decimals", "type": "uint8" }, - { "name": "stable", "type": "bool" }, - { "name": "total_supply", "type": "uint256" }, - { "name": "token0", "type": "address" }, - { "name": "reserve0", "type": "uint256" }, - { "name": "claimable0", "type": "uint256" }, - { "name": "token1", "type": "address" }, - { "name": "reserve1", "type": "uint256" }, - { "name": "claimable1", "type": "uint256" }, - { "name": "gauge", "type": "address" }, - { "name": "gauge_total_supply", "type": "uint256" }, - { "name": "gauge_alive", "type": "bool" }, - { "name": "fee", "type": "address" }, - { "name": "bribe", "type": "address" }, - { "name": "factory", "type": "address" }, - { "name": "emissions", "type": "uint256" }, - { "name": "emissions_token", "type": "address" }, - { "name": "account_balance", "type": "uint256" }, - { "name": "account_earned", "type": "uint256" }, - { "name": "account_staked", "type": "uint256" }, - { "name": "pool_fee", "type": "uint256" } - ] - } - ] - }, - { - "stateMutability": "view", - "type": "function", - "name": "byIndex", - "inputs": [ - { "name": "_index", "type": "uint256" }, - { "name": "_account", "type": "address" } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "components": [ - { "name": "lp", "type": "address" }, - { "name": "symbol", "type": "string" }, - { "name": "decimals", "type": "uint8" }, - { "name": "stable", "type": "bool" }, - { "name": "total_supply", "type": "uint256" }, - { "name": "token0", "type": "address" }, - { "name": "reserve0", "type": "uint256" }, - { "name": "claimable0", "type": "uint256" }, - { "name": "token1", "type": "address" }, - { "name": "reserve1", "type": "uint256" }, - { "name": "claimable1", "type": "uint256" }, - { "name": "gauge", "type": "address" }, - { "name": "gauge_total_supply", "type": "uint256" }, - { "name": "gauge_alive", "type": "bool" }, - { "name": "fee", "type": "address" }, - { "name": "bribe", "type": "address" }, - { "name": "factory", "type": "address" }, - { "name": "emissions", "type": "uint256" }, - { "name": "emissions_token", "type": "address" }, - { "name": "account_balance", "type": "uint256" }, - { "name": "account_earned", "type": "uint256" }, - { "name": "account_staked", "type": "uint256" }, - { "name": "pool_fee", "type": "uint256" } - ] - } - ] - }, - { - "stateMutability": "view", - "type": "function", - "name": "epochsLatest", - "inputs": [ - { "name": "_limit", "type": "uint256" }, - { "name": "_offset", "type": "uint256" } - ], - "outputs": [ - { - "name": "", - "type": "tuple[]", - "components": [ - { "name": "ts", "type": "uint256" }, - { "name": "lp", "type": "address" }, - { "name": "votes", "type": "uint256" }, - { "name": "emissions", "type": "uint256" }, - { - "name": "bribes", - "type": "tuple[]", - "components": [ - { "name": "token", "type": "address" }, - { "name": "amount", "type": "uint256" } - ] - }, - { - "name": "fees", - "type": "tuple[]", - "components": [ - { "name": "token", "type": "address" }, - { "name": "amount", "type": "uint256" } - ] - } - ] - } - ] - }, - { - "stateMutability": "view", - "type": "function", - "name": "epochsByAddress", - "inputs": [ - { "name": "_limit", "type": "uint256" }, - { "name": "_offset", "type": "uint256" }, - { "name": "_address", "type": "address" } - ], - "outputs": [ - { - "name": "", - "type": "tuple[]", - "components": [ - { "name": "ts", "type": "uint256" }, - { "name": "lp", "type": "address" }, - { "name": "votes", "type": "uint256" }, - { "name": "emissions", "type": "uint256" }, - { - "name": "bribes", - "type": "tuple[]", - "components": [ - { "name": "token", "type": "address" }, - { "name": "amount", "type": "uint256" } - ] - }, - { - "name": "fees", - "type": "tuple[]", - "components": [ - { "name": "token", "type": "address" }, - { "name": "amount", "type": "uint256" } - ] - } - ] - } - ] - }, - { - "stateMutability": "view", - "type": "function", - "name": "rewards", - "inputs": [ - { "name": "_limit", "type": "uint256" }, - { "name": "_offset", "type": "uint256" }, - { "name": "_venft_id", "type": "uint256" } - ], - "outputs": [ - { - "name": "", - "type": "tuple[]", - "components": [ - { "name": "venft_id", "type": "uint256" }, - { "name": "lp", "type": "address" }, - { "name": "amount", "type": "uint256" }, - { "name": "token", "type": "address" }, - { "name": "fee", "type": "address" }, - { "name": "bribe", "type": "address" } - ] - } - ] - }, - { - "stateMutability": "view", - "type": "function", - "name": "rewardsByAddress", - "inputs": [ - { "name": "_venft_id", "type": "uint256" }, - { "name": "_pool", "type": "address" } - ], - "outputs": [ - { - "name": "", - "type": "tuple[]", - "components": [ - { "name": "venft_id", "type": "uint256" }, - { "name": "lp", "type": "address" }, - { "name": "amount", "type": "uint256" }, - { "name": "token", "type": "address" }, - { "name": "fee", "type": "address" }, - { "name": "bribe", "type": "address" } - ] - } - ] - }, - { - "stateMutability": "view", - "type": "function", - "name": "registry", - "inputs": [], - "outputs": [{ "name": "", "type": "address" }] - }, - { - "stateMutability": "view", - "type": "function", - "name": "voter", - "inputs": [], - "outputs": [{ "name": "", "type": "address" }] - }, - { - "stateMutability": "view", - "type": "function", - "name": "convertor", - "inputs": [], - "outputs": [{ "name": "", "type": "address" }] - }, - { - "stateMutability": "view", - "type": "function", - "name": "v1_voter", - "inputs": [], - "outputs": [{ "name": "", "type": "address" }] - }, - { - "stateMutability": "view", - "type": "function", - "name": "v1_factory", - "inputs": [], - "outputs": [{ "name": "", "type": "address" }] - }, - { - "stateMutability": "view", - "type": "function", - "name": "v1_token", - "inputs": [], - "outputs": [{ "name": "", "type": "address" }] - } -] + { + "stateMutability": "nonpayable", + "type": "constructor", + "inputs": [ + { + "name": "_voter", + "type": "address" + }, + { + "name": "_registry", + "type": "address" + }, + { + "name": "_nfpm", + "type": "address" + }, + { + "name": "_slipstream_helper", + "type": "address" + } + ], + "outputs": [] + }, + { + "stateMutability": "view", + "type": "function", + "name": "forSwaps", + "inputs": [ + { + "name": "_limit", + "type": "uint256" + }, + { + "name": "_offset", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "components": [ + { + "name": "lp", + "type": "address" + }, + { + "name": "type", + "type": "int24" + }, + { + "name": "token0", + "type": "address" + }, + { + "name": "token1", + "type": "address" + }, + { + "name": "factory", + "type": "address" + }, + { + "name": "pool_fee", + "type": "uint256" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "tokens", + "inputs": [ + { + "name": "_limit", + "type": "uint256" + }, + { + "name": "_offset", + "type": "uint256" + }, + { + "name": "_account", + "type": "address" + }, + { + "name": "_addresses", + "type": "address[]" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "components": [ + { + "name": "token_address", + "type": "address" + }, + { + "name": "symbol", + "type": "string" + }, + { + "name": "decimals", + "type": "uint8" + }, + { + "name": "account_balance", + "type": "uint256" + }, + { + "name": "listed", + "type": "bool" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "all", + "inputs": [ + { + "name": "_limit", + "type": "uint256" + }, + { + "name": "_offset", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "components": [ + { + "name": "lp", + "type": "address" + }, + { + "name": "symbol", + "type": "string" + }, + { + "name": "decimals", + "type": "uint8" + }, + { + "name": "liquidity", + "type": "uint256" + }, + { + "name": "type", + "type": "int24" + }, + { + "name": "tick", + "type": "int24" + }, + { + "name": "sqrt_ratio", + "type": "uint160" + }, + { + "name": "token0", + "type": "address" + }, + { + "name": "reserve0", + "type": "uint256" + }, + { + "name": "staked0", + "type": "uint256" + }, + { + "name": "token1", + "type": "address" + }, + { + "name": "reserve1", + "type": "uint256" + }, + { + "name": "staked1", + "type": "uint256" + }, + { + "name": "gauge", + "type": "address" + }, + { + "name": "gauge_liquidity", + "type": "uint256" + }, + { + "name": "gauge_alive", + "type": "bool" + }, + { + "name": "fee", + "type": "address" + }, + { + "name": "bribe", + "type": "address" + }, + { + "name": "factory", + "type": "address" + }, + { + "name": "emissions", + "type": "uint256" + }, + { + "name": "emissions_token", + "type": "address" + }, + { + "name": "pool_fee", + "type": "uint256" + }, + { + "name": "unstaked_fee", + "type": "uint256" + }, + { + "name": "token0_fees", + "type": "uint256" + }, + { + "name": "token1_fees", + "type": "uint256" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "byIndex", + "inputs": [ + { + "name": "_index", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "components": [ + { + "name": "lp", + "type": "address" + }, + { + "name": "symbol", + "type": "string" + }, + { + "name": "decimals", + "type": "uint8" + }, + { + "name": "liquidity", + "type": "uint256" + }, + { + "name": "type", + "type": "int24" + }, + { + "name": "tick", + "type": "int24" + }, + { + "name": "sqrt_ratio", + "type": "uint160" + }, + { + "name": "token0", + "type": "address" + }, + { + "name": "reserve0", + "type": "uint256" + }, + { + "name": "staked0", + "type": "uint256" + }, + { + "name": "token1", + "type": "address" + }, + { + "name": "reserve1", + "type": "uint256" + }, + { + "name": "staked1", + "type": "uint256" + }, + { + "name": "gauge", + "type": "address" + }, + { + "name": "gauge_liquidity", + "type": "uint256" + }, + { + "name": "gauge_alive", + "type": "bool" + }, + { + "name": "fee", + "type": "address" + }, + { + "name": "bribe", + "type": "address" + }, + { + "name": "factory", + "type": "address" + }, + { + "name": "emissions", + "type": "uint256" + }, + { + "name": "emissions_token", + "type": "address" + }, + { + "name": "pool_fee", + "type": "uint256" + }, + { + "name": "unstaked_fee", + "type": "uint256" + }, + { + "name": "token0_fees", + "type": "uint256" + }, + { + "name": "token1_fees", + "type": "uint256" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "positions", + "inputs": [ + { + "name": "_limit", + "type": "uint256" + }, + { + "name": "_offset", + "type": "uint256" + }, + { + "name": "_account", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "components": [ + { + "name": "id", + "type": "uint256" + }, + { + "name": "lp", + "type": "address" + }, + { + "name": "liquidity", + "type": "uint256" + }, + { + "name": "staked", + "type": "uint256" + }, + { + "name": "amount0", + "type": "uint256" + }, + { + "name": "amount1", + "type": "uint256" + }, + { + "name": "staked0", + "type": "uint256" + }, + { + "name": "staked1", + "type": "uint256" + }, + { + "name": "unstaked_earned0", + "type": "uint256" + }, + { + "name": "unstaked_earned1", + "type": "uint256" + }, + { + "name": "emissions_earned", + "type": "uint256" + }, + { + "name": "tick_lower", + "type": "int24" + }, + { + "name": "tick_upper", + "type": "int24" + }, + { + "name": "sqrt_ratio_lower", + "type": "uint160" + }, + { + "name": "sqrt_ratio_upper", + "type": "uint160" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "epochsLatest", + "inputs": [ + { + "name": "_limit", + "type": "uint256" + }, + { + "name": "_offset", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "components": [ + { + "name": "ts", + "type": "uint256" + }, + { + "name": "lp", + "type": "address" + }, + { + "name": "votes", + "type": "uint256" + }, + { + "name": "emissions", + "type": "uint256" + }, + { + "name": "bribes", + "type": "tuple[]", + "components": [ + { + "name": "token", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ] + }, + { + "name": "fees", + "type": "tuple[]", + "components": [ + { + "name": "token", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ] + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "epochsByAddress", + "inputs": [ + { + "name": "_limit", + "type": "uint256" + }, + { + "name": "_offset", + "type": "uint256" + }, + { + "name": "_address", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "components": [ + { + "name": "ts", + "type": "uint256" + }, + { + "name": "lp", + "type": "address" + }, + { + "name": "votes", + "type": "uint256" + }, + { + "name": "emissions", + "type": "uint256" + }, + { + "name": "bribes", + "type": "tuple[]", + "components": [ + { + "name": "token", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ] + }, + { + "name": "fees", + "type": "tuple[]", + "components": [ + { + "name": "token", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ] + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "rewards", + "inputs": [ + { + "name": "_limit", + "type": "uint256" + }, + { + "name": "_offset", + "type": "uint256" + }, + { + "name": "_venft_id", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "components": [ + { + "name": "venft_id", + "type": "uint256" + }, + { + "name": "lp", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + }, + { + "name": "token", + "type": "address" + }, + { + "name": "fee", + "type": "address" + }, + { + "name": "bribe", + "type": "address" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "rewardsByAddress", + "inputs": [ + { + "name": "_venft_id", + "type": "uint256" + }, + { + "name": "_pool", + "type": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "components": [ + { + "name": "venft_id", + "type": "uint256" + }, + { + "name": "lp", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + }, + { + "name": "token", + "type": "address" + }, + { + "name": "fee", + "type": "address" + }, + { + "name": "bribe", + "type": "address" + } + ] + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "registry", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "voter", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "nfpm", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + }, + { + "stateMutability": "view", + "type": "function", + "name": "cl_helper", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address" + } + ] + } +] \ No newline at end of file diff --git a/src/adaptors/extra-finance/contract.js b/src/adaptors/extra-finance/contract.js index 8fd3e2c8ab..bed54636e2 100644 --- a/src/adaptors/extra-finance/contract.js +++ b/src/adaptors/extra-finance/contract.js @@ -3,8 +3,8 @@ const { ethers, Contract, BigNumber } = require('ethers'); const pairsSugarContractAbi = require("./abis/veloPairsSugarV2.json"); const veloPairAddress = { - optimism: '0x3b21531Bd00289f10C7D8B64b9389095f521A4d3', - base: '0x2073D8035bB2b0F2e85aAF5a8732C6f397F9ff9b' + optimism: '0xF6F6955756Db870258C31B49cB51860b77b53194', + base: '0xC301856B4262E49E9239ec8a2d0c754d5ae317c0' } const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000" @@ -26,11 +26,9 @@ exports.getAllVeloPools = async function (chain) { const simpleRpcProvider = new ethers.providers.JsonRpcProvider(rpcUrl); const veloPairContract = new Contract(veloPairAddress[chain], pairsSugarContractAbi, simpleRpcProvider) const [poolInfoList1, poolInfoList2] = await Promise.all([ - veloPairContract.all(300, 0, ADDRESS_ZERO), - veloPairContract.all(370, 300, ADDRESS_ZERO), + veloPairContract.all(300, 0), + veloPairContract.all(370, 300), ]) const poolInfoList = poolInfoList1.concat(poolInfoList2) return poolInfoList - // const res = await veloPairContract.all(10000, 0, ADDRESS_ZERO) - // return res } From e70b131014a921f9dfbbb1cad9343117679cf2d3 Mon Sep 17 00:00:00 2001 From: slasher125 Date: Thu, 9 May 2024 16:09:37 +0400 Subject: [PATCH 72/73] remove robo vault --- src/adaptors/return-finance/index.js | 8 +++++++- src/utils/exclude.js | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/adaptors/return-finance/index.js b/src/adaptors/return-finance/index.js index 95ceeaf905..6fa6e60552 100644 --- a/src/adaptors/return-finance/index.js +++ b/src/adaptors/return-finance/index.js @@ -68,7 +68,13 @@ const getApy = async () => { chain: 'ethereum', }); - return [aavePolygon, aaveAvalanche, compoundV3Base, makerDao, convexFinance]; + return [ + aavePolygon, + aaveAvalanche, + compoundV3Base, + makerDao, + convexFinance, + ].filter((i) => utils.keepFinite(i)); }; module.exports = { diff --git a/src/utils/exclude.js b/src/utils/exclude.js index e098678501..6bd6ec9497 100644 --- a/src/utils/exclude.js +++ b/src/utils/exclude.js @@ -92,6 +92,7 @@ const excludeAdaptors = [ 'mycelium-perpetual-swaps', 'lyra-v1', 'reflexer', + 'robo-vault', ]; const excludePools = [ From fc2d6cfb6a10221b123d78c4faa33b3e52edc6d5 Mon Sep 17 00:00:00 2001 From: Angelos Kappos Date: Thu, 9 May 2024 17:17:12 +0200 Subject: [PATCH 73/73] IndigoProtocol/ Add Yields for Indigo Stability Pools (#1301) * IndigoProtocol/ Add Yields for Indigo Stability Pools - create appropriate functionality to get APY for each Stability Pool - fetch Prices/APR/AssetAnalytics/ADA price to USD - calculate TVL * IndigoProtocol/ Add Indigo Stability Pools - update response of TVL - update APY rewards * IndigoProtocol/ Add Indigo Stability Pools - update response of TVL - update APY rewards --- src/adaptors/indigo/http-helper.js | 22 ++++++++ src/adaptors/indigo/index.js | 84 ++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 src/adaptors/indigo/http-helper.js create mode 100644 src/adaptors/indigo/index.js diff --git a/src/adaptors/indigo/http-helper.js b/src/adaptors/indigo/http-helper.js new file mode 100644 index 0000000000..3022dc700a --- /dev/null +++ b/src/adaptors/indigo/http-helper.js @@ -0,0 +1,22 @@ +const axios = require("axios") + +async function get(endpoint, options) { + try { + return (await axios.get(endpoint, options)).data + } catch (e) { + throw new Error(`Failed to get ${endpoint}`) + } +} + +async function post(endpoint, body, options) { + try { + return (await axios.post(endpoint, body, options)).data + } catch (e) { + throw new Error(`Failed to post ${endpoint}`) + } +} + +module.exports = { + get, + post +} \ No newline at end of file diff --git a/src/adaptors/indigo/index.js b/src/adaptors/indigo/index.js new file mode 100644 index 0000000000..946ade49e9 --- /dev/null +++ b/src/adaptors/indigo/index.js @@ -0,0 +1,84 @@ +const { get, post } = require('./http-helper') + +// Get Pool Data for each Stability Pool +async function apy() { + const stabilityPools = await fetchStabilityPools(); + const adaPriceUsd = await fetchAdaPriceToUsd(); + + return Promise.all(stabilityPools.map(async (pool) => { + const adaRewardsKey = `sp_${pool.asset}_ada`; + const indyRewardsKey = `sp_${pool.asset}_indy`; + + const [adaApy, indyApy] = await Promise.all([ + fetchApr(adaRewardsKey), + fetchApr(indyRewardsKey) + ]); + + const assetAnalytics = await fetchAssetAnalytics(pool.asset); + const tvlUsd = await calculateTvlUsd(assetAnalytics, adaPriceUsd); + + return { + pool: pool.asset, + chain: "Cardano", + project: "indigo", + symbol: pool.asset, + apyReward: (adaApy || 0) + (indyApy || 0), + rewardTokens: ['ADA', 'INDY'], + underlyingTokens: [pool.asset], + tvlUsd: Number(tvlUsd), + }; + })); +} + +// fetch stability pools +async function fetchStabilityPools() { + return await get(`https://analytics.indigoprotocol.io/api/stability-pools`); +} + +// Fetch APR for each Stability Pool +async function fetchApr(key) { + return await post(`https://analytics.indigoprotocol.io/api/apr/?key=${key}`) + .then(res => { + return parseFloat(res.value) || 0; + }) + .catch((error) => { + console.error(`Error fetching APR for ${key}:`, error); + return 0; + }); +} + +// Fetch iAsset analytics for a specific asset +async function fetchAssetAnalytics(assetName) { + try { + const response = await get(`https://analytics.indigoprotocol.io/api/assets/${assetName}/analytics`); + return response[assetName]; + } catch (error) { + console.error(`Error fetching analytics for ${assetName}:`, error); + return null; + } +} + +// Fetch the ADA price in USD +async function fetchAdaPriceToUsd() { + try { + const response = await get('https://analytics.indigoprotocol.io/api/price?from=ADA&to=USD'); + return response.price; + } catch (error) { + console.error('Error fetching ADA price:', error); + return 0; + } +} + +// Calculate TVL in USD +async function calculateTvlUsd(assetAnalytics, adaPriceUsd) { + if (!assetAnalytics) return 0; + + return assetAnalytics.totalValueLocked * adaPriceUsd; +} + +module.exports = { + timetravel: false, + apy: apy, + url: 'https://app.indigoprotocol.io/stability-pools', +}; +