navi-sdk
Version:
The NAVI SDK Client provides tools for interacting with the Sui blockchain networks, designed for handling transactions, accounts, and smart contracts efficiently. This documentation covers the setup, account management, and transaction handling within th
39 lines (38 loc) • 1.92 kB
JavaScript
;
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.makeMAGMAPTB = makeMAGMAPTB;
const config_1 = require("../config");
function makeMAGMAPTB(txb, poolId, byAmountIn, coinA, coinB, amount, a2b, typeArguments, amountLimit) {
return __awaiter(this, void 0, void 0, function* () {
let coinTypeA = typeArguments[0];
let coinTypeB = typeArguments[1];
const sqrtPriceLimit = BigInt(a2b ? "4295048016" : "79226673515401279992447579055");
const moduleName = a2b ? 'swap_a2b' : 'swap_b2a';
const coinABs = txb.moveCall({
target: `${config_1.AggregatorConfig.magmaPackageId}::pool_script_v2::${moduleName}`,
arguments: [
txb.object(config_1.AggregatorConfig.magmaConfigId),
txb.object(poolId),
coinA,
coinB,
txb.pure.bool(byAmountIn),
amount,
txb.pure.u64(amountLimit),
txb.pure.u128(sqrtPriceLimit),
txb.pure.bool(false),
txb.object(config_1.AggregatorConfig.clockAddress),
],
typeArguments: [coinTypeA, coinTypeB],
});
return coinABs;
});
}