-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add Hyperlynx V3 yield adapter (HyperEVM) #2763
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| const { request, gql } = require('graphql-request'); | ||
| const utils = require('../utils'); | ||
|
|
||
| // Hyperlynx V3 — Uniswap V3 concentrated-liquidity pools on HyperEVM. | ||
| const PROJECT = 'hyperlynx-v3'; | ||
| const CHAIN = 'hyperevm'; | ||
| const MIN_TVL_USD = 10000; | ||
|
|
||
| const SUBGRAPH_URL = | ||
| 'https://api.goldsky.com/api/public/project_cmg87miatabz301usdo94h2v3/subgraphs/uniswap-v3-hyperevm/prod/gn'; | ||
|
|
||
| const poolsQuery = gql` | ||
| query getPools($first: Int!, $skip: Int!, $minTvl: BigDecimal!) { | ||
| pools( | ||
| first: $first | ||
| skip: $skip | ||
| orderBy: totalValueLockedUSD | ||
| orderDirection: desc | ||
| where: { totalValueLockedUSD_gt: $minTvl } | ||
| ) { | ||
| id | ||
| token0 { id symbol decimals } | ||
| token1 { id symbol decimals } | ||
| feeTier | ||
| totalValueLockedUSD | ||
| poolDayData(first: 7, orderBy: date, orderDirection: desc) { | ||
| date | ||
| volumeUSD | ||
| feesUSD | ||
| tvlUSD | ||
| } | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| async function fetchAllPools() { | ||
| const all = []; | ||
| const first = 1000; | ||
| let skip = 0; | ||
| while (true) { | ||
| const { pools } = await request(SUBGRAPH_URL, poolsQuery, { | ||
| first, | ||
| skip, | ||
| minTvl: String(MIN_TVL_USD), | ||
| }); | ||
| if (!pools?.length) break; | ||
| all.push(...pools); | ||
| if (pools.length < first) break; | ||
| skip += first; | ||
| } | ||
| return all; | ||
| } | ||
|
|
||
| async function apy() { | ||
| const pools = await fetchAllPools(); | ||
|
|
||
| return pools | ||
| .map((p) => { | ||
| const days = p.poolDayData || []; | ||
| const day = days[0]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would opt to use the last full day as I believe |
||
| const tvlUsd = Number(day?.tvlUSD) || Number(p.totalValueLockedUSD); | ||
| if (!Number.isFinite(tvlUsd) || tvlUsd < MIN_TVL_USD) return null; | ||
|
|
||
| const feesUsd = Number(day?.feesUSD); | ||
| const apyBase = Number.isFinite(feesUsd) ? ((feesUsd * 365) / tvlUsd) * 100 : NaN; | ||
|
|
||
| const fees7d = days.reduce((s, d) => s + (Number(d.feesUSD) || 0), 0); | ||
| const volume7d = days.reduce((s, d) => s + (Number(d.volumeUSD) || 0), 0); | ||
| const apyBase7d = days.length | ||
| ? (((fees7d / days.length) * 365) / tvlUsd) * 100 | ||
| : NaN; | ||
|
Comment on lines
+67
to
+71
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
The PR objective says this field is a trailing 7-day average, but dividing by 🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @isagieth pls implement this fix to only compute if > 7 days
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
const fees7d = days.reduce((s, d) => s + (Number(d.feesUSD) || 0), 0);
const volume7d = days.reduce((s, d) => s + (Number(d.volumeUSD) || 0), 0);
const apyBase7d = days.length === 7
? ((fees7d / 7) * 365 / tvlUsd) * 100
: NaN;This way, pools with fewer than 7 day buckets simply won't report |
||
|
|
||
| return { | ||
| pool: p.id, | ||
| chain: utils.formatChain(CHAIN), | ||
| project: PROJECT, | ||
| symbol: `${p.token0.symbol}-${p.token1.symbol}`, | ||
| tvlUsd, | ||
| apyBase, | ||
| apyBase7d, | ||
| underlyingTokens: [p.token0.id, p.token1.id], | ||
| poolMeta: `${Number(p.feeTier) / 10000}%`, | ||
| url: 'https://hyperlynx.fi/liquidity', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| volumeUsd1d: Number(day?.volumeUSD) || 0, | ||
| volumeUsd7d: volume7d, | ||
| }; | ||
| }) | ||
| .filter(Boolean) | ||
| .filter((p) => utils.keepFinite(p)); | ||
|
Comment on lines
+64
to
+89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Don't drop pools just because the daily bucket is missing. When 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| module.exports = { | ||
| protocolId: '8107', | ||
| timetravel: false, | ||
| apy, | ||
| url: 'https://hyperlynx.fi', | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: DefiLlama/yield-server
Length of output: 17449
🏁 Script executed:
Repository: DefiLlama/yield-server
Length of output: 14751
🏁 Script executed:
Repository: DefiLlama/yield-server
Length of output: 10768
🏁 Script executed:
Repository: DefiLlama/yield-server
Length of output: 5581
🏁 Script executed:
Repository: DefiLlama/yield-server
Length of output: 10306
Add a timeout/abort path to the Goldsky request.
graphql-requestsupportssignal, so a boundedAbortSignal.timeout(...)orAbortControllerhere would keep a stalled response from blocking the adaptor run.🤖 Prompt for AI Agents