@cetusprotocol/aggregator-sdk 0.0.1

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.
Files changed (66) hide show
  1. package/.env.example +4 -0
  2. package/README.md +128 -0
  3. package/bun.lockb +0 -0
  4. package/dist/index.d.mts +266 -0
  5. package/dist/index.d.ts +266 -0
  6. package/dist/index.js +6817 -0
  7. package/dist/index.mjs +6738 -0
  8. package/dist/src/client.d.ts +87 -0
  9. package/dist/src/config.d.ts +26 -0
  10. package/dist/src/const.d.ts +75 -0
  11. package/dist/src/errors.d.ts +31 -0
  12. package/dist/src/index.d.ts +5 -0
  13. package/dist/src/math.d.ts +5 -0
  14. package/dist/src/test_data.test.d.ts +8 -0
  15. package/dist/src/transaction/aftermath.d.ts +24 -0
  16. package/dist/src/transaction/cetus.d.ts +39 -0
  17. package/dist/src/transaction/common.d.ts +12 -0
  18. package/dist/src/transaction/deepbook.d.ts +21 -0
  19. package/dist/src/transaction/flowx.d.ts +20 -0
  20. package/dist/src/transaction/index.d.ts +1 -0
  21. package/dist/src/transaction/kriya.d.ts +21 -0
  22. package/dist/src/transaction/router.d.ts +6 -0
  23. package/dist/src/transaction/swap.d.ts +5 -0
  24. package/dist/src/transaction/turbos.d.ts +22 -0
  25. package/dist/src/types/CoinAssist.d.ts +122 -0
  26. package/dist/src/types/sui.d.ts +112 -0
  27. package/dist/src/utils/account_cap.d.ts +7 -0
  28. package/dist/src/utils/coin.d.ts +4 -0
  29. package/dist/src/utils/coin.spec.d.ts +1 -0
  30. package/dist/src/utils/contracts.d.ts +16 -0
  31. package/dist/src/utils/index.d.ts +1 -0
  32. package/dist/src/utils/transaction.d.ts +3 -0
  33. package/dist/tests/router.test.d.ts +2 -0
  34. package/dist/tests/wallet.test.d.ts +1 -0
  35. package/jest.config.mjs +13 -0
  36. package/package.json +41 -0
  37. package/src/client.ts +383 -0
  38. package/src/config.ts +65 -0
  39. package/src/const.ts +126 -0
  40. package/src/errors.ts +44 -0
  41. package/src/index.ts +5 -0
  42. package/src/math.ts +37 -0
  43. package/src/test_data.test.ts +17 -0
  44. package/src/transaction/aftermath.ts +143 -0
  45. package/src/transaction/cetus.ts +282 -0
  46. package/src/transaction/common.ts +169 -0
  47. package/src/transaction/deepbook.ts +126 -0
  48. package/src/transaction/flowx.ts +98 -0
  49. package/src/transaction/index.ts +1 -0
  50. package/src/transaction/kriya.ts +77 -0
  51. package/src/transaction/router.ts +345 -0
  52. package/src/transaction/swap.ts +163 -0
  53. package/src/transaction/turbos.ts +114 -0
  54. package/src/types/CoinAssist.ts +217 -0
  55. package/src/types/sui.ts +148 -0
  56. package/src/utils/account_cap.ts +62 -0
  57. package/src/utils/coin.spec.ts +10 -0
  58. package/src/utils/coin.ts +61 -0
  59. package/src/utils/contracts.ts +136 -0
  60. package/src/utils/index.ts +1 -0
  61. package/src/utils/transaction.ts +20 -0
  62. package/tests/router.test.ts +249 -0
  63. package/tests/wallet.test.ts +17 -0
  64. package/tsconfig.json +22 -0
  65. package/tsup.config.ts +23 -0
  66. package/version.mjs +28 -0
