Thorchain Cache

ThorchainCache

This class manages retrieving information from up to date Thorchain

Parameters

  • midgard an instance of the midgard API (could be pointing to stagenet,testnet,mainnet) (optional, default defaultMidgard)
  • thornode (optional, default defaultThornode)
  • expirePoolCacheMillis how long should the pools be cached before expiry (optional, default 6000)
  • expireAsgardCacheMillis how long should the inboundAsgard Addresses be cached before expiry (optional, default TEN_MINUTES)
  • expireInboundDetailsCacheMillis how long should the InboundDetails be cached before expiry (optional, default 6000)
  • expireNetworkValuesCacheMillis how long should the Mimir/Constants be cached before expiry (optional, default TEN_MINUTES)

getExchangeRate

Gets the exchange rate of the from asset in terms on the to asset

Parameters

  • from
  • to
  • asset cannot be RUNE.

Returns any Promise

getPoolForAsset

Gets the Liquidity Pool for a given Asset

Parameters

  • asset cannot be RUNE, since Rune is the other side of each pool.

Returns any Promise

getPools

Get all the Liquidity Pools currently cached. if the cache is expired, the pools wioll be re-fetched from midgard

Returns any Promise<Record<string, LiquidityPool»

refereshPoolCache

Refreshes the Pool Cache

NOTE: do not call refereshPoolCache() directly, call getPools() instead which will refresh the cache if it's expired

refereshAsgardCache

Refreshes the asgardAssetsCache Cache

NOTE: do not call refereshAsgardCache() directly, call getAsgardAssets() instead which will refresh the cache if it's expired

refereshInboundDetailCache

Refreshes the InboundDetailCache Cache

NOTE: do not call refereshInboundDetailCache() directly, call getInboundDetails() instead which will refresh the cache if it's expired

refereshNetworkValuesCache

Refreshes the NetworkValuesCache Cache

NOTE: do not call refereshNetworkValuesCache() directly, call getNetworkValuess() instead which will refresh the cache if it's expired

getExpectedSwapOutput

Calcuate the expected slip, output & swapFee given the current pool depths

swapFee - the amount of asset lost according to slip calculations slip - the percent (0-1) of original amount lost to slipfees output - the amount of asset expected from the swap *

Parameters

  • inputAmount CryptoAmount amount to swap from
  • destinationAsset destimation Asset to swap to

Returns any SwapOutput - swap output object - output - fee - slip

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 the Asset you want to convert to

Returns any CryptoAmount of input

getInboundAddresses

Returns any inbound adresses item

getInboundDetails

Returns any inbound details

getNetworkValues

Returns any network values