From 3f6222779c188e5ccf8b08cc0dd28f0c5877a5c4 Mon Sep 17 00:00:00 2001 From: kavsky02 <95619352+kavsky02@users.noreply.github.com> Date: Fri, 17 Nov 2023 10:52:11 +0300 Subject: [PATCH] Add arbitrum pools real yields metrics (#1084) * Add Arbitrum pools + LM rewards APY * Add Arbitrum pools + LM rewards APY * Add Arbitrum pools + LM rewards APY * Add Arbitrum pools + LM rewards APY * Add Arbitrum pools --- src/adaptors/deltaprime/index.js | 160 +++++++++++++++++++++++++++---- 1 file changed, 139 insertions(+), 21 deletions(-) diff --git a/src/adaptors/deltaprime/index.js b/src/adaptors/deltaprime/index.js index 81ce482dc0..37d2b92fd9 100644 --- a/src/adaptors/deltaprime/index.js +++ b/src/adaptors/deltaprime/index.js @@ -28,6 +28,7 @@ const getPoolTotalSupplyAbi = { "type": "function" } +// Avalanche const USDC_POOL_TUP_CONTRACT = '0x2323dAC85C6Ab9bd6a8B5Fb75B0581E31232d12b'; const USDT_POOL_TUP_CONTRACT = '0xd222e10D7Fe6B7f9608F14A8B5Cf703c74eFBcA1'; const WAVAX_POOL_TUP_CONTRACT = '0xD26E504fc642B96751fD55D3E68AF295806542f5'; @@ -40,10 +41,21 @@ const USDT_TOKEN_ADDRESS = '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7'; const BTC_TOKEN_ADDRESS = '0x152b9d0FdC40C096757F570A51E494bd4b943E50'; const ETH_TOKEN_ADDRESS = '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab'; -const getPoolTVL = async (poolAddress) => { +// Arbitrum +const USDC_POOL_TUP_ARBI_CONTRACT = '0x8FE3842e0B7472a57f2A2D56cF6bCe08517A1De0'; +const ETH_POOL_TUP_ARBI_CONTRACT = '0x0BeBEB5679115f143772CfD97359BBcc393d46b3'; +const ARB_POOL_TUP_ARBI_CONTRACT = '0x2B8C610F3fC6F883817637d15514293565C3d08A'; +const BTC_POOL_TUP_ARBI_CONTRACT = '0x5CdE36c23f0909960BA4D6E8713257C6191f8C35'; + +const USDC_TOKEN_ARBI_ADDRESS = '0xaf88d065e77c8cc2239327c5edb3a432268e5831'; +const ETH_TOKEN_ARBI_ADDRESS = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1'; +const ARB_TOKEN_ARBI_ADDRESS = '0x912CE59144191C1204E64559FE8253a0e49E6548'; +const BTC_TOKEN_ARBI_ADDRESS = '0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f'; + +const getPoolTVL = async (poolAddress, chain = 'avax') => { return (await sdk.api.abi.call({ abi: getPoolTotalSupplyAbi, - chain: 'avax', + chain: chain, target: poolAddress, params: [], })).output; @@ -51,15 +63,15 @@ const getPoolTVL = async (poolAddress) => { const getTokenPrice = async (tokenAddress, chain='avax') => { const data = await utils.getData( - `https://coins.llama.fi/prices/current/${chain}:${tokenAddress}` + `https://coins.llama.fi/prices/current/${chain}:${tokenAddress}` ); return data.coins[Object.keys(data.coins)[0]].price } -const getPoolDepositRate = async (poolAddress) => { +const getPoolDepositRate = async (poolAddress, chain = 'avax') => { return (await sdk.api.abi.call({ abi: getPoolDepositRateAbi, - chain: 'avax', + chain: chain, target: poolAddress, params: [], })).output; @@ -85,6 +97,22 @@ const getWavaxPoolDepositRate = async () => { return await getPoolDepositRate(WAVAX_POOL_TUP_CONTRACT) / 1e16; } +const getUsdcPoolArbiDepositRate = async () => { + return await getPoolDepositRate(USDC_POOL_TUP_ARBI_CONTRACT, 'arbitrum') / 1e16; +} + +const getEthPoolArbiDepositRate = async () => { + return await getPoolDepositRate(ETH_POOL_TUP_ARBI_CONTRACT, 'arbitrum') / 1e16; +} + +const getArbPoolArbiDepositRate = async () => { + return await getPoolDepositRate(ARB_POOL_TUP_ARBI_CONTRACT, 'arbitrum') / 1e16; +} + +const getBtcPoolArbiDepositRate = async () => { + return await getPoolDepositRate(BTC_POOL_TUP_ARBI_CONTRACT, 'arbitrum') / 1e16; +} + const getBtcPoolTVL = async() => { const supply = await getPoolTVL(BTC_POOL_TUP_CONTRACT); @@ -99,6 +127,34 @@ const getEthPoolTVL = async() => { return supply * price / 1e18; } +const getEthPoolArbiTVL = async() => { + const supply = await getPoolTVL(ETH_POOL_TUP_ARBI_CONTRACT, 'arbitrum'); + + const price = await getTokenPrice(ETH_TOKEN_ARBI_ADDRESS, 'arbitrum'); + return supply * price / 1e18; +} + +const getArbPoolArbiTVL = async() => { + const supply = await getPoolTVL(ARB_POOL_TUP_ARBI_CONTRACT, 'arbitrum'); + + const price = await getTokenPrice(ARB_TOKEN_ARBI_ADDRESS, 'arbitrum'); + return supply * price / 1e18; +} + +const getBtcPoolArbiTVL = async() => { + const supply = await getPoolTVL(BTC_POOL_TUP_ARBI_CONTRACT, 'arbitrum'); + + const price = await getTokenPrice(BTC_TOKEN_ARBI_ADDRESS, 'arbitrum'); + return supply * price / 1e8; +} + +const getUsdcPoolArbiTVL = async() => { + const supply = await getPoolTVL(USDC_POOL_TUP_ARBI_CONTRACT, 'arbitrum'); + + const price = await getTokenPrice(USDC_TOKEN_ARBI_ADDRESS, 'arbitrum'); + return supply * price / 1e6; +} + const getWavaxPoolTVL = async() => { const supply = await getPoolTVL(WAVAX_POOL_TUP_CONTRACT); @@ -119,62 +175,124 @@ const getUsdtPoolTVL = async() => { } const getPoolsAPYs = async () => { + const usdcPoolTvl = await getUsdcPoolTVL(); const usdcPool = { - pool: `${USDC_TOKEN_ADDRESS}-avalanche`, + pool: `dp-${USDC_TOKEN_ADDRESS}-avalanche`, chain: utils.formatChain('avalanche'), project: 'deltaprime', symbol: utils.formatSymbol('USDC'), - tvlUsd: await getUsdcPoolTVL(), + tvlUsd: usdcPoolTvl, apyBase: await getUsdcPoolDepositRate(), underlyingTokens: [USDC_TOKEN_ADDRESS], - poolMeta: 'USDC lending pool', + rewardTokens: [USDC_TOKEN_ADDRESS], + poolMeta: 'USDC lending pool on Avalanche', }; + const usdtPoolTvl = await getUsdtPoolTVL(); const usdtPool = { - pool: `${USDT_TOKEN_ADDRESS}-avalanche`, + pool: `dp-${USDT_TOKEN_ADDRESS}-avalanche`, chain: utils.formatChain('avalanche'), project: 'deltaprime', symbol: utils.formatSymbol('USDt'), - tvlUsd: await getUsdtPoolTVL(), + tvlUsd: usdtPoolTvl, apyBase: await getUsdtPoolDepositRate(), underlyingTokens: [USDT_TOKEN_ADDRESS], - poolMeta: 'USDt lending pool', + rewardTokens: [USDT_TOKEN_ADDRESS], + poolMeta: 'USDt lending pool on Avalanche', }; + const wavaxPoolTvl = await getWavaxPoolTVL(); const wavaxPool = { - pool: `${WAVAX_TOKEN_ADDRESS}-avalanche`, + pool: `dp-${WAVAX_TOKEN_ADDRESS}-avalanche`, chain: utils.formatChain('avalanche'), project: 'deltaprime', symbol: utils.formatSymbol('WAVAX'), - tvlUsd: await getWavaxPoolTVL(), + tvlUsd: wavaxPoolTvl, apyBase: await getWavaxPoolDepositRate(), underlyingTokens: [WAVAX_TOKEN_ADDRESS], - poolMeta: 'WAVAX lending pool', + rewardTokens: [WAVAX_TOKEN_ADDRESS], + poolMeta: 'WAVAX lending pool on Avalanche', }; + const btcPoolTvl = await getBtcPoolTVL(); const btcPool = { - pool: `${BTC_TOKEN_ADDRESS}-avalanche`, + pool: `dp-${BTC_TOKEN_ADDRESS}-avalanche`, chain: utils.formatChain('avalanche'), project: 'deltaprime', symbol: utils.formatSymbol('BTC.b'), - tvlUsd: await getBtcPoolTVL(), + tvlUsd: btcPoolTvl, apyBase: await getBtcPoolDepositRate(), underlyingTokens: [BTC_TOKEN_ADDRESS], - poolMeta: 'BTC.b lending pool', + rewardTokens: [BTC_TOKEN_ADDRESS], + poolMeta: 'BTC.b lending pool on Avalanche', }; + const ethPoolTvl = await getEthPoolTVL(); const ethPool = { - pool: `${ETH_TOKEN_ADDRESS}-avalanche`, + pool: `dp-${ETH_TOKEN_ADDRESS}-avalanche`, chain: utils.formatChain('avalanche'), project: 'deltaprime', symbol: utils.formatSymbol('WETH.e'), - tvlUsd: await getEthPoolTVL(), + tvlUsd: ethPoolTvl, apyBase: await getEthPoolDepositRate(), underlyingTokens: [ETH_TOKEN_ADDRESS], - poolMeta: 'WETH.e lending pool', + rewardTokens: [ETH_TOKEN_ADDRESS], + poolMeta: 'WETH.e lending pool on Avalanche', + }; + + const ethPoolArbiTvl = await getEthPoolArbiTVL(); + const ethPoolArbi = { + pool: `dp-${ETH_TOKEN_ARBI_ADDRESS}-arbitrum`, + chain: utils.formatChain('arbitrum'), + project: 'deltaprime', + symbol: utils.formatSymbol('WETH'), + tvlUsd: ethPoolArbiTvl, + apyBase: await getEthPoolArbiDepositRate(), + underlyingTokens: [ETH_TOKEN_ARBI_ADDRESS], + rewardTokens: [ETH_TOKEN_ARBI_ADDRESS], + poolMeta: 'WETH lending pool on Arbitrum', + }; + + const usdcPoolArbiTvl = await getUsdcPoolArbiTVL(); + const usdcPoolArbi = { + pool: `dp-${USDC_TOKEN_ARBI_ADDRESS}-arbitrum`, + chain: utils.formatChain('arbitrum'), + project: 'deltaprime', + symbol: utils.formatSymbol('USDC'), + tvlUsd: usdcPoolArbiTvl, + apyBase: await getUsdcPoolArbiDepositRate(), + underlyingTokens: [USDC_TOKEN_ARBI_ADDRESS], + rewardTokens: [USDC_TOKEN_ARBI_ADDRESS], + poolMeta: 'USDC lending pool on Arbitrum', + }; + + const arbPoolArbiTvl = await getArbPoolArbiTVL(); + const arbPoolArbi = { + pool: `dp-${ARB_TOKEN_ARBI_ADDRESS}-arbitrum`, + chain: utils.formatChain('arbitrum'), + project: 'deltaprime', + symbol: utils.formatSymbol('ARB'), + tvlUsd: arbPoolArbiTvl, + apyBase: await getArbPoolArbiDepositRate(), + underlyingTokens: [ARB_TOKEN_ARBI_ADDRESS], + rewardTokens: [ARB_TOKEN_ARBI_ADDRESS], + poolMeta: 'ARB lending pool on Arbitrum', + }; + + const btcPoolArbiTvl = await getBtcPoolArbiTVL(); + const btcPoolArbi = { + pool: `dp-${BTC_TOKEN_ARBI_ADDRESS}-arbitrum`, + chain: utils.formatChain('arbitrum'), + project: 'deltaprime', + symbol: utils.formatSymbol('WBTC'), + tvlUsd: btcPoolArbiTvl, + apyBase: await getBtcPoolArbiDepositRate(), + underlyingTokens: [BTC_TOKEN_ARBI_ADDRESS], + rewardTokens: [BTC_TOKEN_ARBI_ADDRESS], + poolMeta: 'WBTC lending pool on Arbitrum', }; - return [usdcPool, usdtPool, wavaxPool, btcPool, ethPool]; + return [usdcPool, usdtPool, wavaxPool, btcPool, ethPool, ethPoolArbi, usdcPoolArbi, arbPoolArbi, btcPoolArbi]; }; module.exports = {