Conversation
📝 WalkthroughWalkthroughA new adaptor module for 3jane-lending on Ethereum was added; it fetches block heights and market data (Aave, MorphoCredit), computes TVL and 7-day-based APY for USD3 and sUSD3 pools, and exports an apy function, timetravel:false, and a URL. Changes
Sequence DiagramsequenceDiagram
participant Adaptor as 3jane Adaptor
participant SDK as DefiLlama SDK
participant APIs as External APIs (Aave, MorphoCredit)
participant Utils as Utils (keepFinite/format)
participant Response as Pool Data Response
Adaptor->>SDK: fetch current block
Adaptor->>SDK: fetch block (7d ago)
SDK-->>Adaptor: block heights
Adaptor->>APIs: fetch USD3 & sUSD3 totalAssets & pricePerShare
Adaptor->>APIs: fetch waUSDC rate at current & 7d blocks
Adaptor->>APIs: fetch MorphoCredit market data at current & 7d blocks
APIs-->>Adaptor: market data
Adaptor->>Adaptor: compute usd3TvlUsd, susd3TvlUsd
Adaptor->>Adaptor: compute aaveApy (waUSDC growth annualized)
Adaptor->>Adaptor: compute creditApy (supply share growth)
Adaptor->>Adaptor: compute sUSD3 APY = (creditApy + aaveApy) * leverage
Adaptor->>Utils: filter/format pools
Utils-->>Adaptor: formatted pools
Adaptor->>Response: return [USD3-ETH pool, sUSD3-ETH pool]
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/adaptors/3jane-lending/index.js`:
- Around line 99-110: The supply-share-price calculation can divide by zero;
update the sppNow and spp7d computations (used from
marketNow.output.totalSupplyShares and market7d.output.totalSupplyShares) to
check that totalSupplyShares > 0 before dividing and set sppNow/spp7d to null
(or undefined) when the denominator is zero, then compute creditApy only if both
sppNow and spp7d are finite numbers (use Number.isFinite) otherwise set
creditApy = null; ensure downstream uses (susd3Apy and keepFinite) handle null
instead of relying on || 0 so you don't mask missing data with 0 or propagate
Infinity/NaN.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/adaptors/3jane-lending/index.js (1)
131-149: Deduplicate the app URL string into a constant.Using a single constant avoids drift between pool entries and module export.
Suggested refactor
const PROJECT = '3jane-lending'; +const APP_URL = 'https://app.3jane.xyz/supply'; @@ - url: 'https://app.3jane.xyz/supply', + url: APP_URL, @@ - url: 'https://app.3jane.xyz/supply', + url: APP_URL, @@ - url: 'https://app.3jane.xyz/supply', + url: APP_URL,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/adaptors/3jane-lending/index.js` around lines 131 - 149, The app URL 'https://app.3jane.xyz/supply' is duplicated in the pool objects and module.exports; create a single constant (e.g., const APP_URL = 'https://app.3jane.xyz/supply') near the top of the adaptor, replace all literal occurrences in the apy pools (where pool objects are created — referenced by variables like susd3TvlUsd, susd3Apy and the array returned from apy) and in module.exports.url with APP_URL, and ensure utils.keepFinite(p) logic remains unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/adaptors/3jane-lending/index.js`:
- Around line 23-25: The axios GET for the block lookup (`axios.get` using CHAIN
and timestamp) can hang; add an explicit HTTP timeout (e.g., 3–10s) so the
request fails fast instead of blocking the adapter. Update the call that builds
the URL for `https://coins.llama.fi/block/${CHAIN}/${timestamp}` to pass a
timeout option (or use an axios instance with a default timeout) and ensure any
surrounding logic (e.g., the function performing the lookup) handles the timeout
rejection appropriately.
---
Nitpick comments:
In `@src/adaptors/3jane-lending/index.js`:
- Around line 131-149: The app URL 'https://app.3jane.xyz/supply' is duplicated
in the pool objects and module.exports; create a single constant (e.g., const
APP_URL = 'https://app.3jane.xyz/supply') near the top of the adaptor, replace
all literal occurrences in the apy pools (where pool objects are created —
referenced by variables like susd3TvlUsd, susd3Apy and the array returned from
apy) and in module.exports.url with APP_URL, and ensure utils.keepFinite(p)
logic remains unchanged.
| const res = await axios.get( | ||
| `https://coins.llama.fi/block/${CHAIN}/${timestamp}` | ||
| ); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
rg -n "axios\.get\(" src/adaptors/3jane-lending/index.js -C2Repository: DefiLlama/yield-server
Length of output: 214
🏁 Script executed:
rg -n "timeout\s*:" src/adaptors/3jane-lending/index.js -C2Repository: DefiLlama/yield-server
Length of output: 48
🏁 Script executed:
rg -n "axios\\.defaults" src/adaptors/3jane-lending/index.jsRepository: DefiLlama/yield-server
Length of output: 48
🏁 Script executed:
rg -n "axios.*timeout" src/adaptors/ --max-count=5 -lRepository: DefiLlama/yield-server
Length of output: 134
🏁 Script executed:
rg -n "axios.*timeout" src/adaptors/pancakeswap-amm/index.js -C1Repository: DefiLlama/yield-server
Length of output: 242
🏁 Script executed:
rg -n "axios.*timeout" src/adaptors/euler-v2/index.js -C1Repository: DefiLlama/yield-server
Length of output: 257
Add an explicit HTTP timeout for block lookup.
This external request can hang indefinitely and stall the adapter run if the upstream endpoint is slow/unresponsive. Other adapters in the codebase establish timeout configurations as standard practice.
Suggested fix
const SECONDS_PER_DAY = 86400;
+const HTTP_TIMEOUT_MS = 10_000;
@@
const getBlock = async (timestamp) => {
const res = await axios.get(
- `https://coins.llama.fi/block/${CHAIN}/${timestamp}`
+ `https://coins.llama.fi/block/${CHAIN}/${timestamp}`,
+ { timeout: HTTP_TIMEOUT_MS }
);
return res.data.height;
};🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/adaptors/3jane-lending/index.js` around lines 23 - 25, The axios GET for
the block lookup (`axios.get` using CHAIN and timestamp) can hang; add an
explicit HTTP timeout (e.g., 3–10s) so the request fails fast instead of
blocking the adapter. Update the call that builds the URL for
`https://coins.llama.fi/block/${CHAIN}/${timestamp}` to pass a timeout option
(or use an axios instance with a default timeout) and ensure any surrounding
logic (e.g., the function performing the lookup) handles the timeout rejection
appropriately.
Summary by CodeRabbit