Add Covenant (Monad) Yield Coin pools - #2681
Conversation
📝 WalkthroughWalkthroughThis PR adds a Covenant adaptor for Monad. It defines contract ABIs, discovers markets through Envio, loads market data, calculates APY and TVL, filters unsupported markets, and exports formatted pool records. ChangesCovenant Adaptor for Monad Chain
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Adaptor as apy()
participant Envio as Envio GraphQL indexer
participant DataProvider as Covenant data provider
participant PriceAPI as DefiLlama price endpoint
Adaptor->>Envio: query Monad market IDs
Envio-->>Adaptor: marketIds
Adaptor->>DataProvider: getMarketsDetails(covenantLiquid, marketIds)
DataProvider-->>Adaptor: MarketDetails[]
Adaptor->>PriceAPI: request MON/USD price when required
PriceAPI-->>Adaptor: MON/USD price or no price
Adaptor->>Adaptor: calculate APY and zToken TVL
Adaptor-->>Adaptor: return filtered pool records
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 covenant adapter exports pools: Test Suites: 1 passed, 1 total |
Matches Synthetix-v3's convention for sUSD (underlying = USDC, not SNX) and shmonad's use of WMON for MON-denominated yield. The Yield Coin (zToken) is a synthetic claim denominated in the quote unit, not in the deposited baseToken — exposing baseToken in underlyingTokens would mislead users searching the yields page.
|
The covenant adapter exports pools: Test Suites: 1 passed, 1 total |
|
The covenant adapter exports pools: Test Suites: 1 passed, 1 total |
|
The covenant adapter exports pools: Test Suites: 1 passed, 1 total |
| @@ -0,0 +1,64 @@ | |||
| [ | |||
There was a problem hiding this comment.
file is not used, pls remove
| @@ -0,0 +1,139 @@ | |||
| const sdk = require('@defillama/sdk'); | |||
| const superagent = require('superagent'); | |||
There was a problem hiding this comment.
superagent is no longer used in the repository, pls use our pricing helpers in utils instead
| pool: `${d.zToken.tokenAddress.toLowerCase()}-${CHAIN}`, | ||
| chain: utils.formatChain(CHAIN), | ||
| project: PROJECT, | ||
| symbol: utils.formatSymbol(d.zToken.symbol), |
| apyBase, | ||
| underlyingTokens: [underlying.toLowerCase()], | ||
| url: `${APP_URL}/market/${d.marketId.toLowerCase()}?action=swap&input=base&output=yield`, | ||
| poolMeta: `${quoteSym} Yield Coin (backed by ${d.baseToken.symbol})`, |
There was a problem hiding this comment.
reduce the pool meta the text is very long
| } | ||
|
|
||
| module.exports = { | ||
| timetravel: false, |
There was a problem hiding this comment.
pls add the protocolId: 7856
|
|
||
| async function fetchMonUsdPrice() { | ||
| // Native MON, queried by chain identifier (no contract address for the gas token). | ||
| const res = await superagent.get( |
There was a problem hiding this comment.
use defilllama pricing helper in utils
0xkr3p
left a comment
There was a problem hiding this comment.
hi @amorphousguy, thanks for the pr - a few comments to resolve before we can merge
The hardcoded marketId snapshot went stale whenever a market launched or migrated. Enumerate marketIds at runtime from the hosted Envio indexer (unauthenticated GraphQL, same endpoint the production app uses); market state is still read on-chain via DataProvider. Fails loudly on indexer errors rather than serving a stale market set. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Error while running covenant adapter: ● Running covenant Test › Adapter exports the protocolId matching its protocol slug |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/covenant/index.js`:
- Line 64: Update the superagent request in the covenant indexer flow to chain
.timeout({ response, deadline }) before awaiting it, using appropriate response
and total-request deadline values. Preserve the existing await behavior so
timeout errors continue propagating.
🪄 Autofix
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 Plus
Run ID: 6b87f4a8-a375-4d39-8229-5159b60018f1
📒 Files selected for processing (1)
src/adaptors/covenant/index.js
| const CHAIN_ID = 143; // Monad mainnet | ||
|
|
||
| async function fetchMarketIds() { | ||
| const res = await superagent.post(INDEXER_URL).send({ |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ast-grep outline src/adaptors/covenant/index.js --items all
rg -n -C 3 -P '\bsuperagent\.(get|post|put|patch|delete)\s*\(|\.timeout\s*\(' src/adaptors/covenant/index.js
fd -HI -t f '^package\.json$' . -E node_modules -x rg -n -C 2 '"superagent"' {}Repository: DefiLlama/yield-server
Length of output: 1680
🏁 Script executed:
set -euo pipefail
printf '%s\n' '--- manifests containing superagent ---'
git ls-files '*package*.json' '*lock*' |
xargs -r rg -n -C 3 '"superagent"|superagent@' || true
printf '%s\n' '--- repository timeout usage ---'
rg -n -C 3 '\.timeout\s*\(\s*\{|\btimeout\s*:\s*[0-9]+' --glob '!node_modules/**' --glob '!dist/**' . || true
printf '%s\n' '--- fetchMarketIds implementation ---'
sed -n '60,82p' src/adaptors/covenant/index.js
printf '%s\n' '--- superagent package metadata, if vendored or installed ---'
for f in node_modules/superagent/package.json package.json; do
if [ -f "$f" ]; then
printf '%s\n' "--- $f"
rg -n -C 2 '"superagent"|"version"' "$f"
fi
doneRepository: DefiLlama/yield-server
Length of output: 19874
🏁 Script executed:
set -euo pipefail
printf '%s\n' '--- superagent 7.1.6 timeout implementation ---'
rg -n -C 8 'timeout\(|responseTimeout|deadline|_timeout' \
node_modules/superagent/lib node_modules/superagent/index.js \
2>/dev/null || true
printf '%s\n' '--- superagent 7.1.6 package dependency path ---'
rg -n -C 4 '"superagent":|"node_modules/superagent"|from node_modules/superagent' \
package.json package-lock.json node_modules/superagent/package.json \
2>/dev/null || true
printf '%s\n' '--- timeout documentation in the installed package ---'
rg -n -C 5 'response.*deadline|deadline.*response|response timeout|total time' \
node_modules/superagent \
2>/dev/null || trueRepository: DefiLlama/yield-server
Length of output: 50379
Set response and total deadlines for the indexer request.
Superagent 7.1.6 supports .timeout({ response, deadline }). Without these values, a stalled indexer request has no application-level deadline. The existing await propagates the timeout error.
Proposed fix
- const res = await superagent.post(INDEXER_URL).send({
+ const res = await superagent
+ .post(INDEXER_URL)
+ .timeout({ response: 10_000, deadline: 15_000 })
+ .send({📝 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 res = await superagent.post(INDEXER_URL).send({ | |
| const res = await superagent | |
| .post(INDEXER_URL) | |
| .timeout({ response: 10_000, deadline: 15_000 }) | |
| .send({ |
🤖 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/covenant/index.js` at line 64, Update the superagent request in
the covenant indexer flow to chain .timeout({ response, deadline }) before
awaiting it, using appropriate response and total-request deadline values.
Preserve the existing await behavior so timeout errors continue propagating.
Adds yield-server pools for Covenant on Monad. One pool per market for
the Yield Coin (zToken):
(EVMBlockchainAdapter.ts debtTokenAPYCalc), pulled from a single
DataProvider.getMarketsDetails call on Monad mainnet
converted to USD via the quote anchor (USDC = $1, MON via CoinGecko)
TVL adapter (already merged in DefiLlama-Adapters#19272):
https://defillama.com/protocol/covenant
Methodology rationale + source-of-truth ABIs:
https://github.com/covenant-labs/covenant-defillama
Summary by CodeRabbit
Release Notes