feat: add DorkFi yield adapter (Algorand + Voi Network)#2787
feat: add DorkFi yield adapter (Algorand + Voi Network)#2787mikepappalardo wants to merge 2 commits into
Conversation
Reports supply and borrow APY for all 47 DorkFi lending markets across two chains and four pools. Pools: Algorand: 3333688282 (Pool A), 3345940978 (Pool B) Voi: 47139778 (Pool A), 47139781 (Pool B) APY computed from the protocol's kinked utilization curve: borrow APY = borrowRate + utilization × slope supply APY = borrow APY × utilization × (1 − reserveFactor) Markets include ALGO, USDC, goBTC, goETH, WBTC, WETH, LINK, SOL, USDT, VOI, UNIT, WAD, aUSDC, POW, tALGO, FINITE, FOLKS, COOP, GOLD$ and more. Data sourced from DorkFi API (dorkfi-api.nautilus.sh).
📝 WalkthroughWalkthroughAdds a new DefiLlama yield-server adapter for DorkFi (src/adaptors/dorkfi/index.js) that fetches lending market data and TVL for Algorand and Voi chains, computes supply/borrow APYs from kinked utilization curve parameters, and exports ChangesDorkFi Adapter
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant apy as apy()
participant fetchMarketData
participant fetchAnalyticsTVL
participant computeRates
apy->>fetchMarketData: request market data per chain
apy->>fetchAnalyticsTVL: request TVL per chain
fetchMarketData-->>apy: markets or empty fallback
fetchAnalyticsTVL-->>apy: tvl data or empty fallback
apy->>apy: dedup markets by appId:marketId
apy->>computeRates: pass market params
computeRates-->>apy: supply/borrow APY
apy->>apy: filter by tvlUsd >= 1
apy-->>apy: build pool objects
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: one or more packages not found in the registry. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The abracadabra-spell adapter exports pools: Test Suites: 1 passed, 1 total |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/adaptors/dorkfi/index.js (1)
177-188: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider populating
totalSupplyUsdandtotalBorrowUsd.The
Poolinterface defines optionaltotalSupplyUsdandtotalBorrowUsdfields for lending protocols. The adapter already hastotalScaledDepositsandtotalScaledBorrowsfrom the market data. Populating these fields would improve data quality for downstream consumers and DefiLlama's lending protocol dashboards.♻️ Suggested addition
const { borrowApy, supplyApy } = computeRates(market); const symbol = MARKET_SYMBOLS[market.marketId] || `ASA-${market.marketId}`; results.push({ pool: `dorkfi-${chain}-${market.appId}-${market.marketId}`, chain: DL_CHAIN[chain], project: PROJECT, symbol, tvlUsd, apyBase: supplyApy, apyBaseBorrow: borrowApy, + totalSupplyUsd: Number(market.totalScaledDeposits || 0), + totalBorrowUsd: Number(market.totalScaledBorrows || 0), underlyingTokens: getUnderlyingTokens(market), poolMeta: `Pool ${market.appId}`, url: 'https://dork.fi', });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/adaptors/dorkfi/index.js` around lines 177 - 188, Populate the lending pool supply/borrow totals in the DorkFi adapter result object. In `src/adaptors/dorkfi/index.js`, update the object pushed in the main market mapping so it also sets `totalSupplyUsd` and `totalBorrowUsd` using the existing market data fields (`totalScaledDeposits` and `totalScaledBorrows`) alongside `tvlUsd`, `apyBase`, and `apyBaseBorrow`. Keep the change localized to the pool construction logic so the `results.push` payload includes these optional `Pool` fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/adaptors/dorkfi/index.js`:
- Around line 171-172: The `tvlUsd` value in `src/adaptors/dorkfi/index.js` is
taken directly from `tvlMap[key]` and may be a string, which can break the
numeric boundary checks later in `triggerAdaptor.js`. Update the `tvlUsd`
assignment in this adaptor to explicitly convert the API value to a number
before the `if (tvlUsd < 1) continue` filter, using the same numeric handling
pattern already used for other fields so downstream comparisons stay consistent.
---
Nitpick comments:
In `@src/adaptors/dorkfi/index.js`:
- Around line 177-188: Populate the lending pool supply/borrow totals in the
DorkFi adapter result object. In `src/adaptors/dorkfi/index.js`, update the
object pushed in the main market mapping so it also sets `totalSupplyUsd` and
`totalBorrowUsd` using the existing market data fields (`totalScaledDeposits`
and `totalScaledBorrows`) alongside `tvlUsd`, `apyBase`, and `apyBaseBorrow`.
Keep the change localized to the pool construction logic so the `results.push`
payload includes these optional `Pool` fields.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ec5205a5-a04c-405a-b3cb-8221837ba834
📒 Files selected for processing (1)
src/adaptors/dorkfi/index.js
| const tvlUsd = tvlMap[key] || 0; | ||
| if (tvlUsd < 1) continue; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Ensure tvlUsd is a numeric type.
tvlMap[key] comes directly from the API response without explicit Number() conversion. If the API returns a string, the downstream tvlUsd boundary filter in triggerAdaptor.js performs comparisons without casting tvlUsd (only APY fields are cast), which could lead to incorrect filtering.
🛡️ Proposed fix
- const tvlUsd = tvlMap[key] || 0;
+ const tvlUsd = Number(tvlMap[key]) || 0;
if (tvlUsd < 1) continue;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const tvlUsd = tvlMap[key] || 0; | |
| if (tvlUsd < 1) continue; | |
| const tvlUsd = Number(tvlMap[key]) || 0; | |
| if (tvlUsd < 1) continue; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/adaptors/dorkfi/index.js` around lines 171 - 172, The `tvlUsd` value in
`src/adaptors/dorkfi/index.js` is taken directly from `tvlMap[key]` and may be a
string, which can break the numeric boundary checks later in
`triggerAdaptor.js`. Update the `tvlUsd` assignment in this adaptor to
explicitly convert the API value to a number before the `if (tvlUsd < 1)
continue` filter, using the same numeric handling pattern already used for other
fields so downstream comparisons stay consistent.
| return results; | ||
| }; | ||
|
|
||
| module.exports = { apy, timeTravel: false, url: 'https://dork.fi' }; |
There was a problem hiding this comment.
pls add protocolId: 7531
timeTravel should be all lowercase
| symbol, | ||
| tvlUsd, | ||
| apyBase: supplyApy, | ||
| apyBaseBorrow: borrowApy, |
There was a problem hiding this comment.
missing these fields:
ltv, totalSupplyUsd, totalBorrowUsd
| chain: DL_CHAIN[chain], | ||
| project: PROJECT, | ||
| symbol, | ||
| tvlUsd, |
There was a problem hiding this comment.
just checking tvlUsd should be available liquidity, e.g. deposits - borrows
0xkr3p
left a comment
There was a problem hiding this comment.
hi @mikepappalardo, thanks for the PR. A few things to resolve before we can move forwards. I don't think these underlying tokens will resolve we should use coingecko ids where possible particualrly for the popular tokens for example: coingecko:voi-network, coingecko:aave-v3-usdc
|
|
||
| for (const market of dedup(markets)) { | ||
| const key = `${market.appId}:${market.marketId}`; | ||
| const hasTvl = Object.prototype.hasOwnProperty.call(tvlMap, key); |
There was a problem hiding this comment.
can we skip 'paused' markets?
Adds the DorkFi yield adapter for Algorand and Voi Network.
This supersedes closed PR #2599. That PR was closed as stale while review comments were unresolved, and GitHub would not allow it to be reopened after the branch update.
Updates included here:
underlyingTokensfor every DorkFi pool using the on-chain market asset ID as a string.Validated locally:
npm run test --adapter=dorkfiResult: 1 test suite passed, 376 tests passed.
Summary by CodeRabbit