UNPKG

@bluefin-exchange/bluefin7k-aggregator-sdk

Version:
34 lines (33 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.placeDcaOrder = placeDcaOrder; const constants_1 = require("./constants"); const transactions_1 = require("@mysten/sui/transactions"); async function placeDcaOrder({ payCoinType, targetCoinType, payCoinAmountEach, numOrders, interval, slippage, minRate, maxRate, }) { const tx = new transactions_1.Transaction(); const coinElements = []; for (let i = 0; i < numOrders; i++) { const coin = (0, transactions_1.coinWithBalance)({ type: payCoinType, balance: payCoinAmountEach, }); coinElements.push(coin); } const vectorCoin = tx.makeMoveVec({ elements: coinElements, }); tx.moveCall({ target: `${constants_1.DCA_ORDER_MODULE_ID}::place_dca_order`, arguments: [ tx.object(constants_1.GLOBAL_CONFIG_ID), vectorCoin, tx.pure.u64(interval), tx.pure.u64(slippage), tx.pure.u64(minRate), tx.pure.u64(maxRate), tx.object.clock(), ], typeArguments: [payCoinType, targetCoinType], }); return tx; }