10 Commits

Author SHA1 Message Date
Ricardo Guilherme Schmidt
e41d847667
Add malicious ATA methods and corresponding integration tests
- Introduced a new Cargo.toml for the malicious ATA guest program.
- Implemented malicious ATA methods in `malicious_ata.rs`, including create, transfer, and burn functions that simulate malicious behavior.
- Updated the integration test suite to include tests for the malicious ATA program, ensuring it is rejected in various value paths.
- Enhanced existing tests to accommodate the new malicious ATA program and verify that it does not affect the expected state of the AMM.
2026-04-23 11:28:10 -03:00
r4bbit
9444d72c60
feat(amm): route user deposits and LP burns through ATA program
Add `owner` and `ata_program_id` parameters to `add_liquidity`,
`remove_liquidity`, `swap_exact_input`, and `swap_exact_output`. User
deposit-side transfers now emit `ATA::Transfer` chained calls instead of
`Token::Transfer` directly, and LP burns emit `ATA::Burn` instead of
`Token::Burn`. Vault withdrawal chained calls are unchanged.

- Add `ata_program_id` field to `AddLiquidity`, `RemoveLiquidity`,
  `SwapExactInput`, and `SwapExactOutput` instruction variants in
  `amm_core`
- Add `ata_core` dependency to `amm_program` and guest crates
- Update guest binary, unit tests, and integration tests to supply the
  new `owner` account and `ata_program_id` at every call site
- Regenerate `artifacts/amm-idl.json`

Closes #11
2026-04-22 14:35:30 +02:00
Ricardo Guilherme Schmidt
471abef719 refactor!: Update dependencies and implement new required features across multiple modules
- Updated `nssa_core` and `spel-framework` dependencies to their respective release candidates in `Cargo.toml` and `Cargo.lock` files for `amm`, `ata`, and `token` modules.
- Enhanced the `new_definition` function in `amm/src/new_definition.rs` to include new claim logic and updated PDA seed calculations.
- Modified tests in `integration_tests/tests/amm.rs`, `integration_tests/tests/ata.rs`, and `integration_tests/tests/token.rs` to accommodate changes in transaction handling and account initialization.
- Refactored account initialization logic in `ata/src/create.rs` and `token/src/initialize.rs` to include authorization claims.
- Updated various functions in `token/src/mint.rs`, `token/src/new_definition.rs`, and `token/src/transfer.rs` to utilize the new claim system for account states.
- Adjusted the IDL generation tool to use the latest version of `spel-framework-core`.
2026-04-20 12:25:59 +02:00
Ricardo Guilherme Schmidt
6c86b5b9ce feat(amm): apply trading fees to LP accounting
Implement Uniswap V2-style fees-in-reserves: the full swap_amount_in is
deposited into the reserve (growing k = reserve_a * reserve_b), while
only the fee-adjusted effective_amount_in is used to compute the output
amount. This means LPs earn fees proportionally on every removal via
k-growth rather than through a separate vault surplus.

- swap_logic: add fee_bps parameter; compute effective_amount_in for
  output formula only; return full swap_amount_in as the reserve deposit
- Fix all integration test fixture values to match fees-in-reserves math
- Remove dead-code vault_a/b_init_zero helpers from unit tests
2026-04-20 11:29:00 +02:00
Andrea Franz
1f8eea8442 chore(amm): new_definition allows only uninitialized pools 2026-04-14 13:10:09 +02:00
Ricardo Guilherme Schmidt
4a9a441ccd refactor(amm)!: derive pool active state from LP supply instead of explicit flag
Remove the `active: bool` field from `PoolDefinition` and replace it with an
implicit invariant: a pool is considered active when
`liquidity_pool_supply >= MINIMUM_LIQUIDITY`.

BREAKING CHANGE: `PoolDefinition` Borsh serialization format has changed.
Existing on-chain pool accounts encoded with the `active` field are
incompatible with this version.

Closes #25
2026-04-14 11:57:26 +02:00
Ricardo Guilherme Schmidt
9824cd8f90 feat(amm): add configurable fee tiers
- accept a supported fee tier in pool creation
- store fee tiers in AMM pool state and validate them
- update AMM tests and IDL for the new pool creation argument
2026-04-10 13:16:05 +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
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
45ed284825 chore: initial repository setup for programs 2026-03-30 23:58:43 +02:00