UNPKG

@bluefin-exchange/bluefin7k-aggregator-sdk

Version:
31 lines (30 loc) 1.05 kB
import { DCA_ORDER_MODULE_ID, GLOBAL_CONFIG_ID } from "./constants"; import { coinWithBalance, Transaction, } from "@mysten/sui/transactions"; export async function placeDcaOrder({ payCoinType, targetCoinType, payCoinAmountEach, numOrders, interval, slippage, minRate, maxRate, }) { const tx = new Transaction(); const coinElements = []; for (let i = 0; i < numOrders; i++) { const coin = coinWithBalance({ type: payCoinType, balance: payCoinAmountEach, }); coinElements.push(coin); } const vectorCoin = tx.makeMoveVec({ elements: coinElements, }); tx.moveCall({ target: `${DCA_ORDER_MODULE_ID}::place_dca_order`, arguments: [ tx.object(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; }