First create an instance of swap controller to call all methods below.
const sdk = new CryptumSdk({
environment: 'testnet',
apiKey: 'YOUR-API-KEY'
})
Get a list of all supported currencies to swap to and from. Examples: BTC, ETH, XLM, XRP, BNB, USDT and others.
Examples:
sdk.swap.getSupportedCurrencies().then((curencies) => {
console.log(curencies);
})
Get the minimum amount to swap.
Params:
opts.currencyFrom
(string) (required) criptocurrency to swap from.opts.currencyTo
(string) (required) criptocurrency to swap to.
Examples:
sdk.swap.getMinimumAmount({
currencyFrom: "DASH",
currencyTo: "BTC"
}).then((minimumAmount) => {
console.log(minimumAmount);
})
Get estimate amount to receive from the swap.
Params:
opts.currencyFrom
(string) (required) criptocurrency to swap from.opts.currencyTo
(string) (required) criptocurrency to swap to.opts.amount
(string) (required) criptocurrency amount to estimate.
Examples:
sdk.swap.getEstimateAmount({
currencyFrom: "BTC",
currencyTo: "ETH",
amount: "0.06"
}).then((estimateAmount) => {
console.log(estimateAmount);
})
Get the swap order by its id.
Params:
id
(string) (required) swap order id.
Example:
sdk.swap.getOrder('41c62023-ec12-4d5c-8ea3-b1b93a4d63ac').then((order) => {
console.log(order);
})
Create new swap order.
Params:
opts.currencyFrom
(string) (required) currency to swap fromopts.currencyTo
(string) (required) currency to swap toopts.amount
(string) (required) amount to swap fromopts.addressTo
(string) (required) address to swap toopts.memoTo
(string) (required) memo or extra id string to pass along with the addressTo (only for some currencies like XLM, XRP, etc)opts.refundAddress
(string) (required) address to return funds to the user in case the swapping goes wrongopts.refundMemo
(string) (required) memo or extra id string to pass along with the refundAddress (only for some currencies like XLM, XRP, etc)
Example:
sdk.swap.createOrder({
currencyFrom: "SOL",
currencyTo: "ETH",
amountFrom: "5.81",
addressTo: "0x0Cbed4D3f2...d8b1A7B5185",
memoTo: null,
refundAddress: null,
refundMemo: null,
}).then((order) => {
console.log(order);
})
Get all swap orders.
Params:
opts.limit
(number) (required)opts.offset
(number) (required)
Example
sdk.swap.getOrders({
limit: 10,
offset: 1
}).then((orders) => {
console.log(orders);
})