11 Commits

Author SHA1 Message Date
Andrea Franz
36f78a21aa fix(amm): use checked mul/add/sub to avoid overflows/underflows 2026-04-09 19:11:36 +02:00
Andrea Franz
4419e1e9a0 chore(amm)!: rename Swap instruction to SwapExactInput
Renames the Swap instruction and its guest handler to SwapExactInput to
distinguish it from the newly added SwapExactOutput, and to make the
intent of each variant explicit at the call site.

BREAKING CHANGE: the Swap instruction variant and swap() function are
renamed to SwapExactInput and swap_exact_input(). Callers must update
instruction construction and any IDL-generated bindings.
2026-04-09 19:11:36 +02:00
Andrea Franz
664fd849bd feat(amm): add swap exact output instruction
Adds SwapExactOutput to the AMM, allowing callers to specify the exact
desired output amount while the protocol computes the required input
(ceiling division to prevent rounding in the protocol's favour).

The swap-exact-output success tests now use a dedicated small-pool
fixture (reserve_a=1_000, reserve_b=500) rather than the shared
pool_definition_init, which had its reserves bumped to 5_000/2_500 in a
later commit to satisfy the MINIMUM_LIQUIDITY invariant introduced for
new_definition. Using a dedicated fixture keeps each test self-contained
and avoids hardcoded expected values silently breaking when shared
baselines change.
2026-04-09 19:11:36 +02:00
Ricardo Guilherme Schmidt
e61cd594b5 feat(amm): add SyncReserves instruction
Adds a new `SyncReserves` instruction that updates a pool's recorded
reserves to match the actual vault balances. This allows the pool to
absorb donations (direct token transfers to vaults) without breaking
the invariant — only upward adjustments are permitted; vaults may
not be under-collateralized relative to reserves.

Vault reading helpers (`read_fungible_holding`,
`read_vault_fungible_balances`) are implemented in `amm_core` so they
can be shared across instructions without crossing crate boundaries.
2026-04-09 14:48:35 +02:00
Ricardo Guilherme Schmidt
fddd6e15bd feat(amm)!: introduce minimum liquidity lock on pool initialization
Permanently lock `MINIMUM_LIQUIDITY` (1_000) LP tokens in a dedicated
LP-lock holding PDA on pool creation, following the Uniswap v2 "dead
shares" pattern. The pool creator receives `initial_lp - MINIMUM_LIQUIDITY`
tokens instead of the full initial_lp amount.

Adds `compute_lp_lock_holding_pda` and `LP_LOCK_HOLDING_PDA_SEED` to
amm_core, updates new_definition to emit two sequential chained calls
(create LP definition + lock holding, then mint user share), and adjusts
remove liquidity to account for the permanently locked floor.

BREAKING CHANGE: NewDefinition instruction requires an additional LP-lock
holding account derived via `compute_lp_lock_holding_pda(amm_program_id, pool_id)`.
2026-04-09 14:33:49 +02:00
r4bbit
f89a8f9865 chore: update spel and logos-execution-zone dependencies
This removes the need to depend on a custom version, since the necessary
changes have landed in `spel` upstream.
2026-04-01 17:19:36 +02:00
r4bbit
9ebd9fcc12 cleanup(ata): remove redundant test directive 2026-04-01 17:11:51 +02:00
r4bbit
cb8426cbf1 skills: update spel-cli references to use spel 2026-04-01 12:17:52 +02:00
r4bbit
6287bd9df9 chore(ata): add IDL for ata program 2026-04-01 12:17:26 +02:00
r4bbit
45ed284825 chore: initial repository setup for programs 2026-03-30 23:58:43 +02:00
r4bbit
d61d02adf6
Initial commit 2026-03-17 10:18:51 +01:00