Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (23)
📝 WalkthroughWalkthroughAdds swap-backed leverage and deleverage flows using Bundler V3 and Velora adapters alongside existing ERC4626 paths. Introduces new ABI definitions for Bundler3, Morpho GeneralAdapter, and Paraswap. Extends leverage and deleverage hooks to support dual-path flows with route selection and safety checks. Updates modal components for route selection. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Modal as Leverage Modal
participant Hook as useLeverageQuote
participant Velora as Velora API
participant Bundler3 as Bundler3 Contract
participant Morpho as Morpho Protocol
User->>Modal: Select swap route & input collateral
Modal->>Hook: Call useLeverageQuote with swap route
Hook->>Velora: Fetch BUY route (collateral → loan token)
Velora-->>Hook: Price route + amounts
Hook->>Velora: Fetch SELL route (loan token → collateral)
Velora-->>Hook: Sell route for flashLoanAmount
Hook-->>Modal: flashCollateralAmount, flashLoanAmount, swapPriceRoute
Modal->>User: Display quote & preview
User->>Modal: Execute leverage
Modal->>Hook: Call useLeverageTransaction
Hook->>Bundler3: Build & validate callback bundle
Bundler3-->>Hook: Callback hash
Hook->>Bundler3: Execute multicall (callback + Velora swap + Morpho operations)
Bundler3->>Morpho: Flash borrow via callback
Bundler3->>Velora: Execute swap (loan token → collateral)
Bundler3->>Morpho: Supply collateral & borrow
Bundler3-->>Hook: Transaction confirmed
Hook-->>Modal: Success
Modal-->>User: Leverage complete
sequenceDiagram
actor User
participant Modal as Deleverage Modal
participant Hook as useDeleverageQuote
participant Velora as Velora API
participant Bundler3 as Bundler3 Contract
participant Morpho as Morpho Protocol
User->>Modal: Enter repay amount with swap route
Modal->>Hook: Call useDeleverageQuote with swap route & tokens
Hook->>Velora: Fetch SELL route (collateral → loan token)
Velora-->>Hook: Swap price route & amounts
Hook->>Velora: Fetch BUY route (repayAmount → collateral)
Velora-->>Hook: Max collateral for debt repay
Hook-->>Modal: repayAmount, maxCollateralForDebt, swapPriceRoute
Modal->>User: Display quote & collateral needed
User->>Modal: Execute deleverage
Modal->>Hook: Call useDeleverageTransaction
Hook->>Bundler3: Validate swap payload & Velora targets
Hook->>Bundler3: Execute multicall (withdraw + repay + swap collateral back)
Bundler3->>Morpho: Withdraw collateral
Bundler3->>Morpho: Repay debt
Bundler3->>Velora: Execute swap (freed collateral → loan token buffer)
Bundler3-->>Hook: Transaction confirmed
Hook-->>Modal: Success
Modal-->>User: Deleverage complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested labels
✨ 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 latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary by CodeRabbit
New Features
Bug Fixes
Refactoring
Documentation
Chores