@cetusprotocol/aggregator-sdk 0.3.6 → 0.3.7
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/README.md +127 -0
- package/dist/{index.mjs → index.cjs} +61 -15
- package/dist/index.js +15 -61
- package/package.json +2 -1
- package/src/client.ts +2 -2
- package/src/transaction/scallop.ts +1 -0
- package/src/transaction/swap.ts +2 -2
- /package/dist/{index.d.mts → index.d.cts} +0 -0
package/README.md
CHANGED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<!-- PROJECT LOGO -->
|
|
2
|
+
<br />
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a >
|
|
5
|
+
<img src="https://archive.cetus.zone/assets/image/logo.png" alt="Logo" width="100" height="100">
|
|
6
|
+
</a>
|
|
7
|
+
|
|
8
|
+
<h3 align="center">Cetus Plus Swap Aggregator</h3>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
Integrating Cetus-Aggregator-SDK: A Comprehensive Guide, Please see details in document.
|
|
12
|
+
<br />
|
|
13
|
+
<a href="https://cetus-1.gitbook.io/cetus-developer-docs/developer/cetus-plus-aggregator"><strong>Explore the document »</strong>
|
|
14
|
+
</a>
|
|
15
|
+
</p>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
# Welcome to Cetus Plus Swap Aggregator
|
|
19
|
+
|
|
20
|
+
Cetus plus swap aggregator is a high-speed and easy-to-integrate solution designed to optimize your trading experience on the Sui blockchain. This aggregator integrates multiple mainstream decentralized exchanges (DEX) on the Sui chain, including various types of trading platforms, providing users with the best trading prices and the lowest slippage.
|
|
21
|
+
|
|
22
|
+
Core Advantages:
|
|
23
|
+
|
|
24
|
+
High-Speed Transactions: Thanks to advanced algorithms and efficient architecture, our aggregator can execute transactions at lightning speed, ensuring users get the best opportunities in a rapidly changing market.
|
|
25
|
+
|
|
26
|
+
Easy Integration: The aggregator is designed to be simple and easy to integrate. Whether you are an individual developer or a large project team, you can quickly connect and deploy.
|
|
27
|
+
|
|
28
|
+
Multi-Platform Support: Currently, we have integrated multiple mainstream DEXs on the Sui chain, including cetus, deepbook, kriya, flowx, aftermath, afsui, haedal, volo, turbos etc, allowing users to enjoy a diversified trading experience on a single platform.
|
|
29
|
+
|
|
30
|
+
By using our aggregator, you can trade more efficiently and securely on the Sui blockchain, fully leveraging the various opportunities brought by decentralized finance (DeFi).
|
|
31
|
+
|
|
32
|
+
# Install
|
|
33
|
+
|
|
34
|
+
The SDK is published to npm registry. To use the SDK in your project, you can
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
npm install @cetusprotocol/aggregator-sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
# Usage
|
|
41
|
+
|
|
42
|
+
## 1. Init client with rpc and package config
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const client = new AggregatorClient()
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 2. Get best router swap result from aggregator service
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const amount = new BN(1000000)
|
|
52
|
+
const from = "0x2::sui::SUI"
|
|
53
|
+
const target =
|
|
54
|
+
"0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS"
|
|
55
|
+
|
|
56
|
+
const routerRes = await client.findRouters({
|
|
57
|
+
from,
|
|
58
|
+
target,
|
|
59
|
+
amount,
|
|
60
|
+
byAmountIn: true, // true means fix input amount, false means fix output amount
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 3. Confirm and do fast swap
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const routerTx = new Transaction()
|
|
68
|
+
|
|
69
|
+
if (routerRes != null) {
|
|
70
|
+
await client.fastRouterSwap({
|
|
71
|
+
routers: routerRes.routes,
|
|
72
|
+
byAmountIn,
|
|
73
|
+
txb: routerTx,
|
|
74
|
+
slippage: 0.01,
|
|
75
|
+
isMergeTragetCoin: true,
|
|
76
|
+
refreshAllCoins: true,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
let result = await client.devInspectTransactionBlock(routerTx, keypair)
|
|
80
|
+
|
|
81
|
+
if (result.effects.status.status === "success") {
|
|
82
|
+
console.log("Sim exec transaction success")
|
|
83
|
+
const result = await client.signAndExecuteTransaction(routerTx, keypair)
|
|
84
|
+
}
|
|
85
|
+
console.log("result", result)
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 4. Build PTB and return target coin
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
const routerTx = new Transaction()
|
|
93
|
+
const byAmountIn = true;
|
|
94
|
+
|
|
95
|
+
if (routerRes != null) {
|
|
96
|
+
const targetCoin = await client.routerSwap({
|
|
97
|
+
routers: routerRes.routes,
|
|
98
|
+
byAmountIn,
|
|
99
|
+
txb: routerTx,
|
|
100
|
+
inputCoin,
|
|
101
|
+
slippage: 0.01,
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
// you can use this target coin object argument to build your ptb.
|
|
105
|
+
const client.transferOrDestoryCoin(
|
|
106
|
+
txb,
|
|
107
|
+
targetCoinRes.targetCoin,
|
|
108
|
+
targetCoinType
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
let result = await client.devInspectTransactionBlock(routerTx, keypair)
|
|
112
|
+
|
|
113
|
+
if (result.effects.status.status === "success") {
|
|
114
|
+
console.log("Sim exec transaction success")
|
|
115
|
+
const result = await client.signAndExecuteTransaction(routerTx, keypair)
|
|
116
|
+
}
|
|
117
|
+
console.log("result", result)
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
# More About Cetus
|
|
122
|
+
|
|
123
|
+
Use the following links to learn more about Cetus:
|
|
124
|
+
|
|
125
|
+
Learn more about working with Cetus in the [Cetus Documentation](https://cetus-1.gitbook.io/cetus-docs).
|
|
126
|
+
|
|
127
|
+
Join the Cetus community on [Cetus Discord](https://discord.com/channels/1009749448022315008/1009751382783447072).
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var client = require('@mysten/sui/client');
|
|
4
|
+
var utils = require('@mysten/sui/utils');
|
|
5
|
+
var transactions = require('@mysten/sui/transactions');
|
|
4
6
|
|
|
5
7
|
var __create = Object.create;
|
|
6
8
|
var __defProp = Object.defineProperty;
|
|
@@ -47,7 +49,7 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
|
|
|
47
49
|
// file that has been converted to a CommonJS file using a Babel-
|
|
48
50
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
49
51
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
50
|
-
|
|
52
|
+
__defProp(target, "default", { value: mod2, enumerable: true }) ,
|
|
51
53
|
mod2
|
|
52
54
|
));
|
|
53
55
|
var __async = (__this, __arguments, generator) => {
|
|
@@ -5388,7 +5390,7 @@ function extractStructTagFromType(type) {
|
|
|
5388
5390
|
const isSuiCoin = _type === GAS_TYPE_ARG || _type === GAS_TYPE_ARG_LONG;
|
|
5389
5391
|
const structTag = {
|
|
5390
5392
|
full_address: _type,
|
|
5391
|
-
address: isSuiCoin ? "0x2" : normalizeSuiObjectId(parts[0]),
|
|
5393
|
+
address: isSuiCoin ? "0x2" : utils.normalizeSuiObjectId(parts[0]),
|
|
5392
5394
|
module: parts[1],
|
|
5393
5395
|
name: parts[2],
|
|
5394
5396
|
type_arguments: [],
|
|
@@ -5413,7 +5415,7 @@ function normalizeCoinType(coinType) {
|
|
|
5413
5415
|
}
|
|
5414
5416
|
function fixSuiObjectId(value) {
|
|
5415
5417
|
if (value.toLowerCase().startsWith("0x")) {
|
|
5416
|
-
return normalizeSuiObjectId(value);
|
|
5418
|
+
return utils.normalizeSuiObjectId(value);
|
|
5417
5419
|
}
|
|
5418
5420
|
return value;
|
|
5419
5421
|
}
|
|
@@ -5768,9 +5770,9 @@ function swapInPools(client, params, sender, env) {
|
|
|
5768
5770
|
const { from, target, amount, byAmountIn, pools } = params;
|
|
5769
5771
|
const fromCoin = completionCoin(from);
|
|
5770
5772
|
const targetCoin = completionCoin(target);
|
|
5771
|
-
const tx = new Transaction();
|
|
5773
|
+
const tx = new transactions.Transaction();
|
|
5772
5774
|
const direction = compareCoins(fromCoin, targetCoin);
|
|
5773
|
-
const integratePublishedAt = env === 0 /* Mainnet */ ? "
|
|
5775
|
+
const integratePublishedAt = env === 0 /* Mainnet */ ? "0x3a5aa90ffa33d09100d7b6941ea1c0ffe6ab66e77062ddd26320c1b073aabb10" : "0x19dd42e05fa6c9988a60d30686ee3feb776672b5547e328d6dab16563da65293";
|
|
5774
5776
|
const coinA = direction ? fromCoin : targetCoin;
|
|
5775
5777
|
const coinB = direction ? targetCoin : fromCoin;
|
|
5776
5778
|
const typeArguments = [coinA, coinB];
|
|
@@ -6089,9 +6091,9 @@ var DEEPBOOKV3 = "DEEPBOOKV3";
|
|
|
6089
6091
|
var SCALLOP = "SCALLOP";
|
|
6090
6092
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6091
6093
|
var AggregatorClient8 = class {
|
|
6092
|
-
constructor(endpoint, signer, client, env) {
|
|
6094
|
+
constructor(endpoint, signer, client$1, env) {
|
|
6093
6095
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6094
|
-
this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
|
|
6096
|
+
this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
|
|
6095
6097
|
this.signer = signer || "";
|
|
6096
6098
|
this.env = env || 0 /* Mainnet */;
|
|
6097
6099
|
this.allCoins = /* @__PURE__ */ new Map();
|
|
@@ -6209,7 +6211,7 @@ var AggregatorClient8 = class {
|
|
|
6209
6211
|
if (targetCoins.length > 1) {
|
|
6210
6212
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6211
6213
|
txb.moveCall({
|
|
6212
|
-
target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
|
|
6214
|
+
target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
|
|
6213
6215
|
typeArguments: [routers[0].path[routers[0].path.length - 1].target],
|
|
6214
6216
|
arguments: [targetCoins[0], vec]
|
|
6215
6217
|
});
|
|
@@ -6349,7 +6351,7 @@ var AggregatorClient8 = class {
|
|
|
6349
6351
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6350
6352
|
publishedAt() {
|
|
6351
6353
|
if (this.env === 0 /* Mainnet */) {
|
|
6352
|
-
return "
|
|
6354
|
+
return "0x11451575c775a3e633437b827ecbc1eb51a5964b0302210b28f5b89880be21a2";
|
|
6353
6355
|
} else {
|
|
6354
6356
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6355
6357
|
}
|
|
@@ -6359,7 +6361,7 @@ var AggregatorClient8 = class {
|
|
|
6359
6361
|
if (this.env === 0 /* Mainnet */) {
|
|
6360
6362
|
return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a";
|
|
6361
6363
|
} else {
|
|
6362
|
-
return "
|
|
6364
|
+
return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448";
|
|
6363
6365
|
}
|
|
6364
6366
|
}
|
|
6365
6367
|
deepbookv3DeepFeeType() {
|
|
@@ -6381,7 +6383,7 @@ var AggregatorClient8 = class {
|
|
|
6381
6383
|
if (coins.length > 1) {
|
|
6382
6384
|
let vec = txb.makeMoveVec({ elements: coins.slice(1) });
|
|
6383
6385
|
txb.moveCall({
|
|
6384
|
-
target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
|
|
6386
|
+
target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
|
|
6385
6387
|
typeArguments: [coinType],
|
|
6386
6388
|
arguments: [coins[0], vec]
|
|
6387
6389
|
});
|
|
@@ -6731,4 +6733,48 @@ decimal.js/decimal.mjs:
|
|
|
6731
6733
|
*)
|
|
6732
6734
|
*/
|
|
6733
6735
|
|
|
6734
|
-
|
|
6736
|
+
exports.AFSUI = AFSUI;
|
|
6737
|
+
exports.AFTERMATH = AFTERMATH;
|
|
6738
|
+
exports.AggregatorClient = AggregatorClient8;
|
|
6739
|
+
exports.BLUEMOVE = BLUEMOVE;
|
|
6740
|
+
exports.CETUS = CETUS;
|
|
6741
|
+
exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
|
|
6742
|
+
exports.DEEPBOOKV2 = DEEPBOOKV2;
|
|
6743
|
+
exports.DEEPBOOKV3 = DEEPBOOKV3;
|
|
6744
|
+
exports.DEFAULT_ENDPOINT = DEFAULT_ENDPOINT;
|
|
6745
|
+
exports.Env = Env;
|
|
6746
|
+
exports.FLOWXV2 = FLOWXV2;
|
|
6747
|
+
exports.FLOWXV3 = FLOWXV3;
|
|
6748
|
+
exports.HAEDAL = HAEDAL;
|
|
6749
|
+
exports.KRIYA = KRIYA;
|
|
6750
|
+
exports.KRIYAV3 = KRIYAV3;
|
|
6751
|
+
exports.ONE = ONE;
|
|
6752
|
+
exports.SCALLOP = SCALLOP;
|
|
6753
|
+
exports.TEN_POW_NINE = TEN_POW_NINE;
|
|
6754
|
+
exports.TURBOS = TURBOS;
|
|
6755
|
+
exports.TWO = TWO;
|
|
6756
|
+
exports.U128 = U128;
|
|
6757
|
+
exports.U64_MAX = U64_MAX;
|
|
6758
|
+
exports.U64_MAX_BN = U64_MAX_BN;
|
|
6759
|
+
exports.VOLO = VOLO;
|
|
6760
|
+
exports.ZERO = ZERO;
|
|
6761
|
+
exports.buildInputCoin = buildInputCoin;
|
|
6762
|
+
exports.checkInvalidSuiAddress = checkInvalidSuiAddress;
|
|
6763
|
+
exports.compareCoins = compareCoins;
|
|
6764
|
+
exports.completionCoin = completionCoin;
|
|
6765
|
+
exports.composeType = composeType;
|
|
6766
|
+
exports.createTarget = createTarget;
|
|
6767
|
+
exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMsafe;
|
|
6768
|
+
exports.extractAddressFromType = extractAddressFromType;
|
|
6769
|
+
exports.extractStructTagFromType = extractStructTagFromType;
|
|
6770
|
+
exports.fixSuiObjectId = fixSuiObjectId;
|
|
6771
|
+
exports.getDeepbookV3Config = getDeepbookV3Config;
|
|
6772
|
+
exports.getRouterResult = getRouterResult;
|
|
6773
|
+
exports.isSortedSymbols = isSortedSymbols;
|
|
6774
|
+
exports.mintZeroCoin = mintZeroCoin;
|
|
6775
|
+
exports.normalizeCoinType = normalizeCoinType;
|
|
6776
|
+
exports.parseRouterResponse = parseRouterResponse;
|
|
6777
|
+
exports.patchFixSuiObjectId = patchFixSuiObjectId;
|
|
6778
|
+
exports.printTransaction = printTransaction;
|
|
6779
|
+
exports.processEndpoint = processEndpoint;
|
|
6780
|
+
exports.restituteMsafeFastRouterSwapParams = restituteMsafeFastRouterSwapParams;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var utils = require('@mysten/sui/utils');
|
|
5
|
-
var transactions = require('@mysten/sui/transactions');
|
|
1
|
+
import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
|
|
2
|
+
import { normalizeSuiObjectId, SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';
|
|
3
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
6
4
|
|
|
7
5
|
var __create = Object.create;
|
|
8
6
|
var __defProp = Object.defineProperty;
|
|
@@ -49,7 +47,7 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
|
|
|
49
47
|
// file that has been converted to a CommonJS file using a Babel-
|
|
50
48
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
51
49
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
52
|
-
|
|
50
|
+
__defProp(target, "default", { value: mod2, enumerable: true }) ,
|
|
53
51
|
mod2
|
|
54
52
|
));
|
|
55
53
|
var __async = (__this, __arguments, generator) => {
|
|
@@ -5390,7 +5388,7 @@ function extractStructTagFromType(type) {
|
|
|
5390
5388
|
const isSuiCoin = _type === GAS_TYPE_ARG || _type === GAS_TYPE_ARG_LONG;
|
|
5391
5389
|
const structTag = {
|
|
5392
5390
|
full_address: _type,
|
|
5393
|
-
address: isSuiCoin ? "0x2" :
|
|
5391
|
+
address: isSuiCoin ? "0x2" : normalizeSuiObjectId(parts[0]),
|
|
5394
5392
|
module: parts[1],
|
|
5395
5393
|
name: parts[2],
|
|
5396
5394
|
type_arguments: [],
|
|
@@ -5415,7 +5413,7 @@ function normalizeCoinType(coinType) {
|
|
|
5415
5413
|
}
|
|
5416
5414
|
function fixSuiObjectId(value) {
|
|
5417
5415
|
if (value.toLowerCase().startsWith("0x")) {
|
|
5418
|
-
return
|
|
5416
|
+
return normalizeSuiObjectId(value);
|
|
5419
5417
|
}
|
|
5420
5418
|
return value;
|
|
5421
5419
|
}
|
|
@@ -5770,9 +5768,9 @@ function swapInPools(client, params, sender, env) {
|
|
|
5770
5768
|
const { from, target, amount, byAmountIn, pools } = params;
|
|
5771
5769
|
const fromCoin = completionCoin(from);
|
|
5772
5770
|
const targetCoin = completionCoin(target);
|
|
5773
|
-
const tx = new
|
|
5771
|
+
const tx = new Transaction();
|
|
5774
5772
|
const direction = compareCoins(fromCoin, targetCoin);
|
|
5775
|
-
const integratePublishedAt = env === 0 /* Mainnet */ ? "
|
|
5773
|
+
const integratePublishedAt = env === 0 /* Mainnet */ ? "0x3a5aa90ffa33d09100d7b6941ea1c0ffe6ab66e77062ddd26320c1b073aabb10" : "0x19dd42e05fa6c9988a60d30686ee3feb776672b5547e328d6dab16563da65293";
|
|
5776
5774
|
const coinA = direction ? fromCoin : targetCoin;
|
|
5777
5775
|
const coinB = direction ? targetCoin : fromCoin;
|
|
5778
5776
|
const typeArguments = [coinA, coinB];
|
|
@@ -6091,9 +6089,9 @@ var DEEPBOOKV3 = "DEEPBOOKV3";
|
|
|
6091
6089
|
var SCALLOP = "SCALLOP";
|
|
6092
6090
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6093
6091
|
var AggregatorClient8 = class {
|
|
6094
|
-
constructor(endpoint, signer, client
|
|
6092
|
+
constructor(endpoint, signer, client, env) {
|
|
6095
6093
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6096
|
-
this.client = client
|
|
6094
|
+
this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
|
|
6097
6095
|
this.signer = signer || "";
|
|
6098
6096
|
this.env = env || 0 /* Mainnet */;
|
|
6099
6097
|
this.allCoins = /* @__PURE__ */ new Map();
|
|
@@ -6211,7 +6209,7 @@ var AggregatorClient8 = class {
|
|
|
6211
6209
|
if (targetCoins.length > 1) {
|
|
6212
6210
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6213
6211
|
txb.moveCall({
|
|
6214
|
-
target: `${
|
|
6212
|
+
target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
|
|
6215
6213
|
typeArguments: [routers[0].path[routers[0].path.length - 1].target],
|
|
6216
6214
|
arguments: [targetCoins[0], vec]
|
|
6217
6215
|
});
|
|
@@ -6351,7 +6349,7 @@ var AggregatorClient8 = class {
|
|
|
6351
6349
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6352
6350
|
publishedAt() {
|
|
6353
6351
|
if (this.env === 0 /* Mainnet */) {
|
|
6354
|
-
return "
|
|
6352
|
+
return "0x11451575c775a3e633437b827ecbc1eb51a5964b0302210b28f5b89880be21a2";
|
|
6355
6353
|
} else {
|
|
6356
6354
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6357
6355
|
}
|
|
@@ -6361,7 +6359,7 @@ var AggregatorClient8 = class {
|
|
|
6361
6359
|
if (this.env === 0 /* Mainnet */) {
|
|
6362
6360
|
return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a";
|
|
6363
6361
|
} else {
|
|
6364
|
-
return "
|
|
6362
|
+
return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448";
|
|
6365
6363
|
}
|
|
6366
6364
|
}
|
|
6367
6365
|
deepbookv3DeepFeeType() {
|
|
@@ -6383,7 +6381,7 @@ var AggregatorClient8 = class {
|
|
|
6383
6381
|
if (coins.length > 1) {
|
|
6384
6382
|
let vec = txb.makeMoveVec({ elements: coins.slice(1) });
|
|
6385
6383
|
txb.moveCall({
|
|
6386
|
-
target: `${
|
|
6384
|
+
target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
|
|
6387
6385
|
typeArguments: [coinType],
|
|
6388
6386
|
arguments: [coins[0], vec]
|
|
6389
6387
|
});
|
|
@@ -6733,48 +6731,4 @@ decimal.js/decimal.mjs:
|
|
|
6733
6731
|
*)
|
|
6734
6732
|
*/
|
|
6735
6733
|
|
|
6736
|
-
|
|
6737
|
-
exports.AFTERMATH = AFTERMATH;
|
|
6738
|
-
exports.AggregatorClient = AggregatorClient8;
|
|
6739
|
-
exports.BLUEMOVE = BLUEMOVE;
|
|
6740
|
-
exports.CETUS = CETUS;
|
|
6741
|
-
exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
|
|
6742
|
-
exports.DEEPBOOKV2 = DEEPBOOKV2;
|
|
6743
|
-
exports.DEEPBOOKV3 = DEEPBOOKV3;
|
|
6744
|
-
exports.DEFAULT_ENDPOINT = DEFAULT_ENDPOINT;
|
|
6745
|
-
exports.Env = Env;
|
|
6746
|
-
exports.FLOWXV2 = FLOWXV2;
|
|
6747
|
-
exports.FLOWXV3 = FLOWXV3;
|
|
6748
|
-
exports.HAEDAL = HAEDAL;
|
|
6749
|
-
exports.KRIYA = KRIYA;
|
|
6750
|
-
exports.KRIYAV3 = KRIYAV3;
|
|
6751
|
-
exports.ONE = ONE;
|
|
6752
|
-
exports.SCALLOP = SCALLOP;
|
|
6753
|
-
exports.TEN_POW_NINE = TEN_POW_NINE;
|
|
6754
|
-
exports.TURBOS = TURBOS;
|
|
6755
|
-
exports.TWO = TWO;
|
|
6756
|
-
exports.U128 = U128;
|
|
6757
|
-
exports.U64_MAX = U64_MAX;
|
|
6758
|
-
exports.U64_MAX_BN = U64_MAX_BN;
|
|
6759
|
-
exports.VOLO = VOLO;
|
|
6760
|
-
exports.ZERO = ZERO;
|
|
6761
|
-
exports.buildInputCoin = buildInputCoin;
|
|
6762
|
-
exports.checkInvalidSuiAddress = checkInvalidSuiAddress;
|
|
6763
|
-
exports.compareCoins = compareCoins;
|
|
6764
|
-
exports.completionCoin = completionCoin;
|
|
6765
|
-
exports.composeType = composeType;
|
|
6766
|
-
exports.createTarget = createTarget;
|
|
6767
|
-
exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMsafe;
|
|
6768
|
-
exports.extractAddressFromType = extractAddressFromType;
|
|
6769
|
-
exports.extractStructTagFromType = extractStructTagFromType;
|
|
6770
|
-
exports.fixSuiObjectId = fixSuiObjectId;
|
|
6771
|
-
exports.getDeepbookV3Config = getDeepbookV3Config;
|
|
6772
|
-
exports.getRouterResult = getRouterResult;
|
|
6773
|
-
exports.isSortedSymbols = isSortedSymbols;
|
|
6774
|
-
exports.mintZeroCoin = mintZeroCoin;
|
|
6775
|
-
exports.normalizeCoinType = normalizeCoinType;
|
|
6776
|
-
exports.parseRouterResponse = parseRouterResponse;
|
|
6777
|
-
exports.patchFixSuiObjectId = patchFixSuiObjectId;
|
|
6778
|
-
exports.printTransaction = printTransaction;
|
|
6779
|
-
exports.processEndpoint = processEndpoint;
|
|
6780
|
-
exports.restituteMsafeFastRouterSwapParams = restituteMsafeFastRouterSwapParams;
|
|
6734
|
+
export { AFSUI, AFTERMATH, AggregatorClient8 as AggregatorClient, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, KRIYA, KRIYAV3, ONE, SCALLOP, 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/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -384,7 +384,7 @@ export class AggregatorClient {
|
|
|
384
384
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
385
385
|
publishedAt(): string {
|
|
386
386
|
if (this.env === Env.Mainnet) {
|
|
387
|
-
return "
|
|
387
|
+
return "0x11451575c775a3e633437b827ecbc1eb51a5964b0302210b28f5b89880be21a2" // version 5
|
|
388
388
|
} else {
|
|
389
389
|
// return "0x0ed287d6c3fe4962d0994ffddc1d19a15fba6a81533f3f0dcc2bbcedebce0637" // version 2
|
|
390
390
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934"
|
|
@@ -397,7 +397,7 @@ export class AggregatorClient {
|
|
|
397
397
|
// return "0x43811be4677f5a5de7bf2dac740c10abddfaa524aee6b18e910eeadda8a2f6ae" // version 1, deepbookv3
|
|
398
398
|
return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a" // version 3, deepbookv3 & scallop
|
|
399
399
|
} else {
|
|
400
|
-
return "
|
|
400
|
+
return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448"
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
|
|
@@ -31,6 +31,7 @@ export class Scallop implements Dex {
|
|
|
31
31
|
): Promise<TransactionObjectArgument> {
|
|
32
32
|
const { direction, from, target } = path
|
|
33
33
|
|
|
34
|
+
// in scallop swap, the first coin type is always the common coin, the second coin type is always the special
|
|
34
35
|
const [func, coinAType, coinBType] = direction
|
|
35
36
|
? ["swap_a2b", from, target]
|
|
36
37
|
: ["swap_b2a", from, target]
|
package/src/transaction/swap.ts
CHANGED
|
@@ -21,8 +21,8 @@ export async function swapInPools(
|
|
|
21
21
|
const tx = new Transaction()
|
|
22
22
|
const direction = compareCoins(fromCoin, targetCoin)
|
|
23
23
|
const integratePublishedAt = env === Env.Mainnet ?
|
|
24
|
-
"
|
|
25
|
-
"
|
|
24
|
+
"0x3a5aa90ffa33d09100d7b6941ea1c0ffe6ab66e77062ddd26320c1b073aabb10" :
|
|
25
|
+
"0x19dd42e05fa6c9988a60d30686ee3feb776672b5547e328d6dab16563da65293"
|
|
26
26
|
const coinA = direction ? fromCoin : targetCoin
|
|
27
27
|
const coinB = direction ? targetCoin : fromCoin
|
|
28
28
|
|
|
File without changes
|