feat(aave-v3): add Aptos chain support#2474
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds Aptos V3 data support to the Aave V3 adaptor: introduces an Aptos SDK dependency, implements getApyAptos() to fetch reserves and base currency data, compute TVL/APY metrics, and merges Aptos results into the existing APY aggregation flow. Changes
Sequence Diagram(s)sequenceDiagram
participant Aggregator as APY Aggregator
participant AptosFn as getApyAptos()
participant SDK as Aptos SDK (Provider / UiPoolDataProviderClient)
participant Pricing as Market Price Service
participant Response as APY Results
Aggregator->>AptosFn: invoke getApyAptos()
activate AptosFn
AptosFn->>SDK: init provider & request reservesData
SDK-->>AptosFn: reservesData
AptosFn->>SDK: request baseCurrencyData
SDK-->>AptosFn: baseCurrencyData
AptosFn->>Pricing: request market prices
Pricing-->>AptosFn: price data
AptosFn->>AptosFn: compute tvlUsd, supply, borrow, apy (use RAY)
AptosFn-->>Response: mapped pool APY objects
deactivate AptosFn
Response-->>Aggregator: return Aptos APY data
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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)
📝 Coding Plan
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 Tip CodeRabbit can generate a title for your PR based on the changes with custom instructions.Set the |
|
The aave-v3 adapter exports pools: Test Suites: 1 passed, 1 total |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/adaptors/aave-v3/index.js (1)
220-220: Consider using lowercase for chain identifier consistency.Other chains in this adaptor use lowercase identifiers (e.g.,
'ethereum','optimism'). Using'Aptos'with a capital letter may cause inconsistencies in downstream processing or pool lookups.♻️ Suggested change
- chain: 'Aptos', + chain: 'aptos',🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/adaptors/aave-v3/index.js` at line 220, The chain identifier in the adaptor object currently uses a capitalized string ('Aptos'); change it to the lowercase form ('aptos') to match other adaptors and avoid downstream lookup mismatches—locate the object/property where chain: 'Aptos' is set in src/adaptors/aave-v3/index.js and update the value to 'aptos' (ensure any related comparisons or tests expect lowercase as well).package.json (1)
17-17: Consider pinning to an exact version to avoid unexpected breaking changes.The
@aave/aave-v3-aptos-ts-sdkpackage at version^0.0.61is a pre-release (0.0.x). Using the caret allows patch updates that may introduce breaking changes. Pin to0.0.61exactly for stability.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package.json` at line 17, Change the dependency declaration for "@aave/aave-v3-aptos-ts-sdk" from a caret range to an exact version by replacing "^0.0.61" with "0.0.61" in package.json; after updating package.json, run your package manager (npm/yarn/pnpm) to update the lockfile so the exact version is recorded.
🤖 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/aave-v3/index.js`:
- Around line 203-206: The priceUsd calculation is dividing by marketRefDecimals
(the count) instead of the decimal factor; update the computation in the
priceUsd assignment to divide r.priceInMarketReferenceCurrency by
10**marketRefDecimals (or Math.pow(10, marketRefDecimals)) before multiplying by
marketRefPriceUsd so that you use the decimal factor rather than the raw
decimals count (refer to priceUsd, r.priceInMarketReferenceCurrency,
marketRefDecimals, marketRefPriceUsd).
---
Nitpick comments:
In `@package.json`:
- Line 17: Change the dependency declaration for "@aave/aave-v3-aptos-ts-sdk"
from a caret range to an exact version by replacing "^0.0.61" with "0.0.61" in
package.json; after updating package.json, run your package manager
(npm/yarn/pnpm) to update the lockfile so the exact version is recorded.
In `@src/adaptors/aave-v3/index.js`:
- Line 220: The chain identifier in the adaptor object currently uses a
capitalized string ('Aptos'); change it to the lowercase form ('aptos') to match
other adaptors and avoid downstream lookup mismatches—locate the object/property
where chain: 'Aptos' is set in src/adaptors/aave-v3/index.js and update the
value to 'aptos' (ensure any related comparisons or tests expect lowercase as
well).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ee5e38d1-ea7d-4725-9879-d8a24dfc3eb0
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
package.jsonsrc/adaptors/aave-v3/index.js
dffe191 to
a31e98c
Compare
|
The aave-v3 adapter exports pools: Test Suites: 1 passed, 1 total |
src/adaptors/aave-v3/index.js
Outdated
| const tvlUsd = totalSupplyUsd - totalBorrowUsd; | ||
|
|
||
| return { | ||
| pool: `${r.underlyingAsset}-aptos`.toLowerCase(), |
There was a problem hiding this comment.
if available can we use the atoken address rather than underlying?
There was a problem hiding this comment.
if available can we use the atoken address rather than underlying?
Yes, fixed that. Thanks for noticing.
|
The aave-v3 adapter exports pools: Test Suites: 1 passed, 1 total |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/adaptors/aave-v3/index.js (1)
203-205:⚠️ Potential issue | 🔴 CriticalCritical: Price calculation still divides by decimals count instead of decimal factor.
The past review comment indicated this was addressed, but the code still divides by
marketRefDecimals(the count, e.g.,8) instead of10 ** marketRefDecimals(the factor, e.g.,10^8 = 100,000,000). This produces prices that are orders of magnitude too high, causing incorrect TVL, supply, and borrow values.🐛 Proposed fix
const priceUsd = - (Number(r.priceInMarketReferenceCurrency) / marketRefDecimals) * + (Number(r.priceInMarketReferenceCurrency) / 10 ** marketRefDecimals) * marketRefPriceUsd;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/adaptors/aave-v3/index.js` around lines 203 - 205, The computed priceUsd uses marketRefDecimals (the integer count) instead of the decimal scaling factor; change the division to use 10 ** marketRefDecimals (or Math.pow(10, marketRefDecimals)) so priceUsd = (Number(r.priceInMarketReferenceCurrency) / (10 ** marketRefDecimals)) * marketRefPriceUsd; update the expression in the price calculation (look for the priceUsd variable and r.priceInMarketReferenceCurrency / marketRefDecimals) to use the correct decimal factor to avoid values being orders of magnitude off.
🧹 Nitpick comments (1)
src/adaptors/aave-v3/index.js (1)
220-220: Consider usingutils.formatChain('aptos')for consistency.Other Aptos adapters in the codebase (e.g., tortuga, thalaswap) use
utils.formatChain('aptos')rather than hardcoding the chain name. While functionally equivalent (both produce'Aptos'), using the utility function maintains consistency and centralizes chain name normalization.♻️ Proposed fix
- chain: 'Aptos', + chain: utils.formatChain('aptos'),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/adaptors/aave-v3/index.js` at line 220, Replace the hardcoded chain: 'Aptos' value with utils.formatChain('aptos') in the adapter object in src/adaptors/aave-v3/index.js (the object/property named "chain"); if utils.formatChain is not in scope, add the appropriate import/require for the shared utils module so utils.formatChain('aptos') can be used for consistent chain name normalization with other Aptos adapters.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/adaptors/aave-v3/index.js`:
- Around line 203-205: The computed priceUsd uses marketRefDecimals (the integer
count) instead of the decimal scaling factor; change the division to use 10 **
marketRefDecimals (or Math.pow(10, marketRefDecimals)) so priceUsd =
(Number(r.priceInMarketReferenceCurrency) / (10 ** marketRefDecimals)) *
marketRefPriceUsd; update the expression in the price calculation (look for the
priceUsd variable and r.priceInMarketReferenceCurrency / marketRefDecimals) to
use the correct decimal factor to avoid values being orders of magnitude off.
---
Nitpick comments:
In `@src/adaptors/aave-v3/index.js`:
- Line 220: Replace the hardcoded chain: 'Aptos' value with
utils.formatChain('aptos') in the adapter object in
src/adaptors/aave-v3/index.js (the object/property named "chain"); if
utils.formatChain is not in scope, add the appropriate import/require for the
shared utils module so utils.formatChain('aptos') can be used for consistent
chain name normalization with other Aptos adapters.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1032891a-7a8d-4261-bb91-6b0dd1fa4f83
📒 Files selected for processing (1)
src/adaptors/aave-v3/index.js
|
hi @mpsc0x can you install the package in |
|
The aave-v3 adapter exports pools: Test Suites: 1 passed, 1 total |
Added aave-v3 on aptos adaptor
Summary by CodeRabbit
New Features
Chores