@autonomylabs/limit-stop-orders
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

Autonomy Limit/StopLoss Order SDK

Place limit/stoploss orders on BSC and Avalanche using Autonomy Registry.

Installation

yarn add -D @autonomylabs/limit-stop-orders

or

npm install --save-dev @autonomylabs/limit-stop-orders

Initialize the SDK

import { AutonomyLimitStopOrders } from "@autonomylabs/limit-stop-orders";

const autonomyLimitStopOrders = new AutonomyLimitStopOrders(
  chainId, // BSC = 56, Avalanche = 43114
  signerOrProvider, // Web3 Signer or Provider
  routerAddress, // DEX router address, Apeswap by default on BSC / TraderJoe by default on Avalanche
  factoryAddress, // DEX factory adderss, Apeswap by default on BSC / TraderJoe by default on Avalanche
  initCodeHash // DEX init code hash, Apeswap by default on BSC / TraderJoe by default on Avalanche
);

Approve token on Autonomy router

await autonomyLimitStopOrders.approve(
  inputToken, // input token address
  inputAmount, // input amount in BigNumber
  recipient // recipient address
);

Submit an order

await autonomyLimitStopOrders.submitOrder(
  orderType, // Limit or Stop
  inputToken, // input token address
  inputAmount, // input amount in BigNumber
  outputToken, // output token address
  outputAmount, // output amount in BigNumber
  recipient, // recipient address
  autonomyPrepay // if true, small amount will be pre-paid
);

Cancel an order

await autonomyLimitStopOrders.cancelOrder(order);

Get orders

Get all orders

const allOrders = await autonomyLimitStopOrders.getOrders(requesterAddress);

Get open orders

const openOrders = await autonomyLimitStopOrders.getOpenOrders(requesterAddress);

Get executed orders

const executedOrders = await autonomyLimitStopOrders.getExecutedOrders(requesterAddress);

Get cancelled orders

const cancelledOrders = await autonomyLimitStopOrders.getCancelledOrders(requesterAddress);

Get orders by type

const limitOrders = await autonomyLimitStopOrders.getOrdersByType(requesterAddress, "Limit");
const stopLossOrders = await autonomyLimitStopOrders.getOrdersByType(requesterAddress, "Stop");

Readme

Keywords

none

Package Sidebar

Install

npm i @autonomylabs/limit-stop-orders

Weekly Downloads

2

Version

0.0.11

License

none

Unpacked Size

109 kB

Total Files

20

Last publish

Collaborators

  • caraluna