Skip to content

Commit

Permalink
astroport swap api
Browse files Browse the repository at this point in the history
g
  • Loading branch information
slasher125 committed Jan 4, 2024
1 parent c45f901 commit c7a1330
Showing 1 changed file with 8 additions and 40 deletions.
48 changes: 8 additions & 40 deletions src/adaptors/astroport/index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
const { request } = require('graphql-request');
const axios = require('axios');
const num = require('bignumber.js');

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

const yieldQuery = `
query Pools($chains: [String]!, $limit: Int, $sortField: PoolSortFields, $sortDirection: SortDirections) {
pools(chains: $chains, limit: $limit, sortField: $sortField, sortDirection: $sortDirection) {
chainId
poolAddress
poolLiquidityUsd
poolType
tradingFees {
apr
apy
}
token0Address
token1Address
rewardTokenSymbol
protocolRewards {
apr
apy
}
astroRewards {
apr
apy
}
assets {
symbol
}
}
}
`;

const chainIdToNames = {
'phoenix-1': 'Terra2',
'injective-1': 'Injective',
Expand Down Expand Up @@ -62,14 +31,13 @@ const getRewardTokens = (pool) => {
};

const apy = async () => {
let results = await request(API_ENDPOINT, yieldQuery, {
chains: ['phoenix-1', 'injective-1', 'neutron-1', 'pacific-1'],
limit: 100,
sortField: 'TVL',
sortDirection: 'DESC',
});
let results = (
await axios.get(
'https://app.astroport.fi/api/trpc/pools.getAll?input=%7B%22json%22%3A%7B%22chainId%22%3A%5B%22neutron-1%22%5D%7D%7D'
)
).data.result.data.json;

const apy = results?.pools
const apy = results
?.filter((pool) => pool?.poolLiquidityUsd && pool?.poolLiquidityUsd > 10000)
.map((pool) => {
const apyBase = pool?.tradingFees?.apy
Expand All @@ -92,7 +60,7 @@ const apy = async () => {
tvlUsd: pool.poolLiquidityUsd || 0,
apyBase,
apyReward,
rewardTokens: getRewardTokens(pool),
rewardTokens: getRewardTokens(pool) ?? null,
underlyingTokens: [pool.token0Address, pool.token1Address],
url: `https://app.astroport.fi/pools/${pool.poolAddress}/provide`,
};
Expand Down

0 comments on commit c7a1330

Please sign in to comment.