Thorchain Amm

ThorchainAMM

THORChain Class for interacting with THORChain. Recommended main class to use for swapping with THORChain Has access to Midgard and THORNode data

Parameters

  • thorchainQuery an instance of the ThorchainQuery (optional, default defaultQuery)

estimateSwap

Provides a swap estimate for the given swap detail. Will check the params for errors before trying to get the estimate. Uses current pool data, works out inbound and outboud fee, affiliate fees and works out the expected wait time for the swap (in and out)

Parameters

  • params Object amount to swap
    • params.input
    • params.destinationAsset
    • params.destinationAddress
    • params.affiliateAddress (optional, default '')
    • params.interfaceID (optional, default 999)
    • params.affiliateFeePercent (optional, default 0)
    • params.slipLimit

Returns any The SwapEstimate

doSwap

Conducts a swap with the given inputs. Should be called after estimateSwap() to ensure the swap is valid

Parameters

  • wallet wallet to use
  • params swap params

Returns SwapSubmitted Tx Hash, URL of BlockExplorer and expected wait time.

estimateAddLiquidity

Wraps estimate from thorchain query

Parameters

  • params estimate add liquidity

Returns any Estimate add lp object

estimateWithdrawLiquidity

Wraps estimate withdraw from thorchain query

Parameters

  • params estimate withdraw liquidity

Returns any Estimate withdraw lp object

addLiquidityPosition

Parameters

  • wallet wallet class
  • params liquidity parameters

withdrawLiquidityPosition

Parameters

  • wallet wallet needed to perform tx
  • params liquidity parameters