@cetusprotocol/aggregator-sdk 0.0.0-experimental-20240823165112 → 0.0.0-experimental-20240829104900
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 -61
- package/dist/index.d.ts +3 -61
- package/dist/index.js +51 -116
- package/dist/index.mjs +50 -66
- package/dist/src/client.d.ts +2 -1
- package/dist/src/const.d.ts +0 -59
- package/dist/src/transaction/flowx_v3.d.ts +8 -0
- package/dist/tests/test_data.test.d.ts +1 -0
- package/package.json +1 -1
- package/src/client.ts +7 -3
- package/src/const.ts +0 -100
- package/src/transaction/flowx_v3.ts +50 -0
- package/src/transaction/haedal.ts +0 -7
- package/src/utils/coin.ts +1 -2
- package/src/utils/transaction.ts +1 -1
- package/tests/router.test.ts +52 -8
- package/tests/test_data.test.ts +2 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _mysten_sui_client from '@mysten/sui/client';
|
|
2
2
|
import { SuiClient } from '@mysten/sui/client';
|
|
3
3
|
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
4
|
-
import { Signer } from '@mysten/sui/
|
|
4
|
+
import { Signer } from '@mysten/sui/cryptography';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
import Decimal from 'decimal.js';
|
|
7
7
|
|
|
@@ -64,6 +64,7 @@ declare const CETUS = "CETUS";
|
|
|
64
64
|
declare const DEEPBOOKV2 = "DEEPBOOK";
|
|
65
65
|
declare const KRIYA = "KRIYA";
|
|
66
66
|
declare const FLOWXV2 = "FLOWX";
|
|
67
|
+
declare const FLOWXV3 = "FLOWXV3";
|
|
67
68
|
declare const KRIYAV3 = "KRIYAV3";
|
|
68
69
|
declare const TURBOS = "TURBOS";
|
|
69
70
|
declare const AFTERMATH = "AFTERMATH";
|
|
@@ -143,52 +144,6 @@ declare function fixSuiObjectId(value: string): string;
|
|
|
143
144
|
declare function patchFixSuiObjectId(data: any): void;
|
|
144
145
|
declare function createTarget(packageName: string, moduleName: string, functionName: string): `${string}::${string}::${string}`;
|
|
145
146
|
|
|
146
|
-
/**
|
|
147
|
-
* The address representing the clock in the system.
|
|
148
|
-
*/
|
|
149
|
-
/**
|
|
150
|
-
* The address for CoinInfo module.
|
|
151
|
-
*/
|
|
152
|
-
declare const CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
153
|
-
/**
|
|
154
|
-
* The address for CoinStore module.
|
|
155
|
-
*/
|
|
156
|
-
declare const CoinStoreAddress = "0x1::coin::CoinStore";
|
|
157
|
-
declare const SuiZeroCoinFn = "0x2::coin::zero";
|
|
158
|
-
declare const CETUS_MODULE = "cetus";
|
|
159
|
-
declare const DEEPBOOK_MODULE = "deepbook";
|
|
160
|
-
declare const KRIYA_MODULE = "kriya";
|
|
161
|
-
declare const UTILS_MODULE = "utils";
|
|
162
|
-
declare const POOL_MODULT = "pool";
|
|
163
|
-
declare const PAY_MODULE = "pay";
|
|
164
|
-
declare const FLOWX_AMM_MODULE = "flowx_amm";
|
|
165
|
-
declare const TURBOS_MODULE = "turbos";
|
|
166
|
-
declare const AFTERMATH_MODULE = "aftermath";
|
|
167
|
-
declare const DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2";
|
|
168
|
-
declare const DEEPBOOK_CLOB_V2_MODULE = "clob_v2";
|
|
169
|
-
declare const FlashSwapFunc = "flash_swap";
|
|
170
|
-
declare const FlashSwapWithPartnerFunc = "flash_swap_with_partner";
|
|
171
|
-
declare const RepayFalshSwapFunc = "repay_flash_swap";
|
|
172
|
-
declare const RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner";
|
|
173
|
-
declare const FlashSwapA2BFunc = "flash_swap_a2b";
|
|
174
|
-
declare const FlashSwapB2AFunc = "flash_swap_b2a";
|
|
175
|
-
declare const FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b";
|
|
176
|
-
declare const FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a";
|
|
177
|
-
declare const REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b";
|
|
178
|
-
declare const REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a";
|
|
179
|
-
declare const REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = "repay_flash_swap_with_partner_a2b";
|
|
180
|
-
declare const REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = "repay_flash_swap_with_partner_b2a";
|
|
181
|
-
declare const SWAP_A2B_FUNC = "swap_a2b";
|
|
182
|
-
declare const SWAP_B2A_FUNC = "swap_b2a";
|
|
183
|
-
declare const TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin";
|
|
184
|
-
declare const CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold";
|
|
185
|
-
declare const JOIN_FUNC = "join_vec";
|
|
186
|
-
declare const TRANSFER_ACCOUNT_CAP = "transfer_account_cap";
|
|
187
|
-
declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
188
|
-
declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
189
|
-
declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
190
|
-
declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
191
|
-
declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
192
147
|
declare const ZERO: BN;
|
|
193
148
|
declare const ONE: BN;
|
|
194
149
|
declare const TWO: BN;
|
|
@@ -196,19 +151,6 @@ declare const U128: BN;
|
|
|
196
151
|
declare const U64_MAX_BN: BN;
|
|
197
152
|
declare const U64_MAX = "18446744073709551615";
|
|
198
153
|
declare const TEN_POW_NINE = 1000000000;
|
|
199
|
-
declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
200
|
-
declare const TESTNET_FLOWX_AMM_CONTAINER_ID = "";
|
|
201
|
-
declare const TURBOS_VERSIONED = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
202
|
-
declare const MAINNET_AFTERMATH_REGISTRY_ID = "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae";
|
|
203
|
-
declare const TESTNET_AFTERMATH_REGISTRY_ID = "";
|
|
204
|
-
declare const MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4";
|
|
205
|
-
declare const TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "";
|
|
206
|
-
declare const MAINNET_AFTERMATH_TREASURY_ID = "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce";
|
|
207
|
-
declare const TESTNET_AFTERMATH_TREASURY_ID = "";
|
|
208
|
-
declare const MAINNET_AFTERMATH_INSURANCE_FUND_ID = "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b";
|
|
209
|
-
declare const TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
|
|
210
|
-
declare const MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
|
|
211
|
-
declare const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
|
|
212
154
|
|
|
213
155
|
interface FindRouterParams {
|
|
214
156
|
from: string;
|
|
@@ -267,4 +209,4 @@ declare enum Env {
|
|
|
267
209
|
Testnet = 1
|
|
268
210
|
}
|
|
269
211
|
|
|
270
|
-
export { AFSUI, AFTERMATH,
|
|
212
|
+
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type Router, type RouterData, type RouterError, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _mysten_sui_client from '@mysten/sui/client';
|
|
2
2
|
import { SuiClient } from '@mysten/sui/client';
|
|
3
3
|
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
4
|
-
import { Signer } from '@mysten/sui/
|
|
4
|
+
import { Signer } from '@mysten/sui/cryptography';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
import Decimal from 'decimal.js';
|
|
7
7
|
|
|
@@ -64,6 +64,7 @@ declare const CETUS = "CETUS";
|
|
|
64
64
|
declare const DEEPBOOKV2 = "DEEPBOOK";
|
|
65
65
|
declare const KRIYA = "KRIYA";
|
|
66
66
|
declare const FLOWXV2 = "FLOWX";
|
|
67
|
+
declare const FLOWXV3 = "FLOWXV3";
|
|
67
68
|
declare const KRIYAV3 = "KRIYAV3";
|
|
68
69
|
declare const TURBOS = "TURBOS";
|
|
69
70
|
declare const AFTERMATH = "AFTERMATH";
|
|
@@ -143,52 +144,6 @@ declare function fixSuiObjectId(value: string): string;
|
|
|
143
144
|
declare function patchFixSuiObjectId(data: any): void;
|
|
144
145
|
declare function createTarget(packageName: string, moduleName: string, functionName: string): `${string}::${string}::${string}`;
|
|
145
146
|
|
|
146
|
-
/**
|
|
147
|
-
* The address representing the clock in the system.
|
|
148
|
-
*/
|
|
149
|
-
/**
|
|
150
|
-
* The address for CoinInfo module.
|
|
151
|
-
*/
|
|
152
|
-
declare const CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
153
|
-
/**
|
|
154
|
-
* The address for CoinStore module.
|
|
155
|
-
*/
|
|
156
|
-
declare const CoinStoreAddress = "0x1::coin::CoinStore";
|
|
157
|
-
declare const SuiZeroCoinFn = "0x2::coin::zero";
|
|
158
|
-
declare const CETUS_MODULE = "cetus";
|
|
159
|
-
declare const DEEPBOOK_MODULE = "deepbook";
|
|
160
|
-
declare const KRIYA_MODULE = "kriya";
|
|
161
|
-
declare const UTILS_MODULE = "utils";
|
|
162
|
-
declare const POOL_MODULT = "pool";
|
|
163
|
-
declare const PAY_MODULE = "pay";
|
|
164
|
-
declare const FLOWX_AMM_MODULE = "flowx_amm";
|
|
165
|
-
declare const TURBOS_MODULE = "turbos";
|
|
166
|
-
declare const AFTERMATH_MODULE = "aftermath";
|
|
167
|
-
declare const DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2";
|
|
168
|
-
declare const DEEPBOOK_CLOB_V2_MODULE = "clob_v2";
|
|
169
|
-
declare const FlashSwapFunc = "flash_swap";
|
|
170
|
-
declare const FlashSwapWithPartnerFunc = "flash_swap_with_partner";
|
|
171
|
-
declare const RepayFalshSwapFunc = "repay_flash_swap";
|
|
172
|
-
declare const RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner";
|
|
173
|
-
declare const FlashSwapA2BFunc = "flash_swap_a2b";
|
|
174
|
-
declare const FlashSwapB2AFunc = "flash_swap_b2a";
|
|
175
|
-
declare const FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b";
|
|
176
|
-
declare const FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a";
|
|
177
|
-
declare const REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b";
|
|
178
|
-
declare const REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a";
|
|
179
|
-
declare const REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = "repay_flash_swap_with_partner_a2b";
|
|
180
|
-
declare const REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = "repay_flash_swap_with_partner_b2a";
|
|
181
|
-
declare const SWAP_A2B_FUNC = "swap_a2b";
|
|
182
|
-
declare const SWAP_B2A_FUNC = "swap_b2a";
|
|
183
|
-
declare const TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin";
|
|
184
|
-
declare const CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold";
|
|
185
|
-
declare const JOIN_FUNC = "join_vec";
|
|
186
|
-
declare const TRANSFER_ACCOUNT_CAP = "transfer_account_cap";
|
|
187
|
-
declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
188
|
-
declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
189
|
-
declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
190
|
-
declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
191
|
-
declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
192
147
|
declare const ZERO: BN;
|
|
193
148
|
declare const ONE: BN;
|
|
194
149
|
declare const TWO: BN;
|
|
@@ -196,19 +151,6 @@ declare const U128: BN;
|
|
|
196
151
|
declare const U64_MAX_BN: BN;
|
|
197
152
|
declare const U64_MAX = "18446744073709551615";
|
|
198
153
|
declare const TEN_POW_NINE = 1000000000;
|
|
199
|
-
declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
200
|
-
declare const TESTNET_FLOWX_AMM_CONTAINER_ID = "";
|
|
201
|
-
declare const TURBOS_VERSIONED = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
202
|
-
declare const MAINNET_AFTERMATH_REGISTRY_ID = "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae";
|
|
203
|
-
declare const TESTNET_AFTERMATH_REGISTRY_ID = "";
|
|
204
|
-
declare const MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4";
|
|
205
|
-
declare const TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "";
|
|
206
|
-
declare const MAINNET_AFTERMATH_TREASURY_ID = "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce";
|
|
207
|
-
declare const TESTNET_AFTERMATH_TREASURY_ID = "";
|
|
208
|
-
declare const MAINNET_AFTERMATH_INSURANCE_FUND_ID = "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b";
|
|
209
|
-
declare const TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
|
|
210
|
-
declare const MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
|
|
211
|
-
declare const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
|
|
212
154
|
|
|
213
155
|
interface FindRouterParams {
|
|
214
156
|
from: string;
|
|
@@ -267,4 +209,4 @@ declare enum Env {
|
|
|
267
209
|
Testnet = 1
|
|
268
210
|
}
|
|
269
211
|
|
|
270
|
-
export { AFSUI, AFTERMATH,
|
|
212
|
+
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type Router, type RouterData, type RouterError, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
|
package/dist/index.js
CHANGED
|
@@ -5269,66 +5269,6 @@ var Cetus = class {
|
|
|
5269
5269
|
});
|
|
5270
5270
|
}
|
|
5271
5271
|
};
|
|
5272
|
-
|
|
5273
|
-
// src/const.ts
|
|
5274
|
-
var import_bn2 = __toESM(require_bn());
|
|
5275
|
-
var CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
5276
|
-
var CoinStoreAddress = "0x1::coin::CoinStore";
|
|
5277
|
-
var SuiZeroCoinFn = "0x2::coin::zero";
|
|
5278
|
-
var CETUS_MODULE = "cetus";
|
|
5279
|
-
var DEEPBOOK_MODULE = "deepbook";
|
|
5280
|
-
var KRIYA_MODULE = "kriya";
|
|
5281
|
-
var UTILS_MODULE = "utils";
|
|
5282
|
-
var POOL_MODULT = "pool";
|
|
5283
|
-
var PAY_MODULE = "pay";
|
|
5284
|
-
var FLOWX_AMM_MODULE = "flowx_amm";
|
|
5285
|
-
var TURBOS_MODULE = "turbos";
|
|
5286
|
-
var AFTERMATH_MODULE = "aftermath";
|
|
5287
|
-
var DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2";
|
|
5288
|
-
var DEEPBOOK_CLOB_V2_MODULE = "clob_v2";
|
|
5289
|
-
var FlashSwapFunc = "flash_swap";
|
|
5290
|
-
var FlashSwapWithPartnerFunc = "flash_swap_with_partner";
|
|
5291
|
-
var RepayFalshSwapFunc = "repay_flash_swap";
|
|
5292
|
-
var RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner";
|
|
5293
|
-
var FlashSwapA2BFunc = "flash_swap_a2b";
|
|
5294
|
-
var FlashSwapB2AFunc = "flash_swap_b2a";
|
|
5295
|
-
var FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b";
|
|
5296
|
-
var FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a";
|
|
5297
|
-
var REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b";
|
|
5298
|
-
var REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a";
|
|
5299
|
-
var REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = "repay_flash_swap_with_partner_a2b";
|
|
5300
|
-
var REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = "repay_flash_swap_with_partner_b2a";
|
|
5301
|
-
var SWAP_A2B_FUNC = "swap_a2b";
|
|
5302
|
-
var SWAP_B2A_FUNC = "swap_b2a";
|
|
5303
|
-
var TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin";
|
|
5304
|
-
var CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold";
|
|
5305
|
-
var JOIN_FUNC = "join_vec";
|
|
5306
|
-
var TRANSFER_ACCOUNT_CAP = "transfer_account_cap";
|
|
5307
|
-
var DEEPBOOK_PACKAGE_ID2 = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
5308
|
-
var DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
5309
|
-
var CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
5310
|
-
var MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
5311
|
-
var TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
5312
|
-
var ZERO = new import_bn2.default(0);
|
|
5313
|
-
var ONE = new import_bn2.default(1);
|
|
5314
|
-
var TWO = new import_bn2.default(2);
|
|
5315
|
-
var U128 = TWO.pow(new import_bn2.default(128));
|
|
5316
|
-
var U64_MAX_BN = new import_bn2.default("18446744073709551615");
|
|
5317
|
-
var U64_MAX = "18446744073709551615";
|
|
5318
|
-
var TEN_POW_NINE = 1e9;
|
|
5319
|
-
var MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
5320
|
-
var TESTNET_FLOWX_AMM_CONTAINER_ID = "";
|
|
5321
|
-
var TURBOS_VERSIONED = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
5322
|
-
var MAINNET_AFTERMATH_REGISTRY_ID = "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae";
|
|
5323
|
-
var TESTNET_AFTERMATH_REGISTRY_ID = "";
|
|
5324
|
-
var MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4";
|
|
5325
|
-
var TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "";
|
|
5326
|
-
var MAINNET_AFTERMATH_TREASURY_ID = "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce";
|
|
5327
|
-
var TESTNET_AFTERMATH_TREASURY_ID = "";
|
|
5328
|
-
var MAINNET_AFTERMATH_INSURANCE_FUND_ID = "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b";
|
|
5329
|
-
var TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
|
|
5330
|
-
var MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
|
|
5331
|
-
var TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
|
|
5332
5272
|
var EQUAL = 0;
|
|
5333
5273
|
var LESS_THAN = 1;
|
|
5334
5274
|
var GREATER_THAN = 2;
|
|
@@ -5661,7 +5601,7 @@ function compareCoins(coinA, coinB) {
|
|
|
5661
5601
|
}
|
|
5662
5602
|
function mintZeroCoin(txb, coinType) {
|
|
5663
5603
|
return txb.moveCall({
|
|
5664
|
-
target:
|
|
5604
|
+
target: "0x2::coin::zero",
|
|
5665
5605
|
typeArguments: [coinType]
|
|
5666
5606
|
});
|
|
5667
5607
|
}
|
|
@@ -5728,6 +5668,18 @@ var import_bn4 = __toESM(require_bn());
|
|
|
5728
5668
|
|
|
5729
5669
|
// src/math.ts
|
|
5730
5670
|
var import_bn3 = __toESM(require_bn());
|
|
5671
|
+
|
|
5672
|
+
// src/const.ts
|
|
5673
|
+
var import_bn2 = __toESM(require_bn());
|
|
5674
|
+
var ZERO = new import_bn2.default(0);
|
|
5675
|
+
var ONE = new import_bn2.default(1);
|
|
5676
|
+
var TWO = new import_bn2.default(2);
|
|
5677
|
+
var U128 = TWO.pow(new import_bn2.default(128));
|
|
5678
|
+
var U64_MAX_BN = new import_bn2.default("18446744073709551615");
|
|
5679
|
+
var U64_MAX = "18446744073709551615";
|
|
5680
|
+
var TEN_POW_NINE = 1e9;
|
|
5681
|
+
|
|
5682
|
+
// src/math.ts
|
|
5731
5683
|
function CalculateAmountLimit(expectAmount, byAmountIn, slippage) {
|
|
5732
5684
|
let amountLimit = ZERO;
|
|
5733
5685
|
if (byAmountIn) {
|
|
@@ -5905,7 +5857,6 @@ var Haedal = class {
|
|
|
5905
5857
|
throw new Error("Haedal not support b2a swap");
|
|
5906
5858
|
}
|
|
5907
5859
|
const func = "swap_a2b";
|
|
5908
|
-
console.log("haedal path id", path.id);
|
|
5909
5860
|
const args = [txb.object(path.id), txb.object("0x5"), inputCoin];
|
|
5910
5861
|
const res = txb.moveCall({
|
|
5911
5862
|
target: `${client.publishedAt()}::haedal::${func}`,
|
|
@@ -5985,18 +5936,49 @@ var Volo = class {
|
|
|
5985
5936
|
}
|
|
5986
5937
|
};
|
|
5987
5938
|
|
|
5939
|
+
// src/transaction/flowx_v3.ts
|
|
5940
|
+
var FlowxV3 = class {
|
|
5941
|
+
constructor(env) {
|
|
5942
|
+
if (env !== 0 /* Mainnet */) {
|
|
5943
|
+
throw new Error("Flowx clmm only supported on mainnet");
|
|
5944
|
+
}
|
|
5945
|
+
this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
|
|
5946
|
+
this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
|
|
5947
|
+
}
|
|
5948
|
+
swap(client, txb, path, inputCoin) {
|
|
5949
|
+
return __async(this, null, function* () {
|
|
5950
|
+
const { direction, from, target } = path;
|
|
5951
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
5952
|
+
const args = [
|
|
5953
|
+
txb.object(this.poolRegistry),
|
|
5954
|
+
txb.pure.u64(path.feeRate * 1e6),
|
|
5955
|
+
inputCoin,
|
|
5956
|
+
txb.object(this.versioned),
|
|
5957
|
+
txb.object(CLOCK_ADDRESS)
|
|
5958
|
+
];
|
|
5959
|
+
const res = txb.moveCall({
|
|
5960
|
+
target: `${client.publishedAt()}::flowx_clmm::${func}`,
|
|
5961
|
+
typeArguments: [coinAType, coinBType],
|
|
5962
|
+
arguments: args
|
|
5963
|
+
});
|
|
5964
|
+
return res;
|
|
5965
|
+
});
|
|
5966
|
+
}
|
|
5967
|
+
};
|
|
5968
|
+
|
|
5988
5969
|
// src/client.ts
|
|
5989
5970
|
var CETUS = "CETUS";
|
|
5990
5971
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
5991
5972
|
var KRIYA = "KRIYA";
|
|
5992
5973
|
var FLOWXV2 = "FLOWX";
|
|
5974
|
+
var FLOWXV3 = "FLOWXV3";
|
|
5993
5975
|
var KRIYAV3 = "KRIYAV3";
|
|
5994
5976
|
var TURBOS = "TURBOS";
|
|
5995
5977
|
var AFTERMATH = "AFTERMATH";
|
|
5996
5978
|
var HAEDAL = "HAEDAL";
|
|
5997
5979
|
var VOLO = "VOLO";
|
|
5998
5980
|
var AFSUI = "AFSUI";
|
|
5999
|
-
var
|
|
5981
|
+
var AggregatorClient6 = class {
|
|
6000
5982
|
constructor(endpoint, signer, client, env) {
|
|
6001
5983
|
this.endpoint = endpoint;
|
|
6002
5984
|
this.client = client;
|
|
@@ -6107,7 +6089,7 @@ var AggregatorClient5 = class {
|
|
|
6107
6089
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6108
6090
|
txb.moveCall({
|
|
6109
6091
|
target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
|
|
6110
|
-
typeArguments: [routers[0].path[0].
|
|
6092
|
+
typeArguments: [routers[0].path[routers[0].path.length - 1].target],
|
|
6111
6093
|
arguments: [targetCoins[0], vec]
|
|
6112
6094
|
});
|
|
6113
6095
|
}
|
|
@@ -6233,7 +6215,7 @@ var AggregatorClient5 = class {
|
|
|
6233
6215
|
}
|
|
6234
6216
|
publishedAt() {
|
|
6235
6217
|
if (this.env === 0 /* Mainnet */) {
|
|
6236
|
-
return "
|
|
6218
|
+
return "0x98c07fd55b56dfb5dfb573aa52a227d741af2ffa17d51a5d208e214a4bc27f07";
|
|
6237
6219
|
} else {
|
|
6238
6220
|
return "0x0";
|
|
6239
6221
|
}
|
|
@@ -6275,6 +6257,8 @@ var AggregatorClient5 = class {
|
|
|
6275
6257
|
return new KriyaV3(this.env);
|
|
6276
6258
|
case FLOWXV2:
|
|
6277
6259
|
return new FlowxV2(this.env);
|
|
6260
|
+
case FLOWXV3:
|
|
6261
|
+
return new FlowxV3(this.env);
|
|
6278
6262
|
case TURBOS:
|
|
6279
6263
|
return new Turbos(this.env);
|
|
6280
6264
|
case AFTERMATH:
|
|
@@ -6457,72 +6441,23 @@ decimal.js/decimal.mjs:
|
|
|
6457
6441
|
|
|
6458
6442
|
exports.AFSUI = AFSUI;
|
|
6459
6443
|
exports.AFTERMATH = AFTERMATH;
|
|
6460
|
-
exports.
|
|
6461
|
-
exports.AggregatorClient = AggregatorClient5;
|
|
6444
|
+
exports.AggregatorClient = AggregatorClient6;
|
|
6462
6445
|
exports.CETUS = CETUS;
|
|
6463
|
-
exports.CETUS_MODULE = CETUS_MODULE;
|
|
6464
|
-
exports.CETUS_PUBLISHED_AT = CETUS_PUBLISHED_AT;
|
|
6465
|
-
exports.CHECK_COINS_THRESHOLD_FUNC = CHECK_COINS_THRESHOLD_FUNC;
|
|
6466
6446
|
exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
|
|
6467
|
-
exports.CoinInfoAddress = CoinInfoAddress;
|
|
6468
|
-
exports.CoinStoreAddress = CoinStoreAddress;
|
|
6469
6447
|
exports.DEEPBOOKV2 = DEEPBOOKV2;
|
|
6470
|
-
exports.DEEPBOOK_CLOB_V2_MODULE = DEEPBOOK_CLOB_V2_MODULE;
|
|
6471
|
-
exports.DEEPBOOK_CUSTODIAN_V2_MODULE = DEEPBOOK_CUSTODIAN_V2_MODULE;
|
|
6472
|
-
exports.DEEPBOOK_MODULE = DEEPBOOK_MODULE;
|
|
6473
|
-
exports.DEEPBOOK_PACKAGE_ID = DEEPBOOK_PACKAGE_ID2;
|
|
6474
|
-
exports.DEEPBOOK_PUBLISHED_AT = DEEPBOOK_PUBLISHED_AT;
|
|
6475
6448
|
exports.Env = Env;
|
|
6476
6449
|
exports.FLOWXV2 = FLOWXV2;
|
|
6477
|
-
exports.
|
|
6478
|
-
exports.FlashSwapA2BFunc = FlashSwapA2BFunc;
|
|
6479
|
-
exports.FlashSwapB2AFunc = FlashSwapB2AFunc;
|
|
6480
|
-
exports.FlashSwapFunc = FlashSwapFunc;
|
|
6481
|
-
exports.FlashSwapWithPartnerA2BFunc = FlashSwapWithPartnerA2BFunc;
|
|
6482
|
-
exports.FlashSwapWithPartnerB2AFunc = FlashSwapWithPartnerB2AFunc;
|
|
6483
|
-
exports.FlashSwapWithPartnerFunc = FlashSwapWithPartnerFunc;
|
|
6450
|
+
exports.FLOWXV3 = FLOWXV3;
|
|
6484
6451
|
exports.HAEDAL = HAEDAL;
|
|
6485
|
-
exports.JOIN_FUNC = JOIN_FUNC;
|
|
6486
6452
|
exports.KRIYA = KRIYA;
|
|
6487
6453
|
exports.KRIYAV3 = KRIYAV3;
|
|
6488
|
-
exports.KRIYA_MODULE = KRIYA_MODULE;
|
|
6489
|
-
exports.MAINNET_AFTERMATH_INSURANCE_FUND_ID = MAINNET_AFTERMATH_INSURANCE_FUND_ID;
|
|
6490
|
-
exports.MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID;
|
|
6491
|
-
exports.MAINNET_AFTERMATH_REFERRAL_VAULT_ID = MAINNET_AFTERMATH_REFERRAL_VAULT_ID;
|
|
6492
|
-
exports.MAINNET_AFTERMATH_REGISTRY_ID = MAINNET_AFTERMATH_REGISTRY_ID;
|
|
6493
|
-
exports.MAINNET_AFTERMATH_TREASURY_ID = MAINNET_AFTERMATH_TREASURY_ID;
|
|
6494
|
-
exports.MAINNET_CETUS_GLOBAL_CONFIG_ID = MAINNET_CETUS_GLOBAL_CONFIG_ID;
|
|
6495
|
-
exports.MAINNET_FLOWX_AMM_CONTAINER_ID = MAINNET_FLOWX_AMM_CONTAINER_ID;
|
|
6496
6454
|
exports.ONE = ONE;
|
|
6497
|
-
exports.PAY_MODULE = PAY_MODULE;
|
|
6498
|
-
exports.POOL_MODULT = POOL_MODULT;
|
|
6499
|
-
exports.REPAY_FLASH_SWAP_A2B_FUNC = REPAY_FLASH_SWAP_A2B_FUNC;
|
|
6500
|
-
exports.REPAY_FLASH_SWAP_B2A_FUNC = REPAY_FLASH_SWAP_B2A_FUNC;
|
|
6501
|
-
exports.REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC;
|
|
6502
|
-
exports.REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC;
|
|
6503
|
-
exports.RepayFalshSwapFunc = RepayFalshSwapFunc;
|
|
6504
|
-
exports.RepayFlashSwapWithPartnerFunc = RepayFlashSwapWithPartnerFunc;
|
|
6505
|
-
exports.SWAP_A2B_FUNC = SWAP_A2B_FUNC;
|
|
6506
|
-
exports.SWAP_B2A_FUNC = SWAP_B2A_FUNC;
|
|
6507
|
-
exports.SuiZeroCoinFn = SuiZeroCoinFn;
|
|
6508
6455
|
exports.TEN_POW_NINE = TEN_POW_NINE;
|
|
6509
|
-
exports.TESTNET_AFTERMATH_INSURANCE_FUND_ID = TESTNET_AFTERMATH_INSURANCE_FUND_ID;
|
|
6510
|
-
exports.TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID;
|
|
6511
|
-
exports.TESTNET_AFTERMATH_REFERRAL_VAULT_ID = TESTNET_AFTERMATH_REFERRAL_VAULT_ID;
|
|
6512
|
-
exports.TESTNET_AFTERMATH_REGISTRY_ID = TESTNET_AFTERMATH_REGISTRY_ID;
|
|
6513
|
-
exports.TESTNET_AFTERMATH_TREASURY_ID = TESTNET_AFTERMATH_TREASURY_ID;
|
|
6514
|
-
exports.TESTNET_CETUS_GLOBAL_CONFIG_ID = TESTNET_CETUS_GLOBAL_CONFIG_ID;
|
|
6515
|
-
exports.TESTNET_FLOWX_AMM_CONTAINER_ID = TESTNET_FLOWX_AMM_CONTAINER_ID;
|
|
6516
|
-
exports.TRANSFER_ACCOUNT_CAP = TRANSFER_ACCOUNT_CAP;
|
|
6517
|
-
exports.TRANSFER_OR_DESTORY_COIN_FUNC = TRANSFER_OR_DESTORY_COIN_FUNC;
|
|
6518
6456
|
exports.TURBOS = TURBOS;
|
|
6519
|
-
exports.TURBOS_MODULE = TURBOS_MODULE;
|
|
6520
|
-
exports.TURBOS_VERSIONED = TURBOS_VERSIONED;
|
|
6521
6457
|
exports.TWO = TWO;
|
|
6522
6458
|
exports.U128 = U128;
|
|
6523
6459
|
exports.U64_MAX = U64_MAX;
|
|
6524
6460
|
exports.U64_MAX_BN = U64_MAX_BN;
|
|
6525
|
-
exports.UTILS_MODULE = UTILS_MODULE;
|
|
6526
6461
|
exports.VOLO = VOLO;
|
|
6527
6462
|
exports.ZERO = ZERO;
|
|
6528
6463
|
exports.composeType = composeType;
|
package/dist/index.mjs
CHANGED
|
@@ -5267,66 +5267,6 @@ var Cetus = class {
|
|
|
5267
5267
|
});
|
|
5268
5268
|
}
|
|
5269
5269
|
};
|
|
5270
|
-
|
|
5271
|
-
// src/const.ts
|
|
5272
|
-
var import_bn2 = __toESM(require_bn());
|
|
5273
|
-
var CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
5274
|
-
var CoinStoreAddress = "0x1::coin::CoinStore";
|
|
5275
|
-
var SuiZeroCoinFn = "0x2::coin::zero";
|
|
5276
|
-
var CETUS_MODULE = "cetus";
|
|
5277
|
-
var DEEPBOOK_MODULE = "deepbook";
|
|
5278
|
-
var KRIYA_MODULE = "kriya";
|
|
5279
|
-
var UTILS_MODULE = "utils";
|
|
5280
|
-
var POOL_MODULT = "pool";
|
|
5281
|
-
var PAY_MODULE = "pay";
|
|
5282
|
-
var FLOWX_AMM_MODULE = "flowx_amm";
|
|
5283
|
-
var TURBOS_MODULE = "turbos";
|
|
5284
|
-
var AFTERMATH_MODULE = "aftermath";
|
|
5285
|
-
var DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2";
|
|
5286
|
-
var DEEPBOOK_CLOB_V2_MODULE = "clob_v2";
|
|
5287
|
-
var FlashSwapFunc = "flash_swap";
|
|
5288
|
-
var FlashSwapWithPartnerFunc = "flash_swap_with_partner";
|
|
5289
|
-
var RepayFalshSwapFunc = "repay_flash_swap";
|
|
5290
|
-
var RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner";
|
|
5291
|
-
var FlashSwapA2BFunc = "flash_swap_a2b";
|
|
5292
|
-
var FlashSwapB2AFunc = "flash_swap_b2a";
|
|
5293
|
-
var FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b";
|
|
5294
|
-
var FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a";
|
|
5295
|
-
var REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b";
|
|
5296
|
-
var REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a";
|
|
5297
|
-
var REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = "repay_flash_swap_with_partner_a2b";
|
|
5298
|
-
var REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = "repay_flash_swap_with_partner_b2a";
|
|
5299
|
-
var SWAP_A2B_FUNC = "swap_a2b";
|
|
5300
|
-
var SWAP_B2A_FUNC = "swap_b2a";
|
|
5301
|
-
var TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin";
|
|
5302
|
-
var CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold";
|
|
5303
|
-
var JOIN_FUNC = "join_vec";
|
|
5304
|
-
var TRANSFER_ACCOUNT_CAP = "transfer_account_cap";
|
|
5305
|
-
var DEEPBOOK_PACKAGE_ID2 = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
5306
|
-
var DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
5307
|
-
var CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
5308
|
-
var MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
5309
|
-
var TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
5310
|
-
var ZERO = new import_bn2.default(0);
|
|
5311
|
-
var ONE = new import_bn2.default(1);
|
|
5312
|
-
var TWO = new import_bn2.default(2);
|
|
5313
|
-
var U128 = TWO.pow(new import_bn2.default(128));
|
|
5314
|
-
var U64_MAX_BN = new import_bn2.default("18446744073709551615");
|
|
5315
|
-
var U64_MAX = "18446744073709551615";
|
|
5316
|
-
var TEN_POW_NINE = 1e9;
|
|
5317
|
-
var MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
5318
|
-
var TESTNET_FLOWX_AMM_CONTAINER_ID = "";
|
|
5319
|
-
var TURBOS_VERSIONED = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
5320
|
-
var MAINNET_AFTERMATH_REGISTRY_ID = "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae";
|
|
5321
|
-
var TESTNET_AFTERMATH_REGISTRY_ID = "";
|
|
5322
|
-
var MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4";
|
|
5323
|
-
var TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "";
|
|
5324
|
-
var MAINNET_AFTERMATH_TREASURY_ID = "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce";
|
|
5325
|
-
var TESTNET_AFTERMATH_TREASURY_ID = "";
|
|
5326
|
-
var MAINNET_AFTERMATH_INSURANCE_FUND_ID = "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b";
|
|
5327
|
-
var TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
|
|
5328
|
-
var MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
|
|
5329
|
-
var TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
|
|
5330
5270
|
var EQUAL = 0;
|
|
5331
5271
|
var LESS_THAN = 1;
|
|
5332
5272
|
var GREATER_THAN = 2;
|
|
@@ -5659,7 +5599,7 @@ function compareCoins(coinA, coinB) {
|
|
|
5659
5599
|
}
|
|
5660
5600
|
function mintZeroCoin(txb, coinType) {
|
|
5661
5601
|
return txb.moveCall({
|
|
5662
|
-
target:
|
|
5602
|
+
target: "0x2::coin::zero",
|
|
5663
5603
|
typeArguments: [coinType]
|
|
5664
5604
|
});
|
|
5665
5605
|
}
|
|
@@ -5726,6 +5666,18 @@ var import_bn4 = __toESM(require_bn());
|
|
|
5726
5666
|
|
|
5727
5667
|
// src/math.ts
|
|
5728
5668
|
var import_bn3 = __toESM(require_bn());
|
|
5669
|
+
|
|
5670
|
+
// src/const.ts
|
|
5671
|
+
var import_bn2 = __toESM(require_bn());
|
|
5672
|
+
var ZERO = new import_bn2.default(0);
|
|
5673
|
+
var ONE = new import_bn2.default(1);
|
|
5674
|
+
var TWO = new import_bn2.default(2);
|
|
5675
|
+
var U128 = TWO.pow(new import_bn2.default(128));
|
|
5676
|
+
var U64_MAX_BN = new import_bn2.default("18446744073709551615");
|
|
5677
|
+
var U64_MAX = "18446744073709551615";
|
|
5678
|
+
var TEN_POW_NINE = 1e9;
|
|
5679
|
+
|
|
5680
|
+
// src/math.ts
|
|
5729
5681
|
function CalculateAmountLimit(expectAmount, byAmountIn, slippage) {
|
|
5730
5682
|
let amountLimit = ZERO;
|
|
5731
5683
|
if (byAmountIn) {
|
|
@@ -5903,7 +5855,6 @@ var Haedal = class {
|
|
|
5903
5855
|
throw new Error("Haedal not support b2a swap");
|
|
5904
5856
|
}
|
|
5905
5857
|
const func = "swap_a2b";
|
|
5906
|
-
console.log("haedal path id", path.id);
|
|
5907
5858
|
const args = [txb.object(path.id), txb.object("0x5"), inputCoin];
|
|
5908
5859
|
const res = txb.moveCall({
|
|
5909
5860
|
target: `${client.publishedAt()}::haedal::${func}`,
|
|
@@ -5983,18 +5934,49 @@ var Volo = class {
|
|
|
5983
5934
|
}
|
|
5984
5935
|
};
|
|
5985
5936
|
|
|
5937
|
+
// src/transaction/flowx_v3.ts
|
|
5938
|
+
var FlowxV3 = class {
|
|
5939
|
+
constructor(env) {
|
|
5940
|
+
if (env !== 0 /* Mainnet */) {
|
|
5941
|
+
throw new Error("Flowx clmm only supported on mainnet");
|
|
5942
|
+
}
|
|
5943
|
+
this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
|
|
5944
|
+
this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
|
|
5945
|
+
}
|
|
5946
|
+
swap(client, txb, path, inputCoin) {
|
|
5947
|
+
return __async(this, null, function* () {
|
|
5948
|
+
const { direction, from, target } = path;
|
|
5949
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
5950
|
+
const args = [
|
|
5951
|
+
txb.object(this.poolRegistry),
|
|
5952
|
+
txb.pure.u64(path.feeRate * 1e6),
|
|
5953
|
+
inputCoin,
|
|
5954
|
+
txb.object(this.versioned),
|
|
5955
|
+
txb.object(CLOCK_ADDRESS)
|
|
5956
|
+
];
|
|
5957
|
+
const res = txb.moveCall({
|
|
5958
|
+
target: `${client.publishedAt()}::flowx_clmm::${func}`,
|
|
5959
|
+
typeArguments: [coinAType, coinBType],
|
|
5960
|
+
arguments: args
|
|
5961
|
+
});
|
|
5962
|
+
return res;
|
|
5963
|
+
});
|
|
5964
|
+
}
|
|
5965
|
+
};
|
|
5966
|
+
|
|
5986
5967
|
// src/client.ts
|
|
5987
5968
|
var CETUS = "CETUS";
|
|
5988
5969
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
5989
5970
|
var KRIYA = "KRIYA";
|
|
5990
5971
|
var FLOWXV2 = "FLOWX";
|
|
5972
|
+
var FLOWXV3 = "FLOWXV3";
|
|
5991
5973
|
var KRIYAV3 = "KRIYAV3";
|
|
5992
5974
|
var TURBOS = "TURBOS";
|
|
5993
5975
|
var AFTERMATH = "AFTERMATH";
|
|
5994
5976
|
var HAEDAL = "HAEDAL";
|
|
5995
5977
|
var VOLO = "VOLO";
|
|
5996
5978
|
var AFSUI = "AFSUI";
|
|
5997
|
-
var
|
|
5979
|
+
var AggregatorClient6 = class {
|
|
5998
5980
|
constructor(endpoint, signer, client, env) {
|
|
5999
5981
|
this.endpoint = endpoint;
|
|
6000
5982
|
this.client = client;
|
|
@@ -6105,7 +6087,7 @@ var AggregatorClient5 = class {
|
|
|
6105
6087
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6106
6088
|
txb.moveCall({
|
|
6107
6089
|
target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
|
|
6108
|
-
typeArguments: [routers[0].path[0].
|
|
6090
|
+
typeArguments: [routers[0].path[routers[0].path.length - 1].target],
|
|
6109
6091
|
arguments: [targetCoins[0], vec]
|
|
6110
6092
|
});
|
|
6111
6093
|
}
|
|
@@ -6231,7 +6213,7 @@ var AggregatorClient5 = class {
|
|
|
6231
6213
|
}
|
|
6232
6214
|
publishedAt() {
|
|
6233
6215
|
if (this.env === 0 /* Mainnet */) {
|
|
6234
|
-
return "
|
|
6216
|
+
return "0x98c07fd55b56dfb5dfb573aa52a227d741af2ffa17d51a5d208e214a4bc27f07";
|
|
6235
6217
|
} else {
|
|
6236
6218
|
return "0x0";
|
|
6237
6219
|
}
|
|
@@ -6273,6 +6255,8 @@ var AggregatorClient5 = class {
|
|
|
6273
6255
|
return new KriyaV3(this.env);
|
|
6274
6256
|
case FLOWXV2:
|
|
6275
6257
|
return new FlowxV2(this.env);
|
|
6258
|
+
case FLOWXV3:
|
|
6259
|
+
return new FlowxV3(this.env);
|
|
6276
6260
|
case TURBOS:
|
|
6277
6261
|
return new Turbos(this.env);
|
|
6278
6262
|
case AFTERMATH:
|
|
@@ -6453,4 +6437,4 @@ decimal.js/decimal.mjs:
|
|
|
6453
6437
|
*)
|
|
6454
6438
|
*/
|
|
6455
6439
|
|
|
6456
|
-
export { AFSUI, AFTERMATH,
|
|
6440
|
+
export { AFSUI, AFTERMATH, AggregatorClient6 as AggregatorClient, 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, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
2
|
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
3
|
-
import { Signer } from "@mysten/sui/
|
|
3
|
+
import { Signer } from "@mysten/sui/cryptography";
|
|
4
4
|
import BN from "bn.js";
|
|
5
5
|
import { Dex, Env, FindRouterParams, Router, RouterData } from ".";
|
|
6
6
|
import { CoinAsset } from "./types/sui";
|
|
@@ -8,6 +8,7 @@ export declare const CETUS = "CETUS";
|
|
|
8
8
|
export declare const DEEPBOOKV2 = "DEEPBOOK";
|
|
9
9
|
export declare const KRIYA = "KRIYA";
|
|
10
10
|
export declare const FLOWXV2 = "FLOWX";
|
|
11
|
+
export declare const FLOWXV3 = "FLOWXV3";
|
|
11
12
|
export declare const KRIYAV3 = "KRIYAV3";
|
|
12
13
|
export declare const TURBOS = "TURBOS";
|
|
13
14
|
export declare const AFTERMATH = "AFTERMATH";
|
package/dist/src/const.d.ts
CHANGED
|
@@ -1,50 +1,4 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
|
-
/**
|
|
3
|
-
* The address representing the clock in the system.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* The address for CoinInfo module.
|
|
7
|
-
*/
|
|
8
|
-
export declare const CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
9
|
-
/**
|
|
10
|
-
* The address for CoinStore module.
|
|
11
|
-
*/
|
|
12
|
-
export declare const CoinStoreAddress = "0x1::coin::CoinStore";
|
|
13
|
-
export declare const SuiZeroCoinFn = "0x2::coin::zero";
|
|
14
|
-
export declare const CETUS_MODULE = "cetus";
|
|
15
|
-
export declare const DEEPBOOK_MODULE = "deepbook";
|
|
16
|
-
export declare const KRIYA_MODULE = "kriya";
|
|
17
|
-
export declare const UTILS_MODULE = "utils";
|
|
18
|
-
export declare const POOL_MODULT = "pool";
|
|
19
|
-
export declare const PAY_MODULE = "pay";
|
|
20
|
-
export declare const FLOWX_AMM_MODULE = "flowx_amm";
|
|
21
|
-
export declare const TURBOS_MODULE = "turbos";
|
|
22
|
-
export declare const AFTERMATH_MODULE = "aftermath";
|
|
23
|
-
export declare const DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2";
|
|
24
|
-
export declare const DEEPBOOK_CLOB_V2_MODULE = "clob_v2";
|
|
25
|
-
export declare const FlashSwapFunc = "flash_swap";
|
|
26
|
-
export declare const FlashSwapWithPartnerFunc = "flash_swap_with_partner";
|
|
27
|
-
export declare const RepayFalshSwapFunc = "repay_flash_swap";
|
|
28
|
-
export declare const RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner";
|
|
29
|
-
export declare const FlashSwapA2BFunc = "flash_swap_a2b";
|
|
30
|
-
export declare const FlashSwapB2AFunc = "flash_swap_b2a";
|
|
31
|
-
export declare const FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b";
|
|
32
|
-
export declare const FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a";
|
|
33
|
-
export declare const REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b";
|
|
34
|
-
export declare const REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a";
|
|
35
|
-
export declare const REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = "repay_flash_swap_with_partner_a2b";
|
|
36
|
-
export declare const REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = "repay_flash_swap_with_partner_b2a";
|
|
37
|
-
export declare const SWAP_A2B_FUNC = "swap_a2b";
|
|
38
|
-
export declare const SWAP_B2A_FUNC = "swap_b2a";
|
|
39
|
-
export declare const TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin";
|
|
40
|
-
export declare const CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold";
|
|
41
|
-
export declare const JOIN_FUNC = "join_vec";
|
|
42
|
-
export declare const TRANSFER_ACCOUNT_CAP = "transfer_account_cap";
|
|
43
|
-
export declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
44
|
-
export declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
45
|
-
export declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
46
|
-
export declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
47
|
-
export declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
48
2
|
export declare const ZERO: BN;
|
|
49
3
|
export declare const ONE: BN;
|
|
50
4
|
export declare const TWO: BN;
|
|
@@ -52,16 +6,3 @@ export declare const U128: BN;
|
|
|
52
6
|
export declare const U64_MAX_BN: BN;
|
|
53
7
|
export declare const U64_MAX = "18446744073709551615";
|
|
54
8
|
export declare const TEN_POW_NINE = 1000000000;
|
|
55
|
-
export declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
56
|
-
export declare const TESTNET_FLOWX_AMM_CONTAINER_ID = "";
|
|
57
|
-
export declare const TURBOS_VERSIONED = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
58
|
-
export declare const MAINNET_AFTERMATH_REGISTRY_ID = "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae";
|
|
59
|
-
export declare const TESTNET_AFTERMATH_REGISTRY_ID = "";
|
|
60
|
-
export declare const MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4";
|
|
61
|
-
export declare const TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "";
|
|
62
|
-
export declare const MAINNET_AFTERMATH_TREASURY_ID = "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce";
|
|
63
|
-
export declare const TESTNET_AFTERMATH_TREASURY_ID = "";
|
|
64
|
-
export declare const MAINNET_AFTERMATH_INSURANCE_FUND_ID = "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b";
|
|
65
|
-
export declare const TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
|
|
66
|
-
export declare const MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
|
|
67
|
-
export declare const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
|
+
import { AggregatorClient, Dex, Env, Path } from "..";
|
|
3
|
+
export declare class FlowxV3 implements Dex {
|
|
4
|
+
private versioned;
|
|
5
|
+
private poolRegistry;
|
|
6
|
+
constructor(env: Env);
|
|
7
|
+
swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
8
|
+
}
|
|
@@ -6,3 +6,4 @@ export declare const M_SUI = "0x2::sui::SUI";
|
|
|
6
6
|
export declare const M_VSUI = "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT";
|
|
7
7
|
export declare const M_VAPOR = "0xa1f2c11169f32165ad4efb4468ec5bdfc880cd66b22094024b32ab7b76d14d30::vapor::VAPOR";
|
|
8
8
|
export declare const M_HASUI = "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI";
|
|
9
|
+
export declare const M_SSWP = "0x361dd589b98e8fcda9a7ee53b85efabef3569d00416640d2faa516e3801d7ffc::TOKEN::TOKEN";
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
Transaction,
|
|
5
5
|
TransactionObjectArgument,
|
|
6
6
|
} from "@mysten/sui/transactions"
|
|
7
|
-
import { Signer } from "@mysten/sui/
|
|
7
|
+
import { Signer } from "@mysten/sui/cryptography"
|
|
8
8
|
import BN from "bn.js"
|
|
9
9
|
import { SUI_FRAMEWORK_ADDRESS } from "@mysten/sui/utils"
|
|
10
10
|
import {
|
|
@@ -30,11 +30,13 @@ import { KriyaV3 } from "./transaction/kriya_v3"
|
|
|
30
30
|
import { Haedal } from "./transaction/haedal"
|
|
31
31
|
import { Afsui } from "./transaction/afsui"
|
|
32
32
|
import { Volo } from "./transaction/volo"
|
|
33
|
+
import { FlowxV3 } from "./transaction/flowx_v3"
|
|
33
34
|
|
|
34
35
|
export const CETUS = "CETUS"
|
|
35
36
|
export const DEEPBOOKV2 = "DEEPBOOK"
|
|
36
37
|
export const KRIYA = "KRIYA"
|
|
37
38
|
export const FLOWXV2 = "FLOWX"
|
|
39
|
+
export const FLOWXV3 = "FLOWXV3"
|
|
38
40
|
export const KRIYAV3 = "KRIYAV3"
|
|
39
41
|
export const TURBOS = "TURBOS"
|
|
40
42
|
export const AFTERMATH = "AFTERMATH"
|
|
@@ -201,7 +203,7 @@ export class AggregatorClient {
|
|
|
201
203
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) })
|
|
202
204
|
txb.moveCall({
|
|
203
205
|
target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
|
|
204
|
-
typeArguments: [routers[0].path[0].
|
|
206
|
+
typeArguments: [routers[0].path[routers[0].path.length - 1].target],
|
|
205
207
|
arguments: [targetCoins[0], vec],
|
|
206
208
|
})
|
|
207
209
|
}
|
|
@@ -333,7 +335,7 @@ export class AggregatorClient {
|
|
|
333
335
|
|
|
334
336
|
publishedAt(): string {
|
|
335
337
|
if (this.env === Env.Mainnet) {
|
|
336
|
-
return "
|
|
338
|
+
return "0x98c07fd55b56dfb5dfb573aa52a227d741af2ffa17d51a5d208e214a4bc27f07"
|
|
337
339
|
} else {
|
|
338
340
|
return "0x0"
|
|
339
341
|
}
|
|
@@ -388,6 +390,8 @@ export class AggregatorClient {
|
|
|
388
390
|
return new KriyaV3(this.env)
|
|
389
391
|
case FLOWXV2:
|
|
390
392
|
return new FlowxV2(this.env)
|
|
393
|
+
case FLOWXV3:
|
|
394
|
+
return new FlowxV3(this.env)
|
|
391
395
|
case TURBOS:
|
|
392
396
|
return new Turbos(this.env)
|
|
393
397
|
case AFTERMATH:
|
package/src/const.ts
CHANGED
|
@@ -1,82 +1,5 @@
|
|
|
1
1
|
import BN from "bn.js"
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* The address representing the clock in the system.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The address for CoinInfo module.
|
|
9
|
-
*/
|
|
10
|
-
export const CoinInfoAddress = "0x1::coin::CoinInfo"
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The address for CoinStore module.
|
|
14
|
-
*/
|
|
15
|
-
export const CoinStoreAddress = "0x1::coin::CoinStore"
|
|
16
|
-
|
|
17
|
-
export const SuiZeroCoinFn = "0x2::coin::zero"
|
|
18
|
-
|
|
19
|
-
// Module names
|
|
20
|
-
export const CETUS_MODULE = "cetus"
|
|
21
|
-
export const DEEPBOOK_MODULE = "deepbook"
|
|
22
|
-
export const KRIYA_MODULE = "kriya"
|
|
23
|
-
export const UTILS_MODULE = "utils"
|
|
24
|
-
export const POOL_MODULT = "pool"
|
|
25
|
-
export const PAY_MODULE = "pay"
|
|
26
|
-
export const FLOWX_AMM_MODULE = "flowx_amm"
|
|
27
|
-
export const TURBOS_MODULE = "turbos"
|
|
28
|
-
export const AFTERMATH_MODULE = "aftermath"
|
|
29
|
-
|
|
30
|
-
export const DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2"
|
|
31
|
-
export const DEEPBOOK_CLOB_V2_MODULE = "clob_v2"
|
|
32
|
-
|
|
33
|
-
// Function names
|
|
34
|
-
export const FlashSwapFunc = "flash_swap"
|
|
35
|
-
export const FlashSwapWithPartnerFunc = "flash_swap_with_partner"
|
|
36
|
-
export const RepayFalshSwapFunc = "repay_flash_swap"
|
|
37
|
-
export const RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner"
|
|
38
|
-
|
|
39
|
-
export const FlashSwapA2BFunc = "flash_swap_a2b"
|
|
40
|
-
export const FlashSwapB2AFunc = "flash_swap_b2a"
|
|
41
|
-
|
|
42
|
-
export const FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b"
|
|
43
|
-
export const FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a"
|
|
44
|
-
|
|
45
|
-
export const REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b"
|
|
46
|
-
export const REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a"
|
|
47
|
-
|
|
48
|
-
export const REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC =
|
|
49
|
-
"repay_flash_swap_with_partner_a2b"
|
|
50
|
-
export const REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC =
|
|
51
|
-
"repay_flash_swap_with_partner_b2a"
|
|
52
|
-
|
|
53
|
-
export const SWAP_A2B_FUNC = "swap_a2b"
|
|
54
|
-
export const SWAP_B2A_FUNC = "swap_b2a"
|
|
55
|
-
|
|
56
|
-
export const TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin"
|
|
57
|
-
export const CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold"
|
|
58
|
-
|
|
59
|
-
export const JOIN_FUNC = "join_vec"
|
|
60
|
-
|
|
61
|
-
export const TRANSFER_ACCOUNT_CAP = "transfer_account_cap"
|
|
62
|
-
|
|
63
|
-
// Package IDs
|
|
64
|
-
export const DEEPBOOK_PACKAGE_ID =
|
|
65
|
-
"0x000000000000000000000000000000000000000000000000000000000000dee9"
|
|
66
|
-
export const DEEPBOOK_PUBLISHED_AT =
|
|
67
|
-
"0x000000000000000000000000000000000000000000000000000000000000dee9"
|
|
68
|
-
|
|
69
|
-
export const CETUS_PUBLISHED_AT =
|
|
70
|
-
"0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a"
|
|
71
|
-
|
|
72
|
-
// Mainnet Cetus objects IDs
|
|
73
|
-
export const MAINNET_CETUS_GLOBAL_CONFIG_ID =
|
|
74
|
-
"0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f"
|
|
75
|
-
|
|
76
|
-
// Testnet Cetus objects IDs
|
|
77
|
-
export const TESTNET_CETUS_GLOBAL_CONFIG_ID =
|
|
78
|
-
"0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a"
|
|
79
|
-
|
|
80
3
|
export const ZERO = new BN(0)
|
|
81
4
|
|
|
82
5
|
export const ONE = new BN(1)
|
|
@@ -90,26 +13,3 @@ export const U64_MAX_BN = new BN("18446744073709551615")
|
|
|
90
13
|
export const U64_MAX = "18446744073709551615"
|
|
91
14
|
|
|
92
15
|
export const TEN_POW_NINE = 1000000000
|
|
93
|
-
|
|
94
|
-
export const MAINNET_FLOWX_AMM_CONTAINER_ID =
|
|
95
|
-
"0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511"
|
|
96
|
-
export const TESTNET_FLOWX_AMM_CONTAINER_ID = ""
|
|
97
|
-
|
|
98
|
-
export const TURBOS_VERSIONED =
|
|
99
|
-
"0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f"
|
|
100
|
-
|
|
101
|
-
export const MAINNET_AFTERMATH_REGISTRY_ID =
|
|
102
|
-
"0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae"
|
|
103
|
-
export const TESTNET_AFTERMATH_REGISTRY_ID = ""
|
|
104
|
-
export const MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID =
|
|
105
|
-
"0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4"
|
|
106
|
-
export const TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = ""
|
|
107
|
-
export const MAINNET_AFTERMATH_TREASURY_ID =
|
|
108
|
-
"0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce"
|
|
109
|
-
export const TESTNET_AFTERMATH_TREASURY_ID = ""
|
|
110
|
-
export const MAINNET_AFTERMATH_INSURANCE_FUND_ID =
|
|
111
|
-
"0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b"
|
|
112
|
-
export const TESTNET_AFTERMATH_INSURANCE_FUND_ID = ""
|
|
113
|
-
export const MAINNET_AFTERMATH_REFERRAL_VAULT_ID =
|
|
114
|
-
"0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278"
|
|
115
|
-
export const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = ""
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Transaction,
|
|
3
|
+
TransactionObjectArgument,
|
|
4
|
+
} from "@mysten/sui/transactions"
|
|
5
|
+
import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
|
|
6
|
+
|
|
7
|
+
export class FlowxV3 implements Dex {
|
|
8
|
+
private versioned: string
|
|
9
|
+
private poolRegistry: string
|
|
10
|
+
|
|
11
|
+
constructor(env: Env) {
|
|
12
|
+
if (env !== Env.Mainnet) {
|
|
13
|
+
throw new Error("Flowx clmm only supported on mainnet")
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
this.versioned =
|
|
17
|
+
"0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656"
|
|
18
|
+
this.poolRegistry =
|
|
19
|
+
"0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async swap(
|
|
23
|
+
client: AggregatorClient,
|
|
24
|
+
txb: Transaction,
|
|
25
|
+
path: Path,
|
|
26
|
+
inputCoin: TransactionObjectArgument
|
|
27
|
+
): Promise<TransactionObjectArgument> {
|
|
28
|
+
const { direction, from, target } = path
|
|
29
|
+
|
|
30
|
+
const [func, coinAType, coinBType] = direction
|
|
31
|
+
? ["swap_a2b", from, target]
|
|
32
|
+
: ["swap_b2a", target, from]
|
|
33
|
+
|
|
34
|
+
const args = [
|
|
35
|
+
txb.object(this.poolRegistry),
|
|
36
|
+
txb.pure.u64(path.feeRate * 1000000),
|
|
37
|
+
inputCoin,
|
|
38
|
+
txb.object(this.versioned),
|
|
39
|
+
txb.object(CLOCK_ADDRESS),
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
const res = txb.moveCall({
|
|
43
|
+
target: `${client.publishedAt()}::flowx_clmm::${func}`,
|
|
44
|
+
typeArguments: [coinAType, coinBType],
|
|
45
|
+
arguments: args,
|
|
46
|
+
}) as TransactionObjectArgument
|
|
47
|
+
|
|
48
|
+
return res
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
TransactionObjectArgument,
|
|
4
4
|
} from "@mysten/sui/transactions"
|
|
5
5
|
import { AggregatorClient, Dex, Env, Path } from ".."
|
|
6
|
-
import { SUI_SYSTEM_ADDRESS } from "@mysten/sui/utils"
|
|
7
6
|
|
|
8
7
|
export class Haedal implements Dex {
|
|
9
8
|
constructor(env: Env) {
|
|
@@ -19,17 +18,11 @@ export class Haedal implements Dex {
|
|
|
19
18
|
inputCoin: TransactionObjectArgument
|
|
20
19
|
): Promise<TransactionObjectArgument> {
|
|
21
20
|
const { direction } = path
|
|
22
|
-
|
|
23
21
|
if (!direction) {
|
|
24
22
|
throw new Error("Haedal not support b2a swap")
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
const func = "swap_a2b"
|
|
28
|
-
|
|
29
|
-
console.log("haedal path id", path.id)
|
|
30
|
-
|
|
31
25
|
const args = [txb.object(path.id), txb.object("0x5"), inputCoin]
|
|
32
|
-
|
|
33
26
|
const res = txb.moveCall({
|
|
34
27
|
target: `${client.publishedAt()}::haedal::${func}`,
|
|
35
28
|
typeArguments: [],
|
package/src/utils/coin.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SuiZeroCoinFn } from "../const"
|
|
2
1
|
import { CoinAsset } from "../types/sui"
|
|
3
2
|
import { CoinUtils } from "../types/CoinAssist"
|
|
4
3
|
import { TransactionErrorCode } from "../errors"
|
|
@@ -47,7 +46,7 @@ export function mintZeroCoin(
|
|
|
47
46
|
coinType: string
|
|
48
47
|
): TransactionObjectArgument {
|
|
49
48
|
return txb.moveCall({
|
|
50
|
-
target:
|
|
49
|
+
target: "0x2::coin::zero",
|
|
51
50
|
typeArguments: [coinType],
|
|
52
51
|
})
|
|
53
52
|
}
|
package/src/utils/transaction.ts
CHANGED
package/tests/router.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, test } from "@jest/globals"
|
|
2
2
|
import dotenv from "dotenv"
|
|
3
3
|
import { AggregatorClient } from "~/client"
|
|
4
|
-
import { M_CETUS, M_NAVI, M_SUI, M_USDC } from "./test_data.test"
|
|
4
|
+
import { M_CETUS, M_NAVI, M_SSWP, M_SUI, M_USDC } from "./test_data.test"
|
|
5
5
|
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"
|
|
6
6
|
import { printTransaction } from "~/utils/transaction"
|
|
7
7
|
import BN from "bn.js"
|
|
@@ -33,14 +33,14 @@ describe("router module", () => {
|
|
|
33
33
|
keypair = buildTestAccount()
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const wallet = keypair.getPublicKey().toSuiAddress()
|
|
36
|
+
// const wallet = keypair.getPublicKey().toSuiAddress()
|
|
37
37
|
|
|
38
38
|
// console.log("wallet", wallet, "\n", wallet.toString())
|
|
39
39
|
|
|
40
|
+
const wallet =
|
|
41
|
+
"0xfba94aa36e93ccc7d84a6a57040fc51983223f1b522a8d0be3c3bf2c98977ebb"
|
|
40
42
|
// const wallet =
|
|
41
|
-
//
|
|
42
|
-
// const wallet =
|
|
43
|
-
// "0xa459702162b73204eed77420d93d9453b7a7b893a0edea1e268607cf7fa76e03"
|
|
43
|
+
// "0xa459702162b73204eed77420d93d9453b7a7b893a0edea1e268607cf7fa76e03"
|
|
44
44
|
// const wallet =
|
|
45
45
|
// "0xaabf2fedcb36146db164bec930b74a47969c4df98216e049342a3c49b6d11580"
|
|
46
46
|
// const wallet = "0x410456cfc689666936b6bf80fbec958b69499b9f7183ecba07de577c17248a44"
|
|
@@ -139,8 +139,7 @@ describe("router module", () => {
|
|
|
139
139
|
// const target =
|
|
140
140
|
// "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI"
|
|
141
141
|
|
|
142
|
-
const target =
|
|
143
|
-
"0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
|
|
142
|
+
const target = M_USDC
|
|
144
143
|
|
|
145
144
|
const res = await client.findRouters({
|
|
146
145
|
from,
|
|
@@ -156,7 +155,7 @@ describe("router module", () => {
|
|
|
156
155
|
// "KRIYA",
|
|
157
156
|
// "KRIYAV3",
|
|
158
157
|
// "TURBOS",
|
|
159
|
-
"
|
|
158
|
+
"FLOWXV3",
|
|
160
159
|
],
|
|
161
160
|
})
|
|
162
161
|
|
|
@@ -195,6 +194,51 @@ describe("router module", () => {
|
|
|
195
194
|
}
|
|
196
195
|
}, 600000)
|
|
197
196
|
|
|
197
|
+
test("By amount out", async () => {
|
|
198
|
+
const byAmountIn = false
|
|
199
|
+
const amount = "10000000000"
|
|
200
|
+
|
|
201
|
+
const from = M_USDC
|
|
202
|
+
const target = M_SSWP
|
|
203
|
+
|
|
204
|
+
const res = await client.findRouters({
|
|
205
|
+
from,
|
|
206
|
+
target,
|
|
207
|
+
amount: new BN(amount),
|
|
208
|
+
byAmountIn,
|
|
209
|
+
depth: 3,
|
|
210
|
+
providers: ["CETUS"],
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
console.log("amount in", res?.amountIn.toString())
|
|
214
|
+
console.log("amount out", res?.amountOut.toString())
|
|
215
|
+
|
|
216
|
+
const txb = new Transaction()
|
|
217
|
+
if (res != null) {
|
|
218
|
+
console.log(JSON.stringify(res, null, 2))
|
|
219
|
+
await client.fastRouterSwap({
|
|
220
|
+
routers: res.routes,
|
|
221
|
+
byAmountIn,
|
|
222
|
+
txb,
|
|
223
|
+
slippage: 0.02,
|
|
224
|
+
isMergeTragetCoin: false,
|
|
225
|
+
refreshAllCoins: true,
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
printTransaction(txb)
|
|
229
|
+
|
|
230
|
+
let result = await client.devInspectTransactionBlock(txb)
|
|
231
|
+
|
|
232
|
+
if (result.effects.status.status === "success") {
|
|
233
|
+
console.log("Sim exec transaction success")
|
|
234
|
+
// const result = await client.signAndExecuteTransaction(txb, keypair)
|
|
235
|
+
// console.log("result", result)
|
|
236
|
+
} else {
|
|
237
|
+
console.log("result", result)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}, 600000)
|
|
241
|
+
|
|
198
242
|
test("Test Multi Input", async () => {
|
|
199
243
|
const amounts = [1000000000, 2000000000, 10000000000000]
|
|
200
244
|
const froms = [M_USDC, M_SUI, M_CETUS, M_NAVI]
|
package/tests/test_data.test.ts
CHANGED
|
@@ -15,3 +15,5 @@ export const M_VAPOR =
|
|
|
15
15
|
"0xa1f2c11169f32165ad4efb4468ec5bdfc880cd66b22094024b32ab7b76d14d30::vapor::VAPOR"
|
|
16
16
|
export const M_HASUI =
|
|
17
17
|
"0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
|
|
18
|
+
export const M_SSWP =
|
|
19
|
+
"0x361dd589b98e8fcda9a7ee53b85efabef3569d00416640d2faa516e3801d7ffc::TOKEN::TOKEN"
|