Asset
isBigNumberValue
Guard to check whether value is a BigNumber.Value or not
Parameters
vunknown
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 value0will be returned.decimalnumber The decimal places. (optional) (optional, defaultASSET_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 value0will be returned.decimalnumber The decimal places of its associated AssetAmount. (optional) (optional, defaultASSET_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
baseBaseAmount
Returns AssetAmount The asset amount from the given base amount.
assetToBase
Helper to convert asset to base values (e.g. tor -> RUNE)
Parameters
assetAssetAmount
Returns BaseAmount The base amount from the given AssetAmount.
isAssetAmount
Guard to check whether value is an amount of asset or not
Parameters
vAmount<Denomination>
Returns boolean true or false.
isBaseAmount
Guard to check whether value is an amount of a base value or not
Parameters
vAmount<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
paramParams The asset amount format options.param.amountparam.decimalparam.trimZeros(optional, defaultfalse)
Returns string The formatted asset amount string from the given options.
formatBaseAmount
Formats a BaseAmount value into a string
Parameters
amountBaseAmount
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
assetAsset
Returns boolean true or false
isSynthAsset
Helper to check whether an asset is synth asset
Parameters
assetAssetasset.synth
Returns boolean true or false
assetFromString
-
**See: https://docs.thorchain.org/developers/transaction-memos#asset-notation
If the naming convention fails, it returns null **
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
sstring The given string.
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
assetAsset The given asset.asset.chainasset.symbolasset.synth
Returns string The string from the given asset.
AssetCurrencySymbol
Currency symbols currently supported
currencySymbolByAsset
Returns currency symbols by given Asset
Parameters
assetAsset 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
paramsParams The asset amount currency format options.params.amountparams.assetparams.decimalparams.trimZeros(optional, defaultfalse)
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
paramsParams The base amount currency format options.params.amountparams.decimalparams.trimZeros(optional, defaultfalse)
Returns string The formatted base amount string using its currency format.
eqAsset
Checks equality of two Assets
Parameters
aAsset Asset onebAsset Asset two
Returns boolean Result of equality check
strip0x
Removes 0x or 0X from address
Parameters
addr