Skip to content

Commit

Permalink
Add arbitrum pools real yields metrics (#1084)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kavsky02 authored Nov 17, 2023
1 parent 0ae1300 commit 3f62227
Showing 1 changed file with 139 additions and 21 deletions.
160 changes: 139 additions & 21 deletions src/adaptors/deltaprime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -40,26 +41,37 @@ 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;
}

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;
Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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 = {
Expand Down

0 comments on commit 3f62227

Please sign in to comment.