SPLTokenSwapProgram.deposit constructor

SPLTokenSwapProgram.deposit({
  1. required SolAddress tokenSwap,
  2. required SolAddress authority,
  3. required SolAddress userTransferAuthority,
  4. required SolAddress sourceA,
  5. required SolAddress sourceB,
  6. required SolAddress intoA,
  7. required SolAddress intoB,
  8. required SolAddress poolToken,
  9. required SolAddress poolAccount,
  10. required SolAddress mintA,
  11. required SolAddress mintB,
  12. required SolAddress swapProgramId,
  13. required SolAddress tokenProgramIdA,
  14. required SolAddress tokenProgramIdB,
  15. required SolAddress poolTokenProgramId,
  16. required SPLTokenSwapDepositLayout layout,
})

Deposit both types of tokens into the pool. The output is a "pool" token representing ownership in the pool. Inputs are converted to the current ratio.

Implementation

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

    /// swap authority
    required SolAddress authority,

    /// user transfer authority
    required SolAddress userTransferAuthority,
    // token_a user transfer authority can transfer amount
    required SolAddress sourceA,

    /// token_b user transfer authority can transfer amount
    required SolAddress sourceB,

    /// token_a Base Account to deposit into.
    required SolAddress intoA,

    /// token_b Base Account to deposit into.
    required SolAddress intoB,

    /// Pool MINT account, swap authority is the owner.
    required SolAddress poolToken,

    /// Pool Account to deposit the generated tokens
    required SolAddress poolAccount,

    /// Token A mint
    required SolAddress mintA,

    /// Token B mint
    required SolAddress mintB,
    required SolAddress swapProgramId,

    /// Token A program id
    required SolAddress tokenProgramIdA,

    /// Token B program id
    required SolAddress tokenProgramIdB,

    /// Pool Token program id
    required SolAddress poolTokenProgramId,
    required SPLTokenSwapDepositLayout layout}) {
  return SPLTokenSwapProgram(
      layout: layout,
      keys: [
        tokenSwap.toReadOnly(),
        authority.toReadOnly(),
        userTransferAuthority.toSigner(),
        sourceA.toWritable(),
        sourceB.toWritable(),
        intoA.toWritable(),
        intoB.toWritable(),
        poolToken.toWritable(),
        poolAccount.toWritable(),
        mintA.toReadOnly(),
        mintB.toReadOnly(),
        tokenProgramIdA.toReadOnly(),
        tokenProgramIdB.toReadOnly(),
        poolTokenProgramId.toReadOnly(),
      ],
      programId: swapProgramId);
}