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. theswap
account's swap authority.:user_token
- Required. The user's account for tokenA
orB
.:swap_a
- Required. Theswap
account for tokenA
.:swap_b
- Required. Theswap
account for tokenB
.:user_pool
- Required. The user's account for the pool token. Pool tokens will be deposited here.:pool_mint
- Required. Theswap
pool token's mint.:user_authority
- Required. Account delegated to transfer the user's tokens.:amount
- Required. Amount of tokenA
orB
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. theswap
account's swap authority.:user_a
- Required. The user's account for tokenA
.:user_b
- Required. The user's account for tokenB
.:swap_a
- Required. Theswap
account for tokenA
.:swap_b
- Required. Theswap
account for tokenB
.:user_pool
- Required. The user's account for the pool token. Pool tokens will be deposited here.:pool_mint
- Required. Theswap
pool token's mint.:user_authority
- Required. Account delegated to transfer the user's tokens.:amount_a
- Required. Maximum amount of tokenA
to deposit.:amount_b
- Required. Maximum amount of tokenB
to deposit.:amount_pool
- Required. Amount of pool tokens to mint.
Specs
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. TheA
token account in token swaps. Must be owned byauthority
.:token_b
- Required. TheB
token 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
- Thenew
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
- Thenew
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
- Thenew
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
- Thenew
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 thenew
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. theswap
account's swap authority.:user_source
- Required. User's source token account. Must have the same mint asswap_source
.:swap_source
- Required.swap
source 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.swap
destination token account. Must have the same mint asuser_destination
.:pool_mint
- Required. Theswap
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. theswap
account's swap authority.:user_token
- Required. The user's account for tokenA
orB
.:swap_a
- Required. Theswap
account for tokenA
.:swap_b
- Required. Theswap
account for tokenB
.:user_pool
- Required. The user's account for the pool token. Pool tokens with be withdrawn from here.:pool_mint
- Required. Theswap
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 tokenA
orB
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. theswap
account's swap authority.:user_a
- Required. The user's account for tokenA
.:user_b
- Required. The user's account for tokenB
.:swap_a
- Required. Theswap
account for tokenA
.:swap_b
- Required. Theswap
account for tokenB
.:user_pool
- Required. The user's account for the pool token. Pool tokens with be withdrawn from here.:pool_mint
- Required. Theswap
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 tokenA
to withdraw.:amount_b
- Required. Minimum amount of tokenB
to withdraw.:amount_pool
- Required. Amount of pool tokens to burn.