UNPKG

client-aftermath-ts-sdk

Version:
103 lines (102 loc) 4.57 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LimitOrders = void 0; const caller_1 = require("../../general/utils/caller"); class LimitOrders extends caller_1.Caller { // ========================================================================= // Constructor // ========================================================================= constructor(config) { super(config, "limit-orders"); } // ========================================================================= // Class Objects // ========================================================================= /** * Fetches the API for dollar cost averaging active orders list. * @async * @param { LimitOrderObject } inputs - An object containing the walletAddress. * @returns { Promise<LimitOrderObject[]> } A promise that resolves to object with array of fetched events for active limit orders */ getActiveLimitOrders(inputs) { return __awaiter(this, void 0, void 0, function* () { return this.fetchApi("active", inputs); }); } /** * Fetches the API for limit cost finished orders list. * @async * @param { LimitOrderObject } inputs - An object containing the walletAddress. * @returns { Promise<LimitOrderObject[]> } A promise that resolves to object with array of fetched events for past limit orders */ getPastLimitOrders(inputs) { return __awaiter(this, void 0, void 0, function* () { return this.fetchApi("past", inputs); }); } // ========================================================================= // Transactions // ========================================================================= /** * Fetches the API transaction for creating Limit order. * @param { ApiLimitOrdersCreateOrderTransactionBody } inputs - The inputs for the transaction. * @returns { Promise<Transaction> } A promise that resolves with the API transaction. */ getCreateLimitOrderTx(inputs) { return __awaiter(this, void 0, void 0, function* () { return this.fetchApiTransaction("transactions/create-order", inputs); }); } /** * Fetches the API for canceling Limit order. * @param inputs - The inputs for the transaction. * @returns { Promise<boolean> } A promise that resolves with transaction execution status. */ cancelLimitOrder(inputs) { return __awaiter(this, void 0, void 0, function* () { return this.fetchApi(`cancel`, inputs); }); } // ========================================================================= // Interactions // ========================================================================= /** * Method for getting the cancellation limit order message to sign. * @param inputs - The inputs for the message. * @returns Message to sign. */ cancelLimitOrdersMessageToSign(inputs) { return { action: "CANCEL_LIMIT_ORDERS", order_object_ids: inputs.orderIds, }; } // ========================================================================= // Configuration // ========================================================================= /** * Method for getting a minimum allowable order size. * @returns Minimum order size in usd. */ getMinOrderSizeUsd() { return __awaiter(this, void 0, void 0, function* () { return this.fetchApi("min-order-size-usd", {}); }); } } exports.LimitOrders = LimitOrders; // ========================================================================= // Constants // ========================================================================= LimitOrders.constants = { gasAmount: BigInt(50000000), };