fix(swap): route Paraswap collateral swaps through the adapter#3012
fix(swap): route Paraswap collateral swaps through the adapter#3012mgrabina wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f12961556b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
📦 Next.js Bundle Analysis for aave-uiThis analysis was generated by the Next.js Bundle Analysis action. 🤖 🎉 Global Bundle Size Decreased
DetailsThe global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster. Any third party scripts you have added directly to your app using the If you want further insight into what is behind the changes, give @next/bundle-analyzer a try! One Page Changed SizeThe following page changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. |
f129615 to
e503750
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e503750296
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
📦 Next.js Bundle Analysis for aave-uiThis analysis was generated by the Next.js Bundle Analysis action. 🤖 🎉 Global Bundle Size Decreased
DetailsThe global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster. Any third party scripts you have added directly to your app using the If you want further insight into what is behind the changes, give @next/bundle-analyzer a try! |
e503750 to
0f02a38
Compare
|
📦 Next.js Bundle Analysis for aave-uiThis analysis was generated by the Next.js Bundle Analysis action. 🤖
|
| Page | Size (compressed) |
|---|---|
global |
1.25 MB (🟡 +1 B) |
Details
The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.
Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis
If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!
Non-flashloan Paraswap collateral swaps were sent to the plain SwapActionsViaParaswap path, which swaps the aTokens directly. That depends on Paraswap pricing the aTokens, which it doesn't do correctly on every chain: on Sonic it reports aUSDC as 18 decimals and values it at $0, so the quote is rejected (ESTIMATED_LOSS_GREATER_THAN_MAX_IMPACT) or the build fails (Source Decimals Mismatch). Restore the pre-refactor behavior: Paraswap collateral swaps always go through the collateral-swap adapter, which operates on the underlying tokens. It runs swapAndDeposit (no flashloan) or a flashloan depending on the health-factor impact, as before. The quote uses the underlying tokens too, which Paraswap prices correctly.
0f02a38 to
6acb5e1
Compare
|
📦 Next.js Bundle Analysis for aave-uiThis analysis was generated by the Next.js Bundle Analysis action. 🤖 🎉 Global Bundle Size Decreased
DetailsThe global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster. Any third party scripts you have added directly to your app using the If you want further insight into what is behind the changes, give @next/bundle-analyzer a try! One Page Changed SizeThe following page changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. |
General Changes
Source Decimals Mismatch(swap out of USDC) andPrice impact too high/ESTIMATED_LOSS_GREATER_THAN_MAX_IMPACT(swap into USDC).Developer Notes
Root cause. The Swaps refactor (#2739) changed non-flashloan collateral swaps to render the plain
SwapActionsViaParaswappath, which swaps the aTokens directly through Paraswap. That depends on Paraswap pricing the aTokens correctly, which it doesn't on every chain. On Sonic, Paraswap has wrong metadata for aUSDC — it reportssrcDecimals/destDecimals: 18(aUSDC is 6) and values it at$0:So both directions break on Sonic, at different stages (quote vs build), and neither is fixable client-side — Paraswap mis-values the aToken server-side.
Fix — restore the pre-refactor behavior. Before #2739, Paraswap collateral swaps quoted and built on the underlying tokens and executed via the collateral-swap adapter with
flashtoggled by health factor (pool.swapCollateral({ flash });flash: false=swapAndDeposit). This change restores that:useSwapQuote— quote Paraswap collateral on the underlying tokens (excludeCollateralSwapfrom the ParaswapusesAddressToSwapbranch), which Paraswap prices correctly.CollateralSwapActions— Paraswap collateral always rendersCollateralSwapActionsViaParaswapAdapters(the adapter operates on underlying), instead of the direct-aTokenSwapActionsViaParaswap.CollateralSwapActionsViaParaswapAdapters—useFlashLoan: state.useFlashloan ?? false(was hardcodedtrue), so a healthy HF runsswapAndDeposit(no flashloan) and a low HF flashloans — exactly the old behavior.useFlowSelectoralready computesuseFlashloanfrom the HF impact.Scope / safety:
swapAndDepositvia the adapter, not a flashloan), so no new flashloan fee for healthy positions.SwapActionsViaParaswapis unchanged and still used for plainSwap.