@@ -0,0 +1,7 @@
1
+ import { SuiClient } from "@mysten/sui/client";
2
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
3
+ export type GetOrCreateAccountCapResult = {
4
+ accountCap: TransactionObjectArgument;
5
+ isCreate: boolean;
6
+ };
7
+ export declare function getOrCreateAccountCap(txb: Transaction, client: SuiClient, owner: string): Promise<GetOrCreateAccountCapResult>;
@@ -0,0 +1,4 @@
1
+ export declare function completionCoin(s: string): string;
2
+ export declare function compareCoins(coinA: string, coinB: string): boolean;
3
+ export declare function parseTurbosPoolFeeType(typeData: string): string | null;
4
+ export declare function parseAftermathFeeType(typeData: string): string | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { SuiAddress, SuiStructTag } from '../types/sui';
2
+ export declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
3
+ export declare function composeType(address: string, generics: SuiAddress[]): SuiAddress;
4
+ export declare function composeType(address: string, struct: string, generics?: SuiAddress[]): SuiAddress;
5
+ export declare function composeType(address: string, module: string, struct: string, generics?: SuiAddress[]): SuiAddress;
6
+ export declare function extractAddressFromType(type: string): string;
7
+ export declare function extractStructTagFromType(type: string): SuiStructTag;
8
+ export declare function normalizeCoinType(coinType: string): string;
9
+ export declare function fixSuiObjectId(value: string): string;
10
+ /**
11
+ * Recursively traverses the given data object and patches any string values that represent Sui object IDs.
12
+ *
13
+ * @param {any} data - The data object to be patched.
14
+ */
15
+ export declare function patchFixSuiObjectId(data: any): void;
16
+ export declare function createTarget(packageName: string, moduleName: string, functionName: string): `${string}::${string}::${string}`;
@@ -0,0 +1 @@
1
+ export * from './contracts';
@@ -0,0 +1,3 @@
1
+ import { Transaction } from "@mysten/sui/transactions";
2
+ export declare function printTransaction(tx: Transaction, isPrint?: boolean): Promise<void>;
3
+ export declare function checkInvalidSuiAddress(address: string): boolean;
@@ -0,0 +1,2 @@
1
+ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
2
+ export declare function buildTestAccount(): Ed25519Keypair;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ // jest.config.mjs
2
+ export default {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+ transform: {
6
+ '^.+\\.tsx?$': ['ts-jest', {
7
+ tsconfig: './tsconfig.json'
8
+ }]
9
+ },
10
+ moduleNameMapper: {
11
+ '^~/(.*)$': '<rootDir>/src/$1'
12
+ }
13
+ };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@cetusprotocol/aggregator-sdk",
3
+ "version": "0.0.1",
4
+ "sideEffects": false,
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "module": "dist/index.js",
8
+ "scripts": {
9
+ "build": "tsup --format cjs,esm --dts",
10
+ "dev": "tsup --watch",
11
+ "test": "node -r esm node_modules/.bin/jest",
12
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
13
+ "publish:test": "node version.mjs && npm publish --tag experimental"
14
+ },
15
+ "devDependencies": {
16
+ "@types/bn.js": "^5.1.5",
17
+ "@types/bun": "latest",
18
+ "bn.js": "^5.2.1",
19
+ "decimal.js": "^10.4.3",
20
+ "tsup": "^8.0.2"
21
+ },
22
+ "peerDependencies": {
23
+ "typescript": "^5.0.0"
24
+ },
25
+ "dependencies": {
26
+ "@babel/core": "^7.24.5",
27
+ "@babel/preset-env": "^7.24.5",
28
+ "@babel/preset-typescript": "^7.24.1",
29
+ "@jest/globals": "^29.7.0",
30
+ "@mysten/sui": "^1.0.5",
31
+ "@types/jest": "^29.5.12",
32
+ "@types/node": "^20.12.12",
33
+ "babel-jest": "^29.7.0",
34
+ "bip39": "^3.1.0",
35
+ "dotenv": "^16.4.5",
36
+ "jest": "^29.7.0",
37
+ "node-fetch": "^3.3.2",
38
+ "ts-jest": "^29.1.3",
39
+ "typescript": "^5.4.5"
40
+ }
41
+ }
package/src/client.ts ADDED
@@ -0,0 +1,383 @@
1
+ import type { AggregatorConfig } from "./config"
2
+ import Decimal from "decimal.js"
3
+ import { SuiClient } from "@mysten/sui/client"
4
+ import { CoinAsset } from "./types/sui"
5
+ import { createTarget, extractStructTagFromType } from "./utils"
6
+ import { Transaction } from "@mysten/sui/transactions"
7
+ import {
8
+ buildInputCoin,
9
+ checkCoinThresholdAndMergeCoin,
10
+ transferOrDestoryCoin,
11
+ } from "./transaction/common"
12
+ import { expectInputRouterSwap, expectOutputRouterSwap } from "./transaction"
13
+ import { CalculateAmountLimit } from "./math"
14
+ import { Signer } from "@mysten/sui/dist/cjs/cryptography"
15
+ import BN from "bn.js"
16
+ import { swapInPools } from "./transaction/swap"
17
+ import { completionCoin } from "./utils/coin"
18
+ import { SUI_FRAMEWORK_ADDRESS } from "@mysten/sui/utils"
19
+ import { AFTERMATH_AMM, JOIN_FUNC, PAY_MODULE, TURBOS_DEX } from "./const"
20
+
21
+ export type ExtendedDetails = {
22
+ aftermathPoolFlatness?: number
23
+ aftermathLpSupplyType?: string
24
+ turbosFeeType?: string
25
+ }
26
+
27
+ export type Path = {
28
+ id: string
29
+ a2b: boolean
30
+ provider: string
31
+ from: string
32
+ target: string
33
+ feeRate: number
34
+ amountIn: number
35
+ amountOut: number
36
+ extendedDetails?: ExtendedDetails
37
+ version?: string
38
+ }
39
+
40
+ export type Router = {
41
+ path: Path[]
42
+ amountIn: BN
43
+ amountOut: BN
44
+ initialPrice: Decimal
45
+ }
46
+
47
+ export type RouterData = {
48
+ amountIn: BN
49
+ amountOut: BN
50
+ routes: Router[]
51
+ }
52
+
53
+ export type AggregatorResponse = {
54
+ code: number
55
+ msg: string
56
+ data: RouterData
57
+ }
58
+
59
+ export type BuildRouterSwapParams = {
60
+ routers: Router[]
61
+ amountIn: BN
62
+ amountOut: BN
63
+ byAmountIn: boolean
64
+ slippage: number
65
+ fromCoinType: string
66
+ targetCoinType: string
67
+ partner?: string
68
+ isMergeTragetCoin?: boolean
69
+ refreshAllCoins?: boolean
70
+ }
71
+
72
+ export interface FindRouterParams {
73
+ from: string
74
+ target: string
75
+ amount: BN
76
+ byAmountIn: boolean
77
+ depth: number | null
78
+ splitAlgorithm: string | null
79
+ splitFactor: number | null
80
+ splitCount: number | null
81
+ providers: string[] | null
82
+ }
83
+
84
+ export interface SwapInPoolsParams {
85
+ from: string
86
+ target: string
87
+ amount: BN
88
+ byAmountIn: boolean
89
+ pools: string[]
90
+ }
91
+
92
+ export interface SwapInPoolsResult {
93
+ isExceed: boolean
94
+ routeData?: RouterData
95
+ }
96
+
97
+ export class AggregatorClient {
98
+ private config: AggregatorConfig
99
+
100
+ private wallet: string
101
+
102
+ private client: SuiClient
103
+
104
+ private allCoins: CoinAsset[]
105
+
106
+ constructor(config: AggregatorConfig) {
107
+ this.config = config
108
+ this.client = new SuiClient({ url: config.getFullNodeUrl() })
109
+ this.wallet = config.getWallet()
110
+ this.allCoins = []
111
+ }
112
+
113
+ async getAllCoins(): Promise<CoinAsset[]> {
114
+ let cursor = null
115
+ let limit = 50
116
+
117
+ const allCoins: CoinAsset[] = []
118
+
119
+ while (true) {
120
+ const gotAllCoins = await this.client.getAllCoins({
121
+ owner: this.wallet,
122
+ cursor,
123
+ limit,
124
+ })
125
+ for (const coin of gotAllCoins.data) {
126
+ allCoins.push({
127
+ coinAddress: extractStructTagFromType(coin.coinType).source_address,
128
+ coinObjectId: coin.coinObjectId,
129
+ balance: BigInt(coin.balance),
130
+ })
131
+ }
132
+
133
+ if (gotAllCoins.data.length < limit) {
134
+ break
135
+ }
136
+ cursor = gotAllCoins.data[limit - 1].coinObjectId
137
+ }
138
+
139
+ return allCoins
140
+ }
141
+
142
+ async findRouter(
143
+ fromRouterParams: FindRouterParams
144
+ ): Promise<RouterData | null> {
145
+ const {
146
+ from,
147
+ target,
148
+ amount,
149
+ byAmountIn,
150
+ depth,
151
+ splitAlgorithm,
152
+ splitFactor,
153
+ splitCount,
154
+ providers,
155
+ } = fromRouterParams
156
+ const fromCoin = completionCoin(from)
157
+ const targetCoin = completionCoin(target)
158
+
159
+ let url =
160
+ this.config.getAggregatorUrl() +
161
+ `/find_routes?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`
162
+
163
+ if (depth) {
164
+ url += `&depth=${depth}`
165
+ }
166
+
167
+ if (splitAlgorithm) {
168
+ url += `&split_algorithm=${splitAlgorithm}`
169
+ }
170
+
171
+ if (splitFactor) {
172
+ url += `&split_factor=${splitFactor}`
173
+ }
174
+
175
+ if (splitCount) {
176
+ url += `&split_count=${splitCount}`
177
+ }
178
+
179
+ if (providers) {
180
+ if (providers.length > 0) {
181
+ url += `&providers=${providers.join(",")}`
182
+ }
183
+ }
184
+
185
+ const response = await fetch(url)
186
+ const data = await response.json()
187
+
188
+ if (data.data != null) {
189
+ const res = parseRouterResponse(data.data)
190
+ return res
191
+ }
192
+
193
+ return null
194
+ }
195
+
196
+ async swapInPools(
197
+ params: SwapInPoolsParams
198
+ ): Promise<SwapInPoolsResult | null> {
199
+ let result
200
+ try {
201
+ result = await swapInPools(this.client, params, this.config)
202
+ } catch (e) {
203
+ return null
204
+ }
205
+
206
+ return result
207
+ }
208
+
209
+ async routerSwap(params: BuildRouterSwapParams): Promise<Transaction> {
210
+ const {
211
+ routers: _,
212
+ amountIn,
213
+ amountOut,
214
+ byAmountIn,
215
+ slippage,
216
+ fromCoinType,
217
+ targetCoinType,
218
+ partner,
219
+ isMergeTragetCoin,
220
+ refreshAllCoins,
221
+ } = params
222
+ const amountLimit = CalculateAmountLimit(
223
+ byAmountIn ? amountOut : amountIn,
224
+ byAmountIn,
225
+ slippage
226
+ )
227
+
228
+ const txb = new Transaction()
229
+
230
+ if (refreshAllCoins || this.allCoins.length === 0) {
231
+ this.allCoins = await this.getAllCoins()
232
+ }
233
+
234
+ const allCoins = this.allCoins
235
+ let targetCoins = []
236
+
237
+ if (byAmountIn) {
238
+ const buildFromCoinRes = buildInputCoin(
239
+ txb,
240
+ allCoins,
241
+ BigInt(amountIn.toString()),
242
+ fromCoinType
243
+ )
244
+ const fromCoin = buildFromCoinRes.targetCoin
245
+ const swapedCoins = await expectInputRouterSwap(
246
+ this.client,
247
+ params,
248
+ txb,
249
+ fromCoin,
250
+ this.config,
251
+ partner
252
+ )
253
+ const mergedCoin = checkCoinThresholdAndMergeCoin(
254
+ txb,
255
+ swapedCoins,
256
+ targetCoinType,
257
+ amountLimit,
258
+ this.config
259
+ )
260
+ targetCoins.push(mergedCoin)
261
+ } else {
262
+ const fromCoin = buildInputCoin(
263
+ txb,
264
+ allCoins,
265
+ BigInt(amountLimit),
266
+ fromCoinType
267
+ ).targetCoin
268
+ const swapedCoins = await expectOutputRouterSwap(
269
+ params,
270
+ txb,
271
+ fromCoin,
272
+ this.config,
273
+ partner
274
+ )
275
+ targetCoins.push(...swapedCoins)
276
+ }
277
+
278
+ if (isMergeTragetCoin) {
279
+ const targetCoinRes = buildInputCoin(
280
+ txb,
281
+ allCoins,
282
+ BigInt(0),
283
+ targetCoinType
284
+ )
285
+ txb.mergeCoins(targetCoinRes.targetCoin, targetCoins)
286
+ if (targetCoinRes.isMintZeroCoin) {
287
+ transferOrDestoryCoin(
288
+ txb,
289
+ targetCoinRes.targetCoin,
290
+ targetCoinType,
291
+ this.config
292
+ )
293
+ }
294
+ } else {
295
+ if (targetCoins.length > 1) {
296
+ const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) })
297
+ txb.moveCall({
298
+ target: createTarget(SUI_FRAMEWORK_ADDRESS, PAY_MODULE, JOIN_FUNC),
299
+ typeArguments: [targetCoinType],
300
+ arguments: [targetCoins[0], vec],
301
+ })
302
+ }
303
+ transferOrDestoryCoin(txb, targetCoins[0], targetCoinType, this.config)
304
+ }
305
+
306
+ return txb
307
+ }
308
+
309
+ async signAndExecuteTransaction(txb: Transaction, signer: Signer) {
310
+ const res = await this.client.signAndExecuteTransaction({
311
+ transaction: txb,
312
+ signer,
313
+ options: {
314
+ showEffects: true,
315
+ showEvents: true,
316
+ showInput: true,
317
+ showBalanceChanges: true,
318
+ },
319
+ })
320
+ return res
321
+ }
322
+
323
+ async devInspectTransactionBlock(txb: Transaction, signer: Signer) {
324
+ const res = await this.client.devInspectTransactionBlock({
325
+ transactionBlock: txb,
326
+ sender: signer.getPublicKey().toSuiAddress(),
327
+ })
328
+
329
+ return res
330
+ }
331
+
332
+ async sendTransaction(txb: Transaction, signer: Signer) {
333
+ const res = await this.client.signAndExecuteTransaction({
334
+ transaction: txb,
335
+ signer,
336
+ })
337
+
338
+ return res
339
+ }
340
+ }
341
+
342
+ function parseRouterResponse(data: any): RouterData {
343
+ return {
344
+ amountIn: new BN(data.amount_in.toString()),
345
+ amountOut: new BN(data.amount_out.toString()),
346
+ routes: data.routes.map((route: any) => {
347
+ return {
348
+ path: route.path.map((path: any) => {
349
+ let version
350
+ if (path.provider === AFTERMATH_AMM) {
351
+ version =
352
+ path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3"
353
+ }
354
+
355
+ let extendedDetails
356
+ if (path.provider === TURBOS_DEX || path.provider === AFTERMATH_AMM) {
357
+ extendedDetails = {
358
+ aftermathLpSupplyType:
359
+ path.extended_details?.aftermath_lp_supply_type,
360
+ turbosFeeType: path.extended_details?.turbos_fee_type,
361
+ }
362
+ }
363
+
364
+ return {
365
+ id: path.id,
366
+ a2b: path.direction,
367
+ provider: path.provider,
368
+ from: path.from,
369
+ target: path.target,
370
+ feeRate: path.fee_rate,
371
+ amountIn: path.amount_in,
372
+ amountOut: path.amount_out,
373
+ extendedDetails,
374
+ version,
375
+ }
376
+ }),
377
+ amountIn: new BN(route.amount_in.toString()),
378
+ amountOut: new BN(route.amount_out.toString()),
379
+ initialPrice: new Decimal(route.initial_price.toString()),
380
+ }
381
+ }),
382
+ }
383
+ }
package/src/config.ts ADDED
@@ -0,0 +1,65 @@
1
+ export type Package = {
2
+ packageName: string
3
+ packageId: string
4
+ publishedAt: string
5
+ }
6
+
7
+ export enum ENV {
8
+ MAINNET,
9
+ TESTNET,
10
+ }
11
+
12
+ export class AggregatorConfig {
13
+ private aggregatorUrl: string;
14
+ private fullNodeUrl: string;
15
+ private wallet: string;
16
+ private packages: Package[];
17
+ private env: ENV;
18
+
19
+ constructor(aggregatorUrl: string, fullNodeUrl: string, wallet: string, packages: Package[], env: ENV) {
20
+ this.aggregatorUrl = aggregatorUrl;
21
+ this.fullNodeUrl = fullNodeUrl;
22
+ this.wallet = wallet;
23
+ this.packages = packages;
24
+ this.env = env;
25
+ }
26
+
27
+ getAggregatorUrl(): string {
28
+ return this.aggregatorUrl;
29
+ }
30
+
31
+ getFullNodeUrl(): string {
32
+ return this.fullNodeUrl;
33
+ }
34
+
35
+ getWallet(): string {
36
+ return this.wallet;
37
+ }
38
+
39
+ getENV(): ENV {
40
+ return this.env
41
+ }
42
+
43
+ getPackages(): Package[] {
44
+ return this.packages;
45
+ }
46
+
47
+ getPackage(packageName: string) {
48
+ return this.packages.find(pkg => pkg.packageName === packageName);
49
+ }
50
+
51
+ addPackage(newPackage: Package): void {
52
+ if (!newPackage.packageName || !newPackage.packageId || !newPackage.publishedAt) {
53
+ throw new Error("Invalid package data");
54
+ }
55
+ this.packages.push(newPackage);
56
+ }
57
+
58
+ removePackageById(packageId: string): void {
59
+ this.packages = this.packages.filter(pkg => pkg.packageId !== packageId);
60
+ }
61
+
62
+ findPackageById(packageId: string): Package | undefined {
63
+ return this.packages.find(pkg => pkg.packageId === packageId);
64
+ }
65
+ }
package/src/const.ts ADDED
@@ -0,0 +1,126 @@
1
+ import BN from "bn.js"
2
+
3
+ /**
4
+ * The address representing the clock in the system.
5
+ */
6
+ export const CLOCK_ADDRESS =
7
+ "0x0000000000000000000000000000000000000000000000000000000000000006"
8
+
9
+ /**
10
+ * The address for CoinInfo module.
11
+ */
12
+ export const CoinInfoAddress = "0x1::coin::CoinInfo"
13
+
14
+ /**
15
+ * The address for CoinStore module.
16
+ */
17
+ export const CoinStoreAddress = "0x1::coin::CoinStore"
18
+
19
+ export const SuiZeroCoinFn = "0x2::coin::zero"
20
+
21
+ // Dex names
22
+ export const AGGREGATOR = "aggregator"
23
+ export const CETUS_DEX = "CETUS"
24
+ export const DEEPBOOK_DEX = "DEEPBOOK"
25
+ export const KRIYA_DEX = "KRIYA"
26
+ export const FLOWX_AMM = "FLOWX"
27
+ export const TURBOS_DEX = "TURBOS"
28
+ export const AFTERMATH_AMM = "AFTERMATH"
29
+
30
+ export const INTEGRATE = "integrate"
31
+
32
+ // Module names
33
+ export const CETUS_MODULE = "cetus"
34
+ export const DEEPBOOK_MODULE = "deepbook"
35
+ export const KRIYA_MODULE = "kriya"
36
+ export const UTILS_MODULE = "utils"
37
+ export const POOL_MODULT = "pool"
38
+ export const PAY_MODULE = "pay"
39
+ export const FLOWX_AMM_MODULE = "flowx_amm"
40
+ export const TURBOS_MODULE = "turbos"
41
+ export const AFTERMATH_MODULE = "aftermath"
42
+
43
+ export const DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2"
44
+ export const DEEPBOOK_CLOB_V2_MODULE = "clob_v2"
45
+
46
+ // Function names
47
+ export const FlashSwapFunc = "flash_swap"
48
+ export const FlashSwapWithPartnerFunc = "flash_swap_with_partner"
49
+ export const RepayFalshSwapFunc = "repay_flash_swap"
50
+ export const RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner"
51
+
52
+ export const FlashSwapA2BFunc = "flash_swap_a2b"
53
+ export const FlashSwapB2AFunc = "flash_swap_b2a"
54
+
55
+ export const FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b"
56
+ export const FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a"
57
+
58
+ export const REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b"
59
+ export const REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a"
60
+
61
+ export const REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC =
62
+ "repay_flash_swap_with_partner_a2b"
63
+ export const REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC =
64
+ "repay_flash_swap_with_partner_b2a"
65
+
66
+ export const SWAP_A2B_FUNC = "swap_a2b"
67
+ export const SWAP_B2A_FUNC = "swap_b2a"
68
+
69
+ export const TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin"
70
+ export const CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold"
71
+
72
+ export const JOIN_FUNC = "join_vec"
73
+
74
+ export const TRANSFER_ACCOUNT_CAP = "transfer_account_cap"
75
+
76
+ // Package IDs
77
+ export const DEEPBOOK_PACKAGE_ID =
78
+ "0x000000000000000000000000000000000000000000000000000000000000dee9"
79
+ export const DEEPBOOK_PUBLISHED_AT =
80
+ "0x000000000000000000000000000000000000000000000000000000000000dee9"
81
+
82
+ export const CETUS_PUBLISHED_AT =
83
+ "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a"
84
+
85
+ // Mainnet Cetus objects IDs
86
+ export const MAINNET_CETUS_GLOBAL_CONFIG_ID =
87
+ "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f"
88
+
89
+ // Testnet Cetus objects IDs
90
+ export const TESTNET_CETUS_GLOBAL_CONFIG_ID =
91
+ "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a"
92
+
93
+ export const ZERO = new BN(0)
94
+
95
+ export const ONE = new BN(1)
96
+
97
+ export const TWO = new BN(2)
98
+
99
+ export const U128 = TWO.pow(new BN(128))
100
+
101
+ export const U64_MAX_BN = new BN("18446744073709551615")
102
+
103
+ export const U64_MAX = "18446744073709551615"
104
+
105
+ export const MAINNET_FLOWX_AMM_CONTAINER_ID =
106
+ "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511"
107
+ export const TESTNET_FLOWX_AMM_CONTAINER_ID = ""
108
+
109
+ export const TURBOS_VERSIONED =
110
+ "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f"
111
+
112
+ export const MAINNET_AFTERMATH_REGISTRY_ID =
113
+ "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae"
114
+ export const TESTNET_AFTERMATH_REGISTRY_ID = ""
115
+ export const MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID =
116
+ "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4"
117
+ export const TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = ""
118
+ export const MAINNET_AFTERMATH_TREASURY_ID =
119
+ "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce"
120
+ export const TESTNET_AFTERMATH_TREASURY_ID = ""
121
+ export const MAINNET_AFTERMATH_INSURANCE_FUND_ID =
122
+ "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b"
123
+ export const TESTNET_AFTERMATH_INSURANCE_FUND_ID = ""
124
+ export const MAINNET_AFTERMATH_REFERRAL_VAULT_ID =
125
+ "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278"
126
+ export const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = ""