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.fromAsset
    • params.amount
    • params.destinationAsset
    • params.destinationAddress
    • params.affiliateAddress (optional, default '')
    • params.interfaceID (optional, default `555`)
    • params.affiliateBps (optional, default 0)
    • params.toleranceBps
    • params.wallet
    • params.walletIndex

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

estimateAddSaver

Parameters

  • addAssetAmount

estimateWithdrawSaver

Parameters

  • withdrawParams

getSaverPosition

Parameters

  • getsaver

addSaver

Parameters

  • wallet wallet needed to execute tx
  • addAssetAmount asset amount being added to savers

Returns any submitted tx

withdrawSaver

Parameters

  • wallet wallet to execute the transaction
  • withdrawParams params needed for withdraw

getLoanQuoteOpen

Parameters

  • loanOpenParams

getLoanQuoteClose

Parameters

  • loanCloseParams

addLoan

Parameters

  • wallet wallet needed to execute transaction
  • loanOpenParams params needed to open the loan

Returns any submitted tx

withdrawLoan

Parameters

  • wallet wallet to execute the transaction
  • loanCloseParams params needed for withdrawing the loan

getThornamesByAddress

Get all Thornames and its data associated owned by an address

Parameters

  • address address

Returns any thornames data