@cetusprotocol/aggregator-sdk 0.3.18 → 0.3.20
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +29 -15
- package/dist/index.mjs +29 -16
- package/dist/src/client.d.ts +1 -0
- package/example/package.json +17 -0
- package/example/swap.ts +21 -0
- package/example/tsconfig.json +12 -0
- package/package.json +1 -1
- package/src/api.ts +1 -1
- package/src/client.ts +3 -0
- package/src/utils/msafe.ts +27 -18
package/dist/index.d.mts
CHANGED
|
@@ -78,6 +78,7 @@ declare const SUILEND = "SUILEND";
|
|
|
78
78
|
declare const BLUEFIN = "BLUEFIN";
|
|
79
79
|
declare const HAEDALPMM = "HAEDALPMM";
|
|
80
80
|
declare const ALPHAFI = "ALPHAFI";
|
|
81
|
+
declare const SPRINGSUI = "SPRINGSUI";
|
|
81
82
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
82
83
|
type BuildRouterSwapParams = {
|
|
83
84
|
routers: Router[];
|
|
@@ -292,4 +293,4 @@ declare enum Env {
|
|
|
292
293
|
Testnet = 1
|
|
293
294
|
}
|
|
294
295
|
|
|
295
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
|
296
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ declare const SUILEND = "SUILEND";
|
|
|
78
78
|
declare const BLUEFIN = "BLUEFIN";
|
|
79
79
|
declare const HAEDALPMM = "HAEDALPMM";
|
|
80
80
|
declare const ALPHAFI = "ALPHAFI";
|
|
81
|
+
declare const SPRINGSUI = "SPRINGSUI";
|
|
81
82
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
82
83
|
type BuildRouterSwapParams = {
|
|
83
84
|
routers: Router[];
|
|
@@ -292,4 +293,4 @@ declare enum Env {
|
|
|
292
293
|
Testnet = 1
|
|
293
294
|
}
|
|
294
295
|
|
|
295
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
|
296
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/index.js
CHANGED
|
@@ -6270,6 +6270,7 @@ var SUILEND = "SUILEND";
|
|
|
6270
6270
|
var BLUEFIN = "BLUEFIN";
|
|
6271
6271
|
var HAEDALPMM = "HAEDALPMM";
|
|
6272
6272
|
var ALPHAFI = "ALPHAFI";
|
|
6273
|
+
var SPRINGSUI = "SPRINGSUI";
|
|
6273
6274
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6274
6275
|
function isBuilderRouterSwapParams(params) {
|
|
6275
6276
|
return Array.isArray(params.routers);
|
|
@@ -6643,6 +6644,8 @@ var AggregatorClient19 = class {
|
|
|
6643
6644
|
return new Scallop(this.env);
|
|
6644
6645
|
case SUILEND:
|
|
6645
6646
|
return new Suilend(this.env);
|
|
6647
|
+
case SPRINGSUI:
|
|
6648
|
+
return new Suilend(this.env);
|
|
6646
6649
|
case BLUEFIN:
|
|
6647
6650
|
return new Bluefin(this.env);
|
|
6648
6651
|
case HAEDALPMM:
|
|
@@ -6783,24 +6786,34 @@ function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt, package
|
|
|
6783
6786
|
// src/utils/msafe.ts
|
|
6784
6787
|
var import_bn6 = __toESM(require_bn());
|
|
6785
6788
|
var dealWithFastRouterSwapParamsForMsafe = (data) => {
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6789
|
+
var _a, _b, _c;
|
|
6790
|
+
const result = __spreadProps(__spreadValues({}, data), {
|
|
6791
|
+
amountIn: (_a = data == null ? void 0 : data.amountIn) == null ? void 0 : _a.toString(),
|
|
6792
|
+
amountOut: (_b = data == null ? void 0 : data.amountIn) == null ? void 0 : _b.toString(),
|
|
6793
|
+
routes: (_c = data == null ? void 0 : data.routes) == null ? void 0 : _c.map((item) => {
|
|
6794
|
+
var _a2, _b2, _c2;
|
|
6795
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
6796
|
+
amountIn: (_a2 = item == null ? void 0 : item.amountIn) == null ? void 0 : _a2.toString(),
|
|
6797
|
+
amountOut: (_b2 = item == null ? void 0 : item.amountOut) == null ? void 0 : _b2.toString(),
|
|
6798
|
+
initialPrice: (_c2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _c2.toString()
|
|
6799
|
+
});
|
|
6800
|
+
})
|
|
6793
6801
|
});
|
|
6794
6802
|
return result;
|
|
6795
6803
|
};
|
|
6796
6804
|
var restituteMsafeFastRouterSwapParams = (data) => {
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6805
|
+
var _a;
|
|
6806
|
+
const result = __spreadProps(__spreadValues({}, data), {
|
|
6807
|
+
amountIn: new import_bn6.default(data == null ? void 0 : data.amountIn),
|
|
6808
|
+
amountOut: new import_bn6.default(data == null ? void 0 : data.amountIn),
|
|
6809
|
+
routes: (_a = data == null ? void 0 : data.routes) == null ? void 0 : _a.map((item) => {
|
|
6810
|
+
var _a2;
|
|
6811
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
6812
|
+
amountIn: new import_bn6.default(item == null ? void 0 : item.amountIn),
|
|
6813
|
+
amountOut: new import_bn6.default(item == null ? void 0 : item.amountOut),
|
|
6814
|
+
initialPrice: new decimal_default((_a2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _a2.toString())
|
|
6815
|
+
});
|
|
6816
|
+
})
|
|
6804
6817
|
});
|
|
6805
6818
|
return result;
|
|
6806
6819
|
};
|
|
@@ -6910,7 +6923,7 @@ function getRouter(endpoint, params) {
|
|
|
6910
6923
|
url += `&providers=${providers.join(",")}`;
|
|
6911
6924
|
}
|
|
6912
6925
|
}
|
|
6913
|
-
url += "&v=
|
|
6926
|
+
url += "&v=1000320";
|
|
6914
6927
|
const response = yield fetch(url);
|
|
6915
6928
|
return response;
|
|
6916
6929
|
} catch (error) {
|
|
@@ -7022,6 +7035,7 @@ exports.KRIYA = KRIYA;
|
|
|
7022
7035
|
exports.KRIYAV3 = KRIYAV3;
|
|
7023
7036
|
exports.ONE = ONE;
|
|
7024
7037
|
exports.SCALLOP = SCALLOP;
|
|
7038
|
+
exports.SPRINGSUI = SPRINGSUI;
|
|
7025
7039
|
exports.SUILEND = SUILEND;
|
|
7026
7040
|
exports.TEN_POW_NINE = TEN_POW_NINE;
|
|
7027
7041
|
exports.TURBOS = TURBOS;
|
package/dist/index.mjs
CHANGED
|
@@ -6268,6 +6268,7 @@ var SUILEND = "SUILEND";
|
|
|
6268
6268
|
var BLUEFIN = "BLUEFIN";
|
|
6269
6269
|
var HAEDALPMM = "HAEDALPMM";
|
|
6270
6270
|
var ALPHAFI = "ALPHAFI";
|
|
6271
|
+
var SPRINGSUI = "SPRINGSUI";
|
|
6271
6272
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6272
6273
|
function isBuilderRouterSwapParams(params) {
|
|
6273
6274
|
return Array.isArray(params.routers);
|
|
@@ -6641,6 +6642,8 @@ var AggregatorClient19 = class {
|
|
|
6641
6642
|
return new Scallop(this.env);
|
|
6642
6643
|
case SUILEND:
|
|
6643
6644
|
return new Suilend(this.env);
|
|
6645
|
+
case SPRINGSUI:
|
|
6646
|
+
return new Suilend(this.env);
|
|
6644
6647
|
case BLUEFIN:
|
|
6645
6648
|
return new Bluefin(this.env);
|
|
6646
6649
|
case HAEDALPMM:
|
|
@@ -6781,24 +6784,34 @@ function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt, package
|
|
|
6781
6784
|
// src/utils/msafe.ts
|
|
6782
6785
|
var import_bn6 = __toESM(require_bn());
|
|
6783
6786
|
var dealWithFastRouterSwapParamsForMsafe = (data) => {
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6787
|
+
var _a, _b, _c;
|
|
6788
|
+
const result = __spreadProps(__spreadValues({}, data), {
|
|
6789
|
+
amountIn: (_a = data == null ? void 0 : data.amountIn) == null ? void 0 : _a.toString(),
|
|
6790
|
+
amountOut: (_b = data == null ? void 0 : data.amountIn) == null ? void 0 : _b.toString(),
|
|
6791
|
+
routes: (_c = data == null ? void 0 : data.routes) == null ? void 0 : _c.map((item) => {
|
|
6792
|
+
var _a2, _b2, _c2;
|
|
6793
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
6794
|
+
amountIn: (_a2 = item == null ? void 0 : item.amountIn) == null ? void 0 : _a2.toString(),
|
|
6795
|
+
amountOut: (_b2 = item == null ? void 0 : item.amountOut) == null ? void 0 : _b2.toString(),
|
|
6796
|
+
initialPrice: (_c2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _c2.toString()
|
|
6797
|
+
});
|
|
6798
|
+
})
|
|
6791
6799
|
});
|
|
6792
6800
|
return result;
|
|
6793
6801
|
};
|
|
6794
6802
|
var restituteMsafeFastRouterSwapParams = (data) => {
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6803
|
+
var _a;
|
|
6804
|
+
const result = __spreadProps(__spreadValues({}, data), {
|
|
6805
|
+
amountIn: new import_bn6.default(data == null ? void 0 : data.amountIn),
|
|
6806
|
+
amountOut: new import_bn6.default(data == null ? void 0 : data.amountIn),
|
|
6807
|
+
routes: (_a = data == null ? void 0 : data.routes) == null ? void 0 : _a.map((item) => {
|
|
6808
|
+
var _a2;
|
|
6809
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
6810
|
+
amountIn: new import_bn6.default(item == null ? void 0 : item.amountIn),
|
|
6811
|
+
amountOut: new import_bn6.default(item == null ? void 0 : item.amountOut),
|
|
6812
|
+
initialPrice: new decimal_default((_a2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _a2.toString())
|
|
6813
|
+
});
|
|
6814
|
+
})
|
|
6802
6815
|
});
|
|
6803
6816
|
return result;
|
|
6804
6817
|
};
|
|
@@ -6908,7 +6921,7 @@ function getRouter(endpoint, params) {
|
|
|
6908
6921
|
url += `&providers=${providers.join(",")}`;
|
|
6909
6922
|
}
|
|
6910
6923
|
}
|
|
6911
|
-
url += "&v=
|
|
6924
|
+
url += "&v=1000320";
|
|
6912
6925
|
const response = yield fetch(url);
|
|
6913
6926
|
return response;
|
|
6914
6927
|
} catch (error) {
|
|
@@ -6998,4 +7011,4 @@ decimal.js/decimal.mjs:
|
|
|
6998
7011
|
*)
|
|
6999
7012
|
*/
|
|
7000
7013
|
|
|
7001
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient19 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, SCALLOP, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
|
7014
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient19 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, SCALLOP, SPRINGSUI, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/src/client.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare const SUILEND = "SUILEND";
|
|
|
22
22
|
export declare const BLUEFIN = "BLUEFIN";
|
|
23
23
|
export declare const HAEDALPMM = "HAEDALPMM";
|
|
24
24
|
export declare const ALPHAFI = "ALPHAFI";
|
|
25
|
+
export declare const SPRINGSUI = "SPRINGSUI";
|
|
25
26
|
export declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
26
27
|
export type BuildRouterSwapParams = {
|
|
27
28
|
routers: Router[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aggregator-example",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Cetus Aggregator SDK usage example",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"swap": "ts-node swap.ts"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@cetusprotocol/aggregator-sdk": "^0.3.18",
|
|
11
|
+
"@mysten/sui.js": "^0.49.1"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"typescript": "^5.0.0",
|
|
15
|
+
"ts-node": "^10.9.1"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/example/swap.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AggregatorClient } from "@cetusprotocol/aggregator-sdk"
|
|
2
|
+
import BN from "bn.js"
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
// default to mainnet
|
|
6
|
+
const client = new AggregatorClient()
|
|
7
|
+
|
|
8
|
+
const from = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"
|
|
9
|
+
const target = "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS"
|
|
10
|
+
|
|
11
|
+
const routers = await client.findRouters({
|
|
12
|
+
from,
|
|
13
|
+
target,
|
|
14
|
+
amount: new BN(1000000000),
|
|
15
|
+
byAmountIn: true,
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
console.log(routers)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main()
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
package/src/client.ts
CHANGED
|
@@ -63,6 +63,7 @@ export const SUILEND = "SUILEND"
|
|
|
63
63
|
export const BLUEFIN = "BLUEFIN"
|
|
64
64
|
export const HAEDALPMM = "HAEDALPMM"
|
|
65
65
|
export const ALPHAFI = "ALPHAFI"
|
|
66
|
+
export const SPRINGSUI = "SPRINGSUI"
|
|
66
67
|
export const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2"
|
|
67
68
|
|
|
68
69
|
export type BuildRouterSwapParams = {
|
|
@@ -581,6 +582,8 @@ export class AggregatorClient {
|
|
|
581
582
|
return new Scallop(this.env)
|
|
582
583
|
case SUILEND:
|
|
583
584
|
return new Suilend(this.env)
|
|
585
|
+
case SPRINGSUI:
|
|
586
|
+
return new Suilend(this.env)
|
|
584
587
|
case BLUEFIN:
|
|
585
588
|
return new Bluefin(this.env)
|
|
586
589
|
case HAEDALPMM:
|
package/src/utils/msafe.ts
CHANGED
|
@@ -3,29 +3,38 @@ import BN from 'bn.js'
|
|
|
3
3
|
import Decimal from "decimal.js"
|
|
4
4
|
|
|
5
5
|
export const dealWithFastRouterSwapParamsForMsafe = (data: any) => {
|
|
6
|
-
|
|
6
|
+
const result = {
|
|
7
|
+
...data,
|
|
8
|
+
amountIn: data?.amountIn?.toString(),
|
|
9
|
+
amountOut: data?.amountIn?.toString(),
|
|
10
|
+
routes: data?.routes?.map((item:any) => {
|
|
7
11
|
return {
|
|
8
|
-
...
|
|
9
|
-
amountIn:
|
|
10
|
-
amountOut:
|
|
11
|
-
initialPrice:
|
|
12
|
-
path: route.path
|
|
12
|
+
...item,
|
|
13
|
+
amountIn: item?.amountIn?.toString(),
|
|
14
|
+
amountOut: item?.amountOut?.toString(),
|
|
15
|
+
initialPrice: item?.initialPrice?.toString()
|
|
13
16
|
}
|
|
14
17
|
})
|
|
15
|
-
|
|
16
|
-
return result
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
return result
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export const restituteMsafeFastRouterSwapParams = (data: any) => {
|
|
25
|
+
const result = {
|
|
26
|
+
...data,
|
|
27
|
+
amountIn: new BN(data?.amountIn),
|
|
28
|
+
amountOut: new BN(data?.amountIn),
|
|
29
|
+
routes: data?.routes?.map((item:any) => {
|
|
21
30
|
return {
|
|
22
|
-
...
|
|
23
|
-
amountIn: new BN(
|
|
24
|
-
amountOut: new BN(
|
|
25
|
-
initialPrice: new Decimal(
|
|
26
|
-
path: route.path
|
|
31
|
+
...item,
|
|
32
|
+
amountIn: new BN(item?.amountIn),
|
|
33
|
+
amountOut: new BN(item?.amountOut),
|
|
34
|
+
initialPrice: new Decimal(item?.initialPrice?.toString())
|
|
27
35
|
}
|
|
28
36
|
})
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return result
|
|
40
|
+
}
|