SPLTokenSwapProgram.withdrawSingleToken constructor

SPLTokenSwapProgram.withdrawSingleToken({
  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 destinationAccount,
  10. required SolAddress destinationMint,
  11. required SolAddress poolTokenProgramId,
  12. required SolAddress destinationTokenProgramId,
  13. required SPLTokenSwapWithdrawSingleTokenLayout layout,
  14. required SolAddress swapProgramId,
})

Withdraw one token type from the pool at the current ratio given the exact amount out expected.

Implementation

factory SPLTokenSwapProgram.withdrawSingleToken({
  /// 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 potentially withdraw from.
  required SolAddress fromA,

  /// token_b Swap Account to potentially withdraw from.
  required SolAddress fromB,

  /// Destination account
  required SolAddress destinationAccount,

  /// Token (A|B) DESTINATION mint
  required SolAddress destinationMint,

  /// Pool Token program id
  required SolAddress poolTokenProgramId,

  /// Token (A|B) DESTINATION program id
  required SolAddress destinationTokenProgramId,
  required SPLTokenSwapWithdrawSingleTokenLayout layout,
  required SolAddress swapProgramId,
}) {
  return SPLTokenSwapProgram(
      layout: layout,
      keys: [
        tokenSwap.toReadOnly(),
        authority.toReadOnly(),
        userTransferAuthority.toSigner(),
        poolMint.toWritable(),
        sourcePoolAccount.toWritable(),
        fromA.toWritable(),
        fromB.toWritable(),
        destinationAccount.toWritable(),
        feeAccount.toWritable(),
        destinationMint.toReadOnly(),
        poolTokenProgramId.toReadOnly(),
        destinationTokenProgramId.toReadOnly()
      ],
      programId: swapProgramId);
}