@cetusprotocol/aggregator-sdk 0.3.10 → 0.3.12
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/bun.lockb +0 -0
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +42 -8
- package/dist/index.mjs +41 -8
- package/dist/src/api.d.ts +3 -1
- package/dist/src/client.d.ts +1 -0
- package/dist/src/transaction/bluefin.d.ts +7 -0
- package/package.json +2 -1
- package/src/api.ts +4 -2
- package/src/client.ts +11 -3
- package/src/transaction/bluefin.ts +43 -0
- package/tests/router.test.ts +3 -8
package/bun.lockb
CHANGED
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -75,6 +75,7 @@ declare const BLUEMOVE = "BLUEMOVE";
|
|
|
75
75
|
declare const DEEPBOOKV3 = "DEEPBOOKV3";
|
|
76
76
|
declare const SCALLOP = "SCALLOP";
|
|
77
77
|
declare const SUILEND = "SUILEND";
|
|
78
|
+
declare const BLUEFIN = "BLUEFIN";
|
|
78
79
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
79
80
|
type BuildRouterSwapParams = {
|
|
80
81
|
routers: Router[];
|
|
@@ -205,6 +206,8 @@ type ExtendedDetails = {
|
|
|
205
206
|
afterSqrtPrice?: string;
|
|
206
207
|
deepbookv3DeepFee?: number;
|
|
207
208
|
scallopScoinTreasury?: string;
|
|
209
|
+
haedalPmmBasePriceSeed?: string;
|
|
210
|
+
haedalPmmQuotePriceSeed?: string;
|
|
208
211
|
};
|
|
209
212
|
type Path = {
|
|
210
213
|
id: string;
|
|
@@ -215,8 +218,8 @@ type Path = {
|
|
|
215
218
|
feeRate: number;
|
|
216
219
|
amountIn: number;
|
|
217
220
|
amountOut: number;
|
|
218
|
-
extendedDetails?: ExtendedDetails;
|
|
219
221
|
version?: string;
|
|
222
|
+
extendedDetails?: ExtendedDetails;
|
|
220
223
|
};
|
|
221
224
|
type Router = {
|
|
222
225
|
path: Path[];
|
|
@@ -266,4 +269,4 @@ declare enum Env {
|
|
|
266
269
|
Testnet = 1
|
|
267
270
|
}
|
|
268
271
|
|
|
269
|
-
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, 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, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
|
272
|
+
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, 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, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ declare const BLUEMOVE = "BLUEMOVE";
|
|
|
75
75
|
declare const DEEPBOOKV3 = "DEEPBOOKV3";
|
|
76
76
|
declare const SCALLOP = "SCALLOP";
|
|
77
77
|
declare const SUILEND = "SUILEND";
|
|
78
|
+
declare const BLUEFIN = "BLUEFIN";
|
|
78
79
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
79
80
|
type BuildRouterSwapParams = {
|
|
80
81
|
routers: Router[];
|
|
@@ -205,6 +206,8 @@ type ExtendedDetails = {
|
|
|
205
206
|
afterSqrtPrice?: string;
|
|
206
207
|
deepbookv3DeepFee?: number;
|
|
207
208
|
scallopScoinTreasury?: string;
|
|
209
|
+
haedalPmmBasePriceSeed?: string;
|
|
210
|
+
haedalPmmQuotePriceSeed?: string;
|
|
208
211
|
};
|
|
209
212
|
type Path = {
|
|
210
213
|
id: string;
|
|
@@ -215,8 +218,8 @@ type Path = {
|
|
|
215
218
|
feeRate: number;
|
|
216
219
|
amountIn: number;
|
|
217
220
|
amountOut: number;
|
|
218
|
-
extendedDetails?: ExtendedDetails;
|
|
219
221
|
version?: string;
|
|
222
|
+
extendedDetails?: ExtendedDetails;
|
|
220
223
|
};
|
|
221
224
|
type Router = {
|
|
222
225
|
path: Path[];
|
|
@@ -266,4 +269,4 @@ declare enum Env {
|
|
|
266
269
|
Testnet = 1
|
|
267
270
|
}
|
|
268
271
|
|
|
269
|
-
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, 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, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
|
272
|
+
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, 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, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/index.js
CHANGED
|
@@ -6111,6 +6111,34 @@ var Suilend = class {
|
|
|
6111
6111
|
}
|
|
6112
6112
|
};
|
|
6113
6113
|
|
|
6114
|
+
// src/transaction/bluefin.ts
|
|
6115
|
+
var Bluefin = class {
|
|
6116
|
+
constructor(env) {
|
|
6117
|
+
if (env !== 0 /* Mainnet */) {
|
|
6118
|
+
throw new Error("Bluefin only supported on mainnet");
|
|
6119
|
+
}
|
|
6120
|
+
this.globalConfig = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
|
|
6121
|
+
}
|
|
6122
|
+
swap(client, txb, path, inputCoin) {
|
|
6123
|
+
return __async(this, null, function* () {
|
|
6124
|
+
const { direction, from, target } = path;
|
|
6125
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6126
|
+
const args = [
|
|
6127
|
+
txb.object(this.globalConfig),
|
|
6128
|
+
txb.object(path.id),
|
|
6129
|
+
inputCoin,
|
|
6130
|
+
txb.object(CLOCK_ADDRESS)
|
|
6131
|
+
];
|
|
6132
|
+
const res = txb.moveCall({
|
|
6133
|
+
target: `${client.publishedAtV2()}::bluefin::${func}`,
|
|
6134
|
+
typeArguments: [coinAType, coinBType],
|
|
6135
|
+
arguments: args
|
|
6136
|
+
});
|
|
6137
|
+
return res;
|
|
6138
|
+
});
|
|
6139
|
+
}
|
|
6140
|
+
};
|
|
6141
|
+
|
|
6114
6142
|
// src/client.ts
|
|
6115
6143
|
var CETUS = "CETUS";
|
|
6116
6144
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6127,8 +6155,9 @@ var BLUEMOVE = "BLUEMOVE";
|
|
|
6127
6155
|
var DEEPBOOKV3 = "DEEPBOOKV3";
|
|
6128
6156
|
var SCALLOP = "SCALLOP";
|
|
6129
6157
|
var SUILEND = "SUILEND";
|
|
6158
|
+
var BLUEFIN = "BLUEFIN";
|
|
6130
6159
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6131
|
-
var
|
|
6160
|
+
var AggregatorClient9 = class {
|
|
6132
6161
|
constructor(endpoint, signer, client$1, env) {
|
|
6133
6162
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6134
6163
|
this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
|
|
@@ -6402,12 +6431,12 @@ var AggregatorClient8 = class {
|
|
|
6402
6431
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6403
6432
|
}
|
|
6404
6433
|
}
|
|
6405
|
-
// Include deepbookv3, scallop
|
|
6434
|
+
// Include deepbookv3, scallop, bluefin
|
|
6406
6435
|
publishedAtV2() {
|
|
6407
6436
|
if (this.env === 0 /* Mainnet */) {
|
|
6408
|
-
return "
|
|
6437
|
+
return "0x81ade554cb24a7564ca43a4bfb7381b08d9e5c5f375162c95215b696ab903502";
|
|
6409
6438
|
} else {
|
|
6410
|
-
return "
|
|
6439
|
+
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6411
6440
|
}
|
|
6412
6441
|
}
|
|
6413
6442
|
deepbookv3DeepFeeType() {
|
|
@@ -6474,6 +6503,8 @@ var AggregatorClient8 = class {
|
|
|
6474
6503
|
return new Scallop(this.env);
|
|
6475
6504
|
case SUILEND:
|
|
6476
6505
|
return new Suilend(this.env);
|
|
6506
|
+
case BLUEFIN:
|
|
6507
|
+
return new Bluefin(this.env);
|
|
6477
6508
|
default:
|
|
6478
6509
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6479
6510
|
}
|
|
@@ -6537,7 +6568,7 @@ function parseRouterResponse(data) {
|
|
|
6537
6568
|
routes: data.routes.map((route) => {
|
|
6538
6569
|
return {
|
|
6539
6570
|
path: route.path.map((path) => {
|
|
6540
|
-
var _a, _b, _c, _d, _e;
|
|
6571
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6541
6572
|
let version;
|
|
6542
6573
|
if (path.provider === AFTERMATH) {
|
|
6543
6574
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
@@ -6549,7 +6580,9 @@ function parseRouterResponse(data) {
|
|
|
6549
6580
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
6550
6581
|
afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price,
|
|
6551
6582
|
deepbookv3DeepFee: (_d = path.extended_details) == null ? void 0 : _d.deepbookv3_deep_fee,
|
|
6552
|
-
scallopScoinTreasury: (_e = path.extended_details) == null ? void 0 : _e.scallop_scoin_treasury
|
|
6583
|
+
scallopScoinTreasury: (_e = path.extended_details) == null ? void 0 : _e.scallop_scoin_treasury,
|
|
6584
|
+
haedalPmmBasePriceSeed: (_f = path.extended_details) == null ? void 0 : _f.haedal_pmm_base_price_seed,
|
|
6585
|
+
haedalPmmQuotePriceSeed: (_g = path.extended_details) == null ? void 0 : _g.haedal_pmm_quote_price_seed
|
|
6553
6586
|
};
|
|
6554
6587
|
}
|
|
6555
6588
|
return {
|
|
@@ -6691,7 +6724,7 @@ function getRouter(endpoint, params) {
|
|
|
6691
6724
|
url += `&providers=${providers.join(",")}`;
|
|
6692
6725
|
}
|
|
6693
6726
|
}
|
|
6694
|
-
url += "&v=
|
|
6727
|
+
url += "&v=1000312";
|
|
6695
6728
|
const response = yield fetch(url);
|
|
6696
6729
|
return response;
|
|
6697
6730
|
} catch (error) {
|
|
@@ -6783,7 +6816,8 @@ decimal.js/decimal.mjs:
|
|
|
6783
6816
|
|
|
6784
6817
|
exports.AFSUI = AFSUI;
|
|
6785
6818
|
exports.AFTERMATH = AFTERMATH;
|
|
6786
|
-
exports.AggregatorClient =
|
|
6819
|
+
exports.AggregatorClient = AggregatorClient9;
|
|
6820
|
+
exports.BLUEFIN = BLUEFIN;
|
|
6787
6821
|
exports.BLUEMOVE = BLUEMOVE;
|
|
6788
6822
|
exports.CETUS = CETUS;
|
|
6789
6823
|
exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
|
package/dist/index.mjs
CHANGED
|
@@ -6109,6 +6109,34 @@ var Suilend = class {
|
|
|
6109
6109
|
}
|
|
6110
6110
|
};
|
|
6111
6111
|
|
|
6112
|
+
// src/transaction/bluefin.ts
|
|
6113
|
+
var Bluefin = class {
|
|
6114
|
+
constructor(env) {
|
|
6115
|
+
if (env !== 0 /* Mainnet */) {
|
|
6116
|
+
throw new Error("Bluefin only supported on mainnet");
|
|
6117
|
+
}
|
|
6118
|
+
this.globalConfig = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
|
|
6119
|
+
}
|
|
6120
|
+
swap(client, txb, path, inputCoin) {
|
|
6121
|
+
return __async(this, null, function* () {
|
|
6122
|
+
const { direction, from, target } = path;
|
|
6123
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6124
|
+
const args = [
|
|
6125
|
+
txb.object(this.globalConfig),
|
|
6126
|
+
txb.object(path.id),
|
|
6127
|
+
inputCoin,
|
|
6128
|
+
txb.object(CLOCK_ADDRESS)
|
|
6129
|
+
];
|
|
6130
|
+
const res = txb.moveCall({
|
|
6131
|
+
target: `${client.publishedAtV2()}::bluefin::${func}`,
|
|
6132
|
+
typeArguments: [coinAType, coinBType],
|
|
6133
|
+
arguments: args
|
|
6134
|
+
});
|
|
6135
|
+
return res;
|
|
6136
|
+
});
|
|
6137
|
+
}
|
|
6138
|
+
};
|
|
6139
|
+
|
|
6112
6140
|
// src/client.ts
|
|
6113
6141
|
var CETUS = "CETUS";
|
|
6114
6142
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6125,8 +6153,9 @@ var BLUEMOVE = "BLUEMOVE";
|
|
|
6125
6153
|
var DEEPBOOKV3 = "DEEPBOOKV3";
|
|
6126
6154
|
var SCALLOP = "SCALLOP";
|
|
6127
6155
|
var SUILEND = "SUILEND";
|
|
6156
|
+
var BLUEFIN = "BLUEFIN";
|
|
6128
6157
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6129
|
-
var
|
|
6158
|
+
var AggregatorClient9 = class {
|
|
6130
6159
|
constructor(endpoint, signer, client, env) {
|
|
6131
6160
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6132
6161
|
this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
|
|
@@ -6400,12 +6429,12 @@ var AggregatorClient8 = class {
|
|
|
6400
6429
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6401
6430
|
}
|
|
6402
6431
|
}
|
|
6403
|
-
// Include deepbookv3, scallop
|
|
6432
|
+
// Include deepbookv3, scallop, bluefin
|
|
6404
6433
|
publishedAtV2() {
|
|
6405
6434
|
if (this.env === 0 /* Mainnet */) {
|
|
6406
|
-
return "
|
|
6435
|
+
return "0x81ade554cb24a7564ca43a4bfb7381b08d9e5c5f375162c95215b696ab903502";
|
|
6407
6436
|
} else {
|
|
6408
|
-
return "
|
|
6437
|
+
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6409
6438
|
}
|
|
6410
6439
|
}
|
|
6411
6440
|
deepbookv3DeepFeeType() {
|
|
@@ -6472,6 +6501,8 @@ var AggregatorClient8 = class {
|
|
|
6472
6501
|
return new Scallop(this.env);
|
|
6473
6502
|
case SUILEND:
|
|
6474
6503
|
return new Suilend(this.env);
|
|
6504
|
+
case BLUEFIN:
|
|
6505
|
+
return new Bluefin(this.env);
|
|
6475
6506
|
default:
|
|
6476
6507
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6477
6508
|
}
|
|
@@ -6535,7 +6566,7 @@ function parseRouterResponse(data) {
|
|
|
6535
6566
|
routes: data.routes.map((route) => {
|
|
6536
6567
|
return {
|
|
6537
6568
|
path: route.path.map((path) => {
|
|
6538
|
-
var _a, _b, _c, _d, _e;
|
|
6569
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6539
6570
|
let version;
|
|
6540
6571
|
if (path.provider === AFTERMATH) {
|
|
6541
6572
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
@@ -6547,7 +6578,9 @@ function parseRouterResponse(data) {
|
|
|
6547
6578
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
6548
6579
|
afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price,
|
|
6549
6580
|
deepbookv3DeepFee: (_d = path.extended_details) == null ? void 0 : _d.deepbookv3_deep_fee,
|
|
6550
|
-
scallopScoinTreasury: (_e = path.extended_details) == null ? void 0 : _e.scallop_scoin_treasury
|
|
6581
|
+
scallopScoinTreasury: (_e = path.extended_details) == null ? void 0 : _e.scallop_scoin_treasury,
|
|
6582
|
+
haedalPmmBasePriceSeed: (_f = path.extended_details) == null ? void 0 : _f.haedal_pmm_base_price_seed,
|
|
6583
|
+
haedalPmmQuotePriceSeed: (_g = path.extended_details) == null ? void 0 : _g.haedal_pmm_quote_price_seed
|
|
6551
6584
|
};
|
|
6552
6585
|
}
|
|
6553
6586
|
return {
|
|
@@ -6689,7 +6722,7 @@ function getRouter(endpoint, params) {
|
|
|
6689
6722
|
url += `&providers=${providers.join(",")}`;
|
|
6690
6723
|
}
|
|
6691
6724
|
}
|
|
6692
|
-
url += "&v=
|
|
6725
|
+
url += "&v=1000312";
|
|
6693
6726
|
const response = yield fetch(url);
|
|
6694
6727
|
return response;
|
|
6695
6728
|
} catch (error) {
|
|
@@ -6779,4 +6812,4 @@ decimal.js/decimal.mjs:
|
|
|
6779
6812
|
*)
|
|
6780
6813
|
*/
|
|
6781
6814
|
|
|
6782
|
-
export { AFSUI, AFTERMATH,
|
|
6815
|
+
export { AFSUI, AFTERMATH, AggregatorClient9 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, 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, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/src/api.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export type ExtendedDetails = {
|
|
|
25
25
|
afterSqrtPrice?: string;
|
|
26
26
|
deepbookv3DeepFee?: number;
|
|
27
27
|
scallopScoinTreasury?: string;
|
|
28
|
+
haedalPmmBasePriceSeed?: string;
|
|
29
|
+
haedalPmmQuotePriceSeed?: string;
|
|
28
30
|
};
|
|
29
31
|
export type Path = {
|
|
30
32
|
id: string;
|
|
@@ -35,8 +37,8 @@ export type Path = {
|
|
|
35
37
|
feeRate: number;
|
|
36
38
|
amountIn: number;
|
|
37
39
|
amountOut: number;
|
|
38
|
-
extendedDetails?: ExtendedDetails;
|
|
39
40
|
version?: string;
|
|
41
|
+
extendedDetails?: ExtendedDetails;
|
|
40
42
|
};
|
|
41
43
|
export type Router = {
|
|
42
44
|
path: Path[];
|
package/dist/src/client.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare const BLUEMOVE = "BLUEMOVE";
|
|
|
19
19
|
export declare const DEEPBOOKV3 = "DEEPBOOKV3";
|
|
20
20
|
export declare const SCALLOP = "SCALLOP";
|
|
21
21
|
export declare const SUILEND = "SUILEND";
|
|
22
|
+
export declare const BLUEFIN = "BLUEFIN";
|
|
22
23
|
export declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
23
24
|
export type BuildRouterSwapParams = {
|
|
24
25
|
routers: Router[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
|
+
import { AggregatorClient, Dex, Env, Path } from "..";
|
|
3
|
+
export declare class Bluefin implements Dex {
|
|
4
|
+
private globalConfig;
|
|
5
|
+
constructor(env: Env);
|
|
6
|
+
swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cetusprotocol/aggregator-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@babel/preset-typescript": "^7.24.1",
|
|
29
29
|
"@jest/globals": "^29.7.0",
|
|
30
30
|
"@mysten/sui": "^1.6.0",
|
|
31
|
+
"@pythnetwork/pyth-sui-js": "^2.1.0",
|
|
31
32
|
"@types/jest": "^29.5.12",
|
|
32
33
|
"@types/node": "^20.12.12",
|
|
33
34
|
"babel-jest": "^29.7.0",
|
package/src/api.ts
CHANGED
|
@@ -35,6 +35,8 @@ export type ExtendedDetails = {
|
|
|
35
35
|
afterSqrtPrice?: string
|
|
36
36
|
deepbookv3DeepFee?: number
|
|
37
37
|
scallopScoinTreasury?: string
|
|
38
|
+
haedalPmmBasePriceSeed?: string
|
|
39
|
+
haedalPmmQuotePriceSeed?: string
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export type Path = {
|
|
@@ -46,8 +48,8 @@ export type Path = {
|
|
|
46
48
|
feeRate: number
|
|
47
49
|
amountIn: number
|
|
48
50
|
amountOut: number
|
|
49
|
-
extendedDetails?: ExtendedDetails
|
|
50
51
|
version?: string
|
|
52
|
+
extendedDetails?: ExtendedDetails
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
export type Router = {
|
|
@@ -168,7 +170,7 @@ async function getRouter(endpoint: string, params: FindRouterParams) {
|
|
|
168
170
|
}
|
|
169
171
|
|
|
170
172
|
// set newest sdk version
|
|
171
|
-
url += "&v=
|
|
173
|
+
url += "&v=1000312"
|
|
172
174
|
|
|
173
175
|
const response = await fetch(url)
|
|
174
176
|
return response
|
package/src/client.ts
CHANGED
|
@@ -38,6 +38,7 @@ import { buildInputCoin } from "./utils/coin"
|
|
|
38
38
|
import { DeepbookV3 } from "./transaction/deepbook_v3"
|
|
39
39
|
import { Scallop } from "./transaction/scallop"
|
|
40
40
|
import { Suilend } from "./transaction/suilend"
|
|
41
|
+
import { Bluefin } from "./transaction/bluefin"
|
|
41
42
|
|
|
42
43
|
export const CETUS = "CETUS"
|
|
43
44
|
export const DEEPBOOKV2 = "DEEPBOOK"
|
|
@@ -54,6 +55,7 @@ export const BLUEMOVE = "BLUEMOVE"
|
|
|
54
55
|
export const DEEPBOOKV3 = "DEEPBOOKV3"
|
|
55
56
|
export const SCALLOP = "SCALLOP"
|
|
56
57
|
export const SUILEND = "SUILEND"
|
|
58
|
+
export const BLUEFIN = "BLUEFIN"
|
|
57
59
|
export const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2"
|
|
58
60
|
|
|
59
61
|
export type BuildRouterSwapParams = {
|
|
@@ -408,14 +410,16 @@ export class AggregatorClient {
|
|
|
408
410
|
}
|
|
409
411
|
}
|
|
410
412
|
|
|
411
|
-
// Include deepbookv3, scallop
|
|
413
|
+
// Include deepbookv3, scallop, bluefin
|
|
412
414
|
publishedAtV2(): string {
|
|
413
415
|
if (this.env === Env.Mainnet) {
|
|
414
416
|
// return "0x43811be4677f5a5de7bf2dac740c10abddfaa524aee6b18e910eeadda8a2f6ae" // version 1, deepbookv3
|
|
415
417
|
// return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a" // version 3, deepbookv3 & scallop
|
|
416
|
-
return "0x16d9418726c26d8cb4ce8c9dd75917fa9b1c7bf47d38d7a1a22603135f0f2a56" // version 4 add suilend
|
|
418
|
+
// return "0x16d9418726c26d8cb4ce8c9dd75917fa9b1c7bf47d38d7a1a22603135f0f2a56" // version 4, add suilend
|
|
419
|
+
// return "0x3b6d71bdeb8ce5b06febfd3cfc29ecd60d50da729477c8b8038ecdae34541b91" // version 5, add bluefin
|
|
420
|
+
return "0x81ade554cb24a7564ca43a4bfb7381b08d9e5c5f375162c95215b696ab903502" // version 6, force upgrade scallop
|
|
417
421
|
} else {
|
|
418
|
-
return "
|
|
422
|
+
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78"
|
|
419
423
|
}
|
|
420
424
|
}
|
|
421
425
|
|
|
@@ -496,6 +500,8 @@ export class AggregatorClient {
|
|
|
496
500
|
return new Scallop(this.env)
|
|
497
501
|
case SUILEND:
|
|
498
502
|
return new Suilend(this.env)
|
|
503
|
+
case BLUEFIN:
|
|
504
|
+
return new Bluefin(this.env)
|
|
499
505
|
default:
|
|
500
506
|
throw new Error(`Unsupported dex ${provider}`)
|
|
501
507
|
}
|
|
@@ -580,6 +586,8 @@ export function parseRouterResponse(data: any): RouterData {
|
|
|
580
586
|
deepbookv3DeepFee: path.extended_details?.deepbookv3_deep_fee,
|
|
581
587
|
scallopScoinTreasury:
|
|
582
588
|
path.extended_details?.scallop_scoin_treasury,
|
|
589
|
+
haedalPmmBasePriceSeed: path.extended_details?.haedal_pmm_base_price_seed,
|
|
590
|
+
haedalPmmQuotePriceSeed: path.extended_details?.haedal_pmm_quote_price_seed,
|
|
583
591
|
}
|
|
584
592
|
}
|
|
585
593
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Transaction,
|
|
3
|
+
TransactionArgument,
|
|
4
|
+
TransactionObjectArgument,
|
|
5
|
+
} from "@mysten/sui/transactions"
|
|
6
|
+
import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
|
|
7
|
+
|
|
8
|
+
export class Bluefin implements Dex {
|
|
9
|
+
private globalConfig: string
|
|
10
|
+
|
|
11
|
+
constructor(env: Env) {
|
|
12
|
+
if (env !== Env.Mainnet) {
|
|
13
|
+
throw new Error("Bluefin only supported on mainnet")
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
this.globalConfig =
|
|
17
|
+
"0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async swap(
|
|
21
|
+
client: AggregatorClient,
|
|
22
|
+
txb: Transaction,
|
|
23
|
+
path: Path,
|
|
24
|
+
inputCoin: TransactionObjectArgument
|
|
25
|
+
): Promise<TransactionObjectArgument> {
|
|
26
|
+
const { direction, from, target } = path
|
|
27
|
+
const [func, coinAType, coinBType] = direction
|
|
28
|
+
? ["swap_a2b", from, target]
|
|
29
|
+
: ["swap_b2a", target, from]
|
|
30
|
+
const args = [
|
|
31
|
+
txb.object(this.globalConfig),
|
|
32
|
+
txb.object(path.id),
|
|
33
|
+
inputCoin,
|
|
34
|
+
txb.object(CLOCK_ADDRESS),
|
|
35
|
+
]
|
|
36
|
+
const res = txb.moveCall({
|
|
37
|
+
target: `${client.publishedAtV2()}::bluefin::${func}`,
|
|
38
|
+
typeArguments: [coinAType, coinBType],
|
|
39
|
+
arguments: args,
|
|
40
|
+
}) as TransactionArgument
|
|
41
|
+
return res
|
|
42
|
+
}
|
|
43
|
+
}
|
package/tests/router.test.ts
CHANGED
|
@@ -36,16 +36,11 @@ describe("router module", () => {
|
|
|
36
36
|
const wallet = keypair.getPublicKey().toSuiAddress()
|
|
37
37
|
console.log("wallet: ", wallet)
|
|
38
38
|
|
|
39
|
-
// // const endpoint =
|
|
40
|
-
// // "https://api-sui-cloudfront.cetus.zone/router_v2/find_routes"
|
|
41
39
|
const endpoint = aggregatorURL
|
|
42
40
|
|
|
43
41
|
const suiClient = new SuiClient({
|
|
44
42
|
url: fullNodeURL,
|
|
45
43
|
})
|
|
46
|
-
// const suiClient = new SuiClient({
|
|
47
|
-
// url: "https://fullnode.testnet.sui.io:443",
|
|
48
|
-
// })
|
|
49
44
|
|
|
50
45
|
client = new AggregatorClient(endpoint, wallet, suiClient, Env.Mainnet)
|
|
51
46
|
})
|
|
@@ -112,9 +107,9 @@ describe("router module", () => {
|
|
|
112
107
|
|
|
113
108
|
test("Build router tx", async () => {
|
|
114
109
|
const byAmountIn = true
|
|
115
|
-
const amount = "
|
|
110
|
+
const amount = "3574839"
|
|
111
|
+
const target = "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI"
|
|
116
112
|
const from = "0x2::sui::SUI"
|
|
117
|
-
const target = "0xaf3aae4940a248739ce4964857381fc3f3149a6d05375bfbb2118592907e3bbb::dam::DAM"
|
|
118
113
|
|
|
119
114
|
const res = await client.findRouters({
|
|
120
115
|
from,
|
|
@@ -122,6 +117,7 @@ describe("router module", () => {
|
|
|
122
117
|
amount: new BN(amount),
|
|
123
118
|
byAmountIn,
|
|
124
119
|
depth: 3,
|
|
120
|
+
providers: ["SCALLOP"],
|
|
125
121
|
})
|
|
126
122
|
|
|
127
123
|
if (res != null) {
|
|
@@ -153,7 +149,6 @@ describe("router module", () => {
|
|
|
153
149
|
for (const event of result.events) {
|
|
154
150
|
console.log("event", JSON.stringify(event, null, 2))
|
|
155
151
|
}
|
|
156
|
-
console.log("txb", )
|
|
157
152
|
|
|
158
153
|
// if (result.effects.status.status === "success") {
|
|
159
154
|
// // console.log("Sim exec transaction success")
|