@cetusprotocol/aggregator-sdk 1.5.1 → 1.5.2
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.cjs +37 -14
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +37 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43,9 +43,9 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
|
|
|
43
43
|
mod2
|
|
44
44
|
));
|
|
45
45
|
|
|
46
|
-
// node_modules/bn.js/lib/bn.js
|
|
46
|
+
// node_modules/.pnpm/bn.js@5.2.3/node_modules/bn.js/lib/bn.js
|
|
47
47
|
var require_bn = __commonJS({
|
|
48
|
-
"node_modules/bn.js/lib/bn.js"(exports, module) {
|
|
48
|
+
"node_modules/.pnpm/bn.js@5.2.3/node_modules/bn.js/lib/bn.js"(exports$1, module) {
|
|
49
49
|
(function(module2, exports2) {
|
|
50
50
|
function assert(val, msg) {
|
|
51
51
|
if (!val) throw new Error(msg || "Assertion failed");
|
|
@@ -351,7 +351,7 @@ var require_bn = __commonJS({
|
|
|
351
351
|
};
|
|
352
352
|
if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") {
|
|
353
353
|
try {
|
|
354
|
-
BN7.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
|
|
354
|
+
BN7.prototype[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = inspect;
|
|
355
355
|
} catch (e) {
|
|
356
356
|
BN7.prototype.inspect = inspect;
|
|
357
357
|
}
|
|
@@ -1768,6 +1768,10 @@ var require_bn = __commonJS({
|
|
|
1768
1768
|
var mask = 67108863 ^ 67108863 >>> r << r;
|
|
1769
1769
|
this.words[this.length - 1] &= mask;
|
|
1770
1770
|
}
|
|
1771
|
+
if (this.length === 0) {
|
|
1772
|
+
this.words[0] = 0;
|
|
1773
|
+
this.length = 1;
|
|
1774
|
+
}
|
|
1771
1775
|
return this._strip();
|
|
1772
1776
|
};
|
|
1773
1777
|
BN7.prototype.maskn = function maskn(bits) {
|
|
@@ -2783,7 +2787,7 @@ var require_bn = __commonJS({
|
|
|
2783
2787
|
var res = this.imod(a._invmp(this.m).mul(this.r2));
|
|
2784
2788
|
return res._forceRed(this);
|
|
2785
2789
|
};
|
|
2786
|
-
})(typeof module === "undefined" || module, exports);
|
|
2790
|
+
})(typeof module === "undefined" || module, exports$1);
|
|
2787
2791
|
}
|
|
2788
2792
|
});
|
|
2789
2793
|
|
|
@@ -3416,7 +3420,7 @@ var AGGREGATOR_V3_CONFIG = {
|
|
|
3416
3420
|
};
|
|
3417
3421
|
|
|
3418
3422
|
// src/api.ts
|
|
3419
|
-
var SDK_VERSION =
|
|
3423
|
+
var SDK_VERSION = 1010502;
|
|
3420
3424
|
function parseRouterResponse(data, byAmountIn) {
|
|
3421
3425
|
let packages = /* @__PURE__ */ new Map();
|
|
3422
3426
|
if (data.packages) {
|
|
@@ -3852,7 +3856,7 @@ var AggregatorConfig = class {
|
|
|
3852
3856
|
// src/math.ts
|
|
3853
3857
|
var import_bn3 = __toESM(require_bn());
|
|
3854
3858
|
|
|
3855
|
-
// node_modules/decimal.js/decimal.mjs
|
|
3859
|
+
// node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.mjs
|
|
3856
3860
|
var EXP_LIMIT = 9e15;
|
|
3857
3861
|
var MAX_DIGITS = 1e9;
|
|
3858
3862
|
var NUMERALS = "0123456789abcdef";
|
|
@@ -6021,7 +6025,7 @@ function tanh(x) {
|
|
|
6021
6025
|
function trunc(x) {
|
|
6022
6026
|
return finalise(x = new this(x), x.e + 1, 1);
|
|
6023
6027
|
}
|
|
6024
|
-
P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
|
|
6028
|
+
P[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = P.toString;
|
|
6025
6029
|
P[Symbol.toStringTag] = "Decimal";
|
|
6026
6030
|
var Decimal = P.constructor = clone(DEFAULTS);
|
|
6027
6031
|
LN10 = new Decimal(LN10);
|
|
@@ -9300,7 +9304,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9300
9304
|
return outputCoin;
|
|
9301
9305
|
}
|
|
9302
9306
|
async routerSwap(params) {
|
|
9303
|
-
const { router, inputCoin, slippage, txb, partner } = params;
|
|
9307
|
+
const { router, inputCoin, slippage, txb, partner, cetusDlmmPartner } = params;
|
|
9304
9308
|
if (slippage > 1 || slippage < 0) {
|
|
9305
9309
|
throw new Error(CLIENT_CONFIG.ERRORS.INVALID_SLIPPAGE);
|
|
9306
9310
|
}
|
|
@@ -9334,7 +9338,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9334
9338
|
amountOut.toString(),
|
|
9335
9339
|
amountLimit.toString(),
|
|
9336
9340
|
priceInfoObjectIds,
|
|
9337
|
-
partner ?? this.partner
|
|
9341
|
+
partner ?? this.partner,
|
|
9342
|
+
cetusDlmmPartner ?? this.cetusDlmmPartner
|
|
9338
9343
|
);
|
|
9339
9344
|
} else {
|
|
9340
9345
|
return this.expectOutputSwapV3(
|
|
@@ -9357,7 +9362,15 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9357
9362
|
* @throws Error if input coin amount exceeds maxAmountIn
|
|
9358
9363
|
*/
|
|
9359
9364
|
async routerSwapWithMaxAmountIn(params) {
|
|
9360
|
-
const {
|
|
9365
|
+
const {
|
|
9366
|
+
router,
|
|
9367
|
+
inputCoin,
|
|
9368
|
+
slippage,
|
|
9369
|
+
txb,
|
|
9370
|
+
partner,
|
|
9371
|
+
cetusDlmmPartner,
|
|
9372
|
+
maxAmountIn
|
|
9373
|
+
} = params;
|
|
9361
9374
|
if (slippage > 1 || slippage < 0) {
|
|
9362
9375
|
throw new Error(CLIENT_CONFIG.ERRORS.INVALID_SLIPPAGE);
|
|
9363
9376
|
}
|
|
@@ -9392,7 +9405,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9392
9405
|
amountOut.toString(),
|
|
9393
9406
|
amountLimit.toString(),
|
|
9394
9407
|
priceInfoObjectIds,
|
|
9395
|
-
partner ?? this.partner
|
|
9408
|
+
partner ?? this.partner,
|
|
9409
|
+
cetusDlmmPartner ?? this.cetusDlmmPartner
|
|
9396
9410
|
);
|
|
9397
9411
|
} else {
|
|
9398
9412
|
return this.expectOutputSwapV3WithMaxAmountIn(
|
|
@@ -9409,7 +9423,14 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9409
9423
|
// auto build input coin
|
|
9410
9424
|
// auto merge, transfer or destory target coin.
|
|
9411
9425
|
async fastRouterSwap(params) {
|
|
9412
|
-
const {
|
|
9426
|
+
const {
|
|
9427
|
+
router,
|
|
9428
|
+
slippage,
|
|
9429
|
+
txb,
|
|
9430
|
+
partner,
|
|
9431
|
+
cetusDlmmPartner,
|
|
9432
|
+
payDeepFeeAmount
|
|
9433
|
+
} = params;
|
|
9413
9434
|
const fromCoinType = router.paths[0].from;
|
|
9414
9435
|
const targetCoinType = router.paths[router.paths.length - 1].target;
|
|
9415
9436
|
const byAmountIn = router.byAmountIn;
|
|
@@ -9450,6 +9471,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9450
9471
|
slippage,
|
|
9451
9472
|
txb,
|
|
9452
9473
|
partner: partner ?? this.partner,
|
|
9474
|
+
cetusDlmmPartner: cetusDlmmPartner ?? this.cetusDlmmPartner,
|
|
9453
9475
|
deepbookv3DeepFee: deepCoin
|
|
9454
9476
|
};
|
|
9455
9477
|
const targetCoin = await this.routerSwap(routerSwapParams);
|
|
@@ -9565,7 +9587,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9565
9587
|
}
|
|
9566
9588
|
}
|
|
9567
9589
|
async fixableRouterSwapV3(params) {
|
|
9568
|
-
const { router, inputCoin, slippage, txb, partner } = params;
|
|
9590
|
+
const { router, inputCoin, slippage, txb, partner, cetusDlmmPartner } = params;
|
|
9569
9591
|
checkOverlayFeeConfig(this.overlayFeeRate, this.overlayFeeReceiver);
|
|
9570
9592
|
let overlayFee = 0;
|
|
9571
9593
|
if (router.byAmountIn) {
|
|
@@ -9594,7 +9616,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9594
9616
|
expectedAmountOut.toString(),
|
|
9595
9617
|
amountLimit.toString(),
|
|
9596
9618
|
priceInfoObjectIds,
|
|
9597
|
-
partner ?? this.partner
|
|
9619
|
+
partner ?? this.partner,
|
|
9620
|
+
cetusDlmmPartner ?? this.cetusDlmmPartner
|
|
9598
9621
|
);
|
|
9599
9622
|
} else {
|
|
9600
9623
|
return this.expectOutputSwapV3(
|
package/dist/index.d.cts
CHANGED
|
@@ -365,6 +365,7 @@ type BuildRouterSwapParamsV3 = {
|
|
|
365
365
|
slippage: number;
|
|
366
366
|
txb: Transaction;
|
|
367
367
|
partner?: string;
|
|
368
|
+
cetusDlmmPartner?: string;
|
|
368
369
|
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
369
370
|
fixable?: boolean;
|
|
370
371
|
};
|
|
@@ -373,6 +374,7 @@ type BuildFastRouterSwapParamsV3 = {
|
|
|
373
374
|
slippage: number;
|
|
374
375
|
txb: Transaction;
|
|
375
376
|
partner?: string;
|
|
377
|
+
cetusDlmmPartner?: string;
|
|
376
378
|
refreshAllCoins?: boolean;
|
|
377
379
|
payDeepFeeAmount?: number;
|
|
378
380
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -365,6 +365,7 @@ type BuildRouterSwapParamsV3 = {
|
|
|
365
365
|
slippage: number;
|
|
366
366
|
txb: Transaction;
|
|
367
367
|
partner?: string;
|
|
368
|
+
cetusDlmmPartner?: string;
|
|
368
369
|
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
369
370
|
fixable?: boolean;
|
|
370
371
|
};
|
|
@@ -373,6 +374,7 @@ type BuildFastRouterSwapParamsV3 = {
|
|
|
373
374
|
slippage: number;
|
|
374
375
|
txb: Transaction;
|
|
375
376
|
partner?: string;
|
|
377
|
+
cetusDlmmPartner?: string;
|
|
376
378
|
refreshAllCoins?: boolean;
|
|
377
379
|
payDeepFeeAmount?: number;
|
|
378
380
|
};
|
package/dist/index.js
CHANGED
|
@@ -37,9 +37,9 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
|
|
|
37
37
|
mod2
|
|
38
38
|
));
|
|
39
39
|
|
|
40
|
-
// node_modules/bn.js/lib/bn.js
|
|
40
|
+
// node_modules/.pnpm/bn.js@5.2.3/node_modules/bn.js/lib/bn.js
|
|
41
41
|
var require_bn = __commonJS({
|
|
42
|
-
"node_modules/bn.js/lib/bn.js"(exports, module) {
|
|
42
|
+
"node_modules/.pnpm/bn.js@5.2.3/node_modules/bn.js/lib/bn.js"(exports$1, module) {
|
|
43
43
|
(function(module2, exports2) {
|
|
44
44
|
function assert(val, msg) {
|
|
45
45
|
if (!val) throw new Error(msg || "Assertion failed");
|
|
@@ -345,7 +345,7 @@ var require_bn = __commonJS({
|
|
|
345
345
|
};
|
|
346
346
|
if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") {
|
|
347
347
|
try {
|
|
348
|
-
BN7.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
|
|
348
|
+
BN7.prototype[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = inspect;
|
|
349
349
|
} catch (e) {
|
|
350
350
|
BN7.prototype.inspect = inspect;
|
|
351
351
|
}
|
|
@@ -1762,6 +1762,10 @@ var require_bn = __commonJS({
|
|
|
1762
1762
|
var mask = 67108863 ^ 67108863 >>> r << r;
|
|
1763
1763
|
this.words[this.length - 1] &= mask;
|
|
1764
1764
|
}
|
|
1765
|
+
if (this.length === 0) {
|
|
1766
|
+
this.words[0] = 0;
|
|
1767
|
+
this.length = 1;
|
|
1768
|
+
}
|
|
1765
1769
|
return this._strip();
|
|
1766
1770
|
};
|
|
1767
1771
|
BN7.prototype.maskn = function maskn(bits) {
|
|
@@ -2777,7 +2781,7 @@ var require_bn = __commonJS({
|
|
|
2777
2781
|
var res = this.imod(a._invmp(this.m).mul(this.r2));
|
|
2778
2782
|
return res._forceRed(this);
|
|
2779
2783
|
};
|
|
2780
|
-
})(typeof module === "undefined" || module, exports);
|
|
2784
|
+
})(typeof module === "undefined" || module, exports$1);
|
|
2781
2785
|
}
|
|
2782
2786
|
});
|
|
2783
2787
|
|
|
@@ -3410,7 +3414,7 @@ var AGGREGATOR_V3_CONFIG = {
|
|
|
3410
3414
|
};
|
|
3411
3415
|
|
|
3412
3416
|
// src/api.ts
|
|
3413
|
-
var SDK_VERSION =
|
|
3417
|
+
var SDK_VERSION = 1010502;
|
|
3414
3418
|
function parseRouterResponse(data, byAmountIn) {
|
|
3415
3419
|
let packages = /* @__PURE__ */ new Map();
|
|
3416
3420
|
if (data.packages) {
|
|
@@ -3846,7 +3850,7 @@ var AggregatorConfig = class {
|
|
|
3846
3850
|
// src/math.ts
|
|
3847
3851
|
var import_bn3 = __toESM(require_bn());
|
|
3848
3852
|
|
|
3849
|
-
// node_modules/decimal.js/decimal.mjs
|
|
3853
|
+
// node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.mjs
|
|
3850
3854
|
var EXP_LIMIT = 9e15;
|
|
3851
3855
|
var MAX_DIGITS = 1e9;
|
|
3852
3856
|
var NUMERALS = "0123456789abcdef";
|
|
@@ -6015,7 +6019,7 @@ function tanh(x) {
|
|
|
6015
6019
|
function trunc(x) {
|
|
6016
6020
|
return finalise(x = new this(x), x.e + 1, 1);
|
|
6017
6021
|
}
|
|
6018
|
-
P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
|
|
6022
|
+
P[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = P.toString;
|
|
6019
6023
|
P[Symbol.toStringTag] = "Decimal";
|
|
6020
6024
|
var Decimal = P.constructor = clone(DEFAULTS);
|
|
6021
6025
|
LN10 = new Decimal(LN10);
|
|
@@ -9294,7 +9298,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9294
9298
|
return outputCoin;
|
|
9295
9299
|
}
|
|
9296
9300
|
async routerSwap(params) {
|
|
9297
|
-
const { router, inputCoin, slippage, txb, partner } = params;
|
|
9301
|
+
const { router, inputCoin, slippage, txb, partner, cetusDlmmPartner } = params;
|
|
9298
9302
|
if (slippage > 1 || slippage < 0) {
|
|
9299
9303
|
throw new Error(CLIENT_CONFIG.ERRORS.INVALID_SLIPPAGE);
|
|
9300
9304
|
}
|
|
@@ -9328,7 +9332,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9328
9332
|
amountOut.toString(),
|
|
9329
9333
|
amountLimit.toString(),
|
|
9330
9334
|
priceInfoObjectIds,
|
|
9331
|
-
partner ?? this.partner
|
|
9335
|
+
partner ?? this.partner,
|
|
9336
|
+
cetusDlmmPartner ?? this.cetusDlmmPartner
|
|
9332
9337
|
);
|
|
9333
9338
|
} else {
|
|
9334
9339
|
return this.expectOutputSwapV3(
|
|
@@ -9351,7 +9356,15 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9351
9356
|
* @throws Error if input coin amount exceeds maxAmountIn
|
|
9352
9357
|
*/
|
|
9353
9358
|
async routerSwapWithMaxAmountIn(params) {
|
|
9354
|
-
const {
|
|
9359
|
+
const {
|
|
9360
|
+
router,
|
|
9361
|
+
inputCoin,
|
|
9362
|
+
slippage,
|
|
9363
|
+
txb,
|
|
9364
|
+
partner,
|
|
9365
|
+
cetusDlmmPartner,
|
|
9366
|
+
maxAmountIn
|
|
9367
|
+
} = params;
|
|
9355
9368
|
if (slippage > 1 || slippage < 0) {
|
|
9356
9369
|
throw new Error(CLIENT_CONFIG.ERRORS.INVALID_SLIPPAGE);
|
|
9357
9370
|
}
|
|
@@ -9386,7 +9399,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9386
9399
|
amountOut.toString(),
|
|
9387
9400
|
amountLimit.toString(),
|
|
9388
9401
|
priceInfoObjectIds,
|
|
9389
|
-
partner ?? this.partner
|
|
9402
|
+
partner ?? this.partner,
|
|
9403
|
+
cetusDlmmPartner ?? this.cetusDlmmPartner
|
|
9390
9404
|
);
|
|
9391
9405
|
} else {
|
|
9392
9406
|
return this.expectOutputSwapV3WithMaxAmountIn(
|
|
@@ -9403,7 +9417,14 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9403
9417
|
// auto build input coin
|
|
9404
9418
|
// auto merge, transfer or destory target coin.
|
|
9405
9419
|
async fastRouterSwap(params) {
|
|
9406
|
-
const {
|
|
9420
|
+
const {
|
|
9421
|
+
router,
|
|
9422
|
+
slippage,
|
|
9423
|
+
txb,
|
|
9424
|
+
partner,
|
|
9425
|
+
cetusDlmmPartner,
|
|
9426
|
+
payDeepFeeAmount
|
|
9427
|
+
} = params;
|
|
9407
9428
|
const fromCoinType = router.paths[0].from;
|
|
9408
9429
|
const targetCoinType = router.paths[router.paths.length - 1].target;
|
|
9409
9430
|
const byAmountIn = router.byAmountIn;
|
|
@@ -9444,6 +9465,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9444
9465
|
slippage,
|
|
9445
9466
|
txb,
|
|
9446
9467
|
partner: partner ?? this.partner,
|
|
9468
|
+
cetusDlmmPartner: cetusDlmmPartner ?? this.cetusDlmmPartner,
|
|
9447
9469
|
deepbookv3DeepFee: deepCoin
|
|
9448
9470
|
};
|
|
9449
9471
|
const targetCoin = await this.routerSwap(routerSwapParams);
|
|
@@ -9559,7 +9581,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9559
9581
|
}
|
|
9560
9582
|
}
|
|
9561
9583
|
async fixableRouterSwapV3(params) {
|
|
9562
|
-
const { router, inputCoin, slippage, txb, partner } = params;
|
|
9584
|
+
const { router, inputCoin, slippage, txb, partner, cetusDlmmPartner } = params;
|
|
9563
9585
|
checkOverlayFeeConfig(this.overlayFeeRate, this.overlayFeeReceiver);
|
|
9564
9586
|
let overlayFee = 0;
|
|
9565
9587
|
if (router.byAmountIn) {
|
|
@@ -9588,7 +9610,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9588
9610
|
expectedAmountOut.toString(),
|
|
9589
9611
|
amountLimit.toString(),
|
|
9590
9612
|
priceInfoObjectIds,
|
|
9591
|
-
partner ?? this.partner
|
|
9613
|
+
partner ?? this.partner,
|
|
9614
|
+
cetusDlmmPartner ?? this.cetusDlmmPartner
|
|
9592
9615
|
);
|
|
9593
9616
|
} else {
|
|
9594
9617
|
return this.expectOutputSwapV3(
|