Add Base rebalancer flow#1184
Conversation
✅ Deploy Preview for vortexfi ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
❌ Deploy Preview for vortex-sandbox failed. Why did it fail? →
|
There was a problem hiding this comment.
Pull request overview
Adds a new “USDC → BRLA → USDC” rebalancing flow targeting the Base Nabla instance by default, with optional routing via Avenia vs SquidRouter and resumable state persisted in Supabase storage.
Changes:
- Extend BRLA shared quote types/service to support specifying
outputPaymentMethodfor onchain swap quotes (e.g. Base). - Introduce a new Base rebalancing flow (steps + orchestrator) and Base coverage-ratio check used by default (legacy flow preserved behind
--legacy). - Add shared Supabase-backed state manager abstraction and a simple EVM nonce manager for sequential tx submission.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/shared/src/services/brla/types.ts | Extends onchain swap quote params to optionally specify output payment method. |
| packages/shared/src/services/brla/brlaApiService.ts | Uses optional output payment method when building onchain swap quote requests. |
| apps/rebalancer/src/utils/nonce.ts | Adds a nonce manager to issue sequential nonces for EVM transactions. |
| apps/rebalancer/src/utils/config.ts | Consolidates EVM executor secret usage and adds Base EVM client getter. |
| apps/rebalancer/src/services/stateManager.ts | Refactors state persistence into a reusable Supabase storage state manager; adds state for Base flow. |
| apps/rebalancer/src/services/indexer/index.ts | Adds Base Nabla BRLA pool coverage-ratio read via onchain calls. |
| apps/rebalancer/src/rebalance/usdc-brla-usdc-base/steps.ts | Implements Base rebalance step functions (Nabla swap, Avenia transfer/swap, Squid route swap). |
| apps/rebalancer/src/rebalance/usdc-brla-usdc-base/index.ts | Orchestrates the new Base flow with resumability and optional forced routing. |
| apps/rebalancer/src/rebalance/brla-to-axlusdc/index.ts | Updates legacy flow to use the renamed state manager and phase order constants. |
| apps/rebalancer/src/index.ts | Switches default run path to Base flow; adds --legacy and --route=... flags. |
| apps/rebalancer/README.md | Updates env var documentation for the new consolidated EVM secret and legacy-only Pendulum secret. |
| apps/rebalancer/.env.example | Updates example env vars for the new consolidated EVM secret and legacy-only Pendulum secret. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…tion or class' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…tion or class' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…tion or class' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
ebma
left a comment
There was a problem hiding this comment.
I think some parts could be cleaner or refactored, like duplicate imports of the USDC token contract, or the ABI functions but it's also fine with me to leave as is since it's just the rebalancer. @gianfra-t what about the code-quality comments from the bot?
| return balance.toString(); | ||
| } | ||
|
|
||
| import { checkInitialUsdcBalanceOnBase } from "../usdc-brla-usdc-base/steps.ts"; |
About
Rebalancer now checks by default the Base Nabla instance, for USDC -> BRLA rebalances.
If not specified otherwise, the flow compares between:
0x58E5Cb2dA15f01CB8FAefef202aa25238efCBdcf).This PR also adds rebalancing logic for the other direction, BRLA -> USDC. Only with the main nabla DEX path is included for now.
New commands and flags
--route=aveniaor--route=squidrouterforces the path to one or the other regardless of the rate comparison.New env variables