SPLTokenSwapProgram.create constructor

SPLTokenSwapProgram.create({
  1. required SolAddress tokenSwapAccount,
  2. required SolAddress authority,
  3. required SolAddress tokenAccountA,
  4. required SolAddress tokenAccountB,
  5. required SolAddress tokenPool,
  6. required SolAddress feeAccount,
  7. required SolAddress tokenAccountPool,
  8. required SolAddress poolTokenProgramId,
  9. required SolAddress swapProgramId,
  10. required SPLTokenSwapInitSwapLayout layout,
})

Initializes a new swap

Implementation

factory SPLTokenSwapProgram.create(
    {
    /// New Token-swap to create.
    required SolAddress tokenSwapAccount,

    /// swap authority derived from
    required SolAddress authority,

    /// token_a Account. Must be non zero, owned by swap authority.
    required SolAddress tokenAccountA,

    /// token_b Account. Must be non zero, owned by swap authority.
    required SolAddress tokenAccountB,

    /// Pool Token Account to deposit trading and withdraw fees.
    required SolAddress tokenPool,
    required SolAddress feeAccount,

    /// Pool Token Account to deposit the initial pool token
    required SolAddress tokenAccountPool,

    /// Pool Token program id
    required SolAddress poolTokenProgramId,
    required SolAddress swapProgramId,
    required SPLTokenSwapInitSwapLayout layout}) {
  return SPLTokenSwapProgram(
      layout: layout,
      keys: [
        tokenSwapAccount.toWritable(),
        authority.toReadOnly(),
        tokenAccountA.toReadOnly(),
        tokenAccountB.toReadOnly(),
        tokenPool.toWritable(),
        feeAccount.toReadOnly(),
        tokenAccountPool.toWritable(),
        poolTokenProgramId.toReadOnly(),
      ],
      programId: swapProgramId);
}