UNPKG

@devasher/kuru-sdk

Version:

Ethers v6 SDK to interact with Kuru (forked from @kuru-labs/kuru-sdk)

48 lines 2.13 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PositionWithdrawer = void 0; const ethers_1 = require("ethers"); const OrderBook_json_1 = __importDefault(require("../../abi/OrderBook.json")); const txConfig_1 = __importDefault(require("../utils/txConfig")); class PositionWithdrawer { /** * @dev Cancels a batch of liquidity positions from the contract * @param signer - The signer object * @param contractAddress - The contract address * @param orderIds - Array of order IDs to cancel * @returns A promise that resolves to the transaction receipt */ static async withdrawLiquidity(signer, contractAddress, orderIds) { // Create contract instance const contract = new ethers_1.ethers.Contract(contractAddress, OrderBook_json_1.default.abi, signer); // Call the contract to cancel orders const tx = await contract.batchCancelFlipOrders(orderIds); const receipt = await tx.wait(); return receipt; } /** * @dev Constructs a transaction for batch liquidity withdrawal * @param signer - The signer instance * @param contractAddress - The contract address * @param orderIds - Array of order IDs to cancel * @param txOptions - Transaction options * @returns A promise that resolves to the transaction request object */ static async constructBatchWithdrawTransaction(signer, contractAddress, orderIds, txOptions) { const address = await signer.getAddress(); const orderbookInterface = new ethers_1.ethers.Interface(OrderBook_json_1.default.abi); const data = orderbookInterface.encodeFunctionData('batchCancelFlipOrders', [orderIds]); return (0, txConfig_1.default)({ from: address, to: contractAddress, signer, data, txOptions, }); } } exports.PositionWithdrawer = PositionWithdrawer; //# sourceMappingURL=withdraw.js.map