Links

Limit Order SDK

The SDK combines creating and canceling limit order functions.
Before using the SDK, you need to install
npm i @openocean.finance/limitorder-sdk

How to use the sdk in your project

import { openoceanLimitOrderSdk } from '@openocean.finance/limitorder-sdk';
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(wallet, order) {
const {
provider, // wallet provider
chainKey, // chain key, pleaze refer to supported chains
chainId,// chian id
account, // user's wallet address
} = wallet
const {
makerTokenAddress, // maker token address
makerTokenDecimals, // maker token decimals
takerTokenAddress, // taker token address
takerTokenDecimals, // taker token decimals
makerAmount, // maker amount with decimals
takerAmount, // taker amount with decimals
gasPrice, // gas price
expire, // time difference counted by millisecond
receiver, // receiver(Optional)
receiverInputData, // receiver input data(Optional)
} = order
// You need to upload the result "Create limit order"
// to finalize the limit order implementation.
let result = await openoceanLimitOrderSdk.createLimitOrder(wallet, order)
}

Cancel Limit Order:

// You have to use Openocean API to get your limit order information to cancel order.
const function cancelOrder(wallet, order){
const {
provider, // wallet provider
chainKey, // chain key, pleaze refer to supported chains
chainId,// chian id
account, // user's wallet address
} = wallet
const {
orderData, // order data
gasPrice, // gas price
} = order
const result = await openoceanLimitOrderSdk.cancelLimitOrder(wallet, order)
}