test(swap-vm): concentrated liquidity single-sided position tests at 1800 USDC/WETH market price#77
Draft
krboktv wants to merge 1 commit into
Draft
Conversation
… at 1800 USDC/WETH market price Co-authored-by: Kirill <krboktv@gmail.com>
|
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
Adds test coverage for concentrated liquidity single-sided positions with the market price at 1800 USDC per WETH — positions where the whole price range sits on one side of the market, so the LP deposits only one token (Uniswap V3-style limit-order liquidity).
Unit tests
price-range.test.ts— newsingle-sided positions (1800 USDC per WETH market price)block:computeMaxAllocationfor a 1800–2200 range above the market allocates WETH only (USDC reserve is exactly0)computeMaxAllocationfor a 1500–1800 range below the market allocates USDC only (WETH reserve is exactly0)computeFixedAllocationsingle-sided equivalents for both rangesfromPriceBoundsfrom a USDC-only allocation returns exactly1800concentrate-liquidity-math.test.ts— newsingle-sided position at 1800 USDC per WETH market priceblock:computeLiquidityFromAmountswith spot at the sqrt max bound (range above market) yieldsactualLt = 0(WETH-only)computeLiquidityFromAmountswith spot at the sqrt min bound (range below market) yieldsactualGt = 0(USDC-only)computeLiquidityAndPricerecovers the spot at the range bound from single-sided (one-token) balances for both casesE2E tests (
tests/swap-vm.spec.ts)Two fork-based tests over
AquaXYCAmmStrategy.newConcentrate:0USDC / ~400 WETH, verifies the wrong-direction swap (WETH → USDC) reverts on-chain since the position holds no USDC, then swaps 1800 USDC and gets ~1 WETH at an effective price of1800.4296(right at the bound plus slippage).0WETH, verifies USDC → WETH reverts, then sells 1 WETH for1799.717746USDC.Both tests also assert that both tokens must still be registered in the Aqua strategy (the empty side is shipped with amount
0), becauseAqua.safeBalancesreverts withSafeBalancesForTokenNotInActiveStrategyotherwise.Note: at the range boundary the price bounds must be passed in sqrt(P) order (higher human USDC-per-WETH quote = lower sqrt) —
PriceRange.newcannot normalize human-ordered bounds when spot coincides with a bound; the tests document this with comments.Verification
601 passed(592 baseline + 9 new) —pnpm vitest runintypescript/swap-vm