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
thorchainCachean instance of the ThorchainCache (could be pointing to stagenet,testnet,mainnet) (optional, defaultdefaultCache)chainAttributesatrributes used to calculate waitTime & conf counting (optional, defaultchain_defaults_1.DefaultChainAttributes)
quoteSwap
Parameters
quoteSwapParamsObject input paramsquoteSwapParams.fromAssetquoteSwapParams.destinationAssetquoteSwapParams.amountquoteSwapParams.destinationAddressquoteSwapParams.streamingIntervalquoteSwapParams.streamingQuantityquoteSwapParams.toleranceBpsquoteSwapParams.affiliateBpsquoteSwapParams.affiliateAddressquoteSwapParams.height
validateAmount
Validate a cryptoAmount is well formed
Parameters
cryptoAmountCryptoAmount CryptoAmount to validate
Returns (void | Error) Error if the cryptoAmount is not well formed
outboundDelay
- **See: https://gitlab.com/thorchain/thornode/-/blob/develop/x/thorchain/manager_txout_current.go#L548 **
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 convertasset: 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
inputamount/asset to convert to outAssetoutAssetouAssetthe 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
paramsparameters needed for a estimated liquidity position
Returns any type object EstimateLP
checkLiquidityPosition
Parameters
assetassetOrRuneAddressnull-nullAsset for lpaddressaddress used for Lp
Returns any Type Object liquidityPosition
getPoolRatios
Do not send assetNativeRune, There is no pool for it.
Parameters
assetasset 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
assetasset needed to retrieve dust values
Returns any object type dust values
estimateWithdrawSaver
Parameters
withdrawParamsheight?, asset, address, withdrawalBasisPoints
Returns any savers withdrawal quote with extras
getSaverPosition
Parameters
paramsgetSaver object > asset, addresss, height?
Returns any Savers position object
getLoanQuoteOpen
Parameters
loanOpenParamsObject params needed for the end PointloanOpenParams.assetloanOpenParams.amountloanOpenParams.targetAssetloanOpenParams.destinationloanOpenParams.minOutloanOpenParams.affiliateBpsloanOpenParams.affiliateloanOpenParams.height
getLoanQuoteClose
Parameters
loanOpenParamsObject params needed for the end PointloanOpenParams.assetloanOpenParams.amountloanOpenParams.loanAssetloanOpenParams.loanOwnerloanOpenParams.minOutloanOpenParams.height
getThornameDetails
Parameters
thornameinput paramheight
Returns any retrieves details for a thorname
estimateThorname
Generate the memo and estimate the cost of register or update a THORName
Parameters
paramsthornameName to registerchainChain to update / registerchainAddressAddress to add to chain aliasownerOwner address (rune address)preferredAssetreferred assetexpirityexpirity of the domain in MILLISECONDSisUpdatetrue only if the domain is already register and you want to update its data
Returns any memo and value of deposit