Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate Reservoir's yield data #1013

Merged
merged 6 commits into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/adaptors/reservoir/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { request, gql } = require('graphql-request');

const GRAPHQL_URL = 'https://data.staging.arkiver.net/robolabs/reservoir-mainnet-v2/graphql';

const graphQuery = gql`
query GetStats {
PairSnapshots {
swapApr
managedApy
pair {
address
curveId
token0
token1
token0Symbol
token1Symbol
tvlUSD
}
}
}
`;

const getApy = async () => {
const { PairSnapshots } = await request(GRAPHQL_URL, graphQuery);

return PairSnapshots.map((snapshot) => {
const symbols = snapshot.pair.token0Symbol + '-' + snapshot.pair.token1Symbol
const poolType = snapshot.pair.curveId === 0 ? 'Constant Product' : 'Stable'
return {
pool: snapshot.pair.address,
chain: 'Avalanche',
project: 'reservoir',
symbol: symbols,
tvlUsd: snapshot.pair.tvlUSD,
apyBase: (snapshot.swapApr + snapshot.managedApy) * 100, // to convert into percentage form
apyReward: 0,
rewardTokens: [], // we do not have incentive tokens at this point
underlyingTokens: [snapshot.pair.token0, snapshot.pair.token1],
poolMeta: poolType
}
})
}

module.exports = {
timetravel: false,
apy: getApy,
url: 'https://analytics.reservoir.fi/',
};