fix(amm): require signer on user token holdings in swap and add-liquidity

The swap and add-liquidity instructions debited user-owned token holdings
without requiring those accounts to be signers. Mark them `signer` so a
transaction can't move a user's tokens without their authorization:

- add liquidity: `user_holding_lp` is now `#[account(mut, signer)]`
- swap (both directions): `user_holding_a` and `user_holding_b` are now
  `#[account(mut, signer)]`

Regenerate artifacts/amm-idl.json to reflect the new signer metadata.

Update integration tests accordingly: swaps now sign and supply nonces for
both user holdings (incrementing both nonces), and
`amm_new_definition_precreated_zero_balance_user_lp` becomes
`amm_new_definition_precreated_user_lp_unsigned_fails`, asserting an unsigned
pre-existing LP holding is rejected and the transaction reverts.
This commit is contained in:
r4bbit
2026-06-29 09:00:30 +02:00
parent 065a4e4937
commit 4cd7c074f1
4 changed files with 250 additions and 377 deletions
+5 -5
View File
@@ -194,7 +194,7 @@
{
"name": "user_holding_lp",
"writable": true,
"signer": false,
"signer": true,
"init": false
},
{
@@ -425,13 +425,13 @@
{
"name": "user_holding_a",
"writable": true,
"signer": false,
"signer": true,
"init": false
},
{
"name": "user_holding_b",
"writable": true,
"signer": false,
"signer": true,
"init": false
},
{
@@ -496,13 +496,13 @@
{
"name": "user_holding_a",
"writable": true,
"signer": false,
"signer": true,
"init": false
},
{
"name": "user_holding_b",
"writable": true,
"signer": false,
"signer": true,
"init": false
},
{