Coding Guide
A coding overview to XChainJS.
General
The foundation of xchainjs is defined in the xchain-util package
Address
: a crypto address as a string.BaseAmount
: a bigNumber in 1e8 format. E.g. 1 BTC = 100,000,000 in BaseAmountAssetAmount
: a BaseAmount*10^8. E.g. 1 BTC = 1 in Asset Amount.Asset
: Asset details {Chain, symbol, ticker, isSynth}
All Assets
must conform to the Asset NotationassetFromString()
is used to quickly create assets and will assign chain and synth.
CryptoAmount:
is a class that has:
All crypto should use the CryptoAmount
object with the understanding they are in BaseAmount format. An example to switch between them:
Query
Major data types for the mayarchain-query package.
EstimateSwapParams
The input Type for estimateSwap
. This is designed to be created by interfaces and passed into EstimateSwap. Also see Swap Memo for more information.
SwapEstimate
The internal return type is used within estimateSwap after the calculation is done.
TxDetails
Return type of estimateSwap
. This is designed to be used by interfaces to give them all the information they need to display to the user.
Do not use toAddress
after expiry
as the Asgard vault rotates
AMM
Major data types for the thorchain-query package.
Package description
Code examples
Install procedures
ExecuteSwap
Input Type for doSwap where a swap will be actually conducted. Based on EstimateSwapParams.
TxSubmitted
Last updated