Solana.SPL.TokenSwap (Solana.SPL v0.1.1) View Source

Functions for interacting with Solana's Token Swap Program.

Link to this section Summary

Functions

The size of a serialized token swap account.

Creates the instructions to deposit A or B tokens into the pool.

Creates the instructions to deposit both A and B tokens into the pool.

Translates the result of a Solana.RPC.Request.get_account_info/2 into token swap account information.

The Token Swap Program's ID.

Creates the instructions to initialize a new token swap account.

Creates the instructions to swap token A for token B or vice versa.

Creates the instructions to withdraw A or B tokens from the pool.

Creates the instructions to withdraw both A and B tokens from the pool.

Link to this section Functions

Specs

byte_size() :: pos_integer()

The size of a serialized token swap account.

Creates the instructions to deposit A or B tokens into the pool.

Options

  • :swap - Required. The token swap to use.

  • :authority - Required. the swap account's swap authority.

  • :user_token - Required. The user's account for token A or B.

  • :swap_a - Required. The swap account for token A.

  • :swap_b - Required. The swap account for token B.

  • :user_pool - Required. The user's account for the pool token. Pool tokens will be deposited here.

  • :pool_mint - Required. The swap pool token's mint.

  • :user_authority - Required. Account delegated to transfer the user's tokens.

  • :amount - Required. Amount of token A or B to deposit.

  • :amount_pool - Required. Minimum amount of pool tokens to mint.

Creates the instructions to deposit both A and B tokens into the pool.

Options

  • :swap - Required. The token swap to use.

  • :authority - Required. the swap account's swap authority.

  • :user_a - Required. The user's account for token A.

  • :user_b - Required. The user's account for token B.

  • :swap_a - Required. The swap account for token A.

  • :swap_b - Required. The swap account for token B.

  • :user_pool - Required. The user's account for the pool token. Pool tokens will be deposited here.

  • :pool_mint - Required. The swap pool token's mint.

  • :user_authority - Required. Account delegated to transfer the user's tokens.

  • :amount_a - Required. Maximum amount of token A to deposit.

  • :amount_b - Required. Maximum amount of token B to deposit.

  • :amount_pool - Required. Amount of pool tokens to mint.

Specs

from_account_info(info :: map()) :: map() | :error

Translates the result of a Solana.RPC.Request.get_account_info/2 into token swap account information.

Specs

id() :: binary()

The Token Swap Program's ID.

Creates the instructions to initialize a new token swap account.

Options

  • :payer - Required. The account that will pay for the token swap account creation.

  • :balance - Required. The lamport balance the token swap account should have.

  • :authority - Required. The token swap account's swap authority

  • :new - Required. The public key of the newly-created token swap account.

  • :token_a - Required. The A token account in token swaps. Must be owned by authority.

  • :token_b - Required. The B token account in token swaps. Must be owned by authority.

  • :pool - Required. The token account which holds outside liquidity and enables A/B trades.

  • :pool_mint - Required. The mint of the pool.

  • :fee_account - Required. The token account which receives all trading and withdrawal fees.

  • :trade_fee - The new swap account's trading fee. Trade fees are extra token amounts that are held inside the token accounts during a trade, making the value of liquidity tokens rise. The default value is {0, 1}.

  • :owner_trade_fee - The new swap account's owner trading fee. Owner trading fees are extra token amounts that are held inside the token accounts during a trade, with the equivalent in pool tokens minted to the owner of the program. The default value is {0, 1}.

  • :owner_withdraw_fee - The new swap account's owner withdraw fee. Owner withdraw fees are extra liquidity pool token amounts that are sent to the owner on every withdrawal. The default value is {0, 1}.

  • :host_fee - The new swap account's host fee. Host fees are a proportion of the owner trading fees, sent to an extra account provided during the trade. The default value is {0, 1}.

  • :curve - Required. The automated market maker (AMM) curve to use for the new token swap account. Should take the form {type, params}. See the docs on which curves are available.

Creates the instructions to swap token A for token B or vice versa.

Options

  • :swap - Required. The token swap to use.

  • :authority - Required. the swap account's swap authority.

  • :user_source - Required. User's source token account. Must have the same mint as swap_source.

  • :swap_source - Required. swap source token account. Must have the same mint as user_source.

  • :user_destination - Required. User's destination token account. Must have the same mint as swap_destination.

  • :swap_destination - Required. swap destination token account. Must have the same mint as user_destination.

  • :pool_mint - Required. The swap pool token's mint.

  • :fee_account - Required. The token account which receives all trading and withdrawal fees.

  • :host_fee_account - Host account to gather fees.

  • :user_authority - Required. Account delegated to transfer the user's tokens.

  • :amount - Required. Amount to transfer from the source account.

  • :minimum_return - Required. Minimum number of tokens the user will receive.

Creates the instructions to withdraw A or B tokens from the pool.

Options

  • :swap - Required. The token swap to use.

  • :authority - Required. the swap account's swap authority.

  • :user_token - Required. The user's account for token A or B.

  • :swap_a - Required. The swap account for token A.

  • :swap_b - Required. The swap account for token B.

  • :user_pool - Required. The user's account for the pool token. Pool tokens with be withdrawn from here.

  • :pool_mint - Required. The swap pool token's mint.

  • :user_authority - Required. Account delegated to transfer the user's tokens.

  • :fee_account - Required. The token account which receives all trading and withdrawal fees.

  • :amount - Required. Amount of token A or B to withdraw.

  • :amount_pool - Required. Maximum amount of pool tokens to burn.

Creates the instructions to withdraw both A and B tokens from the pool.

Options

  • :swap - Required. The token swap to use.

  • :authority - Required. the swap account's swap authority.

  • :user_a - Required. The user's account for token A.

  • :user_b - Required. The user's account for token B.

  • :swap_a - Required. The swap account for token A.

  • :swap_b - Required. The swap account for token B.

  • :user_pool - Required. The user's account for the pool token. Pool tokens with be withdrawn from here.

  • :pool_mint - Required. The swap pool token's mint.

  • :user_authority - Required. Account delegated to transfer the user's tokens.

  • :fee_account - Required. The token account which receives all trading and withdrawal fees.

  • :amount_a - Required. Minimum amount of token A to withdraw.

  • :amount_b - Required. Minimum amount of token B to withdraw.

  • :amount_pool - Required. Amount of pool tokens to burn.