Skip to content

Commit 1ed486f

Browse files
committed
feat: update reservoir data with new API endpoint
1 parent 62152aa commit 1ed486f

File tree

1 file changed

+16
-31
lines changed

1 file changed

+16
-31
lines changed

src/adaptors/reservoir/index.js

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,26 @@
1-
const { request, gql } = require('graphql-request');
1+
const { get } = require('axios');
22

3-
const GRAPHQL_URL = 'https://data.staging.arkiver.net/robolabs/reservoir-mainnet-v2/graphql';
4-
5-
const graphQuery = gql`
6-
query GetStats {
7-
PairSnapshots {
8-
swapApr
9-
managedApy
10-
pair {
11-
address
12-
curveId
13-
token0
14-
token1
15-
token0Symbol
16-
token1Symbol
17-
tvlUSD
18-
}
19-
}
20-
}
21-
`;
3+
const API_URL = 'https://api.reservoir.fi/v1/pairs';
224

235
const getApy = async () => {
24-
const { PairSnapshots } = await request(GRAPHQL_URL, graphQuery);
6+
const { data: pairs } = await get(API_URL);
7+
8+
console.log(pairs)
259

26-
return PairSnapshots.map((snapshot) => {
27-
const symbols = snapshot.pair.token0Symbol + '-' + snapshot.pair.token1Symbol
28-
const poolType = snapshot.pair.curveId === 0 ? 'Constant Product' : 'Stable'
10+
return pairs.map((pair) => {
11+
const symbols = pair.token0.symbol + '-' + pair.token1.symbol
12+
const poolType = pair.curveId === 0 ? 'Constant Product' : 'Stable'
13+
const tvlUSD = pair.token0.usdPrice * Number(pair.token0Reserve) + pair.token1.usdPrice * Number(pair.token1Reserve)
2914
return {
30-
pool: snapshot.pair.address,
15+
pool: pair.address,
3116
chain: 'Avalanche',
3217
project: 'reservoir',
3318
symbol: symbols,
34-
tvlUsd: snapshot.pair.tvlUSD,
35-
apyBase: (snapshot.swapApr + snapshot.managedApy) * 100, // to convert into percentage form
36-
apyReward: 0,
37-
rewardTokens: [], // we do not have incentive tokens at this point
38-
underlyingTokens: [snapshot.pair.token0, snapshot.pair.token1],
19+
tvlUsd: tvlUSD,
20+
apyBase: pair.swapApr,
21+
apyReward: pair.supplyApr,
22+
rewardTokens: ['0x2e3b32730B4F6b6502BdAa9122df3B026eDE5391'],
23+
underlyingTokens: [pair.token0.contractAddress, pair.token1.contractAddress],
3924
poolMeta: poolType
4025
}
4126
})
@@ -44,5 +29,5 @@ const getApy = async () => {
4429
module.exports = {
4530
timetravel: false,
4631
apy: getApy,
47-
url: 'https://analytics.reservoir.fi/',
32+
url: 'https://app.reservoir.fi/analytics',
4833
};

0 commit comments

Comments
 (0)