Skip to content

Conversation

@josh-orca
Copy link
Contributor

@josh-orca josh-orca commented Nov 5, 2025

This PR introduces a new v2-only instruction that increases position liquidity by specifying token maxima (token_max_a / token_max_b) instead of a direct liquidity amount. It wires the instruction into the program entrypoint, exposes it through the legacy SDK builders and facade, and adds comprehensive parity-level integration tests.


Program (Anchor / Solana)

  • New Handler: increase_liquidity_by_token_amounts_v2.
  • Entry Point: Added the new instruction to programs/whirlpool/src/lib.rs and v2 mod re-exports.
  • Math: Introduced estimate_max_liquidity_from_token_amounts to safely compute liquidity from token maxima using U256 utilities for safe, overflow-free, and fee-aware arithmetic.
  • Events/Errors: Emits the standard LiquidityIncreased event. Returns LiquidityZero when maxima imply no computed liquidity, and TokenMaxExceeded if fee-inclusive amounts surpass the maxima.

Generated Code

  • The IDL (target/idl/whirlpool.json) has been updated.
  • Generated TS/Rust clients are refreshed to include increaseLiquidityByTokenAmountsV2.

Legacy SDK (Builders and Facade)

  • New Builder: legacy-sdk/whirlpool/src/instructions/v2/increase-liquidity-by-token-amounts-ix.ts. Handles transfer-hook remaining accounts and memo program logic.
  • Facade: Added WhirlpoolIx.increaseLiquidityByTokenAmountsV2Ix(...) in src/ix.ts.

Tests (Parity-Level Integration)

A new test suite, increase_liquidity_by_token_amounts_v2.test.ts, provides extensive coverage, including:

  • Token vs Token-2022 variants and two-array/single-array add-liquidity scenarios.
  • Dynamic tick arrays: rent transfer and account resize checks.
  • Delegate flows: successful approved delegate and various failure cases (not-signer, not-approved owner).
  • Invalid accounts (e.g., mint mismatches, position/whirlpool mismatches).
  • Program/Memo constraints (wrong token program A/B, wrong memo program).
  • Extreme price (near min/max) MAX_U64 edge cases.
  • Sqrt price constraints and extremes minSqrtPrice/maxSqrtPrice enforced at current price with pass/fail cases; out-of-bounds yields 0x177b (SqrtPriceOutOfBounds).

@josh-orca
Copy link
Contributor Author

Canceling in favor of alternative PR

@josh-orca josh-orca closed this Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants