Place Order

This function places an order using the Limit Order SDK.

Example:

import {
  LimitOrder,
  Order,
  placeOrderResponse,
  convertDateToUnixTimestamp,
} from "../../src";

async function placeOrder(order: Order): Promise<placeOrderResponse> {
  const limitOrder = new LimitOrder();

  const response: placeOrderResponse = await limitOrder.placeOrder(order);

  return response;
}

const order: Order = {
  signer: "YOUR_WALLET_ADDRESS",
  maker_asset: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
  taker_asset: "0x03e85bfbb8e2a42b7bead9e88e9a1b19dbccf661471061807292120462396ec9",
  maker_amount: 1000000000000000000,
  taker_amount: 1000000000000000000,
  order_price: 5000000000000000000000, // price of the maker asset in terms of the taker asset (unit amount)
  expiration: convertDateToUnixTimestamp({ days: 1 }), // expiration in 1 day
  use_solver: false, // if true, the order will be executed with the solver
  partial_fill: true, // if true, the order will be partially filled
  nonce: 1, // ref. ./getNonce.ts
  order_hash: "order_hash", // ref. ./signMessage.ts
  signature: ["sig_r", "sign_s"], // ref. ./signMessage.ts
};

placeOrder(order);

Response:

Order struct explained in Orders section.

Last updated