Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions artifacts/amm-idl.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,13 @@
{
"name": "user_holding_a",
"writable": true,
"signer": true,
"signer": false,
"init": false
},
{
"name": "user_holding_b",
"writable": true,
"signer": true,
"signer": false,
"init": false
},
{
Expand Down Expand Up @@ -496,13 +496,13 @@
{
"name": "user_holding_a",
"writable": true,
"signer": true,
"signer": false,
"init": false
},
{
"name": "user_holding_b",
"writable": true,
"signer": true,
"signer": false,
"init": false
},
{
Expand Down
21 changes: 13 additions & 8 deletions programs/amm/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,17 @@ pub enum Instruction {
deadline: u64,
},

/// Swap some quantity of Tokens (either Token A or Token B)
/// while maintaining the Pool constant product.
/// Swap some quantity of tokens while maintaining the Pool constant product.
///
/// Swap direction is selected by `token_definition_id_in`; the selected input holding must be
/// authorized so the downstream token transfer can debit it.
///
/// Required accounts:
/// - AMM Pool (initialized)
/// - Vault Holding Account for Token A (initialized)
/// - Vault Holding Account for Token B (initialized)
/// - User Holding Account for Token A
/// - User Holding Account for Token B; either is authorized.
/// - User Holding Account for Token A (initialized)
/// - User Holding Account for Token B (initialized); the input holding is authorized.
/// - Current Tick Account, the pool's TWAP PDA derived as
/// `compute_current_tick_account_pda(twap_oracle_program_id, pool.account_id)`; refreshed
/// with the new spot price
Expand All @@ -193,15 +195,18 @@ pub enum Instruction {
deadline: u64,
},

/// Swap tokens specifying the exact desired output amount,
/// while maintaining the Pool constant product.
/// Swap tokens specifying the exact desired output amount while maintaining the Pool constant
/// product.
///
/// Swap direction is selected by `token_definition_id_in`; the selected input holding must be
/// authorized so the downstream token transfer can debit it.
///
/// Required accounts:
/// - AMM Pool (initialized)
/// - Vault Holding Account for Token A (initialized)
/// - Vault Holding Account for Token B (initialized)
/// - User Holding Account for Token A
/// - User Holding Account for Token B; either is authorized.
/// - User Holding Account for Token A (initialized)
/// - User Holding Account for Token B (initialized); the input holding is authorized.
/// - Current Tick Account, the pool's TWAP PDA derived as
/// `compute_current_tick_account_pda(twap_oracle_program_id, pool.account_id)`; refreshed
/// with the new spot price
Expand Down
14 changes: 10 additions & 4 deletions programs/amm/methods/guest/src/bin/amm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ mod amm {
}

/// Swap some quantity of tokens while maintaining the pool constant product.
///
/// `token_definition_id_in` selects the swap input token; the selected input holding must be
/// authorized for the downstream token transfer.
#[expect(
clippy::too_many_arguments,
reason = "instruction interface requires explicit pool, vault, user accounts, and bounds"
Expand All @@ -312,9 +315,9 @@ mod amm {
vault_a: AccountWithMetadata,
#[account(mut)]
vault_b: AccountWithMetadata,
#[account(mut, signer)]
#[account(mut)]
user_holding_a: AccountWithMetadata,
#[account(mut, signer)]
#[account(mut)]
user_holding_b: AccountWithMetadata,
#[account(mut)]
current_tick_account: AccountWithMetadata,
Expand Down Expand Up @@ -343,6 +346,9 @@ mod amm {
}

/// Swap tokens specifying the exact desired output amount.
///
/// `token_definition_id_in` selects the swap input token; the selected input holding must be
/// authorized for the downstream token transfer.
#[expect(
clippy::too_many_arguments,
reason = "instruction interface requires explicit pool, vault, user accounts, and bounds"
Expand All @@ -357,9 +363,9 @@ mod amm {
vault_a: AccountWithMetadata,
#[account(mut)]
vault_b: AccountWithMetadata,
#[account(mut, signer)]
#[account(mut)]
user_holding_a: AccountWithMetadata,
#[account(mut, signer)]
#[account(mut)]
user_holding_b: AccountWithMetadata,
#[account(mut)]
current_tick_account: AccountWithMetadata,
Expand Down
Loading
Loading