Solana.SPL.TokenSwap (Solana v0.1.0)
View SourceFunctions for interacting with Solana's Token Swap Program.
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.
Functions
@spec 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. theswapaccount's swap authority.:user_token- Required. The user's account for tokenAorB.:swap_a- Required. Theswapaccount for tokenA.:swap_b- Required. Theswapaccount for tokenB.:user_pool- Required. The user's account for the pool token. Pool tokens will be deposited here.:pool_mint- Required. Theswappool token's mint.:user_authority- Required. Account delegated to transfer the user's tokens.:amount(pos_integer/0) - Required. Amount of tokenAorBto deposit.:amount_pool(pos_integer/0) - 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. theswapaccount's swap authority.:user_a- Required. The user's account for tokenA.:user_b- Required. The user's account for tokenB.:swap_a- Required. Theswapaccount for tokenA.:swap_b- Required. Theswapaccount for tokenB.:user_pool- Required. The user's account for the pool token. Pool tokens will be deposited here.:pool_mint- Required. Theswappool token's mint.:user_authority- Required. Account delegated to transfer the user's tokens.:amount_a(pos_integer/0) - Required. Maximum amount of tokenAto deposit.:amount_b(pos_integer/0) - Required. Maximum amount of tokenBto deposit.:amount_pool(pos_integer/0) - Required. Amount of pool tokens to mint.
Translates the result of a Solana.RPC.Request.get_account_info/2 into
token swap account information.
@spec 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(non_neg_integer/0) - 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. TheAtoken account in token swaps. Must be owned byauthority.:token_b- Required. TheBtoken account in token swaps. Must be owned byauthority.:pool- Required. The token account which holds outside liquidity and enables A/B trades.:pool_mint- Required. The mint of thepool.:fee_account- Required. The token account which receives all trading and withdrawal fees.:trade_fee- Thenewswap 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- Thenewswap 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- Thenewswap 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- Thenewswap 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 thenewtoken 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. theswapaccount's swap authority.:user_source- Required. User's source token account. Must have the same mint asswap_source.:swap_source- Required.swapsource token account. Must have the same mint asuser_source.:user_destination- Required. User's destination token account. Must have the same mint asswap_destination.:swap_destination- Required.swapdestination token account. Must have the same mint asuser_destination.:pool_mint- Required. Theswappool 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(pos_integer/0) - Required. Amount to transfer from the source account.:minimum_return(pos_integer/0) - 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. theswapaccount's swap authority.:user_token- Required. The user's account for tokenAorB.:swap_a- Required. Theswapaccount for tokenA.:swap_b- Required. Theswapaccount for tokenB.:user_pool- Required. The user's account for the pool token. Pool tokens with be withdrawn from here.:pool_mint- Required. Theswappool 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(pos_integer/0) - Required. Amount of tokenAorBto withdraw.:amount_pool(pos_integer/0) - 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. theswapaccount's swap authority.:user_a- Required. The user's account for tokenA.:user_b- Required. The user's account for tokenB.:swap_a- Required. Theswapaccount for tokenA.:swap_b- Required. Theswapaccount for tokenB.:user_pool- Required. The user's account for the pool token. Pool tokens with be withdrawn from here.:pool_mint- Required. Theswappool 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(pos_integer/0) - Required. Minimum amount of tokenAto withdraw.:amount_b(pos_integer/0) - Required. Minimum amount of tokenBto withdraw.:amount_pool(pos_integer/0) - Required. Amount of pool tokens to burn.