Links

Limit Order SDK

The SDK combines creating and canceling limit order functions.
Before using the SDK, you need to install openocean-swap-sdk.

How to use the sdk in your project

import { OpenoceanSdk } from '@openocean.finance/openocean-sdk';
​
const openoceanSdk = new OpenoceanSdk();
const { swapSdk } = openoceanSdk;
You can then use all the functions explored by the SDK (API and swapSdk).

Create Limit Order:

// you have to import OpenoceanSdk before you call features:
​
const function putOrder(val) {
const {
makerToken, //intoken address
takerToken, //outtoken address
_makerAddress, //user's wallet
makerAmount, // intoken amount with decimals
takerAmount, // outtoken amount with decimals
chainId,
gasPrice,
expire, // time difference counted by millisecond
decimals // intoken's decimals
} = val
// You need to upload the result "Create limit order"
// to finalize the limit order implementation.
let result = await swapSdk.createLimitOrder(val)
}

Cancel Limit Order:

// You have to use Openocean API to get your limit order information to cancel order.
​
const function cancelOrder(order, gasPrice){
const result = await swapSdk.cancelLimitOrder(order, gasPrice)
}