Skip to content

Commit

Permalink
feat: add astroport sei deployment (#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
afsardo authored Nov 27, 2023
1 parent f508361 commit bcd507b
Showing 1 changed file with 47 additions and 34 deletions.
81 changes: 47 additions & 34 deletions src/adaptors/astroport/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { request } = require('graphql-request');
const num = require('bignumber.js');

const API_ENDPOINT = "https://multichain-api.astroport.fi/graphql";
const API_ENDPOINT = 'https://multichain-api.astroport.fi/graphql';

const yieldQuery = `
query Pools($chains: [String]!, $limit: Int, $sortField: PoolSortFields, $sortDirection: SortDirections) {
Expand Down Expand Up @@ -33,16 +33,22 @@ const yieldQuery = `
`;

const chainIdToNames = {
"phoenix-1": "Terra2",
"injective-1": "Injective",
"neutron-1": "Neutron"
}
'phoenix-1': 'Terra2',
'injective-1': 'Injective',
'neutron-1': 'Neutron',
'pacific-1': 'Sei',
};

const astroDenoms = {
"phoenix-1": "terra1nsuqsk6kh58ulczatwev87ttq2z6r3pusulg9r24mfj2fvtzd4uq3exn26",
"injective-1": "ibc/EBD5A24C554198EBAF44979C5B4D2C2D312E6EBAB71962C92F735499C7575839",
"neutron-1": "ibc/5751B8BCDA688FD0A8EC0B292EEF1CDEAB4B766B63EC632778B196D317C40C3A"
}
'phoenix-1':
'terra1nsuqsk6kh58ulczatwev87ttq2z6r3pusulg9r24mfj2fvtzd4uq3exn26',
'injective-1':
'ibc/EBD5A24C554198EBAF44979C5B4D2C2D312E6EBAB71962C92F735499C7575839',
'neutron-1':
'ibc/5751B8BCDA688FD0A8EC0B292EEF1CDEAB4B766B63EC632778B196D317C40C3A',
'pacific-1':
'ibc/0EC78B75D318EA0AAB6160A12AEE8F3C7FEA3CFEAD001A3B103E11914709F4CE',
};

const getRewardTokens = (pool) => {
const rewardTokens = [];
Expand All @@ -53,37 +59,44 @@ const getRewardTokens = (pool) => {
rewardTokens.push(astroDenoms[pool.chainId]);
}
return rewardTokens.length > 0 ? rewardTokens : undefined;
}
};

const apy = async () => {

let results = await request(API_ENDPOINT, yieldQuery, {
"chains": ["phoenix-1", "injective-1", "neutron-1"],
"limit": 100,
"sortField": "TVL",
"sortDirection": "DESC"
chains: ['phoenix-1', 'injective-1', 'neutron-1', 'pacific-1'],
limit: 100,
sortField: 'TVL',
sortDirection: 'DESC',
});

const apy = results?.pools?.filter(pool => pool?.poolLiquidityUsd && pool?.poolLiquidityUsd > 10000).map((pool) => {
const apyBase = pool?.tradingFees?.apy ? new num(pool?.tradingFees?.apy).times(100).dp(6).toNumber() : 0;
const chain = chainIdToNames[pool.chainId];
const astroRewards = pool?.astroRewards?.apr || 0;
const protocolRewards = pool?.protocolRewards?.apr || 0;
const apyReward = new num(astroRewards).plus(protocolRewards).times(100).dp(6).toNumber();
const apy = results?.pools
?.filter((pool) => pool?.poolLiquidityUsd && pool?.poolLiquidityUsd > 10000)
.map((pool) => {
const apyBase = pool?.tradingFees?.apy
? new num(pool?.tradingFees?.apy).times(100).dp(6).toNumber()
: 0;
const chain = chainIdToNames[pool.chainId];
const astroRewards = pool?.astroRewards?.apr || 0;
const protocolRewards = pool?.protocolRewards?.apr || 0;
const apyReward = new num(astroRewards)
.plus(protocolRewards)
.times(100)
.dp(6)
.toNumber();

return {
pool: `${pool.poolAddress}-${chain}`.toLowerCase(),
project: 'astroport',
chain,
symbol: `${pool.assets[0].symbol}-${pool.assets[1].symbol}`,
tvlUsd: pool.poolLiquidityUsd || 0,
apyBase,
apyReward,
rewardTokens: getRewardTokens(pool),
underlyingTokens: [pool.token0Address, pool.token1Address],
url: `https://app.astroport.fi/pools/${pool.poolAddress}/provide`
}
});
return {
pool: `${pool.poolAddress}-${chain}`.toLowerCase(),
project: 'astroport',
chain,
symbol: `${pool.assets[0].symbol}-${pool.assets[1].symbol}`,
tvlUsd: pool.poolLiquidityUsd || 0,
apyBase,
apyReward,
rewardTokens: getRewardTokens(pool),
underlyingTokens: [pool.token0Address, pool.token1Address],
url: `https://app.astroport.fi/pools/${pool.poolAddress}/provide`,
};
});

return apy;
};
Expand Down

0 comments on commit bcd507b

Please sign in to comment.