SPLTokenSwapProgram.swap constructor
SPLTokenSwapProgram.swap({
- required SolAddress tokenSwap,
- required SolAddress authority,
- required SolAddress userTransferAuthority,
- required SolAddress userSource,
- required SolAddress poolSource,
- required SolAddress poolDestination,
- required SolAddress userDestination,
- required SolAddress poolMint,
- required SolAddress feeAccount,
- required SolAddress sourceMint,
- required SolAddress destinationMint,
- required SolAddress sourceTokenProgramId,
- required SolAddress destinationTokenProgramId,
- required SolAddress poolTokenProgramId,
- required SPLTokenSwapSwapLayout layout,
- required SolAddress swapProgramId,
- SolAddress? hostFeeAccount,
Swap the tokens in the pool.
Implementation
factory SPLTokenSwapProgram.swap({
/// Token-swap
required SolAddress tokenSwap,
/// swap authority
required SolAddress authority,
/// user transfer authority
required SolAddress userTransferAuthority,
/// token_(A|B) SOURCE Account, amount is transferable by
/// user transfer authority,
required SolAddress userSource,
/// token_(A|B) Base Account to swap INTO. Must be the
/// SOURCE token.
required SolAddress poolSource,
/// token_(A|B) Base Account to swap FROM. Must be the
/// DESTINATION token.
required SolAddress poolDestination,
/// token_(A|B) DESTINATION Account assigned to USER as
/// the owner.
required SolAddress userDestination,
/// Pool token mint, to generate trading fees
required SolAddress poolMint,
/// Fee account, to receive trading fees
required SolAddress feeAccount,
/// Token (A|B) SOURCE mint
required SolAddress sourceMint,
/// Token (A|B) DESTINATION mint
required SolAddress destinationMint,
/// Token (A|B) SOURCE program id
required SolAddress sourceTokenProgramId,
/// Token (A|B) DESTINATION program id
required SolAddress destinationTokenProgramId,
/// Pool Token program id
required SolAddress poolTokenProgramId,
required SPLTokenSwapSwapLayout layout,
required SolAddress swapProgramId,
/// Host fee account to receive additional
/// trading fees
SolAddress? hostFeeAccount,
}) {
return SPLTokenSwapProgram(
layout: layout,
keys: [
tokenSwap.toReadOnly(),
authority.toReadOnly(),
userTransferAuthority.toSigner(),
userSource.toWritable(),
poolSource.toWritable(),
poolDestination.toWritable(),
userDestination.toWritable(),
poolMint.toWritable(),
feeAccount.toWritable(),
sourceMint.toReadOnly(),
destinationMint.toReadOnly(),
sourceTokenProgramId.toReadOnly(),
destinationTokenProgramId.toReadOnly(),
poolTokenProgramId.toReadOnly(),
if (hostFeeAccount != null) hostFeeAccount.toWritable()
],
programId: swapProgramId);
}