Add Monetrix yield adapter (sUSDM)#2740
Conversation
📝 WalkthroughWalkthroughA new Monetrix adaptor is added that computes APY for the Hyperliquid sUSDM ERC-4626 vault using a clamped 7-day trailing window of ChangesMonetrix sUSDM Adaptor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 monetrix adapter exports pools: Test Suites: 1 passed, 1 total |
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/monetrix/index.js`:
- Around line 42-43: The totalAssets RPC call in the Promise.all block is
missing a block parameter, causing it to be fetched at the latest head while the
ppsNowRes and ppsPastRes calls are pinned to specific block numbers. Add a block
parameter to the sdk.api.abi.call for the SUSDM totalAssets target to match the
same block number used in the ppsNowRes call so that all three data points are
consistently fetched from the same block height.
🪄 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: d778de1c-c443-484e-b454-aa6b7672c2e9
📒 Files selected for processing (2)
src/adaptors/monetrix/index.jssrc/handlers/triggerEnrichment.js
| const [totalAssetsRes, ppsNowRes, ppsPastRes] = await Promise.all([ | ||
| sdk.api.abi.call({ target: SUSDM, chain: CHAIN, abi: 'uint256:totalAssets' }), |
There was a problem hiding this comment.
Pin totalAssets to the same block as the APY snapshot.
Right now TVL is fetched at whatever the latest head is when the RPC call lands, while the share-price samples are pinned to latest.number/past.block. That can produce a small block-to-block mismatch in tvlUsd.
♻️ Proposed fix
const [totalAssetsRes, ppsNowRes, ppsPastRes] = await Promise.all([
- sdk.api.abi.call({ target: SUSDM, chain: CHAIN, abi: 'uint256:totalAssets' }),
+ sdk.api.abi.call({
+ target: SUSDM,
+ chain: CHAIN,
+ abi: 'uint256:totalAssets',
+ block: latest.number,
+ }),
sdk.api.abi.call({
target: SUSDM,
chain: CHAIN,📝 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 [totalAssetsRes, ppsNowRes, ppsPastRes] = await Promise.all([ | |
| sdk.api.abi.call({ target: SUSDM, chain: CHAIN, abi: 'uint256:totalAssets' }), | |
| const [totalAssetsRes, ppsNowRes, ppsPastRes] = await Promise.all([ | |
| sdk.api.abi.call({ | |
| target: SUSDM, | |
| chain: CHAIN, | |
| abi: 'uint256:totalAssets', | |
| block: latest.number, | |
| }), |
🤖 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/monetrix/index.js` around lines 42 - 43, The totalAssets RPC
call in the Promise.all block is missing a block parameter, causing it to be
fetched at the latest head while the ppsNowRes and ppsPastRes calls are pinned
to specific block numbers. Add a block parameter to the sdk.api.abi.call for the
SUSDM totalAssets target to match the same block number used in the ppsNowRes
call so that all three data points are consistently fetched from the same block
height.
| tvlUsd: tvlUnderlying * usdcPrice, | ||
| apyBase, | ||
| underlyingTokens: [USDM], | ||
| url: 'https://www.monetrix.xyz/', |
| tvlUsd: tvlUnderlying * usdcPrice, | ||
| apyBase, | ||
| underlyingTokens: [USDM], | ||
| url: 'https://www.monetrix.xyz/', |
There was a problem hiding this comment.
update url to be: https://www.monetrix.xyz/app/earn
| : 0; | ||
|
|
||
| // USDM has no price feed yet; it mints/redeems 1:1 against USDC, so price via USDC | ||
| const { pricesByAddress } = await utils.getPrices([USDC], CHAIN); |
There was a problem hiding this comment.
we could use usdm and fallback to usdc so works when pricing is added
|
|
||
| return [ | ||
| { | ||
| pool: `${SUSDM}-${CHAIN}`, |
| tvlUsd: tvlUnderlying * usdcPrice, | ||
| apyBase, | ||
| underlyingTokens: [USDM], | ||
| url: 'https://www.monetrix.xyz/', |
There was a problem hiding this comment.
this is a yield bearing stablecoin so we should add isIntrinsicSource: true
0xkr3p
left a comment
There was a problem hiding this comment.
hi @MonetrixLab, thanks for the PR - i've left a few comments to resolve
Adds the sUSDM pool for Monetrix (TVL already merged, slug
monetrix).usdmto triggerEnrichment.js so the pool is flagged as a stablecoin poolSummary by CodeRabbit
Release Notes