@magmaprotocol/magma-clmm-sdk 0.5.128 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +246 -36
- package/dist/index.js +638 -519
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +624 -507
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -137,11 +137,13 @@ __export(src_exports, {
|
|
|
137
137
|
composeType: () => composeType,
|
|
138
138
|
computeSwap: () => computeSwap,
|
|
139
139
|
computeSwapStep: () => computeSwapStep,
|
|
140
|
+
convertScientificToDecimal: () => convertScientificToDecimal,
|
|
140
141
|
createSplitAmountArray: () => createSplitAmountArray,
|
|
141
142
|
createSplitArray: () => createSplitArray,
|
|
142
143
|
d: () => d,
|
|
143
144
|
decimalsMultiplier: () => decimalsMultiplier,
|
|
144
145
|
default: () => src_default,
|
|
146
|
+
defaultSwapSlippage: () => defaultSwapSlippage,
|
|
145
147
|
estPoolAPR: () => estPoolAPR,
|
|
146
148
|
estPositionAPRWithDeltaMethod: () => estPositionAPRWithDeltaMethod,
|
|
147
149
|
estPositionAPRWithMultiMethod: () => estPositionAPRWithMultiMethod,
|
|
@@ -226,8 +228,8 @@ __export(src_exports, {
|
|
|
226
228
|
module.exports = __toCommonJS(src_exports);
|
|
227
229
|
|
|
228
230
|
// src/modules/poolModule.ts
|
|
229
|
-
var
|
|
230
|
-
var
|
|
231
|
+
var import_utils14 = require("@mysten/sui/utils");
|
|
232
|
+
var import_transactions5 = require("@mysten/sui/transactions");
|
|
231
233
|
|
|
232
234
|
// src/utils/cachedContent.ts
|
|
233
235
|
var cacheTime5min = 5 * 60 * 1e3;
|
|
@@ -291,6 +293,9 @@ var ClmmpoolsError = class extends Error {
|
|
|
291
293
|
return e instanceof ClmmpoolsError && e.errorCode === code;
|
|
292
294
|
}
|
|
293
295
|
};
|
|
296
|
+
var handleMessageError = (code, message, details) => {
|
|
297
|
+
throw new ClmmpoolsError(message, code);
|
|
298
|
+
};
|
|
294
299
|
|
|
295
300
|
// src/math/utils.ts
|
|
296
301
|
var ZERO = new import_bn.default(0);
|
|
@@ -563,6 +568,9 @@ var SwapDirection = /* @__PURE__ */ ((SwapDirection2) => {
|
|
|
563
568
|
return SwapDirection2;
|
|
564
569
|
})(SwapDirection || {});
|
|
565
570
|
|
|
571
|
+
// src/types/zap.ts
|
|
572
|
+
var defaultSwapSlippage = 5e-3;
|
|
573
|
+
|
|
566
574
|
// src/math/apr.ts
|
|
567
575
|
var import_bn5 = __toESM(require("bn.js"));
|
|
568
576
|
var import_decimal4 = __toESM(require("decimal.js"));
|
|
@@ -1329,234 +1337,8 @@ var ClmmPoolUtil = class {
|
|
|
1329
1337
|
}
|
|
1330
1338
|
};
|
|
1331
1339
|
|
|
1332
|
-
// src/utils/contracts.ts
|
|
1333
|
-
var import_utils8 = require("@mysten/sui/utils");
|
|
1334
|
-
|
|
1335
|
-
// src/utils/hex.ts
|
|
1336
|
-
var HEX_REGEXP = /^[-+]?[0-9A-Fa-f]+\.?[0-9A-Fa-f]*?$/;
|
|
1337
|
-
function addHexPrefix(hex) {
|
|
1338
|
-
return !hex.startsWith("0x") ? `0x${hex}` : hex;
|
|
1339
|
-
}
|
|
1340
|
-
function removeHexPrefix(hex) {
|
|
1341
|
-
return hex.startsWith("0x") ? `${hex.slice(2)}` : hex;
|
|
1342
|
-
}
|
|
1343
|
-
function shortString(str, start = 4, end = 4) {
|
|
1344
|
-
const slen = Math.max(start, 1);
|
|
1345
|
-
const elen = Math.max(end, 1);
|
|
1346
|
-
return `${str.slice(0, slen + 2)} ... ${str.slice(-elen)}`;
|
|
1347
|
-
}
|
|
1348
|
-
function shortAddress(address, start = 4, end = 4) {
|
|
1349
|
-
return shortString(addHexPrefix(address), start, end);
|
|
1350
|
-
}
|
|
1351
|
-
function checkAddress(address, options = { leadingZero: true }) {
|
|
1352
|
-
if (typeof address !== "string") {
|
|
1353
|
-
return false;
|
|
1354
|
-
}
|
|
1355
|
-
let str = address;
|
|
1356
|
-
if (options.leadingZero) {
|
|
1357
|
-
if (!address.startsWith("0x")) {
|
|
1358
|
-
return false;
|
|
1359
|
-
}
|
|
1360
|
-
str = str.substring(2);
|
|
1361
|
-
}
|
|
1362
|
-
return HEX_REGEXP.test(str);
|
|
1363
|
-
}
|
|
1364
|
-
function toBuffer(v) {
|
|
1365
|
-
if (!Buffer.isBuffer(v)) {
|
|
1366
|
-
if (Array.isArray(v)) {
|
|
1367
|
-
v = Buffer.from(v);
|
|
1368
|
-
} else if (typeof v === "string") {
|
|
1369
|
-
if (exports.isHexString(v)) {
|
|
1370
|
-
v = Buffer.from(exports.padToEven(exports.stripHexPrefix(v)), "hex");
|
|
1371
|
-
} else {
|
|
1372
|
-
v = Buffer.from(v);
|
|
1373
|
-
}
|
|
1374
|
-
} else if (typeof v === "number") {
|
|
1375
|
-
v = exports.intToBuffer(v);
|
|
1376
|
-
} else if (v === null || v === void 0) {
|
|
1377
|
-
v = Buffer.allocUnsafe(0);
|
|
1378
|
-
} else if (v.toArray) {
|
|
1379
|
-
v = Buffer.from(v.toArray());
|
|
1380
|
-
} else {
|
|
1381
|
-
throw new ClmmpoolsError(`Invalid type`, "InvalidType" /* InvalidType */);
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
return v;
|
|
1385
|
-
}
|
|
1386
|
-
function bufferToHex(buffer) {
|
|
1387
|
-
return addHexPrefix(toBuffer(buffer).toString("hex"));
|
|
1388
|
-
}
|
|
1389
|
-
function hexToNumber(binaryData) {
|
|
1390
|
-
const buffer = new ArrayBuffer(4);
|
|
1391
|
-
const view = new DataView(buffer);
|
|
1392
|
-
for (let i = 0; i < binaryData.length; i++) {
|
|
1393
|
-
view.setUint8(i, binaryData.charCodeAt(i));
|
|
1394
|
-
}
|
|
1395
|
-
const number = view.getUint32(0, true);
|
|
1396
|
-
return number;
|
|
1397
|
-
}
|
|
1398
|
-
function utf8to16(str) {
|
|
1399
|
-
let out;
|
|
1400
|
-
let i;
|
|
1401
|
-
let c;
|
|
1402
|
-
let char2;
|
|
1403
|
-
let char3;
|
|
1404
|
-
out = "";
|
|
1405
|
-
const len = str.length;
|
|
1406
|
-
i = 0;
|
|
1407
|
-
while (i < len) {
|
|
1408
|
-
c = str.charCodeAt(i++);
|
|
1409
|
-
switch (c >> 4) {
|
|
1410
|
-
case 0:
|
|
1411
|
-
case 1:
|
|
1412
|
-
case 2:
|
|
1413
|
-
case 3:
|
|
1414
|
-
case 4:
|
|
1415
|
-
case 5:
|
|
1416
|
-
case 6:
|
|
1417
|
-
case 7:
|
|
1418
|
-
out += str.charAt(i - 1);
|
|
1419
|
-
break;
|
|
1420
|
-
case 12:
|
|
1421
|
-
case 13:
|
|
1422
|
-
char2 = str.charCodeAt(i++);
|
|
1423
|
-
out += String.fromCharCode((c & 31) << 6 | char2 & 63);
|
|
1424
|
-
break;
|
|
1425
|
-
case 14:
|
|
1426
|
-
char2 = str.charCodeAt(i++);
|
|
1427
|
-
char3 = str.charCodeAt(i++);
|
|
1428
|
-
out += String.fromCharCode((c & 15) << 12 | (char2 & 63) << 6 | (char3 & 63) << 0);
|
|
1429
|
-
break;
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
return out;
|
|
1433
|
-
}
|
|
1434
|
-
function hexToString(str) {
|
|
1435
|
-
let val = "";
|
|
1436
|
-
const newStr = removeHexPrefix(str);
|
|
1437
|
-
const len = newStr.length / 2;
|
|
1438
|
-
for (let i = 0; i < len; i++) {
|
|
1439
|
-
val += String.fromCharCode(parseInt(newStr.substr(i * 2, 2), 16));
|
|
1440
|
-
}
|
|
1441
|
-
return utf8to16(val);
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
// src/utils/contracts.ts
|
|
1445
|
-
var EQUAL = 0;
|
|
1446
|
-
var LESS_THAN = 1;
|
|
1447
|
-
var GREATER_THAN = 2;
|
|
1448
|
-
function cmp(a, b) {
|
|
1449
|
-
if (a === b) {
|
|
1450
|
-
return EQUAL;
|
|
1451
|
-
}
|
|
1452
|
-
if (a < b) {
|
|
1453
|
-
return LESS_THAN;
|
|
1454
|
-
}
|
|
1455
|
-
return GREATER_THAN;
|
|
1456
|
-
}
|
|
1457
|
-
function compare(symbolX, symbolY) {
|
|
1458
|
-
let i = 0;
|
|
1459
|
-
const len = symbolX.length <= symbolY.length ? symbolX.length : symbolY.length;
|
|
1460
|
-
const lenCmp = cmp(symbolX.length, symbolY.length);
|
|
1461
|
-
while (i < len) {
|
|
1462
|
-
const elemCmp = cmp(symbolX.charCodeAt(i), symbolY.charCodeAt(i));
|
|
1463
|
-
i += 1;
|
|
1464
|
-
if (elemCmp !== 0) {
|
|
1465
|
-
return elemCmp;
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
return lenCmp;
|
|
1469
|
-
}
|
|
1470
|
-
function isSortedSymbols(symbolX, symbolY) {
|
|
1471
|
-
return compare(symbolX, symbolY) === LESS_THAN;
|
|
1472
|
-
}
|
|
1473
|
-
function composeType(address, ...args) {
|
|
1474
|
-
const generics = Array.isArray(args[args.length - 1]) ? args.pop() : [];
|
|
1475
|
-
const chains = [address, ...args].filter(Boolean);
|
|
1476
|
-
let result = chains.join("::");
|
|
1477
|
-
if (generics && generics.length) {
|
|
1478
|
-
result += `<${generics.join(", ")}>`;
|
|
1479
|
-
}
|
|
1480
|
-
return result;
|
|
1481
|
-
}
|
|
1482
|
-
function extractAddressFromType(type) {
|
|
1483
|
-
return type.split("::")[0];
|
|
1484
|
-
}
|
|
1485
|
-
function extractStructTagFromType(type) {
|
|
1486
|
-
try {
|
|
1487
|
-
let _type = type.replace(/\s/g, "");
|
|
1488
|
-
const genericsString = _type.match(/(<.+>)$/);
|
|
1489
|
-
const generics = genericsString?.[0]?.match(/(\w+::\w+::\w+)(?:<.*?>(?!>))?/g);
|
|
1490
|
-
if (generics) {
|
|
1491
|
-
_type = _type.slice(0, _type.indexOf("<"));
|
|
1492
|
-
const tag = extractStructTagFromType(_type);
|
|
1493
|
-
const structTag2 = {
|
|
1494
|
-
...tag,
|
|
1495
|
-
type_arguments: generics.map((item) => extractStructTagFromType(item).source_address)
|
|
1496
|
-
};
|
|
1497
|
-
structTag2.type_arguments = structTag2.type_arguments.map((item) => {
|
|
1498
|
-
return CoinAssist.isSuiCoin(item) ? item : extractStructTagFromType(item).source_address;
|
|
1499
|
-
});
|
|
1500
|
-
structTag2.source_address = composeType(structTag2.full_address, structTag2.type_arguments);
|
|
1501
|
-
return structTag2;
|
|
1502
|
-
}
|
|
1503
|
-
const parts = _type.split("::");
|
|
1504
|
-
const isSuiCoin = _type === GAS_TYPE_ARG || _type === GAS_TYPE_ARG_LONG;
|
|
1505
|
-
const structTag = {
|
|
1506
|
-
full_address: _type,
|
|
1507
|
-
address: isSuiCoin ? "0x2" : (0, import_utils8.normalizeSuiObjectId)(parts[0]),
|
|
1508
|
-
module: parts[1],
|
|
1509
|
-
name: parts[2],
|
|
1510
|
-
type_arguments: [],
|
|
1511
|
-
source_address: ""
|
|
1512
|
-
};
|
|
1513
|
-
structTag.full_address = `${structTag.address}::${structTag.module}::${structTag.name}`;
|
|
1514
|
-
structTag.source_address = composeType(structTag.full_address, structTag.type_arguments);
|
|
1515
|
-
return structTag;
|
|
1516
|
-
} catch (error) {
|
|
1517
|
-
return {
|
|
1518
|
-
full_address: type,
|
|
1519
|
-
address: "",
|
|
1520
|
-
module: "",
|
|
1521
|
-
name: "",
|
|
1522
|
-
type_arguments: [],
|
|
1523
|
-
source_address: type
|
|
1524
|
-
};
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
function normalizeCoinType(coinType) {
|
|
1528
|
-
return extractStructTagFromType(coinType).source_address;
|
|
1529
|
-
}
|
|
1530
|
-
function fixSuiObjectId(value) {
|
|
1531
|
-
if (value.toLowerCase().startsWith("0x")) {
|
|
1532
|
-
return (0, import_utils8.normalizeSuiObjectId)(value);
|
|
1533
|
-
}
|
|
1534
|
-
return value;
|
|
1535
|
-
}
|
|
1536
|
-
var fixCoinType = (coinType, removePrefix = true) => {
|
|
1537
|
-
const arr = coinType.split("::");
|
|
1538
|
-
const address = arr.shift();
|
|
1539
|
-
let normalizeAddress = (0, import_utils8.normalizeSuiObjectId)(address);
|
|
1540
|
-
if (removePrefix) {
|
|
1541
|
-
normalizeAddress = removeHexPrefix(normalizeAddress);
|
|
1542
|
-
}
|
|
1543
|
-
return `${normalizeAddress}::${arr.join("::")}`;
|
|
1544
|
-
};
|
|
1545
|
-
function patchFixSuiObjectId(data) {
|
|
1546
|
-
for (const key in data) {
|
|
1547
|
-
const type = typeof data[key];
|
|
1548
|
-
if (type === "object") {
|
|
1549
|
-
patchFixSuiObjectId(data[key]);
|
|
1550
|
-
} else if (type === "string") {
|
|
1551
|
-
const value = data[key];
|
|
1552
|
-
if (value && !value.includes("::")) {
|
|
1553
|
-
data[key] = fixSuiObjectId(value);
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
1340
|
// src/math/CoinAssist.ts
|
|
1341
|
+
var import_transactions = require("@mysten/sui/transactions");
|
|
1560
1342
|
var COIN_TYPE = "0x2::coin::Coin";
|
|
1561
1343
|
var COIN_TYPE_ARG_REGEX = /^0x2::coin::Coin<(.+)>$/;
|
|
1562
1344
|
var DEFAULT_GAS_BUDGET_FOR_SPLIT = 1e3;
|
|
@@ -1761,6 +1543,92 @@ var CoinAssist = class {
|
|
|
1761
1543
|
static calculateTotalBalance(coins) {
|
|
1762
1544
|
return coins.reduce((partialSum, c) => partialSum + c.balance, BigInt(0));
|
|
1763
1545
|
}
|
|
1546
|
+
static getCoinAmountObjId(coin_input, amount) {
|
|
1547
|
+
const coin_obj = coin_input.amount_coin_array.find((coin) => {
|
|
1548
|
+
if (!coin.used && d(coin.amount).eq(amount)) {
|
|
1549
|
+
coin.used = true;
|
|
1550
|
+
return true;
|
|
1551
|
+
}
|
|
1552
|
+
return false;
|
|
1553
|
+
});
|
|
1554
|
+
if (!coin_obj) {
|
|
1555
|
+
return handleMessageError("CoinNotFound" /* CoinNotFound */, `Coin not found for ${amount} ${coin_input.coin_type}`);
|
|
1556
|
+
}
|
|
1557
|
+
return coin_obj.coin_object_id;
|
|
1558
|
+
}
|
|
1559
|
+
static buildCoinWithBalance(amount, coin_type, tx) {
|
|
1560
|
+
if (amount === BigInt(0)) {
|
|
1561
|
+
if (CoinAssist.isSuiCoin(coin_type)) {
|
|
1562
|
+
return tx.add((0, import_transactions.coinWithBalance)({ balance: amount, useGasCoin: false }));
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
return tx.add((0, import_transactions.coinWithBalance)({ balance: amount, type: coin_type }));
|
|
1566
|
+
}
|
|
1567
|
+
static buildMultiCoinInput(tx, all_coin_assets, coin_type, amount_arr) {
|
|
1568
|
+
const coin_assets = CoinAssist.getCoinAssets(coin_type, all_coin_assets);
|
|
1569
|
+
if (CoinAssist.isSuiCoin(coin_type)) {
|
|
1570
|
+
const amount_coins2 = tx.splitCoins(
|
|
1571
|
+
tx.gas,
|
|
1572
|
+
amount_arr.map((amount) => tx.pure.u64(amount))
|
|
1573
|
+
);
|
|
1574
|
+
const amount_coin_array2 = amount_arr.map((amount, index) => {
|
|
1575
|
+
return {
|
|
1576
|
+
coin_object_id: amount_coins2[index],
|
|
1577
|
+
amount: amount.toString(),
|
|
1578
|
+
used: false
|
|
1579
|
+
};
|
|
1580
|
+
});
|
|
1581
|
+
return {
|
|
1582
|
+
amount_coin_array: amount_coin_array2,
|
|
1583
|
+
coin_type,
|
|
1584
|
+
remain_coins: coin_assets
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
const total_amount = amount_arr.reduce((acc, curr) => acc + curr, BigInt(0));
|
|
1588
|
+
const selected_coins_result = CoinAssist.selectCoinObjectIdGreaterThanOrEqual(coin_assets, total_amount);
|
|
1589
|
+
if (selected_coins_result.objectArray.length === 0) {
|
|
1590
|
+
return handleMessageError(
|
|
1591
|
+
"InsufficientBalance" /* InsufficientBalance */,
|
|
1592
|
+
`No enough coins for ${coin_type} expect ${total_amount} actual ${CoinAssist.calculateTotalBalance(coin_assets)}`
|
|
1593
|
+
);
|
|
1594
|
+
}
|
|
1595
|
+
const [target_coin, ...other_coins] = selected_coins_result.objectArray;
|
|
1596
|
+
if (other_coins.length > 0) {
|
|
1597
|
+
tx.mergeCoins(target_coin, [...other_coins]);
|
|
1598
|
+
}
|
|
1599
|
+
const amount_coins = tx.splitCoins(
|
|
1600
|
+
target_coin,
|
|
1601
|
+
amount_arr.map((amount) => tx.pure.u64(amount))
|
|
1602
|
+
);
|
|
1603
|
+
const amount_coin_array = amount_arr.map((amount, index) => {
|
|
1604
|
+
return {
|
|
1605
|
+
coin_object_id: amount_coins[index],
|
|
1606
|
+
amount: amount.toString(),
|
|
1607
|
+
used: false
|
|
1608
|
+
};
|
|
1609
|
+
});
|
|
1610
|
+
return {
|
|
1611
|
+
amount_coin_array,
|
|
1612
|
+
remain_coins: selected_coins_result.remainCoins,
|
|
1613
|
+
coin_type
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
static fromBalance(balance, coin_type, tx) {
|
|
1617
|
+
const coin = tx.moveCall({
|
|
1618
|
+
target: `0x2::coin::from_balance`,
|
|
1619
|
+
typeArguments: [coin_type],
|
|
1620
|
+
arguments: [balance]
|
|
1621
|
+
});
|
|
1622
|
+
return coin;
|
|
1623
|
+
}
|
|
1624
|
+
static intoBalance(coin_obj, coin_type, tx) {
|
|
1625
|
+
const coin = tx.moveCall({
|
|
1626
|
+
target: `0x2::coin::into_balance`,
|
|
1627
|
+
typeArguments: [coin_type],
|
|
1628
|
+
arguments: [typeof coin_obj === "string" ? tx.object(coin_obj) : coin_obj]
|
|
1629
|
+
});
|
|
1630
|
+
return coin;
|
|
1631
|
+
}
|
|
1764
1632
|
};
|
|
1765
1633
|
|
|
1766
1634
|
// src/math/collect-fees.ts
|
|
@@ -2374,6 +2242,97 @@ function d(value) {
|
|
|
2374
2242
|
function decimalsMultiplier(decimals) {
|
|
2375
2243
|
return d(10).pow(d(decimals).abs());
|
|
2376
2244
|
}
|
|
2245
|
+
function toDecimalsAmount(amount, decimals, rounding = import_decimal7.default.ROUND_DOWN) {
|
|
2246
|
+
const mul = decimalsMultiplier(d(decimals));
|
|
2247
|
+
return d(amount).mul(mul).toFixed(0, rounding).toString();
|
|
2248
|
+
}
|
|
2249
|
+
function asUintN(int, bits = 32) {
|
|
2250
|
+
return BigInt.asUintN(bits, BigInt(int)).toString();
|
|
2251
|
+
}
|
|
2252
|
+
function asIntN(int, bits = 32) {
|
|
2253
|
+
return Number(BigInt.asIntN(bits, BigInt(int)));
|
|
2254
|
+
}
|
|
2255
|
+
function fromDecimalsAmount(amount, decimals) {
|
|
2256
|
+
const mul = decimalsMultiplier(d(decimals));
|
|
2257
|
+
return d(amount).div(mul).toString();
|
|
2258
|
+
}
|
|
2259
|
+
var fixDEAdd = (num, precision, auto_fix = true) => {
|
|
2260
|
+
if (`${num}` === "0") {
|
|
2261
|
+
if (!parseFloat(precision) || !auto_fix)
|
|
2262
|
+
return "0";
|
|
2263
|
+
return "0.".padEnd(precision + 2, "0");
|
|
2264
|
+
}
|
|
2265
|
+
if (!num)
|
|
2266
|
+
return "--";
|
|
2267
|
+
const number = parseFloat(num);
|
|
2268
|
+
const strN = num.toString();
|
|
2269
|
+
const flag = number < 0;
|
|
2270
|
+
let result = strN;
|
|
2271
|
+
if (strN.toLowerCase().includes("e")) {
|
|
2272
|
+
const n = strN.match(/(\d+?)(?:\.(\d*))?e([+-])(\d+)/);
|
|
2273
|
+
if (!n) {
|
|
2274
|
+
return num.toString();
|
|
2275
|
+
}
|
|
2276
|
+
const nl = n[1] || "0";
|
|
2277
|
+
const nr = n[2] || "";
|
|
2278
|
+
const type = n[3];
|
|
2279
|
+
const floatN = parseInt(n[4], 10);
|
|
2280
|
+
let params = "";
|
|
2281
|
+
let pr = nr.substring(floatN) || "";
|
|
2282
|
+
if (pr)
|
|
2283
|
+
pr = `.${pr}`;
|
|
2284
|
+
if (type !== "-") {
|
|
2285
|
+
for (let i = 0; i < floatN; i++) {
|
|
2286
|
+
params += nr[i] || "0";
|
|
2287
|
+
}
|
|
2288
|
+
result = nl + params + pr;
|
|
2289
|
+
} else {
|
|
2290
|
+
let strL = "0";
|
|
2291
|
+
for (let i = 0; i < floatN; i++) {
|
|
2292
|
+
params = (nl[nl.length - i - 1] || "0") + params;
|
|
2293
|
+
}
|
|
2294
|
+
if (nl.length > floatN) {
|
|
2295
|
+
strL = nl.substring(0, nl.length - floatN);
|
|
2296
|
+
}
|
|
2297
|
+
result = `${strL}.${params}${nr}`;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
if (precision && auto_fix) {
|
|
2301
|
+
let pal = `${result.split(".")[0]}.`;
|
|
2302
|
+
const par = result.split(".")[1] || "";
|
|
2303
|
+
for (let i = 0; i < precision; i++) {
|
|
2304
|
+
pal += par[i] || "0";
|
|
2305
|
+
}
|
|
2306
|
+
result = pal;
|
|
2307
|
+
}
|
|
2308
|
+
return `${flag ? "-" : ""}${result}`;
|
|
2309
|
+
};
|
|
2310
|
+
function convertScientificToDecimal(num_str, precision = 9) {
|
|
2311
|
+
if (num_str === void 0) {
|
|
2312
|
+
return "";
|
|
2313
|
+
}
|
|
2314
|
+
const new_num = num_str?.toLowerCase();
|
|
2315
|
+
if (new_num.includes("e")) {
|
|
2316
|
+
if (new_num.includes("+")) {
|
|
2317
|
+
return fixDEAdd(new_num, precision);
|
|
2318
|
+
}
|
|
2319
|
+
const [base, exponent_str] = new_num.split("e");
|
|
2320
|
+
let integer_part = base;
|
|
2321
|
+
const exponent = Math.abs(parseInt(exponent_str, 10));
|
|
2322
|
+
let zeros = "";
|
|
2323
|
+
let integer_length = integer_part.length;
|
|
2324
|
+
if (base.includes(".")) {
|
|
2325
|
+
const [int_part, frac_part] = base.split(".");
|
|
2326
|
+
integer_part = int_part + frac_part;
|
|
2327
|
+
integer_length = int_part.length;
|
|
2328
|
+
}
|
|
2329
|
+
for (let i = 0; i < exponent - integer_length; i++) {
|
|
2330
|
+
zeros += "0";
|
|
2331
|
+
}
|
|
2332
|
+
return `0.${zeros}${integer_part}`.slice(0, precision + 2);
|
|
2333
|
+
}
|
|
2334
|
+
return num_str;
|
|
2335
|
+
}
|
|
2377
2336
|
|
|
2378
2337
|
// src/math/LiquidityHelper.ts
|
|
2379
2338
|
function withLiquiditySlippage(value, slippage, mode) {
|
|
@@ -2707,73 +2666,300 @@ function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
|
|
|
2707
2666
|
currentSqrtPrice = tempStepResult.nextSqrtPrice;
|
|
2708
2667
|
}
|
|
2709
2668
|
}
|
|
2710
|
-
if (byAmountIn) {
|
|
2711
|
-
amounts.forEach((a, i) => {
|
|
2712
|
-
splitSwapResult.isExceed.push(splitSwapResult.amountInArray[i].lt(a));
|
|
2713
|
-
});
|
|
2714
|
-
} else {
|
|
2715
|
-
amounts.forEach((a, i) => {
|
|
2716
|
-
splitSwapResult.isExceed.push(splitSwapResult.amountOutArray[i].lt(a));
|
|
2717
|
-
});
|
|
2669
|
+
if (byAmountIn) {
|
|
2670
|
+
amounts.forEach((a, i) => {
|
|
2671
|
+
splitSwapResult.isExceed.push(splitSwapResult.amountInArray[i].lt(a));
|
|
2672
|
+
});
|
|
2673
|
+
} else {
|
|
2674
|
+
amounts.forEach((a, i) => {
|
|
2675
|
+
splitSwapResult.isExceed.push(splitSwapResult.amountOutArray[i].lt(a));
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2678
|
+
return splitSwapResult;
|
|
2679
|
+
}
|
|
2680
|
+
var SplitSwap = class {
|
|
2681
|
+
minSplitUnit;
|
|
2682
|
+
amountArray;
|
|
2683
|
+
byAmountIn;
|
|
2684
|
+
a2b;
|
|
2685
|
+
clmmpool;
|
|
2686
|
+
ticks;
|
|
2687
|
+
splitSwapResult;
|
|
2688
|
+
constructor(amount, unit, clmmpool, a2b, byAmountIn, tickData) {
|
|
2689
|
+
this.minSplitUnit = unit;
|
|
2690
|
+
this.a2b = a2b;
|
|
2691
|
+
this.byAmountIn = byAmountIn;
|
|
2692
|
+
this.clmmpool = clmmpool;
|
|
2693
|
+
this.ticks = tickData;
|
|
2694
|
+
this.amountArray = [];
|
|
2695
|
+
this.createSplitSwapParams = this.createSplitSwapParams.bind(this);
|
|
2696
|
+
this.createSplitSwapParams(amount, unit);
|
|
2697
|
+
this.splitSwapResult = {
|
|
2698
|
+
amountInArray: [],
|
|
2699
|
+
amountOutArray: [],
|
|
2700
|
+
feeAmountArray: [],
|
|
2701
|
+
nextSqrtPriceArray: [],
|
|
2702
|
+
isExceed: []
|
|
2703
|
+
};
|
|
2704
|
+
this.computeSwap = this.computeSwap.bind(this);
|
|
2705
|
+
}
|
|
2706
|
+
createSplitSwapParams(amount, unit) {
|
|
2707
|
+
const amountArray = createSplitAmountArray(amount, unit);
|
|
2708
|
+
this.amountArray = amountArray;
|
|
2709
|
+
}
|
|
2710
|
+
computeSwap() {
|
|
2711
|
+
const pool = transClmmpoolDataWithoutTicks(this.clmmpool);
|
|
2712
|
+
this.splitSwapResult = computeSplitSwap(this.a2b, this.byAmountIn, this.amountArray, pool, this.ticks);
|
|
2713
|
+
return this.splitSwapResult;
|
|
2714
|
+
}
|
|
2715
|
+
};
|
|
2716
|
+
|
|
2717
|
+
// src/math/bin.ts
|
|
2718
|
+
var import_decimal9 = __toESM(require("decimal.js"));
|
|
2719
|
+
var import_calc_almm2 = require("@magmaprotocol/calc_almm");
|
|
2720
|
+
var BinMath = class {
|
|
2721
|
+
static getPriceOfBinByBinId(binId, binStep, decimalsA, decimalsB) {
|
|
2722
|
+
const twoDec = new import_decimal9.default(2);
|
|
2723
|
+
const price = new import_decimal9.default((0, import_calc_almm2.get_price_x128_from_real_id)(binId, binStep));
|
|
2724
|
+
return price.div(twoDec.pow(128)).mul(import_decimal9.default.pow(10, decimalsA - decimalsB));
|
|
2725
|
+
}
|
|
2726
|
+
static getBinIdFromPrice(price, binStep, decimalsA, decimalsB) {
|
|
2727
|
+
const twoDec = new import_decimal9.default(2);
|
|
2728
|
+
const tenDec = new import_decimal9.default(10);
|
|
2729
|
+
const realid = (0, import_calc_almm2.get_real_id_from_price_x128)(
|
|
2730
|
+
new import_decimal9.default(price).mul(tenDec.pow(decimalsB - decimalsA)).mul(twoDec.pow(128)).toDecimalPlaces(0).toString(),
|
|
2731
|
+
binStep
|
|
2732
|
+
);
|
|
2733
|
+
return realid;
|
|
2734
|
+
}
|
|
2735
|
+
};
|
|
2736
|
+
|
|
2737
|
+
// src/utils/contracts.ts
|
|
2738
|
+
var import_utils12 = require("@mysten/sui/utils");
|
|
2739
|
+
|
|
2740
|
+
// src/utils/hex.ts
|
|
2741
|
+
var HEX_REGEXP = /^[-+]?[0-9A-Fa-f]+\.?[0-9A-Fa-f]*?$/;
|
|
2742
|
+
function addHexPrefix(hex) {
|
|
2743
|
+
return !hex.startsWith("0x") ? `0x${hex}` : hex;
|
|
2744
|
+
}
|
|
2745
|
+
function removeHexPrefix(hex) {
|
|
2746
|
+
return hex.startsWith("0x") ? `${hex.slice(2)}` : hex;
|
|
2747
|
+
}
|
|
2748
|
+
function shortString(str, start = 4, end = 4) {
|
|
2749
|
+
const slen = Math.max(start, 1);
|
|
2750
|
+
const elen = Math.max(end, 1);
|
|
2751
|
+
return `${str.slice(0, slen + 2)} ... ${str.slice(-elen)}`;
|
|
2752
|
+
}
|
|
2753
|
+
function shortAddress(address, start = 4, end = 4) {
|
|
2754
|
+
return shortString(addHexPrefix(address), start, end);
|
|
2755
|
+
}
|
|
2756
|
+
function checkAddress(address, options = { leadingZero: true }) {
|
|
2757
|
+
if (typeof address !== "string") {
|
|
2758
|
+
return false;
|
|
2759
|
+
}
|
|
2760
|
+
let str = address;
|
|
2761
|
+
if (options.leadingZero) {
|
|
2762
|
+
if (!address.startsWith("0x")) {
|
|
2763
|
+
return false;
|
|
2764
|
+
}
|
|
2765
|
+
str = str.substring(2);
|
|
2766
|
+
}
|
|
2767
|
+
return HEX_REGEXP.test(str);
|
|
2768
|
+
}
|
|
2769
|
+
function toBuffer(v) {
|
|
2770
|
+
if (!Buffer.isBuffer(v)) {
|
|
2771
|
+
if (Array.isArray(v)) {
|
|
2772
|
+
v = Buffer.from(v);
|
|
2773
|
+
} else if (typeof v === "string") {
|
|
2774
|
+
if (exports.isHexString(v)) {
|
|
2775
|
+
v = Buffer.from(exports.padToEven(exports.stripHexPrefix(v)), "hex");
|
|
2776
|
+
} else {
|
|
2777
|
+
v = Buffer.from(v);
|
|
2778
|
+
}
|
|
2779
|
+
} else if (typeof v === "number") {
|
|
2780
|
+
v = exports.intToBuffer(v);
|
|
2781
|
+
} else if (v === null || v === void 0) {
|
|
2782
|
+
v = Buffer.allocUnsafe(0);
|
|
2783
|
+
} else if (v.toArray) {
|
|
2784
|
+
v = Buffer.from(v.toArray());
|
|
2785
|
+
} else {
|
|
2786
|
+
throw new ClmmpoolsError(`Invalid type`, "InvalidType" /* InvalidType */);
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
return v;
|
|
2790
|
+
}
|
|
2791
|
+
function bufferToHex(buffer) {
|
|
2792
|
+
return addHexPrefix(toBuffer(buffer).toString("hex"));
|
|
2793
|
+
}
|
|
2794
|
+
function hexToNumber(binaryData) {
|
|
2795
|
+
const buffer = new ArrayBuffer(4);
|
|
2796
|
+
const view = new DataView(buffer);
|
|
2797
|
+
for (let i = 0; i < binaryData.length; i++) {
|
|
2798
|
+
view.setUint8(i, binaryData.charCodeAt(i));
|
|
2799
|
+
}
|
|
2800
|
+
const number = view.getUint32(0, true);
|
|
2801
|
+
return number;
|
|
2802
|
+
}
|
|
2803
|
+
function utf8to16(str) {
|
|
2804
|
+
let out;
|
|
2805
|
+
let i;
|
|
2806
|
+
let c;
|
|
2807
|
+
let char2;
|
|
2808
|
+
let char3;
|
|
2809
|
+
out = "";
|
|
2810
|
+
const len = str.length;
|
|
2811
|
+
i = 0;
|
|
2812
|
+
while (i < len) {
|
|
2813
|
+
c = str.charCodeAt(i++);
|
|
2814
|
+
switch (c >> 4) {
|
|
2815
|
+
case 0:
|
|
2816
|
+
case 1:
|
|
2817
|
+
case 2:
|
|
2818
|
+
case 3:
|
|
2819
|
+
case 4:
|
|
2820
|
+
case 5:
|
|
2821
|
+
case 6:
|
|
2822
|
+
case 7:
|
|
2823
|
+
out += str.charAt(i - 1);
|
|
2824
|
+
break;
|
|
2825
|
+
case 12:
|
|
2826
|
+
case 13:
|
|
2827
|
+
char2 = str.charCodeAt(i++);
|
|
2828
|
+
out += String.fromCharCode((c & 31) << 6 | char2 & 63);
|
|
2829
|
+
break;
|
|
2830
|
+
case 14:
|
|
2831
|
+
char2 = str.charCodeAt(i++);
|
|
2832
|
+
char3 = str.charCodeAt(i++);
|
|
2833
|
+
out += String.fromCharCode((c & 15) << 12 | (char2 & 63) << 6 | (char3 & 63) << 0);
|
|
2834
|
+
break;
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
return out;
|
|
2838
|
+
}
|
|
2839
|
+
function hexToString(str) {
|
|
2840
|
+
let val = "";
|
|
2841
|
+
const newStr = removeHexPrefix(str);
|
|
2842
|
+
const len = newStr.length / 2;
|
|
2843
|
+
for (let i = 0; i < len; i++) {
|
|
2844
|
+
val += String.fromCharCode(parseInt(newStr.substr(i * 2, 2), 16));
|
|
2845
|
+
}
|
|
2846
|
+
return utf8to16(val);
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
// src/utils/contracts.ts
|
|
2850
|
+
var EQUAL = 0;
|
|
2851
|
+
var LESS_THAN = 1;
|
|
2852
|
+
var GREATER_THAN = 2;
|
|
2853
|
+
function cmp(a, b) {
|
|
2854
|
+
if (a === b) {
|
|
2855
|
+
return EQUAL;
|
|
2856
|
+
}
|
|
2857
|
+
if (a < b) {
|
|
2858
|
+
return LESS_THAN;
|
|
2859
|
+
}
|
|
2860
|
+
return GREATER_THAN;
|
|
2861
|
+
}
|
|
2862
|
+
function compare(symbolX, symbolY) {
|
|
2863
|
+
let i = 0;
|
|
2864
|
+
const len = symbolX.length <= symbolY.length ? symbolX.length : symbolY.length;
|
|
2865
|
+
const lenCmp = cmp(symbolX.length, symbolY.length);
|
|
2866
|
+
while (i < len) {
|
|
2867
|
+
const elemCmp = cmp(symbolX.charCodeAt(i), symbolY.charCodeAt(i));
|
|
2868
|
+
i += 1;
|
|
2869
|
+
if (elemCmp !== 0) {
|
|
2870
|
+
return elemCmp;
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
return lenCmp;
|
|
2874
|
+
}
|
|
2875
|
+
function isSortedSymbols(symbolX, symbolY) {
|
|
2876
|
+
return compare(symbolX, symbolY) === LESS_THAN;
|
|
2877
|
+
}
|
|
2878
|
+
function composeType(address, ...args) {
|
|
2879
|
+
const generics = Array.isArray(args[args.length - 1]) ? args.pop() : [];
|
|
2880
|
+
const chains = [address, ...args].filter(Boolean);
|
|
2881
|
+
let result = chains.join("::");
|
|
2882
|
+
if (generics && generics.length) {
|
|
2883
|
+
result += `<${generics.join(", ")}>`;
|
|
2718
2884
|
}
|
|
2719
|
-
return
|
|
2885
|
+
return result;
|
|
2720
2886
|
}
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2887
|
+
function extractAddressFromType(type) {
|
|
2888
|
+
return type.split("::")[0];
|
|
2889
|
+
}
|
|
2890
|
+
function extractStructTagFromType(type) {
|
|
2891
|
+
try {
|
|
2892
|
+
let _type = type.replace(/\s/g, "");
|
|
2893
|
+
const genericsString = _type.match(/(<.+>)$/);
|
|
2894
|
+
const generics = genericsString?.[0]?.match(/(\w+::\w+::\w+)(?:<.*?>(?!>))?/g);
|
|
2895
|
+
if (generics) {
|
|
2896
|
+
_type = _type.slice(0, _type.indexOf("<"));
|
|
2897
|
+
const tag = extractStructTagFromType(_type);
|
|
2898
|
+
const structTag2 = {
|
|
2899
|
+
...tag,
|
|
2900
|
+
type_arguments: generics.map((item) => extractStructTagFromType(item).source_address)
|
|
2901
|
+
};
|
|
2902
|
+
structTag2.type_arguments = structTag2.type_arguments.map((item) => {
|
|
2903
|
+
return CoinAssist.isSuiCoin(item) ? item : extractStructTagFromType(item).source_address;
|
|
2904
|
+
});
|
|
2905
|
+
structTag2.source_address = composeType(structTag2.full_address, structTag2.type_arguments);
|
|
2906
|
+
return structTag2;
|
|
2907
|
+
}
|
|
2908
|
+
const parts = _type.split("::");
|
|
2909
|
+
const isSuiCoin = _type === GAS_TYPE_ARG || _type === GAS_TYPE_ARG_LONG;
|
|
2910
|
+
const structTag = {
|
|
2911
|
+
full_address: _type,
|
|
2912
|
+
address: isSuiCoin ? "0x2" : (0, import_utils12.normalizeSuiObjectId)(parts[0]),
|
|
2913
|
+
module: parts[1],
|
|
2914
|
+
name: parts[2],
|
|
2915
|
+
type_arguments: [],
|
|
2916
|
+
source_address: ""
|
|
2917
|
+
};
|
|
2918
|
+
structTag.full_address = `${structTag.address}::${structTag.module}::${structTag.name}`;
|
|
2919
|
+
structTag.source_address = composeType(structTag.full_address, structTag.type_arguments);
|
|
2920
|
+
return structTag;
|
|
2921
|
+
} catch (error) {
|
|
2922
|
+
return {
|
|
2923
|
+
full_address: type,
|
|
2924
|
+
address: "",
|
|
2925
|
+
module: "",
|
|
2926
|
+
name: "",
|
|
2927
|
+
type_arguments: [],
|
|
2928
|
+
source_address: type
|
|
2744
2929
|
};
|
|
2745
|
-
this.computeSwap = this.computeSwap.bind(this);
|
|
2746
2930
|
}
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2931
|
+
}
|
|
2932
|
+
function normalizeCoinType(coinType) {
|
|
2933
|
+
return extractStructTagFromType(coinType).source_address;
|
|
2934
|
+
}
|
|
2935
|
+
function fixSuiObjectId(value) {
|
|
2936
|
+
if (value.toLowerCase().startsWith("0x")) {
|
|
2937
|
+
return (0, import_utils12.normalizeSuiObjectId)(value);
|
|
2750
2938
|
}
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2939
|
+
return value;
|
|
2940
|
+
}
|
|
2941
|
+
var fixCoinType = (coinType, removePrefix = true) => {
|
|
2942
|
+
const arr = coinType.split("::");
|
|
2943
|
+
const address = arr.shift();
|
|
2944
|
+
let normalizeAddress = (0, import_utils12.normalizeSuiObjectId)(address);
|
|
2945
|
+
if (removePrefix) {
|
|
2946
|
+
normalizeAddress = removeHexPrefix(normalizeAddress);
|
|
2755
2947
|
}
|
|
2948
|
+
return `${normalizeAddress}::${arr.join("::")}`;
|
|
2756
2949
|
};
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
const twoDec = new import_decimal9.default(2);
|
|
2769
|
-
const tenDec = new import_decimal9.default(10);
|
|
2770
|
-
const realid = (0, import_calc_almm2.get_real_id_from_price_x128)(
|
|
2771
|
-
new import_decimal9.default(price).mul(tenDec.pow(decimalsB - decimalsA)).mul(twoDec.pow(128)).toDecimalPlaces(0).toString(),
|
|
2772
|
-
binStep
|
|
2773
|
-
);
|
|
2774
|
-
return realid;
|
|
2950
|
+
function patchFixSuiObjectId(data) {
|
|
2951
|
+
for (const key in data) {
|
|
2952
|
+
const type = typeof data[key];
|
|
2953
|
+
if (type === "object") {
|
|
2954
|
+
patchFixSuiObjectId(data[key]);
|
|
2955
|
+
} else if (type === "string") {
|
|
2956
|
+
const value = data[key];
|
|
2957
|
+
if (value && !value.includes("::")) {
|
|
2958
|
+
data[key] = fixSuiObjectId(value);
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2775
2961
|
}
|
|
2776
|
-
}
|
|
2962
|
+
}
|
|
2777
2963
|
|
|
2778
2964
|
// src/utils/objects.ts
|
|
2779
2965
|
function getSuiObjectData(resp) {
|
|
@@ -2883,20 +3069,6 @@ function hasPublicTransfer(data) {
|
|
|
2883
3069
|
}
|
|
2884
3070
|
|
|
2885
3071
|
// src/utils/common.ts
|
|
2886
|
-
function toDecimalsAmount(amount, decimals) {
|
|
2887
|
-
const mul = decimalsMultiplier(d(decimals));
|
|
2888
|
-
return Number(d(amount).mul(mul));
|
|
2889
|
-
}
|
|
2890
|
-
function asUintN(int, bits = 32) {
|
|
2891
|
-
return BigInt.asUintN(bits, BigInt(int)).toString();
|
|
2892
|
-
}
|
|
2893
|
-
function asIntN(int, bits = 32) {
|
|
2894
|
-
return Number(BigInt.asIntN(bits, BigInt(int)));
|
|
2895
|
-
}
|
|
2896
|
-
function fromDecimalsAmount(amount, decimals) {
|
|
2897
|
-
const mul = decimalsMultiplier(d(decimals));
|
|
2898
|
-
return Number(d(amount).div(mul));
|
|
2899
|
-
}
|
|
2900
3072
|
function secretKeyToEd25519Keypair(secretKey, ecode = "hex") {
|
|
2901
3073
|
if (secretKey instanceof Uint8Array) {
|
|
2902
3074
|
const key = Buffer.from(secretKey);
|
|
@@ -3223,7 +3395,7 @@ function getRewardInTickRange(pool, tickLower, tickUpper, tickLowerIndex, tickUp
|
|
|
3223
3395
|
// src/utils/transaction-util.ts
|
|
3224
3396
|
var import_bn15 = __toESM(require("bn.js"));
|
|
3225
3397
|
var import_decimal10 = __toESM(require("decimal.js"));
|
|
3226
|
-
var
|
|
3398
|
+
var import_transactions2 = require("@mysten/sui/transactions");
|
|
3227
3399
|
function findAdjustCoin(coinPair) {
|
|
3228
3400
|
const isAdjustCoinA = CoinAssist.isSuiCoin(coinPair.coinTypeA);
|
|
3229
3401
|
const isAdjustCoinB = CoinAssist.isSuiCoin(coinPair.coinTypeB);
|
|
@@ -3314,7 +3486,7 @@ var _TransactionUtil = class {
|
|
|
3314
3486
|
if (amount < 0) {
|
|
3315
3487
|
throw new ClmmpoolsError(`gas Insufficient balance`, "InsufficientBalance" /* InsufficientBalance */);
|
|
3316
3488
|
}
|
|
3317
|
-
const newTx = new
|
|
3489
|
+
const newTx = new import_transactions2.Transaction();
|
|
3318
3490
|
return { fixAmount: amount, newTx };
|
|
3319
3491
|
}
|
|
3320
3492
|
}
|
|
@@ -3404,7 +3576,7 @@ var _TransactionUtil = class {
|
|
|
3404
3576
|
if (sdk.senderAddress.length === 0) {
|
|
3405
3577
|
throw Error("this config sdk senderAddress is empty");
|
|
3406
3578
|
}
|
|
3407
|
-
tx = tx || new
|
|
3579
|
+
tx = tx || new import_transactions2.Transaction();
|
|
3408
3580
|
let primaryCoinAInputs;
|
|
3409
3581
|
let primaryCoinBInputs;
|
|
3410
3582
|
if (inputCoinA == null || inputCoinB == null) {
|
|
@@ -3462,7 +3634,7 @@ var _TransactionUtil = class {
|
|
|
3462
3634
|
if (sdk.senderAddress.length === 0) {
|
|
3463
3635
|
throw Error("this config sdk senderAddress is empty");
|
|
3464
3636
|
}
|
|
3465
|
-
tx = tx || new
|
|
3637
|
+
tx = tx || new import_transactions2.Transaction();
|
|
3466
3638
|
let primaryCoinAInputs;
|
|
3467
3639
|
let primaryCoinBInputs;
|
|
3468
3640
|
if (inputCoinA == null || inputCoinB == null) {
|
|
@@ -3759,7 +3931,7 @@ var _TransactionUtil = class {
|
|
|
3759
3931
|
* @returns
|
|
3760
3932
|
*/
|
|
3761
3933
|
static buildSwapTransaction(sdk, params, allCoinAsset) {
|
|
3762
|
-
let tx = new
|
|
3934
|
+
let tx = new import_transactions2.Transaction();
|
|
3763
3935
|
tx.setSender(sdk.senderAddress);
|
|
3764
3936
|
const primaryCoinInputA = _TransactionUtil.buildCoinForAmount(
|
|
3765
3937
|
tx,
|
|
@@ -3779,7 +3951,7 @@ var _TransactionUtil = class {
|
|
|
3779
3951
|
return tx;
|
|
3780
3952
|
}
|
|
3781
3953
|
static buildCreateLockTransaction(sdk, params, allCoinAsset) {
|
|
3782
|
-
let tx = new
|
|
3954
|
+
let tx = new import_transactions2.Transaction();
|
|
3783
3955
|
tx.setSender(sdk.senderAddress);
|
|
3784
3956
|
const { magma_token } = getPackagerConfigs(sdk.sdkOptions.ve33);
|
|
3785
3957
|
const lockCoinInput = _TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(params.amount), magma_token, false, true);
|
|
@@ -3808,7 +3980,7 @@ var _TransactionUtil = class {
|
|
|
3808
3980
|
}
|
|
3809
3981
|
static buildIncreaseLockAmountTransaction(sdk, params, allCoinAsset) {
|
|
3810
3982
|
const { magma_token } = getPackagerConfigs(sdk.sdkOptions.ve33);
|
|
3811
|
-
let tx = new
|
|
3983
|
+
let tx = new import_transactions2.Transaction();
|
|
3812
3984
|
tx.setSender(sdk.senderAddress);
|
|
3813
3985
|
const lockCoinInput = _TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(params.amount), magma_token, false, true);
|
|
3814
3986
|
tx = _TransactionUtil.buildIncreaseLockAmountTransactionArgs(tx, params, sdk.sdkOptions, lockCoinInput);
|
|
@@ -3829,7 +4001,7 @@ var _TransactionUtil = class {
|
|
|
3829
4001
|
}
|
|
3830
4002
|
// public fun merge<T>(self: &mut VotingEscrow<T>, from_lock: Lock, to_lock: &mut Lock, clock: &Clock, ctx: &mut TxContext) {
|
|
3831
4003
|
static buildMergeLockTransaction(sdk, params) {
|
|
3832
|
-
const tx = new
|
|
4004
|
+
const tx = new import_transactions2.Transaction();
|
|
3833
4005
|
tx.setSender(sdk.senderAddress);
|
|
3834
4006
|
const { integrate, ve33 } = sdk.sdkOptions;
|
|
3835
4007
|
const { voter_id, voting_escrow_id, magma_token, distribution_cfg } = getPackagerConfigs(ve33);
|
|
@@ -3852,7 +4024,7 @@ var _TransactionUtil = class {
|
|
|
3852
4024
|
}
|
|
3853
4025
|
// public fun transfer<T>(lock: Lock, ve: &mut VotingEscrow<T>, to: address, clock: &Clock, ctx: &mut TxContext) {
|
|
3854
4026
|
static buildTransferLockTransaction(sdk, params) {
|
|
3855
|
-
const tx = new
|
|
4027
|
+
const tx = new import_transactions2.Transaction();
|
|
3856
4028
|
tx.setSender(sdk.senderAddress);
|
|
3857
4029
|
const { integrate, ve33 } = sdk.sdkOptions;
|
|
3858
4030
|
const { voting_escrow_id, magma_token } = getPackagerConfigs(ve33);
|
|
@@ -3868,7 +4040,7 @@ var _TransactionUtil = class {
|
|
|
3868
4040
|
}
|
|
3869
4041
|
// public fun increase_unlock_time<T>(self: &mut VotingEscrow<T>, lock: &mut Lock, lock_duration: u64, clock: &Clock, ctx: &mut TxContext) {
|
|
3870
4042
|
static buildIncreaseUnlockTimeTransaction(sdk, params) {
|
|
3871
|
-
const tx = new
|
|
4043
|
+
const tx = new import_transactions2.Transaction();
|
|
3872
4044
|
tx.setSender(sdk.senderAddress);
|
|
3873
4045
|
const oneDay = 24 * 60 * 60;
|
|
3874
4046
|
const newLockDuration = Math.ceil((params.newLockEndAt - Date.now() / 1e3) / oneDay);
|
|
@@ -3886,7 +4058,7 @@ var _TransactionUtil = class {
|
|
|
3886
4058
|
}
|
|
3887
4059
|
// public fun lock_permanent<T>(self: &mut VotingEscrow<T>, lock: &mut Lock, clock: &Clock, ctx: &mut TxContext) {
|
|
3888
4060
|
static buildLockPermanentTransaction(sdk, params) {
|
|
3889
|
-
const tx = new
|
|
4061
|
+
const tx = new import_transactions2.Transaction();
|
|
3890
4062
|
tx.setSender(sdk.senderAddress);
|
|
3891
4063
|
const { integrate, ve33 } = sdk.sdkOptions;
|
|
3892
4064
|
const { voting_escrow_id, magma_token } = getPackagerConfigs(ve33);
|
|
@@ -3901,7 +4073,7 @@ var _TransactionUtil = class {
|
|
|
3901
4073
|
return tx;
|
|
3902
4074
|
}
|
|
3903
4075
|
static buildUnlockPermanentTransaction(sdk, params) {
|
|
3904
|
-
const tx = new
|
|
4076
|
+
const tx = new import_transactions2.Transaction();
|
|
3905
4077
|
tx.setSender(sdk.senderAddress);
|
|
3906
4078
|
const { integrate, ve33 } = sdk.sdkOptions;
|
|
3907
4079
|
const { voting_escrow_id, magma_token, distribution_cfg, voter_id } = getPackagerConfigs(ve33);
|
|
@@ -3922,7 +4094,7 @@ var _TransactionUtil = class {
|
|
|
3922
4094
|
return tx;
|
|
3923
4095
|
}
|
|
3924
4096
|
static buildBurnLockTransaction(sdk, lockId) {
|
|
3925
|
-
const tx = new
|
|
4097
|
+
const tx = new import_transactions2.Transaction();
|
|
3926
4098
|
tx.setSender(sdk.senderAddress);
|
|
3927
4099
|
const { integrate, ve33 } = sdk.sdkOptions;
|
|
3928
4100
|
const { voting_escrow_id, magma_token, distribution_cfg, voter_id } = getPackagerConfigs(ve33);
|
|
@@ -3943,7 +4115,7 @@ var _TransactionUtil = class {
|
|
|
3943
4115
|
return tx;
|
|
3944
4116
|
}
|
|
3945
4117
|
static buildSplitLockTransaction(sdk, lockId, splitAmount) {
|
|
3946
|
-
const tx = new
|
|
4118
|
+
const tx = new import_transactions2.Transaction();
|
|
3947
4119
|
tx.setSender(sdk.senderAddress);
|
|
3948
4120
|
const { integrate, ve33 } = sdk.sdkOptions;
|
|
3949
4121
|
const { voting_escrow_id, magma_token, distribution_cfg, voter_id } = getPackagerConfigs(ve33);
|
|
@@ -3965,7 +4137,7 @@ var _TransactionUtil = class {
|
|
|
3965
4137
|
return tx;
|
|
3966
4138
|
}
|
|
3967
4139
|
static buildVoteTransaction(sdk, params) {
|
|
3968
|
-
const tx = new
|
|
4140
|
+
const tx = new import_transactions2.Transaction();
|
|
3969
4141
|
tx.setSender(sdk.senderAddress);
|
|
3970
4142
|
const { integrate, ve33 } = sdk.sdkOptions;
|
|
3971
4143
|
const { distribution_cfg, voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
@@ -3993,7 +4165,7 @@ var _TransactionUtil = class {
|
|
|
3993
4165
|
return tx;
|
|
3994
4166
|
}
|
|
3995
4167
|
static buildClaimVotingRewardsTransaction(sdk, params) {
|
|
3996
|
-
const tx = new
|
|
4168
|
+
const tx = new import_transactions2.Transaction();
|
|
3997
4169
|
tx.setSender(sdk.senderAddress);
|
|
3998
4170
|
const { integrate, ve33 } = sdk.sdkOptions;
|
|
3999
4171
|
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
@@ -4008,7 +4180,7 @@ var _TransactionUtil = class {
|
|
|
4008
4180
|
return tx;
|
|
4009
4181
|
}
|
|
4010
4182
|
static buildClaimVotingRewardsPoolsTransaction(sdk, params) {
|
|
4011
|
-
const tx = new
|
|
4183
|
+
const tx = new import_transactions2.Transaction();
|
|
4012
4184
|
tx.setSender(sdk.senderAddress);
|
|
4013
4185
|
const { integrate, distribution, ve33 } = sdk.sdkOptions;
|
|
4014
4186
|
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
@@ -4027,7 +4199,7 @@ var _TransactionUtil = class {
|
|
|
4027
4199
|
return tx;
|
|
4028
4200
|
}
|
|
4029
4201
|
static buildClaimAndLockRebases(sdk, params) {
|
|
4030
|
-
const tx = new
|
|
4202
|
+
const tx = new import_transactions2.Transaction();
|
|
4031
4203
|
tx.setSender(sdk.senderAddress);
|
|
4032
4204
|
const { integrate, ve33 } = sdk.sdkOptions;
|
|
4033
4205
|
const { voting_escrow_id, magma_token, reward_distributor_id } = getPackagerConfigs(ve33);
|
|
@@ -4042,7 +4214,7 @@ var _TransactionUtil = class {
|
|
|
4042
4214
|
return tx;
|
|
4043
4215
|
}
|
|
4044
4216
|
static buildPoke(sdk, params) {
|
|
4045
|
-
const tx = new
|
|
4217
|
+
const tx = new import_transactions2.Transaction();
|
|
4046
4218
|
tx.setSender(sdk.senderAddress);
|
|
4047
4219
|
const { integrate, ve33 } = sdk.sdkOptions;
|
|
4048
4220
|
const { distribution_cfg, voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
@@ -4063,7 +4235,7 @@ var _TransactionUtil = class {
|
|
|
4063
4235
|
return tx;
|
|
4064
4236
|
}
|
|
4065
4237
|
static buildClaimVotingBribe(sdk, locks, incentive_tokens) {
|
|
4066
|
-
const tx = new
|
|
4238
|
+
const tx = new import_transactions2.Transaction();
|
|
4067
4239
|
tx.setSender(sdk.senderAddress);
|
|
4068
4240
|
const { integrate, distribution, ve33 } = sdk.sdkOptions;
|
|
4069
4241
|
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
@@ -4191,7 +4363,7 @@ var _TransactionUtil = class {
|
|
|
4191
4363
|
* @returns
|
|
4192
4364
|
*/
|
|
4193
4365
|
static buildSwapTransactionWithoutTransferCoins(sdk, params, allCoinAsset) {
|
|
4194
|
-
const tx = new
|
|
4366
|
+
const tx = new import_transactions2.Transaction();
|
|
4195
4367
|
tx.setSender(sdk.senderAddress);
|
|
4196
4368
|
const primaryCoinInputA = _TransactionUtil.buildCoinForAmount(
|
|
4197
4369
|
tx,
|
|
@@ -4457,7 +4629,7 @@ var _TransactionUtil = class {
|
|
|
4457
4629
|
}
|
|
4458
4630
|
// ------------------------------------------router-v1-------------------------------------------------//
|
|
4459
4631
|
static async buildRouterSwapTransaction(sdk, params, byAmountIn, allCoinAsset, recipient) {
|
|
4460
|
-
let tx = new
|
|
4632
|
+
let tx = new import_transactions2.Transaction();
|
|
4461
4633
|
if (params.paths.length > 1) {
|
|
4462
4634
|
params.partner = "";
|
|
4463
4635
|
}
|
|
@@ -4770,7 +4942,7 @@ var _TransactionUtil = class {
|
|
|
4770
4942
|
return { fromCoin, toCoin, tx };
|
|
4771
4943
|
}
|
|
4772
4944
|
static async buildAggregatorSwapTransaction(sdk, param, allCoinAsset, partner, priceSlippagePoint, recipient) {
|
|
4773
|
-
let tx = new
|
|
4945
|
+
let tx = new import_transactions2.Transaction();
|
|
4774
4946
|
const amountLimit = param.byAmountIn ? Math.round(param.outputAmount * (1 - priceSlippagePoint)) : Math.round(param.inputAmount * (1 + priceSlippagePoint));
|
|
4775
4947
|
const fromCoinBuildResult = _TransactionUtil.buildCoinForAmount(
|
|
4776
4948
|
tx,
|
|
@@ -4953,7 +5125,7 @@ __publicField(TransactionUtil, "callMintZeroValueCoin", (txb, coinType) => {
|
|
|
4953
5125
|
});
|
|
4954
5126
|
|
|
4955
5127
|
// src/utils/tx-block.ts
|
|
4956
|
-
var
|
|
5128
|
+
var import_transactions3 = require("@mysten/sui/transactions");
|
|
4957
5129
|
function checkInvalidSuiAddress(address) {
|
|
4958
5130
|
if (!address.startsWith("0x") || address.length !== 66) {
|
|
4959
5131
|
return false;
|
|
@@ -4963,7 +5135,7 @@ function checkInvalidSuiAddress(address) {
|
|
|
4963
5135
|
var TxBlock = class {
|
|
4964
5136
|
txBlock;
|
|
4965
5137
|
constructor() {
|
|
4966
|
-
this.txBlock = new
|
|
5138
|
+
this.txBlock = new import_transactions3.Transaction();
|
|
4967
5139
|
}
|
|
4968
5140
|
/**
|
|
4969
5141
|
* Transfer sui to many recipoents.
|
|
@@ -5031,7 +5203,7 @@ var TxBlock = class {
|
|
|
5031
5203
|
|
|
5032
5204
|
// src/utils/deepbook-utils.ts
|
|
5033
5205
|
var import_bn16 = __toESM(require("bn.js"));
|
|
5034
|
-
var
|
|
5206
|
+
var import_transactions4 = require("@mysten/sui/transactions");
|
|
5035
5207
|
var FLOAT_SCALING = new import_bn16.default(1e9);
|
|
5036
5208
|
var DeepbookUtils = class {
|
|
5037
5209
|
static createAccountCap(senderAddress, sdkOptions, tx, isTransfer = false) {
|
|
@@ -5112,7 +5284,7 @@ var DeepbookUtils = class {
|
|
|
5112
5284
|
static async getPoolAsks(sdk, poolAddress, baseCoin, quoteCoin) {
|
|
5113
5285
|
const { simulationAccount } = sdk.sdkOptions;
|
|
5114
5286
|
const { deepbook_endpoint_v2 } = sdk.sdkOptions;
|
|
5115
|
-
const tx = new
|
|
5287
|
+
const tx = new import_transactions4.Transaction();
|
|
5116
5288
|
const asks = [];
|
|
5117
5289
|
const typeArguments = [baseCoin, quoteCoin];
|
|
5118
5290
|
const args = [tx.object(poolAddress), tx.pure.u64("0"), tx.pure.u64("999999999999"), tx.object(CLOCK_ADDRESS)];
|
|
@@ -5145,7 +5317,7 @@ var DeepbookUtils = class {
|
|
|
5145
5317
|
static async getPoolBids(sdk, poolAddress, baseCoin, quoteCoin) {
|
|
5146
5318
|
const { simulationAccount } = sdk.sdkOptions;
|
|
5147
5319
|
const { deepbook_endpoint_v2 } = sdk.sdkOptions;
|
|
5148
|
-
const tx = new
|
|
5320
|
+
const tx = new import_transactions4.Transaction();
|
|
5149
5321
|
const bids = [];
|
|
5150
5322
|
const typeArguments = [baseCoin, quoteCoin];
|
|
5151
5323
|
const args = [tx.object(poolAddress), tx.pure.u64("0"), tx.pure.u64("999999999999"), tx.object(CLOCK_ADDRESS)];
|
|
@@ -5249,7 +5421,7 @@ var DeepbookUtils = class {
|
|
|
5249
5421
|
}
|
|
5250
5422
|
static async simulateSwap(sdk, poolID, baseCoin, quoteCoin, a2b, amount) {
|
|
5251
5423
|
const { deepbook_endpoint_v2 } = sdk.sdkOptions;
|
|
5252
|
-
let tx = new
|
|
5424
|
+
let tx = new import_transactions4.Transaction();
|
|
5253
5425
|
const accountCapStr = await this.getAccountCap(sdk);
|
|
5254
5426
|
let accountCap;
|
|
5255
5427
|
if (accountCapStr === "") {
|
|
@@ -5573,7 +5745,7 @@ var PoolModule = class {
|
|
|
5573
5745
|
*/
|
|
5574
5746
|
async creatPoolsTransactionPayload(paramss) {
|
|
5575
5747
|
for (const params of paramss) {
|
|
5576
|
-
if (isSortedSymbols((0,
|
|
5748
|
+
if (isSortedSymbols((0, import_utils14.normalizeSuiAddress)(params.coinTypeA), (0, import_utils14.normalizeSuiAddress)(params.coinTypeB))) {
|
|
5577
5749
|
const swpaCoinTypeB = params.coinTypeB;
|
|
5578
5750
|
params.coinTypeB = params.coinTypeA;
|
|
5579
5751
|
params.coinTypeA = swpaCoinTypeB;
|
|
@@ -5589,7 +5761,7 @@ var PoolModule = class {
|
|
|
5589
5761
|
* @returns {Promise<Transaction>}
|
|
5590
5762
|
*/
|
|
5591
5763
|
async creatPoolTransactionPayload(params) {
|
|
5592
|
-
if (isSortedSymbols((0,
|
|
5764
|
+
if (isSortedSymbols((0, import_utils14.normalizeSuiAddress)(params.coinTypeA), (0, import_utils14.normalizeSuiAddress)(params.coinTypeB))) {
|
|
5593
5765
|
const swpaCoinTypeB = params.coinTypeB;
|
|
5594
5766
|
params.coinTypeB = params.coinTypeA;
|
|
5595
5767
|
params.coinTypeA = swpaCoinTypeB;
|
|
@@ -5602,7 +5774,7 @@ var PoolModule = class {
|
|
|
5602
5774
|
* @returns {Promise<Transaction>}
|
|
5603
5775
|
*/
|
|
5604
5776
|
async createPoolTransactionPayload(params) {
|
|
5605
|
-
if (isSortedSymbols((0,
|
|
5777
|
+
if (isSortedSymbols((0, import_utils14.normalizeSuiAddress)(params.coinTypeA), (0, import_utils14.normalizeSuiAddress)(params.coinTypeB))) {
|
|
5606
5778
|
const swpaCoinTypeB = params.coinTypeB;
|
|
5607
5779
|
params.coinTypeB = params.coinTypeA;
|
|
5608
5780
|
params.coinTypeA = swpaCoinTypeB;
|
|
@@ -5704,7 +5876,7 @@ var PoolModule = class {
|
|
|
5704
5876
|
* @returns {Promise<Transaction>} A promise that resolves to the transaction payload.
|
|
5705
5877
|
*/
|
|
5706
5878
|
async creatPool(params) {
|
|
5707
|
-
const tx = new
|
|
5879
|
+
const tx = new import_transactions5.Transaction();
|
|
5708
5880
|
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
5709
5881
|
const eventConfig = getPackagerConfigs(clmm_pool);
|
|
5710
5882
|
const globalPauseStatusObjectId = eventConfig.global_config_id;
|
|
@@ -5735,7 +5907,7 @@ var PoolModule = class {
|
|
|
5735
5907
|
if (!checkInvalidSuiAddress(this._sdk.senderAddress)) {
|
|
5736
5908
|
throw new ClmmpoolsError("this config sdk senderAddress is not set right", "InvalidSendAddress" /* InvalidSendAddress */);
|
|
5737
5909
|
}
|
|
5738
|
-
const tx = new
|
|
5910
|
+
const tx = new import_transactions5.Transaction();
|
|
5739
5911
|
tx.setSender(this.sdk.senderAddress);
|
|
5740
5912
|
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
5741
5913
|
const eventConfig = getPackagerConfigs(clmm_pool);
|
|
@@ -5800,7 +5972,7 @@ var PoolModule = class {
|
|
|
5800
5972
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
5801
5973
|
const ticks = [];
|
|
5802
5974
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
5803
|
-
const tx = new
|
|
5975
|
+
const tx = new import_transactions5.Transaction();
|
|
5804
5976
|
const start = tx.makeMoveVec({
|
|
5805
5977
|
elements: params.start.map((index) => tx.pure.u32(index)),
|
|
5806
5978
|
type: "u32"
|
|
@@ -5845,7 +6017,7 @@ var PoolModule = class {
|
|
|
5845
6017
|
const limit = 512;
|
|
5846
6018
|
while (true) {
|
|
5847
6019
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
5848
|
-
const tx = new
|
|
6020
|
+
const tx = new import_transactions5.Transaction();
|
|
5849
6021
|
const vecStart = tx.makeMoveVec({
|
|
5850
6022
|
elements: start.map((id) => tx.pure.address(id)),
|
|
5851
6023
|
type: void 0
|
|
@@ -6029,7 +6201,7 @@ var PoolModule = class {
|
|
|
6029
6201
|
* @returns {Promise<Transaction>} A promise that resolves to the transaction payload.
|
|
6030
6202
|
*/
|
|
6031
6203
|
async claimPartnerRefFeePayload(partnerCap, partner, coinType) {
|
|
6032
|
-
const tx = new
|
|
6204
|
+
const tx = new import_transactions5.Transaction();
|
|
6033
6205
|
const { clmm_pool } = this.sdk.sdkOptions;
|
|
6034
6206
|
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
6035
6207
|
const typeArguments = [coinType];
|
|
@@ -6078,8 +6250,8 @@ var PoolModule = class {
|
|
|
6078
6250
|
|
|
6079
6251
|
// src/modules/positionModule.ts
|
|
6080
6252
|
var import_bn17 = __toESM(require("bn.js"));
|
|
6081
|
-
var
|
|
6082
|
-
var
|
|
6253
|
+
var import_transactions6 = require("@mysten/sui/transactions");
|
|
6254
|
+
var import_utils17 = require("@mysten/sui/utils");
|
|
6083
6255
|
var PositionModule = class {
|
|
6084
6256
|
_sdk;
|
|
6085
6257
|
_cache = {};
|
|
@@ -6135,8 +6307,8 @@ var PositionModule = class {
|
|
|
6135
6307
|
* @param {boolean} calculateRewarder Whether to calculate the rewarder of the position.
|
|
6136
6308
|
* @returns {Promise<Position>} Position object.
|
|
6137
6309
|
*/
|
|
6138
|
-
async getPosition(positionHandle, positionID, calculateRewarder = true, showDisplay = true) {
|
|
6139
|
-
let position = await this.getSimplePosition(positionID, showDisplay);
|
|
6310
|
+
async getPosition(positionHandle, positionID, calculateRewarder = true, showDisplay = true, forceRefresh = false) {
|
|
6311
|
+
let position = await this.getSimplePosition(positionID, showDisplay, forceRefresh);
|
|
6140
6312
|
if (calculateRewarder) {
|
|
6141
6313
|
position = await this.updatePositionRewarders(positionHandle, position);
|
|
6142
6314
|
}
|
|
@@ -6148,8 +6320,8 @@ var PositionModule = class {
|
|
|
6148
6320
|
* @param {boolean} calculateRewarder Whether to calculate the rewarder of the position.
|
|
6149
6321
|
* @returns {Promise<Position>} Position object.
|
|
6150
6322
|
*/
|
|
6151
|
-
async getPositionById(positionID, calculateRewarder = true, showDisplay = true) {
|
|
6152
|
-
const position = await this.getSimplePosition(positionID, showDisplay);
|
|
6323
|
+
async getPositionById(positionID, calculateRewarder = true, showDisplay = true, forceRefresh = false) {
|
|
6324
|
+
const position = await this.getSimplePosition(positionID, showDisplay, forceRefresh);
|
|
6153
6325
|
if (calculateRewarder) {
|
|
6154
6326
|
const pool = await this._sdk.Pool.getPool(position.pool, false);
|
|
6155
6327
|
const result = await this.updatePositionRewarders(pool.position_manager.positions_handle, position);
|
|
@@ -6162,10 +6334,10 @@ var PositionModule = class {
|
|
|
6162
6334
|
* @param {string} positionID The ID of the position to get.
|
|
6163
6335
|
* @returns {Promise<Position>} Position object.
|
|
6164
6336
|
*/
|
|
6165
|
-
async getSimplePosition(positionID, showDisplay = true) {
|
|
6337
|
+
async getSimplePosition(positionID, showDisplay = true, forceRefresh = false) {
|
|
6166
6338
|
const cacheKey = `${positionID}_getPositionList`;
|
|
6167
6339
|
let position = this.getSimplePositionByCache(positionID);
|
|
6168
|
-
if (position === void 0) {
|
|
6340
|
+
if (forceRefresh || position === void 0) {
|
|
6169
6341
|
const objectDataResponses = await this.sdk.fullClient.getObject({
|
|
6170
6342
|
id: positionID,
|
|
6171
6343
|
options: { showContent: true, showType: true, showDisplay, showOwner: true }
|
|
@@ -6262,7 +6434,7 @@ var PositionModule = class {
|
|
|
6262
6434
|
*/
|
|
6263
6435
|
async fetchPosFeeAmount(params) {
|
|
6264
6436
|
const { clmm_pool, integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
6265
|
-
const tx = new
|
|
6437
|
+
const tx = new import_transactions6.Transaction();
|
|
6266
6438
|
for (const paramItem of params) {
|
|
6267
6439
|
const typeArguments = [paramItem.coinTypeA, paramItem.coinTypeB];
|
|
6268
6440
|
const args = [
|
|
@@ -6407,8 +6579,8 @@ var PositionModule = class {
|
|
|
6407
6579
|
const tick_lower = asUintN(BigInt(params.tick_lower)).toString();
|
|
6408
6580
|
const tick_upper = asUintN(BigInt(params.tick_upper)).toString();
|
|
6409
6581
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
6410
|
-
tx = tx || new
|
|
6411
|
-
const needOpenPosition = !(0,
|
|
6582
|
+
tx = tx || new import_transactions6.Transaction();
|
|
6583
|
+
const needOpenPosition = !(0, import_utils17.isValidSuiObjectId)(params.pos_id);
|
|
6412
6584
|
const max_amount_a = BigInt(params.max_amount_a);
|
|
6413
6585
|
const max_amount_b = BigInt(params.max_amount_b);
|
|
6414
6586
|
let primaryCoinAInputs;
|
|
@@ -6487,7 +6659,7 @@ var PositionModule = class {
|
|
|
6487
6659
|
}
|
|
6488
6660
|
const { clmm_pool, integrate } = this.sdk.sdkOptions;
|
|
6489
6661
|
const functionName = "remove_liquidity";
|
|
6490
|
-
tx = tx || new
|
|
6662
|
+
tx = tx || new import_transactions6.Transaction();
|
|
6491
6663
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
6492
6664
|
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
6493
6665
|
tx = TransactionUtil.createCollectRewarderAndFeeParams(this._sdk, tx, params, allCoinAsset);
|
|
@@ -6517,7 +6689,7 @@ var PositionModule = class {
|
|
|
6517
6689
|
throw new ClmmpoolsError("this config sdk senderAddress is not set right", "InvalidSendAddress" /* InvalidSendAddress */);
|
|
6518
6690
|
}
|
|
6519
6691
|
const { clmm_pool, integrate } = this.sdk.sdkOptions;
|
|
6520
|
-
tx = tx || new
|
|
6692
|
+
tx = tx || new import_transactions6.Transaction();
|
|
6521
6693
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
6522
6694
|
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
6523
6695
|
tx = TransactionUtil.createCollectRewarderAndFeeParams(this._sdk, tx, params, allCoinAsset);
|
|
@@ -6542,7 +6714,7 @@ var PositionModule = class {
|
|
|
6542
6714
|
*/
|
|
6543
6715
|
openPositionTransactionPayload(params, tx) {
|
|
6544
6716
|
const { clmm_pool, integrate } = this.sdk.sdkOptions;
|
|
6545
|
-
tx = tx || new
|
|
6717
|
+
tx = tx || new import_transactions6.Transaction();
|
|
6546
6718
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
6547
6719
|
const tick_lower = asUintN(BigInt(params.tick_lower)).toString();
|
|
6548
6720
|
const tick_upper = asUintN(BigInt(params.tick_upper)).toString();
|
|
@@ -6570,7 +6742,7 @@ var PositionModule = class {
|
|
|
6570
6742
|
throw new ClmmpoolsError("this config sdk senderAddress is not set right", "InvalidSendAddress" /* InvalidSendAddress */);
|
|
6571
6743
|
}
|
|
6572
6744
|
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress, null, true);
|
|
6573
|
-
tx = tx || new
|
|
6745
|
+
tx = tx || new import_transactions6.Transaction();
|
|
6574
6746
|
const primaryCoinAInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), params.coinTypeA, false);
|
|
6575
6747
|
const primaryCoinBInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), params.coinTypeB, false);
|
|
6576
6748
|
const coinA = inputCoinA ?? primaryCoinAInput.targetCoin;
|
|
@@ -6677,7 +6849,7 @@ var PositionModule = class {
|
|
|
6677
6849
|
|
|
6678
6850
|
// src/modules/rewarderModule.ts
|
|
6679
6851
|
var import_bn18 = __toESM(require("bn.js"));
|
|
6680
|
-
var
|
|
6852
|
+
var import_transactions7 = require("@mysten/sui/transactions");
|
|
6681
6853
|
var RewarderModule = class {
|
|
6682
6854
|
_sdk;
|
|
6683
6855
|
growthGlobal;
|
|
@@ -6914,7 +7086,7 @@ var RewarderModule = class {
|
|
|
6914
7086
|
*/
|
|
6915
7087
|
async fetchPosFeeAmount(params) {
|
|
6916
7088
|
const { clmm_pool, integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
6917
|
-
const tx = new
|
|
7089
|
+
const tx = new import_transactions7.Transaction();
|
|
6918
7090
|
for (const paramItem of params) {
|
|
6919
7091
|
const typeArguments = [paramItem.coinTypeA, paramItem.coinTypeB];
|
|
6920
7092
|
const args = [
|
|
@@ -6957,7 +7129,7 @@ var RewarderModule = class {
|
|
|
6957
7129
|
*/
|
|
6958
7130
|
async fetchPosRewardersAmount(params) {
|
|
6959
7131
|
const { clmm_pool, integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
6960
|
-
const tx = new
|
|
7132
|
+
const tx = new import_transactions7.Transaction();
|
|
6961
7133
|
for (const paramItem of params) {
|
|
6962
7134
|
const typeArguments = [paramItem.coinTypeA, paramItem.coinTypeB];
|
|
6963
7135
|
const args = [
|
|
@@ -7066,7 +7238,7 @@ var RewarderModule = class {
|
|
|
7066
7238
|
throw new ClmmpoolsError("this config sdk senderAddress is not set right", "InvalidSendAddress" /* InvalidSendAddress */);
|
|
7067
7239
|
}
|
|
7068
7240
|
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress, null);
|
|
7069
|
-
let tx = new
|
|
7241
|
+
let tx = new import_transactions7.Transaction();
|
|
7070
7242
|
tx = TransactionUtil.createCollectRewarderAndFeeParams(this._sdk, tx, params, allCoinAsset);
|
|
7071
7243
|
return tx;
|
|
7072
7244
|
}
|
|
@@ -7082,7 +7254,7 @@ var RewarderModule = class {
|
|
|
7082
7254
|
throw new ClmmpoolsError("this config sdk senderAddress is not set right", "InvalidSendAddress" /* InvalidSendAddress */);
|
|
7083
7255
|
}
|
|
7084
7256
|
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress, null);
|
|
7085
|
-
tx = tx || new
|
|
7257
|
+
tx = tx || new import_transactions7.Transaction();
|
|
7086
7258
|
const coinIdList = [];
|
|
7087
7259
|
params.forEach((item) => {
|
|
7088
7260
|
const coinTypeA = normalizeCoinType(item.coinTypeA);
|
|
@@ -7167,7 +7339,7 @@ var RewarderModule = class {
|
|
|
7167
7339
|
// src/modules/routerModule.ts
|
|
7168
7340
|
var import_bn19 = __toESM(require("bn.js"));
|
|
7169
7341
|
var import_cc_graph = require("@syntsugar/cc-graph");
|
|
7170
|
-
var
|
|
7342
|
+
var import_transactions8 = require("@mysten/sui/transactions");
|
|
7171
7343
|
function _pairSymbol(base, quote) {
|
|
7172
7344
|
return {
|
|
7173
7345
|
pair: `${base}-${quote}`,
|
|
@@ -7617,7 +7789,7 @@ var RouterModule = class {
|
|
|
7617
7789
|
return null;
|
|
7618
7790
|
}
|
|
7619
7791
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7620
|
-
const tx = new
|
|
7792
|
+
const tx = new import_transactions8.Transaction();
|
|
7621
7793
|
for (const param of params) {
|
|
7622
7794
|
if (param.stepNums > 1) {
|
|
7623
7795
|
const args = [
|
|
@@ -7757,7 +7929,7 @@ var RouterModule = class {
|
|
|
7757
7929
|
// src/modules/swapModule.ts
|
|
7758
7930
|
var import_bn20 = __toESM(require("bn.js"));
|
|
7759
7931
|
var import_decimal11 = __toESM(require("decimal.js"));
|
|
7760
|
-
var
|
|
7932
|
+
var import_transactions9 = require("@mysten/sui/transactions");
|
|
7761
7933
|
var AMM_SWAP_MODULE = "amm_swap";
|
|
7762
7934
|
var POOL_STRUCT = "Pool";
|
|
7763
7935
|
var SwapModule = class {
|
|
@@ -7827,7 +7999,7 @@ var SwapModule = class {
|
|
|
7827
7999
|
*/
|
|
7828
8000
|
async preSwapWithMultiPool(params) {
|
|
7829
8001
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7830
|
-
const tx = new
|
|
8002
|
+
const tx = new import_transactions9.Transaction();
|
|
7831
8003
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
7832
8004
|
for (let i = 0; i < params.poolAddresses.length; i += 1) {
|
|
7833
8005
|
const args = [
|
|
@@ -7905,7 +8077,7 @@ var SwapModule = class {
|
|
|
7905
8077
|
async preswap(params) {
|
|
7906
8078
|
const { integrate, simulationAccount, clmm_pool } = this.sdk.sdkOptions;
|
|
7907
8079
|
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
7908
|
-
const tx = new
|
|
8080
|
+
const tx = new import_transactions9.Transaction();
|
|
7909
8081
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
7910
8082
|
const args = [
|
|
7911
8083
|
tx.object(global_config_id),
|
|
@@ -8072,7 +8244,7 @@ var SwapModule = class {
|
|
|
8072
8244
|
};
|
|
8073
8245
|
|
|
8074
8246
|
// src/modules/lockModule.ts
|
|
8075
|
-
var
|
|
8247
|
+
var import_transactions10 = require("@mysten/sui/transactions");
|
|
8076
8248
|
var LockModule = class {
|
|
8077
8249
|
_sdk;
|
|
8078
8250
|
constructor(sdk) {
|
|
@@ -8169,7 +8341,7 @@ var LockModule = class {
|
|
|
8169
8341
|
if (this._sdk.senderAddress.length === 0) {
|
|
8170
8342
|
throw Error("this config sdk senderAddress is empty");
|
|
8171
8343
|
}
|
|
8172
|
-
const tx = new
|
|
8344
|
+
const tx = new import_transactions10.Transaction();
|
|
8173
8345
|
tx.setSender(this.sdk.senderAddress);
|
|
8174
8346
|
const { integrate, ve33 } = this.sdk.sdkOptions;
|
|
8175
8347
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
@@ -8204,7 +8376,7 @@ var LockModule = class {
|
|
|
8204
8376
|
if (incentiveTokens.length === 1) {
|
|
8205
8377
|
targetFunc = `${integrate.published_at}::${Voter}::claim_voting_bribes_for_single_pool`;
|
|
8206
8378
|
}
|
|
8207
|
-
const tx = new
|
|
8379
|
+
const tx = new import_transactions10.Transaction();
|
|
8208
8380
|
tx.setSender(this.sdk.senderAddress);
|
|
8209
8381
|
const args = [tx.object(voter_id), tx.object(voting_escrow_id), tx.object(lockId), tx.object(poolId), tx.object(CLOCK_ADDRESS)];
|
|
8210
8382
|
tx.moveCall({
|
|
@@ -8448,7 +8620,7 @@ var LockModule = class {
|
|
|
8448
8620
|
return lockInfo;
|
|
8449
8621
|
}
|
|
8450
8622
|
async aLockSummary(lock_id) {
|
|
8451
|
-
const tx = new
|
|
8623
|
+
const tx = new import_transactions10.Transaction();
|
|
8452
8624
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
8453
8625
|
const { voting_escrow_id, magma_token, voter_id, reward_distributor_id } = getPackagerConfigs(ve33);
|
|
8454
8626
|
const typeArguments = [magma_token];
|
|
@@ -8494,14 +8666,14 @@ var LockModule = class {
|
|
|
8494
8666
|
}
|
|
8495
8667
|
// Return: lock_id => ALockSummary
|
|
8496
8668
|
async getAllLockSummary(lock_ids) {
|
|
8497
|
-
let tx = new
|
|
8669
|
+
let tx = new import_transactions10.Transaction();
|
|
8498
8670
|
for (const lock_id of lock_ids) {
|
|
8499
8671
|
tx = await this._aLockSummary(lock_id, tx);
|
|
8500
8672
|
}
|
|
8501
8673
|
return this._parseLockSummary(tx);
|
|
8502
8674
|
}
|
|
8503
8675
|
async _aLockSummary(lock_id, tx) {
|
|
8504
|
-
tx = tx || new
|
|
8676
|
+
tx = tx || new import_transactions10.Transaction();
|
|
8505
8677
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
8506
8678
|
const { voting_escrow_id, magma_token, voter_id, reward_distributor_id } = getPackagerConfigs(ve33);
|
|
8507
8679
|
const typeArguments = [magma_token];
|
|
@@ -8544,7 +8716,7 @@ var LockModule = class {
|
|
|
8544
8716
|
return res;
|
|
8545
8717
|
}
|
|
8546
8718
|
async allLockSummary() {
|
|
8547
|
-
const tx = new
|
|
8719
|
+
const tx = new import_transactions10.Transaction();
|
|
8548
8720
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
8549
8721
|
const { voting_escrow_id, magma_token, voter_id, minter_id } = getPackagerConfigs(ve33);
|
|
8550
8722
|
const typeArguments = [magma_token];
|
|
@@ -8589,7 +8761,7 @@ var LockModule = class {
|
|
|
8589
8761
|
return summary;
|
|
8590
8762
|
}
|
|
8591
8763
|
async poolWeights(pools) {
|
|
8592
|
-
const tx = new
|
|
8764
|
+
const tx = new import_transactions10.Transaction();
|
|
8593
8765
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
8594
8766
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
8595
8767
|
const typeArguments = [magma_token];
|
|
@@ -8624,14 +8796,14 @@ var LockModule = class {
|
|
|
8624
8796
|
return poolWeights;
|
|
8625
8797
|
}
|
|
8626
8798
|
async getAllVotingFeeRewardTokens(lock_ids) {
|
|
8627
|
-
let tx = new
|
|
8799
|
+
let tx = new import_transactions10.Transaction();
|
|
8628
8800
|
for (const lock_id of lock_ids) {
|
|
8629
8801
|
tx = await this._getVotingFeeRewardTokens(lock_id, tx);
|
|
8630
8802
|
}
|
|
8631
8803
|
return this._parseVotingFeeRewardTokens(tx);
|
|
8632
8804
|
}
|
|
8633
8805
|
async _getVotingFeeRewardTokens(lock_id, tx) {
|
|
8634
|
-
tx = tx || new
|
|
8806
|
+
tx = tx || new import_transactions10.Transaction();
|
|
8635
8807
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
8636
8808
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
8637
8809
|
const typeArguments = [magma_token];
|
|
@@ -8672,7 +8844,7 @@ var LockModule = class {
|
|
|
8672
8844
|
return poolFeeRewardTokens;
|
|
8673
8845
|
}
|
|
8674
8846
|
async getVotingFeeRewardTokens(lock_id) {
|
|
8675
|
-
const tx = new
|
|
8847
|
+
const tx = new import_transactions10.Transaction();
|
|
8676
8848
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
8677
8849
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
8678
8850
|
const typeArguments = [magma_token];
|
|
@@ -8709,14 +8881,14 @@ var LockModule = class {
|
|
|
8709
8881
|
}
|
|
8710
8882
|
// tokens
|
|
8711
8883
|
async getAllBribeRewardTokensOfLock(lock_ids) {
|
|
8712
|
-
let tx = new
|
|
8884
|
+
let tx = new import_transactions10.Transaction();
|
|
8713
8885
|
for (const lock_id of lock_ids) {
|
|
8714
8886
|
tx = await this._getVotingBribeRewardTokens(lock_id, tx);
|
|
8715
8887
|
}
|
|
8716
8888
|
return this._parseVotingBribeRewardTokens(tx);
|
|
8717
8889
|
}
|
|
8718
8890
|
async _getVotingBribeRewardTokens(lock_id, tx) {
|
|
8719
|
-
tx = tx || new
|
|
8891
|
+
tx = tx || new import_transactions10.Transaction();
|
|
8720
8892
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
8721
8893
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
8722
8894
|
const typeArguments = [magma_token];
|
|
@@ -8758,7 +8930,7 @@ var LockModule = class {
|
|
|
8758
8930
|
}
|
|
8759
8931
|
// Return PoolId => tokens
|
|
8760
8932
|
async getVotingBribeRewardTokens(lock_id) {
|
|
8761
|
-
const tx = new
|
|
8933
|
+
const tx = new import_transactions10.Transaction();
|
|
8762
8934
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
8763
8935
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
8764
8936
|
const typeArguments = [magma_token];
|
|
@@ -8794,7 +8966,7 @@ var LockModule = class {
|
|
|
8794
8966
|
return poolBirbeRewardTokens;
|
|
8795
8967
|
}
|
|
8796
8968
|
async getAllFeeRewards(fee_tokens) {
|
|
8797
|
-
let tx = new
|
|
8969
|
+
let tx = new import_transactions10.Transaction();
|
|
8798
8970
|
fee_tokens.forEach((tokens, lock_id) => {
|
|
8799
8971
|
tx = this._getFeeRewards(lock_id, tokens, tx);
|
|
8800
8972
|
});
|
|
@@ -8810,7 +8982,7 @@ var LockModule = class {
|
|
|
8810
8982
|
return tx;
|
|
8811
8983
|
}
|
|
8812
8984
|
_getFeeRewardsInner(lock_id, token_a, token_b, tx) {
|
|
8813
|
-
tx = tx || new
|
|
8985
|
+
tx = tx || new import_transactions10.Transaction();
|
|
8814
8986
|
const { integrate, ve33 } = this.sdk.sdkOptions;
|
|
8815
8987
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
8816
8988
|
const typeArguments = [magma_token, token_a, token_b];
|
|
@@ -8870,7 +9042,7 @@ var LockModule = class {
|
|
|
8870
9042
|
}
|
|
8871
9043
|
// if you have many tokens, call this function multi times
|
|
8872
9044
|
async _getPoolFeeRewards(lock_id, token_a, token_b, poolFeeRewardTokens) {
|
|
8873
|
-
const tx = new
|
|
9045
|
+
const tx = new import_transactions10.Transaction();
|
|
8874
9046
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
8875
9047
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
8876
9048
|
const typeArguments = [magma_token, token_a, token_b];
|
|
@@ -8908,7 +9080,7 @@ var LockModule = class {
|
|
|
8908
9080
|
// params: lock_id => incentive_tokens
|
|
8909
9081
|
// lock_id => Pool => rewardTokens
|
|
8910
9082
|
async getAllIncentiveRewards(lock_incentive_tokens) {
|
|
8911
|
-
let tx = new
|
|
9083
|
+
let tx = new import_transactions10.Transaction();
|
|
8912
9084
|
lock_incentive_tokens.forEach((tokens, lock_id) => {
|
|
8913
9085
|
tx = this._getIncentiveRewards(lock_id, tokens, tx);
|
|
8914
9086
|
});
|
|
@@ -8922,7 +9094,7 @@ var LockModule = class {
|
|
|
8922
9094
|
return this._getIncentiveRewardsInner(lock_id, incentive_tokens.slice(i), tx);
|
|
8923
9095
|
}
|
|
8924
9096
|
_getIncentiveRewardsInner(locksId, incentive_tokens, tx) {
|
|
8925
|
-
tx = tx || new
|
|
9097
|
+
tx = tx || new import_transactions10.Transaction();
|
|
8926
9098
|
if (incentive_tokens.length > 3) {
|
|
8927
9099
|
throw Error("Too many tokens");
|
|
8928
9100
|
}
|
|
@@ -8994,7 +9166,7 @@ var LockModule = class {
|
|
|
8994
9166
|
if (incentive_tokens.length > 3) {
|
|
8995
9167
|
throw Error("Too many tokens");
|
|
8996
9168
|
}
|
|
8997
|
-
const tx = new
|
|
9169
|
+
const tx = new import_transactions10.Transaction();
|
|
8998
9170
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
8999
9171
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
9000
9172
|
const typeArguments = [magma_token, ...incentive_tokens];
|
|
@@ -9033,7 +9205,7 @@ var LockModule = class {
|
|
|
9033
9205
|
return poolBribeRewardTokens;
|
|
9034
9206
|
}
|
|
9035
9207
|
async getPoolBribeRewardTokens(pool_id) {
|
|
9036
|
-
const tx = new
|
|
9208
|
+
const tx = new import_transactions10.Transaction();
|
|
9037
9209
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
9038
9210
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
9039
9211
|
const typeArguments = [magma_token];
|
|
@@ -9069,7 +9241,7 @@ var LockModule = class {
|
|
|
9069
9241
|
return poolBirbeRewardTokens;
|
|
9070
9242
|
}
|
|
9071
9243
|
async getLockVotingStats(lockId) {
|
|
9072
|
-
const tx = new
|
|
9244
|
+
const tx = new import_transactions10.Transaction();
|
|
9073
9245
|
const { integrate, simulationAccount, ve33 } = this.sdk.sdkOptions;
|
|
9074
9246
|
const { magma_token, voter_id } = getPackagerConfigs(ve33);
|
|
9075
9247
|
const args = [tx.object(voter_id), tx.object(lockId), tx.object(CLOCK_ADDRESS)];
|
|
@@ -9112,8 +9284,8 @@ var LockModule = class {
|
|
|
9112
9284
|
|
|
9113
9285
|
// src/modules/tokenModule.ts
|
|
9114
9286
|
var import_js_base64 = require("js-base64");
|
|
9115
|
-
var
|
|
9116
|
-
var
|
|
9287
|
+
var import_transactions11 = require("@mysten/sui/transactions");
|
|
9288
|
+
var import_utils24 = require("@mysten/sui/utils");
|
|
9117
9289
|
var TokenModule = class {
|
|
9118
9290
|
_sdk;
|
|
9119
9291
|
_cache = {};
|
|
@@ -9248,7 +9420,7 @@ var TokenModule = class {
|
|
|
9248
9420
|
}
|
|
9249
9421
|
const tokenConfig = getPackagerConfigs(token);
|
|
9250
9422
|
while (true) {
|
|
9251
|
-
const tx = new
|
|
9423
|
+
const tx = new import_transactions11.Transaction();
|
|
9252
9424
|
tx.moveCall({
|
|
9253
9425
|
target: `${token.published_at}::coin_list::${isOwnerRequest ? "fetch_full_list_with_limit" : "fetch_all_registered_coin_info_with_limit"}`,
|
|
9254
9426
|
arguments: isOwnerRequest ? [tx.pure.address(tokenConfig.coin_registry_id), tx.pure.address(listOwnerAddr), tx.pure.u64(index), tx.pure.u64(limit)] : [tx.pure.address(tokenConfig.coin_registry_id), tx.pure.u64(index), tx.pure.u64(limit)]
|
|
@@ -9291,7 +9463,7 @@ var TokenModule = class {
|
|
|
9291
9463
|
}
|
|
9292
9464
|
const tokenConfig = getPackagerConfigs(token);
|
|
9293
9465
|
while (true) {
|
|
9294
|
-
const tx = new
|
|
9466
|
+
const tx = new import_transactions11.Transaction();
|
|
9295
9467
|
tx.moveCall({
|
|
9296
9468
|
target: `${token.published_at}::lp_list::${isOwnerRequest ? "fetch_full_list_with_limit" : "fetch_all_registered_coin_info_with_limit"}`,
|
|
9297
9469
|
arguments: isOwnerRequest ? [tx.pure.address(tokenConfig.pool_registry_id), tx.pure.address(listOwnerAddr), tx.pure.u64(index), tx.pure.u64(limit)] : [tx.pure.address(tokenConfig.pool_registry_id), tx.pure.u64(index), tx.pure.u64(limit)]
|
|
@@ -9425,7 +9597,7 @@ var TokenModule = class {
|
|
|
9425
9597
|
}
|
|
9426
9598
|
}
|
|
9427
9599
|
if (key === "pyth_id") {
|
|
9428
|
-
value = (0,
|
|
9600
|
+
value = (0, import_utils24.normalizeSuiObjectId)(value);
|
|
9429
9601
|
}
|
|
9430
9602
|
token[key] = value;
|
|
9431
9603
|
}
|
|
@@ -9826,7 +9998,7 @@ var RouterModuleV2 = class {
|
|
|
9826
9998
|
};
|
|
9827
9999
|
|
|
9828
10000
|
// src/modules/configModule.ts
|
|
9829
|
-
var
|
|
10001
|
+
var import_utils26 = require("@mysten/sui/utils");
|
|
9830
10002
|
var import_js_base642 = require("js-base64");
|
|
9831
10003
|
var ConfigModule = class {
|
|
9832
10004
|
_sdk;
|
|
@@ -9982,7 +10154,7 @@ var ConfigModule = class {
|
|
|
9982
10154
|
coin.id = getObjectId(object);
|
|
9983
10155
|
coin.address = extractStructTagFromType(fields.coin_type.fields.name).full_address;
|
|
9984
10156
|
if (fields.pyth_id) {
|
|
9985
|
-
coin.pyth_id = (0,
|
|
10157
|
+
coin.pyth_id = (0, import_utils26.normalizeSuiObjectId)(fields.pyth_id);
|
|
9986
10158
|
}
|
|
9987
10159
|
this.transformExtensions(coin, fields.extension_fields.fields.contents, transformExtensions);
|
|
9988
10160
|
delete coin.coin_type;
|
|
@@ -10043,7 +10215,7 @@ var ConfigModule = class {
|
|
|
10043
10215
|
fields = fields.value.fields;
|
|
10044
10216
|
const pool = { ...fields };
|
|
10045
10217
|
pool.id = getObjectId(object);
|
|
10046
|
-
pool.pool_address = (0,
|
|
10218
|
+
pool.pool_address = (0, import_utils26.normalizeSuiObjectId)(fields.pool_address);
|
|
10047
10219
|
this.transformExtensions(pool, fields.extension_fields.fields.contents, transformExtensions);
|
|
10048
10220
|
return pool;
|
|
10049
10221
|
}
|
|
@@ -10102,7 +10274,7 @@ var ConfigModule = class {
|
|
|
10102
10274
|
fields = fields.value.fields;
|
|
10103
10275
|
const pool = { ...fields };
|
|
10104
10276
|
pool.id = getObjectId(object);
|
|
10105
|
-
pool.pool_address = (0,
|
|
10277
|
+
pool.pool_address = (0, import_utils26.normalizeSuiObjectId)(fields.pool_address);
|
|
10106
10278
|
this.transformExtensions(pool, fields.extension_fields.fields.contents, transformExtensions);
|
|
10107
10279
|
const social_medias = [];
|
|
10108
10280
|
fields.social_media.fields.contents.forEach((item) => {
|
|
@@ -10447,7 +10619,7 @@ var RpcModule = class extends import_client.SuiClient {
|
|
|
10447
10619
|
};
|
|
10448
10620
|
|
|
10449
10621
|
// src/modules/gaugeModule.ts
|
|
10450
|
-
var
|
|
10622
|
+
var import_transactions12 = require("@mysten/sui/transactions");
|
|
10451
10623
|
var GaugeModule = class {
|
|
10452
10624
|
_sdk;
|
|
10453
10625
|
constructor(sdk) {
|
|
@@ -10457,7 +10629,7 @@ var GaugeModule = class {
|
|
|
10457
10629
|
return this._sdk;
|
|
10458
10630
|
}
|
|
10459
10631
|
async depositPosition(params) {
|
|
10460
|
-
const tx = new
|
|
10632
|
+
const tx = new import_transactions12.Transaction();
|
|
10461
10633
|
tx.setSender(this.sdk.senderAddress);
|
|
10462
10634
|
const poolGauge = await this.getPoolGaguers();
|
|
10463
10635
|
const gauge = poolGauge.get(params.poolId);
|
|
@@ -10484,7 +10656,7 @@ var GaugeModule = class {
|
|
|
10484
10656
|
return tx;
|
|
10485
10657
|
}
|
|
10486
10658
|
async withdrawPosition(params) {
|
|
10487
|
-
const tx = new
|
|
10659
|
+
const tx = new import_transactions12.Transaction();
|
|
10488
10660
|
tx.setSender(this.sdk.senderAddress);
|
|
10489
10661
|
const poolGauge = await this.sdk.Gauge.getPoolGaguers();
|
|
10490
10662
|
const gauge = poolGauge.get(params.poolId);
|
|
@@ -10539,7 +10711,7 @@ var GaugeModule = class {
|
|
|
10539
10711
|
return res;
|
|
10540
10712
|
}
|
|
10541
10713
|
async getUserStakedPositionInfoOfPool(userAddr, pool, gauger, poolCoinA, poolCoinB) {
|
|
10542
|
-
const tx = new
|
|
10714
|
+
const tx = new import_transactions12.Transaction();
|
|
10543
10715
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10544
10716
|
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.ve33);
|
|
10545
10717
|
const typeArguments = [poolCoinA, poolCoinB, magma_token];
|
|
@@ -10563,7 +10735,7 @@ var GaugeModule = class {
|
|
|
10563
10735
|
return res;
|
|
10564
10736
|
}
|
|
10565
10737
|
async getPoolGaguers() {
|
|
10566
|
-
const tx = new
|
|
10738
|
+
const tx = new import_transactions12.Transaction();
|
|
10567
10739
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10568
10740
|
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.ve33);
|
|
10569
10741
|
const typeArguments = [magma_token];
|
|
@@ -10603,7 +10775,7 @@ var GaugeModule = class {
|
|
|
10603
10775
|
return poolCoins;
|
|
10604
10776
|
}
|
|
10605
10777
|
async getEmissions() {
|
|
10606
|
-
const tx = new
|
|
10778
|
+
const tx = new import_transactions12.Transaction();
|
|
10607
10779
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10608
10780
|
const { magma_token, minter_id, voting_escrow_id } = getPackagerConfigs(this.sdk.sdkOptions.ve33);
|
|
10609
10781
|
const typeArguments = [magma_token];
|
|
@@ -10637,7 +10809,7 @@ var GaugeModule = class {
|
|
|
10637
10809
|
return res;
|
|
10638
10810
|
}
|
|
10639
10811
|
async getRewardByPosition(params) {
|
|
10640
|
-
const tx = new
|
|
10812
|
+
const tx = new import_transactions12.Transaction();
|
|
10641
10813
|
const { integrate } = this.sdk.sdkOptions;
|
|
10642
10814
|
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.ve33);
|
|
10643
10815
|
const typeArguments = [params.coinTypeA, params.coinTypeB, magma_token];
|
|
@@ -10650,7 +10822,7 @@ var GaugeModule = class {
|
|
|
10650
10822
|
return tx;
|
|
10651
10823
|
}
|
|
10652
10824
|
async getAllRewardByPositions(paramsList) {
|
|
10653
|
-
const tx = new
|
|
10825
|
+
const tx = new import_transactions12.Transaction();
|
|
10654
10826
|
const { integrate } = this.sdk.sdkOptions;
|
|
10655
10827
|
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.ve33);
|
|
10656
10828
|
paramsList.forEach((params) => {
|
|
@@ -10665,7 +10837,7 @@ var GaugeModule = class {
|
|
|
10665
10837
|
return tx;
|
|
10666
10838
|
}
|
|
10667
10839
|
async getEpochRewardByPool(pool, incentive_tokens) {
|
|
10668
|
-
const tx = new
|
|
10840
|
+
const tx = new import_transactions12.Transaction();
|
|
10669
10841
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10670
10842
|
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.ve33);
|
|
10671
10843
|
const typeArguments = [magma_token, ...incentive_tokens];
|
|
@@ -10697,7 +10869,7 @@ var GaugeModule = class {
|
|
|
10697
10869
|
};
|
|
10698
10870
|
|
|
10699
10871
|
// src/modules/almm.ts
|
|
10700
|
-
var
|
|
10872
|
+
var import_transactions13 = require("@mysten/sui/transactions");
|
|
10701
10873
|
var import_calc_almm3 = require("@magmaprotocol/calc_almm");
|
|
10702
10874
|
var import_decimal13 = __toESM(require("decimal.js"));
|
|
10703
10875
|
var import_bn22 = __toESM(require("bn.js"));
|
|
@@ -10792,7 +10964,7 @@ var AlmmModule = class {
|
|
|
10792
10964
|
}
|
|
10793
10965
|
// eg: fetch pool active_index
|
|
10794
10966
|
async fetchPairParams(params) {
|
|
10795
|
-
const tx = new
|
|
10967
|
+
const tx = new import_transactions13.Transaction();
|
|
10796
10968
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10797
10969
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10798
10970
|
const args = [tx.object(params.pair)];
|
|
@@ -10837,7 +11009,7 @@ var AlmmModule = class {
|
|
|
10837
11009
|
const storage_id = (0, import_calc_almm3.get_storage_id_from_real_id)(
|
|
10838
11010
|
BinMath.getBinIdFromPrice(params.priceTokenBPerTokenA, params.bin_step, params.coinADecimal, params.coinBDecimal)
|
|
10839
11011
|
);
|
|
10840
|
-
const tx = new
|
|
11012
|
+
const tx = new import_transactions13.Transaction();
|
|
10841
11013
|
tx.setSender(this.sdk.senderAddress);
|
|
10842
11014
|
const { clmm_pool, almm_pool, integrate } = this.sdk.sdkOptions;
|
|
10843
11015
|
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
@@ -10858,7 +11030,7 @@ var AlmmModule = class {
|
|
|
10858
11030
|
});
|
|
10859
11031
|
return tx;
|
|
10860
11032
|
}
|
|
10861
|
-
async mintByStrategy(params) {
|
|
11033
|
+
async mintByStrategy(params, tx) {
|
|
10862
11034
|
if (params.fixCoinA && params.fixCoinB) {
|
|
10863
11035
|
if (params.amountATotal === 0 || params.amountBTotal === 0) {
|
|
10864
11036
|
if (params.active_bin < params.max_bin && params.active_bin > params.min_bin) {
|
|
@@ -10870,7 +11042,9 @@ var AlmmModule = class {
|
|
|
10870
11042
|
}
|
|
10871
11043
|
}
|
|
10872
11044
|
}
|
|
10873
|
-
|
|
11045
|
+
if (!tx) {
|
|
11046
|
+
tx = new import_transactions13.Transaction();
|
|
11047
|
+
}
|
|
10874
11048
|
const slippage = new import_decimal13.default(params.slippage);
|
|
10875
11049
|
const lower_slippage = new import_decimal13.default(1).sub(slippage.div(new import_decimal13.default(1e4)));
|
|
10876
11050
|
const upper_slippage = new import_decimal13.default(1).plus(slippage.div(new import_decimal13.default(1e4)));
|
|
@@ -10889,18 +11063,18 @@ var AlmmModule = class {
|
|
|
10889
11063
|
let primaryCoinAInputs;
|
|
10890
11064
|
let primaryCoinBInputs;
|
|
10891
11065
|
if (params.fixCoinA && params.fixCoinB) {
|
|
10892
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10893
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
11066
|
+
primaryCoinAInputs = params.coin_object_id_a ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true).targetCoin;
|
|
11067
|
+
primaryCoinBInputs = params.coin_object_id_b ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true).targetCoin;
|
|
10894
11068
|
} else if (params.fixCoinA) {
|
|
10895
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
11069
|
+
primaryCoinAInputs = params.coin_object_id_a ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true).targetCoin;
|
|
10896
11070
|
amount_min = new import_decimal13.default(params.amountBTotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10897
11071
|
amount_max = new import_decimal13.default(params.amountBTotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10898
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
11072
|
+
primaryCoinBInputs = params.coin_object_id_b ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true).targetCoin;
|
|
10899
11073
|
} else if (params.fixCoinB) {
|
|
10900
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
11074
|
+
primaryCoinBInputs = params.coin_object_id_b ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true).targetCoin;
|
|
10901
11075
|
amount_min = new import_decimal13.default(params.amountATotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10902
11076
|
amount_max = new import_decimal13.default(params.amountATotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10903
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeA, false, true);
|
|
11077
|
+
primaryCoinAInputs = params.coin_object_id_a ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeA, false, true).targetCoin;
|
|
10904
11078
|
}
|
|
10905
11079
|
if (params.fixCoinA && params.fixCoinB) {
|
|
10906
11080
|
} else if (params.fixCoinA) {
|
|
@@ -10911,8 +11085,8 @@ var AlmmModule = class {
|
|
|
10911
11085
|
const args = [
|
|
10912
11086
|
tx.object(params.pair),
|
|
10913
11087
|
tx.object(almmConfig.factory),
|
|
10914
|
-
primaryCoinAInputs
|
|
10915
|
-
primaryCoinBInputs
|
|
11088
|
+
primaryCoinAInputs,
|
|
11089
|
+
primaryCoinBInputs,
|
|
10916
11090
|
tx.pure.bool(params.fixCoinA),
|
|
10917
11091
|
tx.pure.u64(params.amountATotal),
|
|
10918
11092
|
tx.pure.bool(params.fixCoinB),
|
|
@@ -10933,72 +11107,15 @@ var AlmmModule = class {
|
|
|
10933
11107
|
});
|
|
10934
11108
|
return tx;
|
|
10935
11109
|
}
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
// const tx = new Transaction()
|
|
10939
|
-
// tx.setSender(this.sdk.senderAddress)
|
|
10940
|
-
// const { almm_pool, integrate } = this.sdk.sdkOptions
|
|
10941
|
-
// const almmConfig = getPackagerConfigs(almm_pool)
|
|
10942
|
-
// const typeArguments = [params.coinTypeA, params.coinTypeB]
|
|
10943
|
-
// const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress)
|
|
10944
|
-
// const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true)
|
|
10945
|
-
// const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true)
|
|
10946
|
-
// const args = [
|
|
10947
|
-
// tx.object(params.pair),
|
|
10948
|
-
// tx.object(almmConfig.factory),
|
|
10949
|
-
// primaryCoinAInputs.targetCoin,
|
|
10950
|
-
// primaryCoinBInputs.targetCoin,
|
|
10951
|
-
// tx.pure.u64(params.amountATotal),
|
|
10952
|
-
// tx.pure.u64(params.amountBTotal),
|
|
10953
|
-
// tx.pure.vector('u32', params.storageIds),
|
|
10954
|
-
// tx.pure.vector('u64', params.binsAPercent),
|
|
10955
|
-
// tx.pure.vector('u64', params.binsBPercent),
|
|
10956
|
-
// tx.pure.address(params.to),
|
|
10957
|
-
// tx.object(CLOCK_ADDRESS),
|
|
10958
|
-
// ]
|
|
10959
|
-
// tx.moveCall({
|
|
10960
|
-
// target: `${integrate.published_at}::${AlmmScript}::mint_percent`,
|
|
10961
|
-
// typeArguments,
|
|
10962
|
-
// arguments: args,
|
|
10963
|
-
// })
|
|
10964
|
-
// return tx
|
|
10965
|
-
// }
|
|
10966
|
-
// // Create a position by amount
|
|
10967
|
-
// async createPositionByAmount(params: MintAmountParams): Promise<Transaction> {
|
|
10968
|
-
// const tx = new Transaction()
|
|
10969
|
-
// tx.setSender(this.sdk.senderAddress)
|
|
10970
|
-
// const { almm_pool, integrate } = this.sdk.sdkOptions
|
|
10971
|
-
// const almmConfig = getPackagerConfigs(almm_pool)
|
|
10972
|
-
// const typeArguments = [params.coinTypeA, params.coinTypeB]
|
|
10973
|
-
// const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress)
|
|
10974
|
-
// const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true)
|
|
10975
|
-
// const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true)
|
|
10976
|
-
// const args = [
|
|
10977
|
-
// tx.object(params.pair),
|
|
10978
|
-
// tx.object(almmConfig.factory),
|
|
10979
|
-
// primaryCoinAInputs.targetCoin,
|
|
10980
|
-
// primaryCoinBInputs.targetCoin,
|
|
10981
|
-
// tx.pure.vector('u32', params.storageIds),
|
|
10982
|
-
// tx.pure.vector('u64', params.amountsA),
|
|
10983
|
-
// tx.pure.vector('u64', params.amountsB),
|
|
10984
|
-
// tx.pure.address(params.to),
|
|
10985
|
-
// tx.object(CLOCK_ADDRESS),
|
|
10986
|
-
// ]
|
|
10987
|
-
// tx.moveCall({
|
|
10988
|
-
// target: `${integrate.published_at}::${AlmmScript}::mint_amounts`,
|
|
10989
|
-
// typeArguments,
|
|
10990
|
-
// arguments: args,
|
|
10991
|
-
// })
|
|
10992
|
-
// return tx
|
|
10993
|
-
// }
|
|
10994
|
-
async addLiquidityByStrategy(params) {
|
|
11110
|
+
async addLiquidityByStrategy(params, tx) {
|
|
11111
|
+
tx = tx || new import_transactions13.Transaction();
|
|
10995
11112
|
if (params.rewards_token.length === 0) {
|
|
10996
|
-
return this._raisePositionByAmounts(params);
|
|
11113
|
+
return this._raisePositionByAmounts(params, tx);
|
|
10997
11114
|
}
|
|
10998
|
-
return this._raisePositionByAmountsReward(params);
|
|
11115
|
+
return this._raisePositionByAmountsReward(params, tx);
|
|
10999
11116
|
}
|
|
11000
|
-
async _raisePositionByAmounts(params) {
|
|
11001
|
-
|
|
11117
|
+
async _raisePositionByAmounts(params, tx) {
|
|
11118
|
+
tx = tx || new import_transactions13.Transaction();
|
|
11002
11119
|
const slippage = new import_decimal13.default(params.slippage);
|
|
11003
11120
|
const lower_slippage = new import_decimal13.default(1).sub(slippage.div(new import_decimal13.default(1e4)));
|
|
11004
11121
|
const upper_slippage = new import_decimal13.default(1).plus(slippage.div(new import_decimal13.default(1e4)));
|
|
@@ -11017,18 +11134,18 @@ var AlmmModule = class {
|
|
|
11017
11134
|
let primaryCoinAInputs;
|
|
11018
11135
|
let primaryCoinBInputs;
|
|
11019
11136
|
if (params.fixCoinA && params.fixCoinB) {
|
|
11020
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
11021
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
11137
|
+
primaryCoinAInputs = params.coin_object_id_a ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true).targetCoin;
|
|
11138
|
+
primaryCoinBInputs = params.coin_object_id_b ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true).targetCoin;
|
|
11022
11139
|
} else if (params.fixCoinA) {
|
|
11023
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
11140
|
+
primaryCoinAInputs = params.coin_object_id_a ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true).targetCoin;
|
|
11024
11141
|
amount_min = new import_decimal13.default(params.amountBTotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
11025
11142
|
amount_max = new import_decimal13.default(params.amountBTotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
11026
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
11143
|
+
primaryCoinBInputs = params.coin_object_id_b ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true).targetCoin;
|
|
11027
11144
|
} else if (params.fixCoinB) {
|
|
11028
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
11145
|
+
primaryCoinBInputs = params.coin_object_id_b ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true).targetCoin;
|
|
11029
11146
|
amount_min = new import_decimal13.default(params.amountATotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
11030
11147
|
amount_max = new import_decimal13.default(params.amountATotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
11031
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeA, false, true);
|
|
11148
|
+
primaryCoinAInputs = params.coin_object_id_a ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeA, false, true).targetCoin;
|
|
11032
11149
|
}
|
|
11033
11150
|
if (params.fixCoinA && params.fixCoinB) {
|
|
11034
11151
|
} else if (params.fixCoinA) {
|
|
@@ -11040,8 +11157,8 @@ var AlmmModule = class {
|
|
|
11040
11157
|
tx.object(params.pair),
|
|
11041
11158
|
tx.object(almmConfig.factory),
|
|
11042
11159
|
tx.object(params.positionId),
|
|
11043
|
-
primaryCoinAInputs
|
|
11044
|
-
primaryCoinBInputs
|
|
11160
|
+
primaryCoinAInputs,
|
|
11161
|
+
primaryCoinBInputs,
|
|
11045
11162
|
tx.pure.bool(params.fixCoinA),
|
|
11046
11163
|
tx.pure.u64(params.amountATotal),
|
|
11047
11164
|
tx.pure.bool(params.fixCoinB),
|
|
@@ -11060,8 +11177,8 @@ var AlmmModule = class {
|
|
|
11060
11177
|
});
|
|
11061
11178
|
return tx;
|
|
11062
11179
|
}
|
|
11063
|
-
async _raisePositionByAmountsReward(params) {
|
|
11064
|
-
|
|
11180
|
+
async _raisePositionByAmountsReward(params, tx) {
|
|
11181
|
+
tx = tx || new import_transactions13.Transaction();
|
|
11065
11182
|
const slippage = new import_decimal13.default(params.slippage);
|
|
11066
11183
|
const lower_slippage = new import_decimal13.default(1).sub(slippage.div(new import_decimal13.default(1e4)));
|
|
11067
11184
|
const upper_slippage = new import_decimal13.default(1).plus(slippage.div(new import_decimal13.default(1e4)));
|
|
@@ -11080,18 +11197,18 @@ var AlmmModule = class {
|
|
|
11080
11197
|
let primaryCoinAInputs;
|
|
11081
11198
|
let primaryCoinBInputs;
|
|
11082
11199
|
if (params.fixCoinA && params.fixCoinB) {
|
|
11083
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
11084
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
11200
|
+
primaryCoinAInputs = params.coin_object_id_a ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true).targetCoin;
|
|
11201
|
+
primaryCoinBInputs = params.coin_object_id_b ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true).targetCoin;
|
|
11085
11202
|
} else if (params.fixCoinA) {
|
|
11086
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
11203
|
+
primaryCoinAInputs = params.coin_object_id_a ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true).targetCoin;
|
|
11087
11204
|
amount_min = new import_decimal13.default(params.amountBTotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
11088
11205
|
amount_max = new import_decimal13.default(params.amountBTotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
11089
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
11206
|
+
primaryCoinBInputs = params.coin_object_id_b ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true).targetCoin;
|
|
11090
11207
|
} else if (params.fixCoinB) {
|
|
11091
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
11208
|
+
primaryCoinBInputs = params.coin_object_id_b ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true).targetCoin;
|
|
11092
11209
|
amount_min = new import_decimal13.default(params.amountATotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
11093
11210
|
amount_max = new import_decimal13.default(params.amountATotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
11094
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeA, false, true);
|
|
11211
|
+
primaryCoinAInputs = params.coin_object_id_a ?? TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeA, false, true).targetCoin;
|
|
11095
11212
|
}
|
|
11096
11213
|
if (params.fixCoinA && params.fixCoinB) {
|
|
11097
11214
|
} else if (params.fixCoinA) {
|
|
@@ -11104,8 +11221,8 @@ var AlmmModule = class {
|
|
|
11104
11221
|
tx.object(almmConfig.factory),
|
|
11105
11222
|
tx.object(almm_pool.config.rewarder_global_vault),
|
|
11106
11223
|
tx.object(params.positionId),
|
|
11107
|
-
primaryCoinAInputs
|
|
11108
|
-
primaryCoinBInputs
|
|
11224
|
+
primaryCoinAInputs,
|
|
11225
|
+
primaryCoinBInputs,
|
|
11109
11226
|
tx.pure.bool(params.fixCoinA),
|
|
11110
11227
|
tx.pure.u64(params.amountATotal),
|
|
11111
11228
|
tx.pure.bool(params.fixCoinB),
|
|
@@ -11124,8 +11241,8 @@ var AlmmModule = class {
|
|
|
11124
11241
|
});
|
|
11125
11242
|
return tx;
|
|
11126
11243
|
}
|
|
11127
|
-
async burnPosition(params) {
|
|
11128
|
-
|
|
11244
|
+
async burnPosition(params, tx) {
|
|
11245
|
+
tx = tx || new import_transactions13.Transaction();
|
|
11129
11246
|
tx.setSender(this.sdk.senderAddress);
|
|
11130
11247
|
const { integrate, clmm_pool, almm_pool } = this.sdk.sdkOptions;
|
|
11131
11248
|
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
@@ -11151,7 +11268,7 @@ var AlmmModule = class {
|
|
|
11151
11268
|
return tx;
|
|
11152
11269
|
}
|
|
11153
11270
|
async shrinkPosition(params) {
|
|
11154
|
-
const tx = new
|
|
11271
|
+
const tx = new import_transactions13.Transaction();
|
|
11155
11272
|
tx.setSender(this.sdk.senderAddress);
|
|
11156
11273
|
const { integrate, clmm_pool, almm_pool } = this.sdk.sdkOptions;
|
|
11157
11274
|
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
@@ -11184,7 +11301,7 @@ var AlmmModule = class {
|
|
|
11184
11301
|
return tx;
|
|
11185
11302
|
}
|
|
11186
11303
|
async collectFeeAndRewardList(paramsList) {
|
|
11187
|
-
let tx = new
|
|
11304
|
+
let tx = new import_transactions13.Transaction();
|
|
11188
11305
|
for (let index = 0; index < paramsList.length; index++) {
|
|
11189
11306
|
const params = paramsList[index];
|
|
11190
11307
|
tx = await this.collectFeeAndReward(params);
|
|
@@ -11193,7 +11310,7 @@ var AlmmModule = class {
|
|
|
11193
11310
|
}
|
|
11194
11311
|
async collectFeeAndReward(params, tx) {
|
|
11195
11312
|
if (!tx) {
|
|
11196
|
-
tx = new
|
|
11313
|
+
tx = new import_transactions13.Transaction();
|
|
11197
11314
|
}
|
|
11198
11315
|
tx = await this.collectFees(params);
|
|
11199
11316
|
if (params.rewards_token.length > 0) {
|
|
@@ -11202,7 +11319,7 @@ var AlmmModule = class {
|
|
|
11202
11319
|
return tx;
|
|
11203
11320
|
}
|
|
11204
11321
|
async collectReward(params, transaction) {
|
|
11205
|
-
const tx = transaction || new
|
|
11322
|
+
const tx = transaction || new import_transactions13.Transaction();
|
|
11206
11323
|
tx.setSender(this.sdk.senderAddress);
|
|
11207
11324
|
const { integrate, clmm_pool, almm_pool } = this.sdk.sdkOptions;
|
|
11208
11325
|
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
@@ -11227,7 +11344,7 @@ var AlmmModule = class {
|
|
|
11227
11344
|
return tx;
|
|
11228
11345
|
}
|
|
11229
11346
|
async collectFees(params, transaction) {
|
|
11230
|
-
const tx = transaction || new
|
|
11347
|
+
const tx = transaction || new import_transactions13.Transaction();
|
|
11231
11348
|
tx.setSender(this.sdk.senderAddress);
|
|
11232
11349
|
const { integrate, almm_pool } = this.sdk.sdkOptions;
|
|
11233
11350
|
const almmConfig = getPackagerConfigs(almm_pool);
|
|
@@ -11242,7 +11359,7 @@ var AlmmModule = class {
|
|
|
11242
11359
|
return tx;
|
|
11243
11360
|
}
|
|
11244
11361
|
async createPairAddLiquidity(params) {
|
|
11245
|
-
const tx = new
|
|
11362
|
+
const tx = new import_transactions13.Transaction();
|
|
11246
11363
|
tx.setSender(this.sdk.senderAddress);
|
|
11247
11364
|
const { clmm_pool, almm_pool, integrate } = this.sdk.sdkOptions;
|
|
11248
11365
|
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
@@ -11280,7 +11397,7 @@ var AlmmModule = class {
|
|
|
11280
11397
|
return tx;
|
|
11281
11398
|
}
|
|
11282
11399
|
async swap(params) {
|
|
11283
|
-
const tx = new
|
|
11400
|
+
const tx = new import_transactions13.Transaction();
|
|
11284
11401
|
tx.setSender(this.sdk.senderAddress);
|
|
11285
11402
|
const { clmm_pool, almm_pool, integrate } = this.sdk.sdkOptions;
|
|
11286
11403
|
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
@@ -11323,7 +11440,7 @@ var AlmmModule = class {
|
|
|
11323
11440
|
return tx;
|
|
11324
11441
|
}
|
|
11325
11442
|
async fetchBins(params) {
|
|
11326
|
-
const tx = new
|
|
11443
|
+
const tx = new import_transactions13.Transaction();
|
|
11327
11444
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
11328
11445
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
11329
11446
|
const args = [tx.object(params.pair), tx.pure.u64(params.offset), tx.pure.u64(params.limit)];
|
|
@@ -11473,7 +11590,7 @@ var AlmmModule = class {
|
|
|
11473
11590
|
for (const item of allPosition) {
|
|
11474
11591
|
poolMap.add(item.pool);
|
|
11475
11592
|
}
|
|
11476
|
-
const poolList = await this.getPoolInfo(Array.from(poolMap));
|
|
11593
|
+
const poolList = await this.getPoolInfo(Array.from(poolMap), false);
|
|
11477
11594
|
const _params = [];
|
|
11478
11595
|
for (const pool of poolList) {
|
|
11479
11596
|
_params.push({
|
|
@@ -11488,7 +11605,7 @@ var AlmmModule = class {
|
|
|
11488
11605
|
const positionsFeesRes = [];
|
|
11489
11606
|
for (const item of allPosition) {
|
|
11490
11607
|
const pool = poolList.find((pool2) => pool2.pool_id === item.pool);
|
|
11491
|
-
const tx = new
|
|
11608
|
+
const tx = new import_transactions13.Transaction();
|
|
11492
11609
|
this._getPositionLiquidity(
|
|
11493
11610
|
{
|
|
11494
11611
|
pair: item.pool,
|
|
@@ -11644,14 +11761,14 @@ var AlmmModule = class {
|
|
|
11644
11761
|
return out;
|
|
11645
11762
|
}
|
|
11646
11763
|
async getPositionsLiquidity(params) {
|
|
11647
|
-
let tx = new
|
|
11764
|
+
let tx = new import_transactions13.Transaction();
|
|
11648
11765
|
for (const param of params) {
|
|
11649
11766
|
tx = await this._getPositionLiquidity(param, tx);
|
|
11650
11767
|
}
|
|
11651
11768
|
return this._parsePositionLiquidity(tx);
|
|
11652
11769
|
}
|
|
11653
11770
|
async _getPositionLiquidity(params, tx) {
|
|
11654
|
-
tx = tx || new
|
|
11771
|
+
tx = tx || new import_transactions13.Transaction();
|
|
11655
11772
|
const { integrate } = this.sdk.sdkOptions;
|
|
11656
11773
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
11657
11774
|
const args = [tx.object(params.pair), tx.object(params.positionId)];
|
|
@@ -11690,7 +11807,7 @@ var AlmmModule = class {
|
|
|
11690
11807
|
return out;
|
|
11691
11808
|
}
|
|
11692
11809
|
async getPairLiquidity(params) {
|
|
11693
|
-
const tx = new
|
|
11810
|
+
const tx = new import_transactions13.Transaction();
|
|
11694
11811
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
11695
11812
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
11696
11813
|
const args = [tx.object(params.pair)];
|
|
@@ -11743,14 +11860,14 @@ var AlmmModule = class {
|
|
|
11743
11860
|
return out;
|
|
11744
11861
|
}
|
|
11745
11862
|
async getEarnedFees(params) {
|
|
11746
|
-
let tx = new
|
|
11863
|
+
let tx = new import_transactions13.Transaction();
|
|
11747
11864
|
for (const param of params) {
|
|
11748
11865
|
tx = await this._getEarnedFees(param, tx);
|
|
11749
11866
|
}
|
|
11750
11867
|
return this._parseEarnedFees(tx);
|
|
11751
11868
|
}
|
|
11752
11869
|
async _getEarnedFees(params, tx) {
|
|
11753
|
-
tx = tx || new
|
|
11870
|
+
tx = tx || new import_transactions13.Transaction();
|
|
11754
11871
|
const { integrate } = this.sdk.sdkOptions;
|
|
11755
11872
|
const typeArguments = [params.coin_a, params.coin_b];
|
|
11756
11873
|
const args = [tx.object(params.pool_id), tx.object(params.position_id)];
|
|
@@ -11785,7 +11902,7 @@ var AlmmModule = class {
|
|
|
11785
11902
|
return out;
|
|
11786
11903
|
}
|
|
11787
11904
|
async getEarnedRewards(params) {
|
|
11788
|
-
let tx = new
|
|
11905
|
+
let tx = new import_transactions13.Transaction();
|
|
11789
11906
|
for (const param of params) {
|
|
11790
11907
|
if (param.rewards_token.length !== 0) {
|
|
11791
11908
|
tx = await this._getEarnedRewards(param, tx);
|
|
@@ -11794,7 +11911,7 @@ var AlmmModule = class {
|
|
|
11794
11911
|
return this._parseEarnedRewards(tx);
|
|
11795
11912
|
}
|
|
11796
11913
|
async _getEarnedRewards(params, tx) {
|
|
11797
|
-
tx = tx || new
|
|
11914
|
+
tx = tx || new import_transactions13.Transaction();
|
|
11798
11915
|
const { integrate } = this.sdk.sdkOptions;
|
|
11799
11916
|
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
11800
11917
|
const args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
@@ -11844,14 +11961,14 @@ var AlmmModule = class {
|
|
|
11844
11961
|
}
|
|
11845
11962
|
// return pool_id => reward_tokens
|
|
11846
11963
|
async getPairRewarders(params) {
|
|
11847
|
-
let tx = new
|
|
11964
|
+
let tx = new import_transactions13.Transaction();
|
|
11848
11965
|
for (const param of params) {
|
|
11849
11966
|
tx = await this._getPairRewarders(param, tx);
|
|
11850
11967
|
}
|
|
11851
11968
|
return this._parsePairRewarders(tx);
|
|
11852
11969
|
}
|
|
11853
11970
|
async _getPairRewarders(params, tx) {
|
|
11854
|
-
tx = tx || new
|
|
11971
|
+
tx = tx || new import_transactions13.Transaction();
|
|
11855
11972
|
const { integrate } = this.sdk.sdkOptions;
|
|
11856
11973
|
const typeArguments = [params.coin_a, params.coin_b];
|
|
11857
11974
|
const args = [tx.object(params.pool_id)];
|
|
@@ -12457,10 +12574,12 @@ var src_default = MagmaClmmSDK;
|
|
|
12457
12574
|
composeType,
|
|
12458
12575
|
computeSwap,
|
|
12459
12576
|
computeSwapStep,
|
|
12577
|
+
convertScientificToDecimal,
|
|
12460
12578
|
createSplitAmountArray,
|
|
12461
12579
|
createSplitArray,
|
|
12462
12580
|
d,
|
|
12463
12581
|
decimalsMultiplier,
|
|
12582
|
+
defaultSwapSlippage,
|
|
12464
12583
|
estPoolAPR,
|
|
12465
12584
|
estPositionAPRWithDeltaMethod,
|
|
12466
12585
|
estPositionAPRWithMultiMethod,
|