Thorchain Query

ThorchainQuery

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

Parameters

  • thorchainCache an instance of the ThorchainCache (could be pointing to stagenet,testnet,mainnet) (optional, default defaultCache)
  • chainAttributes atrributes used to calculate waitTime & conf counting (optional, default chain_defaults_1.DefaultChainAttributes)

quoteSwap

Parameters

  • quoteSwapParams Object input params
    • quoteSwapParams.fromAsset
    • quoteSwapParams.destinationAsset
    • quoteSwapParams.amount
    • quoteSwapParams.destinationAddress
    • quoteSwapParams.streamingInterval
    • quoteSwapParams.streamingQuantity
    • quoteSwapParams.toleranceBps
    • quoteSwapParams.affiliateBps
    • quoteSwapParams.affiliateAddress
    • quoteSwapParams.height

validateAmount

Validate a cryptoAmount is well formed

Parameters

  • cryptoAmount CryptoAmount CryptoAmount to validate

Returns (void | Error) Error if the cryptoAmount is not well formed

outboundDelay

Works out how long an outbound Tx will be held by THORChain before sending.

Parameters

  • outboundAmount : CryptoAmount being sent.

Returns any required delay in seconds

getFeesIn

Convenience method to convert TotalFees to a different CryptoAmount

TotalFees are always calculated and returned in RUNE, this method can be used to show the equivalent fees in another Asset Type

Parameters

  • fees : TotalFees - the fees you want to convert
  • asset : Asset - the asset you want the fees converted to

Returns any TotalFees in asset

convert

Returns the exchange of a CryptoAmount to a different Asset

Ex. convert(input:100 BUSD, outAsset: BTC) -> 0.0001234 BTC

Parameters

  • input amount/asset to convert to outAsset
  • outAsset
  • ouAsset the Asset you want to convert to

Returns any CryptoAmount of input

confCounting

Finds the required confCount required for an inbound or outbound Tx to THORChain. Estimate based on Midgard data only.

Finds the gas asset of the given asset (e.g. BUSD is on BNB), finds the value of asset in Gas Asset then finds the required confirmation count. ConfCount is then times by 6 seconds.

Parameters

  • inbound : CryptoAmount - amount/asset of the outbound amount.

Returns any time in seconds before a Tx is confirmed by THORChain

estimateAddLP

Estimates a liquidity position for given crypto amount value, both asymmetrical and symetrical

Parameters

  • params parameters needed for a estimated liquidity position

Returns any type object EstimateLP

checkLiquidityPosition

Parameters

  • asset
  • assetOrRuneAddress
  • null-null Asset for lp
  • address address used for Lp

Returns any Type Object liquidityPosition

getPoolRatios

Do not send assetNativeRune, There is no pool for it.

Parameters

  • asset asset required to find the pool

Returns any object type ratios

estimateWithdrawLP

Parameters

  • params

getDustValues

// can this become a quried constant? added to inbound_addresses or something

Parameters

  • asset asset needed to retrieve dust values

Returns any object type dust values

estimateWithdrawSaver

Parameters

  • withdrawParams height?, asset, address, withdrawalBasisPoints

Returns any savers withdrawal quote with extras

getSaverPosition

Parameters

  • params getSaver object > asset, addresss, height?

Returns any Savers position object

getLoanQuoteOpen

Parameters

  • loanOpenParams Object params needed for the end Point
    • loanOpenParams.asset
    • loanOpenParams.amount
    • loanOpenParams.targetAsset
    • loanOpenParams.destination
    • loanOpenParams.minOut
    • loanOpenParams.affiliateBps
    • loanOpenParams.affiliate
    • loanOpenParams.height

getLoanQuoteClose

Parameters

  • loanOpenParams Object params needed for the end Point
    • loanOpenParams.asset
    • loanOpenParams.amount
    • loanOpenParams.loanAsset
    • loanOpenParams.loanOwner
    • loanOpenParams.minOut
    • loanOpenParams.height

getThornameDetails

Parameters

  • thorname input param
  • height

Returns any retrieves details for a thorname

estimateThorname

Generate the memo and estimate the cost of register or update a THORName

Parameters

  • params
  • thorname Name to register
  • chain Chain to update / register
  • chainAddress Address to add to chain alias
  • owner Owner address (rune address)
  • preferredAsset referred asset
  • expirity expirity of the domain in MILLISECONDS
  • isUpdate true only if the domain is already register and you want to update its data

Returns any memo and value of deposit