Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
0xprinc authored Jan 1, 2025
2 parents 6bf4bab + ffee1fc commit 138d4cd
Show file tree
Hide file tree
Showing 26 changed files with 1,082 additions and 176 deletions.
2 changes: 1 addition & 1 deletion src/adaptors/aave-v3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ const stkGho = async () => {

const stkghoMeritApy = (
await axios.get('https://apps.aavechan.com/api/merit/base-aprs')
).data.actionsAPR['ethereum-stkgho'];
).data['ethereum-stkgho'];

const stkghoApy = stkghoNativeApy + stkghoMeritApy;

Expand Down
22 changes: 17 additions & 5 deletions src/adaptors/abracadabra-spell/cauldrons.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,43 @@ const POOLS = {
address: '0x7962acfcfc2ccebc810045391d60040f635404fb',
collateralPoolId: '906b233c-8478-4b94-94e5-2d77e6c7c9e5',
symbol: "SOL-USDC",
}, // gmSOL
}, // gmSOLUSDC
{
version: 4,
address: '0x2b02bBeAb8eCAb792d3F4DDA7a76f63Aa21934FA',
collateralPoolId: '61b4c35c-97f6-4c05-a5ff-aeb4426adf5b',
symbol: "ETH-USDC",
}, // gmETH
}, // gmETHUSDC
{
version: 4,
address: '0xD7659D913430945600dfe875434B6d80646d552A',
collateralPoolId: '5b8c0691-b9ff-4d82-97e4-19a1247e6dbf',
symbol: "WBTC.B-USDC",
}, // gmBTC
}, // gmBTCUSDC
{
version: 4,
address: '0x4F9737E994da9811B8830775Fd73E2F1C8e40741',
collateralPoolId: 'f3fa942f-1867-4028-95ff-4eb76816cd07',
symbol: "ARB-USDC",
}, // gmARB
}, // gmARBUSDC
{
version: 4,
address: '0x66805F6e719d7e67D46e8b2501C1237980996C6a',
collateralPoolId: 'dffb3514-d667-4f2f-8df3-f716ebe09c93',
symbol: "LINK-USDC",
}, // gmLINK
}, // gmLINKUSDC
{
version: 4,
address: '0x9fF8b4C842e4a95dAB5089781427c836DAE94831',
collateralPoolId: 'ffb4e407-6507-4615-b776-a0d99cfc1bbb',
symbol: "WBTC.B-WBTC.B",
}, // gmBTC
{
version: 4,
address: '0x625Fe79547828b1B54467E5Ed822a9A8a074bD61',
collateralPoolId: '5e2aac09-71c8-4092-ba4f-00f1ac0d04fd',
symbol: "ETH-ETH",
}, // gmETH
{ version: 4, address: '0x49De724D7125641F56312EBBcbf48Ef107c8FA57' }, // WBTC
{ version: 4, address: '0x780db9770dDc236fd659A39430A8a7cC07D0C320' }, // WETHV2
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const apy = async () => {
pool:
chain === 'FANTOM' ? p.id : `${p.address}-${chain.toLowerCase()}`,
chain: utils.formatChain(chain.toLowerCase()),
project: 'beethoven-x-dex',
project: 'beets-dex',
symbol:
p.address === '0x43da214fab3315aa6c02e0b8f2bfb7ef2e3c60a5'
? 'USDC-DAI'
Expand Down
19 changes: 4 additions & 15 deletions src/adaptors/blend-pools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ const getApy = async (poolId, backstop) => {
if (borrowEmissionsPerAsset > 0) {
borrowEmissionsAPR = (borrowEmissionsPerAsset * usdcPerBlnd) / price;
}
// Estimate borrow APY compoumded daily
// Estimate borrow APY compounded daily
const borrowApy = (1 + reserve.borrowApr / 365) ** 365 - 1;
let totalSupply = reserve.totalSupplyFloat() * price;
let totalBorrow = reserve.totalLiabilitiesFloat() * price;

const url = `https://mainnet.blend.capital/dashboard/?poolId=${poolId}`;

pools.push({
pool: `${reserve.assetId}-stellar`.toLowerCase(),
pool: `${pool.id}-${reserve.assetId}-stellar`.toLowerCase(),
chain: formatChain('stellar'),
project: 'blend-pools',
symbol: reserve.tokenMetadata.symbol,
Expand All @@ -66,7 +66,7 @@ const getApy = async (poolId, backstop) => {
apyBaseBorrow: borrowApy * 100,
apyRewardBorrow: borrowEmissionsAPR * 100,
ltv: totalBorrow / totalSupply,
poolMeta: `Pool ID: ${pool.id}`,
poolMeta: `${pool.config.name} Pool`,
url,
});
}
Expand All @@ -80,18 +80,7 @@ const apy = async () => {

for (const poolId of BLEND_POOLS) {
let poolApys = await getApy(poolId, backstop);
for (const poolApy of poolApys) {
if (poolApy) {
let index = pools.findIndex((pool) => pool.pool == poolApy.pool);
if (index !== -1) {
if (poolApy.apyReward > pools[index].apyReward) {
pools[index] = poolApy;
}
} else {
pools.push(poolApy);
}
}
}
pools.push(...poolApys)
}
return pools;
};
Expand Down
46 changes: 24 additions & 22 deletions src/adaptors/cetus-amm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@ const chains = {
const apy = async (chain) => {
const data = (await axios.get(chains[chain])).data.data.pools;

return data.map((p) => {
const apyReward = p.rewarder_apr.reduce(
(a, b) => a + Number(b.replace('%', '')),
0
);
return {
chain,
project: 'cetus-amm',
pool: p.swap_account,
symbol: p.symbol,
tvlUsd: Number(p.tvl_in_usd),
apyBase: Number(p.apr_24h.replace('%', '')),
apyBase7d: Number(p.apr_7day.replace('%', '')),
volumeUsd1d: Number(p.vol_in_usd_24h),
volumeUsd7d: Number(p.vol_in_usd_7_day),
apyReward,
rewardTokens: apyReward > 0 ? ['sui', 'cetus'] : [],
poolMeta: `${Number(p.fee) * 100}%`,
underlyingTokens: [p.token_a_address, p.token_b_address],
url: `https://app.cetus.zone/liquidity/deposit?poolAddress=${p.swap_account}`,
};
});
return data
.map((p) => {
const apyReward = p.rewarder_apr.reduce(
(a, b) => a + Number(b.replace('%', '')),
0
);
return {
chain,
project: 'cetus-amm',
pool: p.swap_account,
symbol: p.symbol,
tvlUsd: Number(p.tvl_in_usd),
apyBase: Number(p.apr_24h.replace('%', '')),
apyBase7d: Number(p.apr_7day.replace('%', '')),
volumeUsd1d: Number(p.vol_in_usd_24h),
volumeUsd7d: Number(p.vol_in_usd_7_day),
apyReward,
rewardTokens: apyReward > 0 ? ['sui', 'cetus'] : [],
poolMeta: `${Number(p.fee) * 100}%`,
underlyingTokens: [p.token_a_address, p.token_b_address],
url: `https://app.cetus.zone/liquidity/deposit?poolAddress=${p.swap_account}`,
};
})
.filter((i) => i.tvlUsd <= 1e8);
};

const main = async () => {
Expand Down
77 changes: 13 additions & 64 deletions src/adaptors/deltaprime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,11 @@ const getBoostRewardTokenAbi = {
}

// Avalanche
const USDC_POOL_TUP_CONTRACT = '0x2323dAC85C6Ab9bd6a8B5Fb75B0581E31232d12b';
const USDT_POOL_TUP_CONTRACT = '0xd222e10D7Fe6B7f9608F14A8B5Cf703c74eFBcA1';
const WAVAX_POOL_TUP_CONTRACT = '0xD26E504fc642B96751fD55D3E68AF295806542f5';
const BTC_POOL_TUP_CONTRACT = '0x475589b0Ed87591A893Df42EC6076d2499bB63d0';
const ETH_POOL_TUP_CONTRACT = '0xD7fEB276ba254cD9b34804A986CE9a8C3E359148';

const AVAX_POOL_REWARDER_CONTRACT = '0x6373122eD8Eda8ECA439415709318DCB6ddC1af3';
const USDT_POOL_REWARDER_CONTRACT = '0xBC6Ef309f2eC71698eA310D62FF2E0543472D965';
const USDC_POOL_REWARDER_CONTRACT = '0x596f6EFD98daF650CF98A1E62A53AB2a44e7E875';
const BTC_POOL_REWARDER_CONTRACT = '0x3FE9BE379eD15962AFAbE01c002B8c433C6Af4ec';
const USDC_POOL_TUP_CONTRACT = '0x8027e004d80274FB320e9b8f882C92196d779CE8';
const USDT_POOL_TUP_CONTRACT = '0x1b6D7A6044fB68163D8E249Bce86F3eFbb12368e';
const WAVAX_POOL_TUP_CONTRACT = '0xaa39f39802F8C44e48d4cc42E088C09EDF4daad4';
const BTC_POOL_TUP_CONTRACT = '0x70e80001bDbeC5b9e932cEe2FEcC8F123c98F738';
const ETH_POOL_TUP_CONTRACT = '0x2A84c101F3d45610595050a622684d5412bdf510';

const WAVAX_TOKEN_ADDRESS = '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7';
const USDC_TOKEN_ADDRESS = '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E';
Expand All @@ -80,25 +75,18 @@ const GGAVAX_TOKEN_ADDRESS = '0xA25EaF2906FA1a3a13EdAc9B9657108Af7B703e3';
const SAVAX_TOKEN_ADDRESS = '0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE';

// Arbitrum
const USDC_POOL_TUP_ARBI_CONTRACT = '0x5f3DB5899a7937c9ABF0A5Fc91718E6F813e4195';
const ETH_POOL_TUP_ARBI_CONTRACT = '0x2E2fE9Bc7904649b65B6373bAF40F9e2E0b883c5';
const ARB_POOL_TUP_ARBI_CONTRACT = '0x14c82CFc2c651700a66aBDd7dC375c9CeEFDDD72';
const BTC_POOL_TUP_ARBI_CONTRACT = '0x275Caecf5542bF4a3CF64aa78a3f57dc9939675C';
const DAI_POOL_TUP_ARBI_CONTRACT = '0x7Dcf909B1E4b280bEe72C6A69b3a7Ed8adfb63f0';
const USDC_POOL_TUP_ARBI_CONTRACT = '0x8Ac9Dc27a6174a1CC30873B367A60AcdFAb965cc';
const ETH_POOL_TUP_ARBI_CONTRACT = '0x788A8324943beb1a7A47B76959E6C1e6B87eD360';
const ARB_POOL_TUP_ARBI_CONTRACT = '0xC629E8889350F1BBBf6eD1955095C2198dDC41c2';
const BTC_POOL_TUP_ARBI_CONTRACT = '0x0ed7B42B74F039eda928E1AE6F44Eed5EF195Fb5';
const DAI_POOL_TUP_ARBI_CONTRACT = '0xFA354E4289db87bEB81034A3ABD6D465328378f1';

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 DAI_TOKEN_ARBI_ADDRESS = '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1';

const POOL_ADDRESS_TO_REWARDER_CONTRACT = {
'0x2323dAC85C6Ab9bd6a8B5Fb75B0581E31232d12b': USDC_POOL_REWARDER_CONTRACT,
'0xd222e10D7Fe6B7f9608F14A8B5Cf703c74eFBcA1': USDT_POOL_REWARDER_CONTRACT,
'0xD26E504fc642B96751fD55D3E68AF295806542f5': AVAX_POOL_REWARDER_CONTRACT,
'0x475589b0Ed87591A893Df42EC6076d2499bB63d0': BTC_POOL_REWARDER_CONTRACT
}

const getPoolTVL = async (poolAddress, chain = 'avax') => {
return (await sdk.api.abi.call({
abi: getPoolTotalSupplyAbi,
Expand All @@ -115,33 +103,6 @@ const getTokenPrice = async (tokenAddress, chain='avax') => {
return data.coins[Object.keys(data.coins)[0]].price
}

const getPoolBoostRate = async (poolAddress, poolTVL, chain = 'avax') => {
if(chain === 'avax') {
let rewarderContractAddress = POOL_ADDRESS_TO_REWARDER_CONTRACT[poolAddress];

if(rewarderContractAddress) {
let rewardsRatePerSecond = (await sdk.api.abi.call({
abi: getPoolBoostRateAbi,
chain: chain,
target: rewarderContractAddress,
params: [],
})).output;

let rewardTokenAddress = (await sdk.api.abi.call({
abi: getBoostRewardTokenAbi,
chain: chain,
target: rewarderContractAddress,
params: [],
})).output;

let rewardTokenPrice = await getTokenPrice(rewardTokenAddress, chain);

return rewardsRatePerSecond * rewardTokenPrice * 86400 * 365 / poolTVL / 1e16;
}
}
return 0;
}

const getPoolDepositRate = async (poolAddress, chain = 'avax') => {
return (await sdk.api.abi.call({
abi: getPoolDepositRateAbi,
Expand Down Expand Up @@ -262,59 +223,47 @@ const getUsdtPoolTVL = async() => {

const getPoolsAPYs = async () => {
const usdcPoolTvl = await getUsdcPoolTVL();
const usdcRewardApy = await getPoolBoostRate(USDC_POOL_TUP_CONTRACT, usdcPoolTvl, 'avax');
const usdcPool = {
pool: `dp-${USDC_TOKEN_ADDRESS}-avalanche`,
chain: utils.formatChain('avalanche'),
project: 'deltaprime',
symbol: utils.formatSymbol('USDC'),
tvlUsd: usdcPoolTvl,
apyBase: await getUsdcPoolDepositRate(),
apyReward: usdcRewardApy,
underlyingTokens: [USDC_TOKEN_ADDRESS],
rewardTokens: [GGAVAX_TOKEN_ADDRESS],
underlyingTokens: [USDC_TOKEN_ADDRESS]
};

const usdtPoolTvl = await getUsdtPoolTVL();
const usdtRewardApy = await getPoolBoostRate(USDT_POOL_TUP_CONTRACT, usdtPoolTvl, 'avax');
const usdtPool = {
pool: `dp-${USDT_TOKEN_ADDRESS}-avalanche`,
chain: utils.formatChain('avalanche'),
project: 'deltaprime',
symbol: utils.formatSymbol('USDt'),
tvlUsd: usdtPoolTvl,
apyBase: await getUsdtPoolDepositRate(),
apyReward: usdtRewardApy,
underlyingTokens: [USDT_TOKEN_ADDRESS],
rewardTokens: [SAVAX_TOKEN_ADDRESS],
underlyingTokens: [USDT_TOKEN_ADDRESS]
};

const wavaxPoolTvl = await getWavaxPoolTVL();
const wavaxRewardApy = await getPoolBoostRate(WAVAX_POOL_TUP_CONTRACT, wavaxPoolTvl, 'avax');
const wavaxPool = {
pool: `dp-${WAVAX_TOKEN_ADDRESS}-avalanche`,
chain: utils.formatChain('avalanche'),
project: 'deltaprime',
symbol: utils.formatSymbol('WAVAX'),
tvlUsd: wavaxPoolTvl,
apyBase: await getWavaxPoolDepositRate(),
apyReward: wavaxRewardApy,
underlyingTokens: [WAVAX_TOKEN_ADDRESS],
rewardTokens: [SAVAX_TOKEN_ADDRESS],
};

const btcPoolTvl = await getBtcPoolTVL();
const btcRewardApy = await getPoolBoostRate(BTC_POOL_TUP_CONTRACT, btcPoolTvl, 'avax');
const btcPool = {
pool: `dp-${BTC_TOKEN_ADDRESS}-avalanche`,
chain: utils.formatChain('avalanche'),
project: 'deltaprime',
symbol: utils.formatSymbol('BTC.b'),
tvlUsd: btcPoolTvl,
apyBase: await getBtcPoolDepositRate(),
apyReward: btcRewardApy,
underlyingTokens: [BTC_TOKEN_ADDRESS],
rewardTokens: [GGAVAX_TOKEN_ADDRESS],
underlyingTokens: [BTC_TOKEN_ADDRESS]
};

const ethPoolTvl = await getEthPoolTVL();
Expand Down
Loading

0 comments on commit 138d4cd

Please sign in to comment.