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

Constructors

  • Constructor to create a ThorchainAMM instance

    Parameters

    • thorchainQuery: ThorchainQuery = ...

      an instance of the ThorchainQuery

    • wallet: Wallet = ...

    Returns ThorchainAMM

    ThorchainAMM

Properties

thorchainQuery: ThorchainQuery
wallet: Wallet

Methods

  • If there is no existing liquidity position, it is created automatically.

    Parameters

    • params: AddliquidityPosition

      Liquidity parameter

    Returns Promise<TxSubmitted[]>

  • Opens a loan.

    Parameters

    • loanOpenParams: LoanOpenParams

      The parameters for opening the loan.

    Returns Promise<TxSubmitted>

    • The submitted transaction.
  • Adds assets to a saver.

    Parameters

    • addAssetAmount: CryptoAmount

      The amount to add to the saver.

    Returns Promise<TxSubmitted>

    • The submitted transaction.
  • Conducts a swap with the given inputs. This method should be called after estimateSwap() to ensure the swap is valid.

    Parameters

    • __namedParameters: QuoteSwapParams

    Returns Promise<TxSubmitted>

    • The transaction hash, URL of BlockExplorer, and expected wait time.
  • Wraps the estimate from ThorchainQuery for adding liquidity.

    Parameters

    • params: AddliquidityPosition

      The parameters for estimating adding liquidity.

    Returns Promise<EstimateAddLP>

    • The estimated liquidity addition object.
  • Estimates adding to a saver.

    Parameters

    • addAssetAmount: CryptoAmount

      The amount to add to the saver.

    Returns Promise<EstimateAddSaver>

    The estimated addition to the saver object.

    • Provides an estimate for a swap based on the given swap details. Checks the parameters for errors before attempting to retrieve the estimate. Utilizes current pool data to calculate inbound and outbound fees, affiliate fees, and the expected wait time for the swap (inbound and outbound).

    Parameters

    • params: QuoteSwapParams

      Parameters for the swap, including the amount to swap.

    Returns Promise<TxDetails>

    The estimated swap details.

  • Wraps the estimate from ThorchainQuery for withdrawing liquidity.

    Parameters

    • params: WithdrawLiquidityPosition

      The parameters for estimating withdrawing liquidity.

    Returns Promise<EstimateWithdrawLP>

    • The estimated liquidity withdrawal object.
  • Estimates withdrawing from a saver.

    Parameters

    • withdrawParams: SaversWithdraw

      The parameters for withdrawing from the saver.

    Returns Promise<EstimateWithdrawSaver>

    The estimated withdrawal from the saver object.

  • Retrieves a quote for closing a loan.

    Parameters

    • loanCloseParams: LoanCloseParams

      The parameters for closing the loan.

    Returns Promise<LoanCloseQuote>

    The quote for closing the loan.

  • Retrieves a quote for opening a loan.

    Parameters

    • loanOpenParams: LoanOpenParams

      The parameters for opening the loan.

    Returns Promise<LoanOpenQuote>

    The quote for opening the loan.

  • Retrieves the position of a saver.

    Parameters

    • getsaver: getSaver

      The parameters to retrieve the saver position.

    Returns Promise<SaversPosition>

    The saver position object.

  • Retrieves all Thornames and their associated data owned by an address.

    Parameters

    • address: string

      The address to retrieve Thornames for.

    Returns Promise<undefined | ReverseTHORNames>

    The Thornames data.

  • Validate if the asset router is allowed to spend the asset amount in name of the address

    Parameters

    • isApprovedParams: IsApprovedParams

      contains the asset and the amount the router is supposed to spend int name of address

    Returns Promise<string[]>

    the reasons the router of the asset is not allowed to spend the amount. If it is empty, the asset router is allowed to spend the amount

  • Validate swap params

    Parameters

    • quoteSwapParams: QuoteSwapParams

      Swap params

    Returns Promise<string[]>

    the reasons the swap can not be done. If it is empty there are no reason to avoid the swap

  • Withdraws liquidity from a position.

    Parameters

    • params: WithdrawLiquidityPosition

      The wallet to perform the transaction.

    Returns Promise<TxSubmitted[]>

    • The array of transaction submissions.
  • Withdraws assets from a loan.

    Parameters

    • loanCloseParams: LoanCloseParams

      The parameters for withdrawing from the loan.

    Returns Promise<TxSubmitted>

    The submitted transaction.

  • Withdraws assets from a saver.

    Parameters

    • withdrawParams: SaversWithdraw

      The parameters for withdrawing from the saver.

    Returns Promise<TxSubmitted>

    The submitted transaction.

Generated using TypeDoc