Open
Conversation
… and cross-asset flows What it does: Handles buy/sell operations for ERC4626 vaults Supports both same-asset (USDC vaults) and cross-asset (WETH vaults) flows Routes through swap executors for cross-asset conversions Validates all operations before execution Key features: Routing parameter support for DEX configuration Automatic underlying asset detection Comprehensive slippage protection Approval hygiene (zero approvals after each operation)
Uniswap: Executes exact-input and exact-output swaps via Uniswap V3 Supports configurable fee tiers (500/3000/10000 bps) Refunds unused input tokens on exact-output swaps Curve: Optimized for stablecoin swaps (USDC/USDT/DAI) Approximates exact-output swaps (1:1 + 0.2% buffer) Supports both regular and underlying token exchanges
Implements 5 mandatory Chainlink security checks (Euler/Morpho best practices) Supports inverse feeds (e.g., USDC/ETH → ETH/USDC) Configurable price bounds and staleness thresholds
…cross-asset pricing Composes vault share prices from underlying asset prices Handles both same-asset and cross-asset vaults Normalizes to protocol standard (14 decimals)
UniswapV3SwapExecutor exact-output and exact-input swaps CurveSwapExecutor stablecoin swaps Mock DEX interactions Error handling
Mainnet fork at latest block Real contracts: Morpho WETH vault (0x31A5...24f9), Uniswap V3, Chainlink oracles Impersonated whale accounts for token funding Test coverage (20 tests): Buy Flow Tests: Price estimation accuracy Buy execution with Uniswap V3 routing Excess USDC refund Slippage protection Sell Flow Tests: Sell estimation accuracy Sell execution with Uniswap V3 routing Expected USDC receipt Oracle Integration: Vault price calculation Chainlink security checks Stale data handling Edge Cases: Vault withdrawal fees Extreme decimal differences Swap executor failures Approval hygiene Gas Benchmarking: Buy operation: ~635k gas Sell operation: ~478k gas
Orchestrator hasn't been changed recently for this cross-asset work. So the Orchestrator is still building orders assuming the old adapter behavior (underlying amounts), but my new adapter expects shares.
- Rename numeraireToken → underlyingAsset throughout - Rename parameters: estimatedNumeraireAmount → estimatedUnderlyingAmount - Consolidate return values to executionUnderlyingAmount - Add vault underlying decimals validation - Create DRY slippage helper functions - Remove try-catch blocks around swap execution - Remove all inline development comments - Fix mainnet fork test configuration
- Move slippage helper functions from ERC4626ExecutionAdapter to LiquidityOrchestrator - LiquidityOrchestrator now calculates max/min amounts and approves them - Adapter reads max amount from LO's allowance instead of calculating internally - Sell flow passes 0 as minAmount to swap executor (LO validates final amount) - Remove BASIS_POINTS_FACTOR constant from adapter (no longer needed) - Update contract documentation to reflect centralized slippage management
- Add UniswapV3TokenSwapExecutor for dedicated token swaps - Add ERC4626VaultAdapter that delegates to swap executors via LO.executionAdapterOf - Remove ERC4626ExecutionAdapter (replaced by dynamic architecture) - Update MockLiquidityOrchestrator with executionAdapterOf mapping - Add comprehensive E2E tests with mainnet forking - Architecture: tokens → swap executors, vaults → vault adapters → swap executors
New ERC4626 test includes all the test cases withing Adapters.test.ts -> removed repeated test Adapters.test
Now both buy and sell flows have proper slippage protection: Buy: Enforces max spending limit via approval amount Sell: Validates minimum received amount after execution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Introduce a new cross-asset ERC4626 execution and pricing architecture with external swap executors and Chainlink-based price feeds, and update tests and CI to validate cross-asset flows on a mainnet fork.
New Features:
Bug Fixes:
Enhancements:
Build:
CI:
Tests:
Summary by CodeRabbit
New Features
Refactor
Chores
Tests