Asset

isBigNumberValue

Guard to check whether value is a BigNumber.Value or not

Parameters

  • v unknown

Returns boolean true or false.

ASSET_DECIMAL

Default number of asset decimals For history reason and by starting the project on Binance chain assets, it's 8 decimal.F

For example:

RUNE has a maximum of 8 digits of decimal
0.00000001 RUNE == 1 ð (tor)

Type: number

assetAmount

Factory to create values of assets (e.g. RUNE)

Parameters

  • value (string | number | BigNumber | undefined) The asset amount, If the value is undefined, AssetAmount with value 0 will be returned.
  • decimal number The decimal places. (optional) (optional, default ASSET_DECIMAL)

Returns AssetAmount The asset amount from the given value and decimal.*

baseAmount

Factory to create base amounts (e.g. tor)

Parameters

  • value (string | number | BigNumber | undefined) The base amount, If the value is undefined, BaseAmount with value 0 will be returned.
  • decimal number The decimal places of its associated AssetAmount. (optional) (optional, default ASSET_DECIMAL)

Returns BaseAmount The base amount from the given value and decimal. *

baseToAsset

Helper to convert values for a asset from base values (e.g. RUNE from tor)

Parameters

  • base BaseAmount

Returns AssetAmount The asset amount from the given base amount.

assetToBase

Helper to convert asset to base values (e.g. tor -> RUNE)

Parameters

  • asset AssetAmount

Returns BaseAmount The base amount from the given AssetAmount.

isAssetAmount

Guard to check whether value is an amount of asset or not

Parameters

  • v Amount<Denomination>

Returns boolean true or false.

isBaseAmount

Guard to check whether value is an amount of a base value or not

Parameters

  • v Amount<Denomination>

Returns boolean true or false.

formatAssetAmount

Formats an AssetAmount into string based on decimal places

If decimal is not set, amount.decimal is used Note: trimZeros wins over decimal

Parameters

  • param Params The asset amount format options.
    • param.amount
    • param.decimal
    • param.trimZeros (optional, default false)

Returns string The formatted asset amount string from the given options.

formatBaseAmount

Formats a BaseAmount value into a string

Parameters

  • amount BaseAmount

Returns string The formatted base amount string from the given base amount.

AssetBTC

Base "chain" asset on bitcoin main net.

Based on definition in Thorchain common

AssetETH

Base "chain" asset on ethereum main net.

Based on definition in Thorchain common

isValidAsset

Helper to check whether asset is valid

Parameters

  • asset Asset

Returns boolean true or false

isSynthAsset

Helper to check whether an asset is synth asset

Parameters

  • asset Asset
    • asset.synth

Returns boolean true or false

assetFromString

Creates an Asset by a given string

This helper function expects a string with following naming convention: AAA.BBB-CCC where chain: AAA ticker (optional): BBB symbol: BBB-CCC or CCC (if no ticker available)

Parameters

Returns (Asset | null) The asset from the given string.

assetFromStringEx

Similar to an assetFromString, but throws an exception for invalid asset strings

Parameters

  • s

assetToString

Returns an Asset as a string using following naming convention:

AAA.BBB-CCC where chain: AAA ticker (optional): BBB symbol: BBB-CCC or CCC (if no ticker available) symbol (synth): BBB/CCC or CCC (if no ticker available)

Parameters

  • asset Asset The given asset.
    • asset.chain
    • asset.symbol
    • asset.synth

Returns string The string from the given asset.

AssetCurrencySymbol

Currency symbols currently supported

currencySymbolByAsset

Returns currency symbols by given Asset

Parameters

  • asset Asset The given asset.
    • asset.ticker

Returns string The currency symbol from the given asset.

formatAssetAmountCurrency

Formats an asset amount using its currency symbol

If decimal is not set, amount.decimal is used If asset is not set, $ will be used as currency symbol by default trimZeros is false by default Note: trimZeros wins over decimal

Parameters

  • params Params The asset amount currency format options.
    • params.amount
    • params.asset
    • params.decimal
    • params.trimZeros (optional, default false)

Returns string The formatted asset amount string using its currency format.

formatBaseAsAssetAmount

Formats a BaseAmount into a string of an AssetAmount

If decimal is not set, amount.decimal is used Note: trimZeros wins over decimal

Parameters

  • params Params The base amount currency format options.
    • params.amount
    • params.decimal
    • params.trimZeros (optional, default false)

Returns string The formatted base amount string using its currency format.

eqAsset

Checks equality of two Assets

Parameters

  • a Asset Asset one
  • b Asset Asset two

Returns boolean Result of equality check

strip0x

Removes 0x or 0X from address

Parameters

  • addr