Options
All
  • Public
  • Public/Protected
  • All
Menu

Swap class represents a swap trade on a particular pool.

Typically, users don't have to manually instantiate this class. Use Pool.prepareSwap instead.

Hierarchy

  • Swap

Index

Constructors

  • new Swap(pool: Pool, assetDeposited: Asset, amount: number, slippagePct: number, swapForExact?: boolean): Swap
  • Parameters

    • pool: Pool

      The pool the swap is going to be performed in.

    • assetDeposited: Asset

      The asset that will be swapped (deposited in the contract).

    • amount: number

      Either the amount to swap (deposit) or the amount to receive depending on the swapForExact parameter.

    • slippagePct: number

      The maximum amount of slippage allowed in performing the swap.

    • swapForExact: boolean = false

      If true then amount is what you want to receive from the swap. Otherwise, it's an amount that you want to swap (deposit).

    Returns Swap

Properties

amount: number

Either the amount to swap (deposit) or the amount to receive depending on the swapForExact parameter.

assetDeposited: Asset

The asset that will be swapped (deposited in the contract).

assetReceived: Asset

The asset that will be received.

effect: SwapEffect

The effect of the swap computed at the time of construction.

pool: Pool

The pool the swap is going to be performed in.

slippagePct: number

The maximum amount of slippage allowed in performing the swap.

swapForExact: boolean = false

If true then amount is what you want to receive from the swap. Otherwise, it's an amount that you want to swap (deposit). Note that the contracts do not support the "swap exact for" swap. It works by calculating the amount to deposit on the client side and doing a normal swap on the exchange.

Methods

  • Creates the transactions needed to perform the swap trade and returns them as a transaction group ready to be signed and committed.

    Parameters

    • address: string

      The account that will be performing the swap.

    Returns Promise<TransactionGroup>

    A transaction group that when executed will perform the swap.

  • validateSwap(): void

Generated using TypeDoc