THORChain Class for interacting with THORChain. Recommended main class to use for swapping with THORChain Has access to Midgard and THORNode data
midgardan instance of the midgard API (could be pointing to stagenet,testnet,mainnet)
expirePoolCacheMillishow long should the pools be cached before expiry (optional, default
chainAttributesatrributes used to calculate waitTime & conf counting (optional, default
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)
paramsamount to swap
Returns any The SwapEstimate
Convinience 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
fees: TotalFees - the fees you want to convert
asset: Asset - the asset you want the fees converted to
Returns any TotalFees in asset
Returns the exchange of a CryptoAmount to a different Asset
Ex. convert(input:100 BUSD, outAsset: BTC) -> 0.0001234 BTC
inputamount/asset to convert to outAsset
ouAssetthe Asset you want to convert to
Returns any CryptoAmount of input
Conducts a swap with the given inputs. Should be called after estimateSwap() to ensure the swap is valid
walletwallet to use
destinationAddresswere to send the output of the swap
affiliateAddresswere to send the affilate Address, should be a THOR address (optional) (optional, default
interfaceIDid if the calling interface (optional) (optional, default
Returns SwapSubmitted Tx Hash, URL of BlockExplorer and expected wait time.
Basic Checks for swap information
Does the calculations for the swap. Used by estimateSwap
Looks for errors or issues within swap prams before doing the swap.
- **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.
outboundAmount: CryptoAmount being sent.
Returns any required delay in seconds
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.
inbound: CryptoAmount - amount/asset of the outbound amount.
Returns any time in seconds before a Tx is confirmed by THORChain