SPLTokenSwapProgram.withdraw constructor

SPLTokenSwapProgram.withdraw({
  1. required SolAddress tokenSwap,
  2. required SolAddress authority,
  3. required SolAddress userTransferAuthority,
  4. required SolAddress poolMint,
  5. required SolAddress feeAccount,
  6. required SolAddress sourcePoolAccount,
  7. required SolAddress fromA,
  8. required SolAddress fromB,
  9. required SolAddress userAccountA,
  10. required SolAddress userAccountB,
  11. required SolAddress mintA,
  12. required SolAddress mintB,
  13. required SolAddress poolTokenProgramId,
  14. required SolAddress tokenProgramIdA,
  15. required SolAddress tokenProgramIdB,
  16. required SPLTokenSwapWithdrawLayout layout,
  17. required SolAddress swapProgramId,
})

Withdraw both types of tokens from the pool at the current ratio, given pool tokens. The pool tokens are burned in exchange for an equivalent amount of token A and B.

Implementation

factory SPLTokenSwapProgram.withdraw({
  /// Token-swap
  required SolAddress tokenSwap,

  /// swap authority
  required SolAddress authority,

  /// user transfer authority
  required SolAddress userTransferAuthority,

  /// Pool mint account, swap authority is the owner
  required SolAddress poolMint,

  /// Fee account, to receive withdrawal fees
  required SolAddress feeAccount,

  /// SOURCE Pool account, amount is transferable by user
  /// transfer authority.
  required SolAddress sourcePoolAccount,

  /// token_a Swap Account to withdraw FROM.
  required SolAddress fromA,

  /// token_b Swap Account to withdraw FROM.
  required SolAddress fromB,

  /// token_a user Account to credit.
  required SolAddress userAccountA,

  /// token_b user Account to credit.
  required SolAddress userAccountB,

  /// Token A mint
  required SolAddress mintA,

  /// Token B mint
  required SolAddress mintB,

  /// Pool Token program id
  required SolAddress poolTokenProgramId,

  /// Token A program id
  required SolAddress tokenProgramIdA,

  /// Token B program id
  required SolAddress tokenProgramIdB,
  required SPLTokenSwapWithdrawLayout layout,
  required SolAddress swapProgramId,
}) {
  return SPLTokenSwapProgram(
      layout: layout,
      keys: [
        tokenSwap.toReadOnly(),
        authority.toReadOnly(),
        userTransferAuthority.toSigner(),
        poolMint.toWritable(),
        sourcePoolAccount.toWritable(),
        fromA.toWritable(),
        fromB.toWritable(),
        userAccountA.toWritable(),
        userAccountB.toWritable(),
        feeAccount.toWritable(),
        mintA.toReadOnly(),
        mintB.toReadOnly(),
        poolTokenProgramId.toReadOnly(),
        tokenProgramIdA.toReadOnly(),
        tokenProgramIdB.toReadOnly(),
      ],
      programId: swapProgramId);
}