@cetusprotocol/aggregator-sdk 0.0.0-experimental-20241011180351 → 0.0.0-experimental-20241011205228
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.mts +3 -39
- package/dist/index.d.ts +3 -39
- package/dist/index.js +19 -148
- package/dist/index.mjs +19 -139
- package/dist/src/api.d.ts +0 -16
- package/dist/src/client.d.ts +2 -7
- package/dist/src/transaction/index.d.ts +1 -1
- package/dist/src/utils/index.d.ts +0 -3
- package/dist/tests/test_data.test.d.ts +0 -3
- package/package.json +1 -1
- package/src/api.ts +7 -33
- package/src/client.ts +11 -78
- package/src/transaction/afsui.ts +1 -0
- package/src/transaction/aftermath.ts +2 -0
- package/src/transaction/deepbook_v2.ts +1 -0
- package/src/transaction/index.ts +1 -2
- package/src/utils/index.ts +0 -3
- package/tests/router.test.ts +27 -29
- package/tests/test_data.test.ts +0 -3
- package/dist/src/transaction/deepbook_v3.d.ts +0 -13
- package/dist/src/utils/api.d.ts +0 -1
- package/src/transaction/deepbook_v3.ts +0 -68
- package/src/utils/api.ts +0 -6
- package/test.json +0 -5
package/dist/index.mjs
CHANGED
|
@@ -5712,16 +5712,6 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
|
|
|
5712
5712
|
}
|
|
5713
5713
|
|
|
5714
5714
|
// src/utils/transaction.ts
|
|
5715
|
-
function printTransaction(tx, isPrint = true) {
|
|
5716
|
-
return __async(this, null, function* () {
|
|
5717
|
-
console.log(`inputs`, tx.getData().inputs);
|
|
5718
|
-
tx.getData().commands.forEach((item, index) => {
|
|
5719
|
-
if (isPrint) {
|
|
5720
|
-
console.log(`transaction ${index}: `, JSON.stringify(item, null, 2));
|
|
5721
|
-
}
|
|
5722
|
-
});
|
|
5723
|
-
});
|
|
5724
|
-
}
|
|
5725
5715
|
function checkInvalidSuiAddress(address) {
|
|
5726
5716
|
if (!address.startsWith("0x") || address.length !== 66) {
|
|
5727
5717
|
return false;
|
|
@@ -6000,45 +5990,6 @@ var Bluemove = class {
|
|
|
6000
5990
|
}
|
|
6001
5991
|
};
|
|
6002
5992
|
|
|
6003
|
-
// src/transaction/deepbook_v3.ts
|
|
6004
|
-
var DeepbookV3 = class {
|
|
6005
|
-
constructor(env) {
|
|
6006
|
-
this.deepbookV3Config = env === 0 /* Mainnet */ ? "0x0" : "0xe19b5d072346cae83a037d4e3c8492068a74410a74e5830b3a68012db38296aa";
|
|
6007
|
-
this.deepCoinType = env === 0 /* Mainnet */ ? "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP" : "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6008
|
-
}
|
|
6009
|
-
swap(client, txb, path, inputCoin, deepbookv3DeepFee) {
|
|
6010
|
-
return __async(this, null, function* () {
|
|
6011
|
-
var _a, _b, _c;
|
|
6012
|
-
const { direction, from, target } = path;
|
|
6013
|
-
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6014
|
-
let deepFee;
|
|
6015
|
-
if (deepbookv3DeepFee) {
|
|
6016
|
-
if (((_a = path.extendedDetails) == null ? void 0 : _a.deepbookv3DeepFee) && ((_b = path.extendedDetails) == null ? void 0 : _b.deepbookv3DeepFee) > 0) {
|
|
6017
|
-
const splitAmounts = [(_c = path.extendedDetails) == null ? void 0 : _c.deepbookv3DeepFee];
|
|
6018
|
-
deepFee = txb.splitCoins(deepbookv3DeepFee, splitAmounts)[0];
|
|
6019
|
-
} else {
|
|
6020
|
-
deepFee = mintZeroCoin(txb, this.deepCoinType);
|
|
6021
|
-
}
|
|
6022
|
-
} else {
|
|
6023
|
-
deepFee = mintZeroCoin(txb, this.deepCoinType);
|
|
6024
|
-
}
|
|
6025
|
-
const args = [
|
|
6026
|
-
txb.object(this.deepbookV3Config),
|
|
6027
|
-
txb.object(path.id),
|
|
6028
|
-
inputCoin,
|
|
6029
|
-
deepFee,
|
|
6030
|
-
txb.object(CLOCK_ADDRESS)
|
|
6031
|
-
];
|
|
6032
|
-
const res = txb.moveCall({
|
|
6033
|
-
target: `${client.publishedAt()}::deepbookv3::${func}`,
|
|
6034
|
-
typeArguments: [coinAType, coinBType],
|
|
6035
|
-
arguments: args
|
|
6036
|
-
});
|
|
6037
|
-
return res;
|
|
6038
|
-
});
|
|
6039
|
-
}
|
|
6040
|
-
};
|
|
6041
|
-
|
|
6042
5993
|
// src/client.ts
|
|
6043
5994
|
var CETUS = "CETUS";
|
|
6044
5995
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6052,10 +6003,9 @@ var HAEDAL = "HAEDAL";
|
|
|
6052
6003
|
var VOLO = "VOLO";
|
|
6053
6004
|
var AFSUI = "AFSUI";
|
|
6054
6005
|
var BLUEMOVE = "BLUEMOVE";
|
|
6055
|
-
var
|
|
6056
|
-
var AggregatorClient7 = class {
|
|
6006
|
+
var AggregatorClient6 = class {
|
|
6057
6007
|
constructor(endpoint, signer, client, env) {
|
|
6058
|
-
this.endpoint =
|
|
6008
|
+
this.endpoint = endpoint;
|
|
6059
6009
|
this.client = client;
|
|
6060
6010
|
this.signer = signer;
|
|
6061
6011
|
this.env = env;
|
|
@@ -6092,7 +6042,7 @@ var AggregatorClient7 = class {
|
|
|
6092
6042
|
return getRouterResult(this.endpoint, params);
|
|
6093
6043
|
});
|
|
6094
6044
|
}
|
|
6095
|
-
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner
|
|
6045
|
+
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner) {
|
|
6096
6046
|
return __async(this, null, function* () {
|
|
6097
6047
|
if (routers.length === 0) {
|
|
6098
6048
|
throw new Error("No router found");
|
|
@@ -6109,14 +6059,11 @@ var AggregatorClient7 = class {
|
|
|
6109
6059
|
let nextCoin = inputCoins[i];
|
|
6110
6060
|
for (const path of routers[i].path) {
|
|
6111
6061
|
const dex = this.newDex(path.provider, partner);
|
|
6112
|
-
nextCoin = yield dex.swap(this, txb, path, nextCoin
|
|
6062
|
+
nextCoin = yield dex.swap(this, txb, path, nextCoin);
|
|
6113
6063
|
}
|
|
6114
6064
|
outputCoins.push(nextCoin);
|
|
6115
6065
|
}
|
|
6116
6066
|
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType);
|
|
6117
|
-
if (deepbookv3DeepFee) {
|
|
6118
|
-
this.transferOrDestoryCoin(txb, deepbookv3DeepFee, this.deepbookv3DeepFeeType());
|
|
6119
|
-
}
|
|
6120
6067
|
const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
|
|
6121
6068
|
txb,
|
|
6122
6069
|
outputCoins,
|
|
@@ -6188,7 +6135,7 @@ var AggregatorClient7 = class {
|
|
|
6188
6135
|
}
|
|
6189
6136
|
routerSwap(params) {
|
|
6190
6137
|
return __async(this, null, function* () {
|
|
6191
|
-
const { routers, inputCoin, slippage, byAmountIn, txb, partner
|
|
6138
|
+
const { routers, inputCoin, slippage, byAmountIn, txb, partner } = params;
|
|
6192
6139
|
const amountIn = routers.reduce(
|
|
6193
6140
|
(acc, router) => acc.add(router.amountIn),
|
|
6194
6141
|
new import_bn5.default(0)
|
|
@@ -6208,8 +6155,7 @@ var AggregatorClient7 = class {
|
|
|
6208
6155
|
inputCoin,
|
|
6209
6156
|
routers,
|
|
6210
6157
|
new import_bn5.default(amountLimit),
|
|
6211
|
-
partner
|
|
6212
|
-
deepbookv3DeepFee
|
|
6158
|
+
partner
|
|
6213
6159
|
);
|
|
6214
6160
|
return targetCoin2;
|
|
6215
6161
|
}
|
|
@@ -6237,8 +6183,7 @@ var AggregatorClient7 = class {
|
|
|
6237
6183
|
txb,
|
|
6238
6184
|
partner,
|
|
6239
6185
|
isMergeTragetCoin,
|
|
6240
|
-
refreshAllCoins
|
|
6241
|
-
payDeepFeeAmount
|
|
6186
|
+
refreshAllCoins
|
|
6242
6187
|
} = params;
|
|
6243
6188
|
if (refreshAllCoins || this.allCoins.length === 0) {
|
|
6244
6189
|
this.allCoins = yield this.getAllCoins();
|
|
@@ -6265,30 +6210,13 @@ var AggregatorClient7 = class {
|
|
|
6265
6210
|
BigInt(amount.toString()),
|
|
6266
6211
|
fromCoinType
|
|
6267
6212
|
);
|
|
6268
|
-
let buildDeepFeeCoinRes;
|
|
6269
|
-
if (payDeepFeeAmount && payDeepFeeAmount > 0) {
|
|
6270
|
-
buildDeepFeeCoinRes = buildInputCoin(
|
|
6271
|
-
txb,
|
|
6272
|
-
this.allCoins,
|
|
6273
|
-
BigInt(payDeepFeeAmount),
|
|
6274
|
-
this.deepbookv3DeepFeeType()
|
|
6275
|
-
);
|
|
6276
|
-
} else {
|
|
6277
|
-
buildDeepFeeCoinRes = buildInputCoin(
|
|
6278
|
-
txb,
|
|
6279
|
-
this.allCoins,
|
|
6280
|
-
BigInt(0),
|
|
6281
|
-
this.deepbookv3DeepFeeType()
|
|
6282
|
-
);
|
|
6283
|
-
}
|
|
6284
6213
|
const targetCoin = yield this.routerSwap({
|
|
6285
6214
|
routers,
|
|
6286
6215
|
inputCoin: buildFromCoinRes.targetCoin,
|
|
6287
6216
|
slippage,
|
|
6288
6217
|
byAmountIn,
|
|
6289
6218
|
txb,
|
|
6290
|
-
partner
|
|
6291
|
-
deepbookv3DeepFee: buildDeepFeeCoinRes.targetCoin
|
|
6219
|
+
partner
|
|
6292
6220
|
});
|
|
6293
6221
|
if (isMergeTragetCoin) {
|
|
6294
6222
|
const targetCoinRes = buildInputCoin(
|
|
@@ -6312,16 +6240,9 @@ var AggregatorClient7 = class {
|
|
|
6312
6240
|
}
|
|
6313
6241
|
publishedAt() {
|
|
6314
6242
|
if (this.env === 0 /* Mainnet */) {
|
|
6315
|
-
return "
|
|
6316
|
-
} else {
|
|
6317
|
-
return "0xf92cdec6c2d73a12d8afa8dd41199b3e95b621272bbc655996539cd30de6a462";
|
|
6318
|
-
}
|
|
6319
|
-
}
|
|
6320
|
-
deepbookv3DeepFeeType() {
|
|
6321
|
-
if (this.env === 0 /* Mainnet */) {
|
|
6322
|
-
return "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6243
|
+
return "0x7eb2f30d541c06fa7bcf26444845df56361647df0e778b82e5707fb26754c398";
|
|
6323
6244
|
} else {
|
|
6324
|
-
return "
|
|
6245
|
+
return "0x6cbaa3e9fbe902d90191b12f315932bc58079cba422bafbd4b4369f80e61f595";
|
|
6325
6246
|
}
|
|
6326
6247
|
}
|
|
6327
6248
|
transferOrDestoryCoin(txb, coin, coinType) {
|
|
@@ -6355,8 +6276,6 @@ var AggregatorClient7 = class {
|
|
|
6355
6276
|
return new Cetus(this.env, partner);
|
|
6356
6277
|
case DEEPBOOKV2:
|
|
6357
6278
|
return new DeepbookV2(this.env);
|
|
6358
|
-
case DEEPBOOKV3:
|
|
6359
|
-
return new DeepbookV3(this.env);
|
|
6360
6279
|
case KRIYA:
|
|
6361
6280
|
return new KriyaV2(this.env);
|
|
6362
6281
|
case KRIYAV3:
|
|
@@ -6414,44 +6333,26 @@ var AggregatorClient7 = class {
|
|
|
6414
6333
|
return res;
|
|
6415
6334
|
});
|
|
6416
6335
|
}
|
|
6417
|
-
getDeepbookV3Config() {
|
|
6418
|
-
return __async(this, null, function* () {
|
|
6419
|
-
const res = yield getDeepbookV3Config(this.endpoint);
|
|
6420
|
-
if (res) {
|
|
6421
|
-
return res.data;
|
|
6422
|
-
}
|
|
6423
|
-
return null;
|
|
6424
|
-
});
|
|
6425
|
-
}
|
|
6426
6336
|
};
|
|
6427
6337
|
function parseRouterResponse(data) {
|
|
6428
|
-
|
|
6429
|
-
for (const route of data.routes) {
|
|
6430
|
-
for (const path of route.path) {
|
|
6431
|
-
if (path.extended_details && path.extended_details.deepbookv3_deep_fee) {
|
|
6432
|
-
totalDeepFee += Number(path.extended_details.deepbookv3_deep_fee);
|
|
6433
|
-
}
|
|
6434
|
-
}
|
|
6435
|
-
}
|
|
6436
|
-
let routerData = {
|
|
6338
|
+
return {
|
|
6437
6339
|
amountIn: new import_bn5.default(data.amount_in.toString()),
|
|
6438
6340
|
amountOut: new import_bn5.default(data.amount_out.toString()),
|
|
6439
6341
|
insufficientLiquidity: false,
|
|
6440
6342
|
routes: data.routes.map((route) => {
|
|
6441
6343
|
return {
|
|
6442
6344
|
path: route.path.map((path) => {
|
|
6443
|
-
var _a, _b, _c
|
|
6345
|
+
var _a, _b, _c;
|
|
6444
6346
|
let version;
|
|
6445
6347
|
if (path.provider === AFTERMATH) {
|
|
6446
6348
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
6447
6349
|
}
|
|
6448
6350
|
let extendedDetails;
|
|
6449
|
-
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS
|
|
6351
|
+
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS) {
|
|
6450
6352
|
extendedDetails = {
|
|
6451
6353
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
6452
6354
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
6453
|
-
afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price
|
|
6454
|
-
deepbookv3DeepFee: (_d = path.extended_details) == null ? void 0 : _d.deepbookv3_deep_fee
|
|
6355
|
+
afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price
|
|
6455
6356
|
};
|
|
6456
6357
|
}
|
|
6457
6358
|
return {
|
|
@@ -6471,10 +6372,8 @@ function parseRouterResponse(data) {
|
|
|
6471
6372
|
amountOut: new import_bn5.default(route.amount_out.toString()),
|
|
6472
6373
|
initialPrice: new decimal_default(route.initial_price.toString())
|
|
6473
6374
|
};
|
|
6474
|
-
})
|
|
6475
|
-
totalDeepFee
|
|
6375
|
+
})
|
|
6476
6376
|
};
|
|
6477
|
-
return routerData;
|
|
6478
6377
|
}
|
|
6479
6378
|
|
|
6480
6379
|
// src/transaction/index.ts
|
|
@@ -6505,14 +6404,6 @@ var restituteMsafeFastRouterSwapParams = (data) => {
|
|
|
6505
6404
|
return result;
|
|
6506
6405
|
};
|
|
6507
6406
|
|
|
6508
|
-
// src/utils/api.ts
|
|
6509
|
-
function processEndpoint(endpoint) {
|
|
6510
|
-
if (endpoint.endsWith("/find_routes")) {
|
|
6511
|
-
return endpoint.replace("/find_routes", "");
|
|
6512
|
-
}
|
|
6513
|
-
return endpoint;
|
|
6514
|
-
}
|
|
6515
|
-
|
|
6516
6407
|
// src/api.ts
|
|
6517
6408
|
function getRouterResult(endpoint, params) {
|
|
6518
6409
|
return __async(this, null, function* () {
|
|
@@ -6575,7 +6466,7 @@ function getRouter(endpoint, params) {
|
|
|
6575
6466
|
} = params;
|
|
6576
6467
|
const fromCoin = completionCoin(from);
|
|
6577
6468
|
const targetCoin = completionCoin(target);
|
|
6578
|
-
let url = `${endpoint}
|
|
6469
|
+
let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`;
|
|
6579
6470
|
if (depth) {
|
|
6580
6471
|
url += `&depth=${depth}`;
|
|
6581
6472
|
}
|
|
@@ -6617,7 +6508,7 @@ function postRouterWithLiquidityChanges(endpoint, params) {
|
|
|
6617
6508
|
} = params;
|
|
6618
6509
|
const fromCoin = completionCoin(from);
|
|
6619
6510
|
const targetCoin = completionCoin(target);
|
|
6620
|
-
const url = `${endpoint}
|
|
6511
|
+
const url = `${endpoint}`;
|
|
6621
6512
|
const providersStr = providers == null ? void 0 : providers.join(",");
|
|
6622
6513
|
const requestData = {
|
|
6623
6514
|
from: fromCoin,
|
|
@@ -6636,6 +6527,7 @@ function postRouterWithLiquidityChanges(endpoint, params) {
|
|
|
6636
6527
|
delta_liquidity: change.deltaLiquidity
|
|
6637
6528
|
}))
|
|
6638
6529
|
};
|
|
6530
|
+
console.log("requestData", JSON.stringify(requestData, null, 2));
|
|
6639
6531
|
try {
|
|
6640
6532
|
const response = yield fetch(url, {
|
|
6641
6533
|
method: "POST",
|
|
@@ -6651,18 +6543,6 @@ function postRouterWithLiquidityChanges(endpoint, params) {
|
|
|
6651
6543
|
}
|
|
6652
6544
|
});
|
|
6653
6545
|
}
|
|
6654
|
-
function getDeepbookV3Config(endpoint) {
|
|
6655
|
-
return __async(this, null, function* () {
|
|
6656
|
-
const url = `${endpoint}/deepbookv3_config`;
|
|
6657
|
-
try {
|
|
6658
|
-
const response = yield fetch(url);
|
|
6659
|
-
return response.json();
|
|
6660
|
-
} catch (error) {
|
|
6661
|
-
console.error("Error:", error);
|
|
6662
|
-
return null;
|
|
6663
|
-
}
|
|
6664
|
-
});
|
|
6665
|
-
}
|
|
6666
6546
|
|
|
6667
6547
|
// src/index.ts
|
|
6668
6548
|
var Env = /* @__PURE__ */ ((Env2) => {
|
|
@@ -6682,4 +6562,4 @@ decimal.js/decimal.mjs:
|
|
|
6682
6562
|
*)
|
|
6683
6563
|
*/
|
|
6684
6564
|
|
|
6685
|
-
export { AFSUI, AFTERMATH,
|
|
6565
|
+
export { AFSUI, AFTERMATH, AggregatorClient6 as AggregatorClient, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, Env, FLOWXV2, FLOWXV3, HAEDAL, KRIYA, KRIYAV3, ONE, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
|
package/dist/src/api.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export type ExtendedDetails = {
|
|
|
23
23
|
aftermathLpSupplyType?: string;
|
|
24
24
|
turbosFeeType?: string;
|
|
25
25
|
afterSqrtPrice?: string;
|
|
26
|
-
deepbookv3DeepFee?: number;
|
|
27
26
|
};
|
|
28
27
|
export type Path = {
|
|
29
28
|
id: string;
|
|
@@ -52,7 +51,6 @@ export type RouterData = {
|
|
|
52
51
|
amountOut: BN;
|
|
53
52
|
routes: Router[];
|
|
54
53
|
insufficientLiquidity: boolean;
|
|
55
|
-
totalDeepFee?: number;
|
|
56
54
|
error?: RouterError;
|
|
57
55
|
};
|
|
58
56
|
export type AggregatorResponse = {
|
|
@@ -61,17 +59,3 @@ export type AggregatorResponse = {
|
|
|
61
59
|
data: RouterData;
|
|
62
60
|
};
|
|
63
61
|
export declare function getRouterResult(endpoint: string, params: FindRouterParams): Promise<RouterData | null>;
|
|
64
|
-
export type DeepbookV3Config = {
|
|
65
|
-
id: string;
|
|
66
|
-
is_alternative_payment: boolean;
|
|
67
|
-
deep_fee_vault: number;
|
|
68
|
-
whitelist: number;
|
|
69
|
-
whitelist_pools: string[];
|
|
70
|
-
last_updated_time: number;
|
|
71
|
-
};
|
|
72
|
-
export type DeepbookV3ConfigResponse = {
|
|
73
|
-
code: number;
|
|
74
|
-
msg: string;
|
|
75
|
-
data: DeepbookV3Config;
|
|
76
|
-
};
|
|
77
|
-
export declare function getDeepbookV3Config(endpoint: string): Promise<DeepbookV3ConfigResponse | null>;
|
package/dist/src/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { SuiClient } from "@mysten/sui/client";
|
|
|
2
2
|
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
3
3
|
import { Signer } from "@mysten/sui/cryptography";
|
|
4
4
|
import BN from "bn.js";
|
|
5
|
-
import { Dex, Env, FindRouterParams, Router, RouterData
|
|
5
|
+
import { Dex, Env, FindRouterParams, Router, RouterData } from ".";
|
|
6
6
|
import { CoinAsset } from "./types/sui";
|
|
7
7
|
export declare const CETUS = "CETUS";
|
|
8
8
|
export declare const DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -16,7 +16,6 @@ export declare const HAEDAL = "HAEDAL";
|
|
|
16
16
|
export declare const VOLO = "VOLO";
|
|
17
17
|
export declare const AFSUI = "AFSUI";
|
|
18
18
|
export declare const BLUEMOVE = "BLUEMOVE";
|
|
19
|
-
export declare const DEEPBOOKV3 = "DEEPBOOKV3";
|
|
20
19
|
export type BuildRouterSwapParams = {
|
|
21
20
|
routers: Router[];
|
|
22
21
|
byAmountIn: boolean;
|
|
@@ -24,7 +23,6 @@ export type BuildRouterSwapParams = {
|
|
|
24
23
|
slippage: number;
|
|
25
24
|
txb: Transaction;
|
|
26
25
|
partner?: string;
|
|
27
|
-
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
28
26
|
};
|
|
29
27
|
export type BuildFastRouterSwapParams = {
|
|
30
28
|
routers: Router[];
|
|
@@ -34,7 +32,6 @@ export type BuildFastRouterSwapParams = {
|
|
|
34
32
|
partner?: string;
|
|
35
33
|
isMergeTragetCoin?: boolean;
|
|
36
34
|
refreshAllCoins?: boolean;
|
|
37
|
-
payDeepFeeAmount?: number;
|
|
38
35
|
};
|
|
39
36
|
export interface SwapInPoolsParams {
|
|
40
37
|
from: string;
|
|
@@ -56,19 +53,17 @@ export declare class AggregatorClient {
|
|
|
56
53
|
constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
|
|
57
54
|
getAllCoins(): Promise<CoinAsset[]>;
|
|
58
55
|
findRouters(params: FindRouterParams): Promise<RouterData | null>;
|
|
59
|
-
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string
|
|
56
|
+
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string): Promise<TransactionObjectArgument>;
|
|
60
57
|
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
|
|
61
58
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
62
59
|
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
63
60
|
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
64
61
|
publishedAt(): string;
|
|
65
|
-
deepbookv3DeepFeeType(): string;
|
|
66
62
|
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
67
63
|
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
68
64
|
newDex(provider: string, partner?: string): Dex;
|
|
69
65
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<import("@mysten/sui/client").SuiTransactionBlockResponse>;
|
|
70
66
|
devInspectTransactionBlock(txb: Transaction): Promise<import("@mysten/sui/client").DevInspectResults>;
|
|
71
67
|
sendTransaction(txb: Transaction, signer: Signer): Promise<import("@mysten/sui/client").SuiTransactionBlockResponse>;
|
|
72
|
-
getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
|
|
73
68
|
}
|
|
74
69
|
export declare function parseRouterResponse(data: any): RouterData;
|
|
@@ -2,5 +2,5 @@ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions
|
|
|
2
2
|
import { AggregatorClient, Path } from "..";
|
|
3
3
|
export declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
4
4
|
export interface Dex {
|
|
5
|
-
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument
|
|
5
|
+
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
6
6
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export declare const T_USDC = "";
|
|
2
|
-
export declare const T_DEEP = "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
3
|
-
export declare const T_DBUSDC = "0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7::DBUSDC::DBUSDC";
|
|
4
|
-
export declare const T_DBUSDT = "0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7::DBUSDT::DBUSDT";
|
|
5
2
|
export declare const M_USDC = "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN";
|
|
6
3
|
export declare const M_CETUS = "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS";
|
|
7
4
|
export declare const M_NAVI = "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX";
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -33,7 +33,6 @@ export type ExtendedDetails = {
|
|
|
33
33
|
aftermathLpSupplyType?: string
|
|
34
34
|
turbosFeeType?: string
|
|
35
35
|
afterSqrtPrice?: string
|
|
36
|
-
deepbookv3DeepFee?: number
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
export type Path = {
|
|
@@ -66,7 +65,6 @@ export type RouterData = {
|
|
|
66
65
|
amountOut: BN
|
|
67
66
|
routes: Router[]
|
|
68
67
|
insufficientLiquidity: boolean
|
|
69
|
-
totalDeepFee?: number
|
|
70
68
|
error?: RouterError
|
|
71
69
|
}
|
|
72
70
|
|
|
@@ -142,7 +140,7 @@ async function getRouter(endpoint: string, params: FindRouterParams) {
|
|
|
142
140
|
const fromCoin = completionCoin(from)
|
|
143
141
|
const targetCoin = completionCoin(target)
|
|
144
142
|
|
|
145
|
-
let url = `${endpoint}
|
|
143
|
+
let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`
|
|
146
144
|
|
|
147
145
|
if (depth) {
|
|
148
146
|
url += `&depth=${depth}`
|
|
@@ -193,8 +191,11 @@ async function postRouterWithLiquidityChanges(
|
|
|
193
191
|
|
|
194
192
|
const fromCoin = completionCoin(from)
|
|
195
193
|
const targetCoin = completionCoin(target)
|
|
196
|
-
|
|
194
|
+
|
|
195
|
+
const url = `${endpoint}`
|
|
196
|
+
|
|
197
197
|
const providersStr = providers?.join(",")
|
|
198
|
+
|
|
198
199
|
const requestData = {
|
|
199
200
|
from: fromCoin,
|
|
200
201
|
target: targetCoin,
|
|
@@ -213,6 +214,8 @@ async function postRouterWithLiquidityChanges(
|
|
|
213
214
|
})),
|
|
214
215
|
}
|
|
215
216
|
|
|
217
|
+
console.log("requestData", JSON.stringify(requestData, null, 2))
|
|
218
|
+
|
|
216
219
|
try {
|
|
217
220
|
const response = await fetch(url, {
|
|
218
221
|
method: "POST",
|
|
@@ -228,32 +231,3 @@ async function postRouterWithLiquidityChanges(
|
|
|
228
231
|
return null
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
|
-
|
|
232
|
-
export type DeepbookV3Config = {
|
|
233
|
-
id: string
|
|
234
|
-
is_alternative_payment: boolean
|
|
235
|
-
deep_fee_vault: number
|
|
236
|
-
whitelist: number
|
|
237
|
-
whitelist_pools: string[]
|
|
238
|
-
// unix timestamp in seconds
|
|
239
|
-
last_updated_time: number
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export type DeepbookV3ConfigResponse = {
|
|
243
|
-
code: number
|
|
244
|
-
msg: string
|
|
245
|
-
data: DeepbookV3Config
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export async function getDeepbookV3Config(
|
|
249
|
-
endpoint: string
|
|
250
|
-
): Promise<DeepbookV3ConfigResponse | null> {
|
|
251
|
-
const url = `${endpoint}/deepbookv3_config`
|
|
252
|
-
try {
|
|
253
|
-
const response = await fetch(url)
|
|
254
|
-
return response.json() as Promise<DeepbookV3ConfigResponse>
|
|
255
|
-
} catch (error) {
|
|
256
|
-
console.error("Error:", error)
|
|
257
|
-
return null
|
|
258
|
-
}
|
|
259
|
-
}
|