@cetusprotocol/aggregator-sdk 1.5.9 → 1.6.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.
package/README.md CHANGED
@@ -27,6 +27,8 @@ Easy Integration: The aggregator is designed to be simple and easy to integrate.
27
27
 
28
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
29
 
30
+ Sponsored Transactions: The SDK can build swap PTBs that do not use the user's gas coin, allowing a separate sponsor account to pay transaction gas.
31
+
30
32
  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
33
 
32
34
  # Aggregator SDK
@@ -55,7 +57,7 @@ const from = "0x2::sui::SUI"
55
57
  const target =
56
58
  "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS"
57
59
 
58
- const routers = await client.findRouters({
60
+ const routerRes = await client.findRouters({
59
61
  from,
60
62
  target,
61
63
  amount,
@@ -70,7 +72,7 @@ const txb = new Transaction()
70
72
 
71
73
  if (routerRes != null) {
72
74
  await client.fastRouterSwap({
73
- routers,
75
+ router: routerRes,
74
76
  txb,
75
77
  slippage: 0.01,
76
78
  })
@@ -85,7 +87,83 @@ if (routerRes != null) {
85
87
  }
86
88
  ```
87
89
 
88
- ### 4. Build PTB and return target coin
90
+ ### 4. Sponsored transaction: sponsor pays gas
91
+
92
+ Set `sponsored: true` when building the swap. In this mode the swap does not use `txb.gas` as input or output, because the gas coin belongs to the sponsor.
93
+
94
+ ```typescript
95
+ import { Transaction } from "@mysten/sui/transactions"
96
+ import { SUI_TYPE_ARG } from "@mysten/sui/utils"
97
+
98
+ const sender = userSigner.toSuiAddress()
99
+ const sponsor = sponsorSigner.toSuiAddress()
100
+ const txb = new Transaction()
101
+
102
+ await client.fastRouterSwap({
103
+ router: routerRes,
104
+ txb,
105
+ slippage: 0.01,
106
+ sponsored: true,
107
+ })
108
+
109
+ // Build command-only bytes. Pass sender so CoinWithBalance can resolve
110
+ // the user's input coins before the sponsor adds gas data.
111
+ const txKindBytes = await client.buildTransactionKind(txb, sender)
112
+
113
+ const { objects: gasCoins } = await client.client.listCoins({
114
+ owner: sponsor,
115
+ coinType: SUI_TYPE_ARG,
116
+ limit: 1,
117
+ })
118
+
119
+ const sponsorCoins = gasCoins.map((coin) => ({
120
+ objectId: coin.objectId,
121
+ version: coin.version,
122
+ digest: coin.digest,
123
+ }))
124
+
125
+ const sponsoredTx = client.buildSponsoredTransaction({
126
+ txKindBytes,
127
+ sender,
128
+ sponsor,
129
+ sponsorCoins,
130
+ gasBudget: "100000000",
131
+ })
132
+
133
+ const result = await client.signAndExecuteSponsoredTransaction(
134
+ sponsoredTx,
135
+ userSigner,
136
+ sponsorSigner
137
+ )
138
+ ```
139
+
140
+ For a gas-station integration, the same flow is split across two parties: the user builds `txKindBytes`, the sponsor sets `gasOwner` and `gasPayment`, then both parties sign the same full transaction bytes.
141
+
142
+ #### Sponsor secret for the real transaction test
143
+
144
+ The real sponsored transaction test reuses the existing wallet secret as the user/sender and adds one sponsor secret:
145
+
146
+ ```bash
147
+ SUI_WALLET_SECRET="user_base64_secret" \
148
+ SUI_SPONSOR_SECRET="sponsor_base64_secret" \
149
+ npx vitest run tests/unit/sponsored.test.ts
150
+ ```
151
+
152
+ `SUI_WALLET_SECRET` owns the swap input coins and signs as the transaction sender. `SUI_SPONSOR_SECRET` owns the gas coin and signs as the gas sponsor. Use two different accounts; the sponsor account only needs enough SUI to cover `SPONSORED_GAS_BUDGET` (`100000000` MIST by default).
153
+
154
+ Optional test variables:
155
+
156
+ ```bash
157
+ SPONSORED_SWAP_AMOUNT=1000000
158
+ SPONSORED_GAS_BUDGET=100000000
159
+ SUI_RPC="https://fullnode.mainnet.sui.io:443"
160
+ ```
161
+
162
+ If either secret is missing, `tests/unit/sponsored.test.ts` is skipped and no transaction is submitted.
163
+
164
+ Keep both secrets in your local shell or `.env` file, and do not commit them.
165
+
166
+ ### 5. Build PTB and return target coin
89
167
 
90
168
  ```typescript
91
169
  const txb = new Transaction()
@@ -93,7 +171,7 @@ const byAmountIn = true
93
171
 
94
172
  if (routerRes != null) {
95
173
  const targetCoin = await client.routerSwap({
96
- routers,
174
+ router: routerRes,
97
175
  txb,
98
176
  inputCoin,
99
177
  slippage: 0.01,
package/dist/index.cjs CHANGED
@@ -3416,7 +3416,7 @@ var AGGREGATOR_V3_CONFIG = {
3416
3416
  };
3417
3417
 
3418
3418
  // src/api.ts
3419
- var SDK_VERSION = 1010509;
3419
+ var SDK_VERSION = 1010601;
3420
3420
  function parseRouterResponse(data, byAmountIn) {
3421
3421
  let packages = /* @__PURE__ */ new Map();
3422
3422
  if (data.packages) {
@@ -9589,7 +9589,15 @@ var _AggregatorClient = class _AggregatorClient {
9589
9589
  // auto build input coin
9590
9590
  // auto merge, transfer or destory target coin.
9591
9591
  async fastRouterSwap(params) {
9592
- const { router, slippage, txb, partner, cetusDlmmPartner, payDeepFeeAmount } = params;
9592
+ const {
9593
+ router,
9594
+ slippage,
9595
+ txb,
9596
+ partner,
9597
+ cetusDlmmPartner,
9598
+ payDeepFeeAmount,
9599
+ sponsored = false
9600
+ } = params;
9593
9601
  const fromCoinType = router.paths[0].from;
9594
9602
  const targetCoinType = router.paths[router.paths.length - 1].target;
9595
9603
  const byAmountIn = router.byAmountIn;
@@ -9614,7 +9622,7 @@ var _AggregatorClient = class _AggregatorClient {
9614
9622
  const amount = byAmountIn ? expectedAmountIn : amountLimit;
9615
9623
  let inputCoin = transactions.coinWithBalance({
9616
9624
  balance: BigInt(amount.toString()),
9617
- useGasCoin: true,
9625
+ useGasCoin: !sponsored,
9618
9626
  type: fromCoinType
9619
9627
  });
9620
9628
  let deepCoin;
@@ -9634,22 +9642,46 @@ var _AggregatorClient = class _AggregatorClient {
9634
9642
  deepbookv3DeepFee: deepCoin
9635
9643
  };
9636
9644
  const targetCoin = await this.routerSwap(routerSwapParams);
9645
+ await this.deliverTargetCoin(
9646
+ txb,
9647
+ targetCoin,
9648
+ targetCoinType,
9649
+ router.packages,
9650
+ sponsored
9651
+ );
9652
+ }
9653
+ // Delivers a swap's output coin. In sponsored mode the SDK must not query or touch
9654
+ // coins through `this.signer`, because the transaction sender may be different from
9655
+ // the SDK instance signer. Let the router transfer helper deliver the output to the
9656
+ // transaction sender instead.
9657
+ async deliverTargetCoin(txb, targetCoin, targetCoinType, packages, sponsored) {
9658
+ if (sponsored) {
9659
+ transferOrDestroyCoin(
9660
+ {
9661
+ coin: targetCoin,
9662
+ coinType: targetCoinType,
9663
+ packages
9664
+ },
9665
+ txb
9666
+ );
9667
+ return;
9668
+ }
9637
9669
  if (CoinUtils.isSuiCoin(targetCoinType)) {
9638
9670
  txb.mergeCoins(txb.gas, [targetCoin]);
9671
+ return;
9672
+ }
9673
+ const targetCoinObjID = await this.getOneCoinUsedToMerge(targetCoinType);
9674
+ if (targetCoinObjID != null) {
9675
+ txb.mergeCoins(txb.object(targetCoinObjID), [targetCoin]);
9639
9676
  } else {
9640
- const targetCoinObjID = await this.getOneCoinUsedToMerge(targetCoinType);
9641
- if (targetCoinObjID != null) {
9642
- txb.mergeCoins(txb.object(targetCoinObjID), [targetCoin]);
9643
- } else {
9644
- transferOrDestroyCoin(
9645
- {
9646
- coin: targetCoin,
9647
- coinType: targetCoinType,
9648
- packages: router.packages
9649
- },
9650
- txb
9651
- );
9652
- }
9677
+ transferOrDestroyCoin(
9678
+ {
9679
+ coin: targetCoin,
9680
+ coinType: targetCoinType,
9681
+ packages
9682
+ },
9683
+ txb
9684
+ );
9653
9685
  }
9654
9686
  }
9655
9687
  async mergeSwap(params) {
@@ -9698,7 +9730,7 @@ var _AggregatorClient = class _AggregatorClient {
9698
9730
  return finalOutputCoin;
9699
9731
  }
9700
9732
  async fastMergeSwap(params) {
9701
- const { router, slippage, txb, partner } = params;
9733
+ const { router, slippage, txb, partner, sponsored = false } = params;
9702
9734
  if (!router || !router.allRoutes || router.allRoutes.length === 0) {
9703
9735
  throw new Error("Invalid router: no routes found");
9704
9736
  }
@@ -9714,7 +9746,7 @@ var _AggregatorClient = class _AggregatorClient {
9714
9746
  coinTypeSet.add(firstCoinType);
9715
9747
  const coin = transactions.coinWithBalance({
9716
9748
  balance: BigInt(route.amountIn.toString()),
9717
- useGasCoin: CoinUtils.isSuiCoin(firstCoinType),
9749
+ useGasCoin: !sponsored && CoinUtils.isSuiCoin(firstCoinType),
9718
9750
  type: firstCoinType
9719
9751
  });
9720
9752
  inputCoins.push({ coinType: firstCoinType, coin });
@@ -9727,23 +9759,13 @@ var _AggregatorClient = class _AggregatorClient {
9727
9759
  partner: partner ?? this.partner
9728
9760
  };
9729
9761
  const targetCoin = await this.mergeSwap(mergeSwapParams);
9730
- if (CoinUtils.isSuiCoin(targetCoinType)) {
9731
- txb.mergeCoins(txb.gas, [targetCoin]);
9732
- } else {
9733
- const targetCoinObjID = await this.getOneCoinUsedToMerge(targetCoinType);
9734
- if (targetCoinObjID != null) {
9735
- txb.mergeCoins(txb.object(targetCoinObjID), [targetCoin]);
9736
- } else {
9737
- transferOrDestroyCoin(
9738
- {
9739
- coin: targetCoin,
9740
- coinType: targetCoinType,
9741
- packages: router.packages
9742
- },
9743
- txb
9744
- );
9745
- }
9746
- }
9762
+ await this.deliverTargetCoin(
9763
+ txb,
9764
+ targetCoin,
9765
+ targetCoinType,
9766
+ router.packages,
9767
+ sponsored
9768
+ );
9747
9769
  }
9748
9770
  async fixableRouterSwapV3(params) {
9749
9771
  const { router, inputCoin, slippage, txb, partner } = params;
@@ -9942,6 +9964,70 @@ var _AggregatorClient = class _AggregatorClient {
9942
9964
  });
9943
9965
  return res;
9944
9966
  }
9967
+ // ---------------------------------------------------------------------------
9968
+ // Sponsored transactions
9969
+ //
9970
+ // A sponsored transaction lets a sponsor (gas station) pay gas for a transaction
9971
+ // whose commands are authored by a different sender. The sender and the sponsor both
9972
+ // sign the same transaction bytes, and the transaction is submitted with both
9973
+ // signatures. See: https://docs.sui.io/concepts/transactions/sponsored-transactions
9974
+ //
9975
+ // Build the swap with `sponsored: true` (e.g. `fastRouterSwap`/`fastMergeSwap`) so the
9976
+ // gas coin is never used, then:
9977
+ // - Remote gas station: `buildTransactionKind(txb, sender)` -> station assembles gas
9978
+ // data with `buildSponsoredTransaction` -> station builds/signs full bytes -> user
9979
+ // signs the same bytes -> `executeWithSignatures`.
9980
+ // - Local sponsor (both keypairs available): `signAndExecuteSponsoredTransaction`.
9981
+ // ---------------------------------------------------------------------------
9982
+ // Builds the TransactionKind bytes (commands only, no gas data) to hand to a sponsor /
9983
+ // gas station. Pass `sender` when the transaction contains CoinWithBalance intents,
9984
+ // because those are resolved while building the kind.
9985
+ async buildTransactionKind(txb, sender) {
9986
+ if (sender) {
9987
+ txb.setSender(sender);
9988
+ }
9989
+ return txb.build({ client: this.client, onlyTransactionKind: true });
9990
+ }
9991
+ // Assembles a sponsored transaction from TransactionKind bytes plus the gas data
9992
+ // provided by the sponsor. The returned transaction is ready to be built and signed by
9993
+ // both the sender and the sponsor.
9994
+ buildSponsoredTransaction(params) {
9995
+ const { txKindBytes, sender, sponsor, sponsorCoins, gasBudget, gasPrice } = params;
9996
+ const tx = transactions.Transaction.fromKind(txKindBytes);
9997
+ tx.setSender(sender);
9998
+ tx.setGasOwner(sponsor);
9999
+ tx.setGasPayment(sponsorCoins);
10000
+ if (gasBudget != null) {
10001
+ tx.setGasBudget(gasBudget);
10002
+ }
10003
+ if (gasPrice != null) {
10004
+ tx.setGasPrice(gasPrice);
10005
+ }
10006
+ return tx;
10007
+ }
10008
+ // Builds the full transaction bytes (including gas data) that both parties must sign.
10009
+ // Returns the exact bytes the signatures must be produced over.
10010
+ async buildTransactionBytes(txb) {
10011
+ return txb.build({ client: this.client });
10012
+ }
10013
+ // Executes a transaction from pre-built bytes plus the collected signatures. The
10014
+ // signatures MUST be produced over exactly these `bytes` (see `buildTransactionBytes`).
10015
+ async executeWithSignatures(bytes, signatures) {
10016
+ return this.client.executeTransaction({
10017
+ transaction: bytes,
10018
+ signatures,
10019
+ include: { effects: true, events: true, balanceChanges: true }
10020
+ });
10021
+ }
10022
+ // Convenience for the local dual-key case: signs the transaction with both the user's
10023
+ // and the sponsor's signer and executes it. `txb` must already have its sender, gas
10024
+ // owner and gas payment set (e.g. via `buildSponsoredTransaction`).
10025
+ async signAndExecuteSponsoredTransaction(txb, userSigner, sponsorSigner) {
10026
+ const bytes = await txb.build({ client: this.client });
10027
+ const { signature: sponsorSig } = await sponsorSigner.signTransaction(bytes);
10028
+ const { signature: userSig } = await userSigner.signTransaction(bytes);
10029
+ return this.executeWithSignatures(bytes, [userSig, sponsorSig]);
10030
+ }
9945
10031
  };
9946
10032
  _AggregatorClient.CONFIG = {
9947
10033
  [1 /* Testnet */]: {
package/dist/index.d.cts CHANGED
@@ -21,10 +21,6 @@ interface MergeSwapFromCoin {
21
21
  coinType: string;
22
22
  amount: BN | string | number | bigint;
23
23
  }
24
- interface MergeSwapFromCoin {
25
- coinType: string;
26
- amount: BN | string | number | bigint;
27
- }
28
24
  interface MergeSwapParams {
29
25
  target: string;
30
26
  byAmountIn: boolean;
@@ -32,17 +28,6 @@ interface MergeSwapParams {
32
28
  providers?: string[];
33
29
  froms: MergeSwapFromCoin[];
34
30
  }
35
- interface MergeSwapParams {
36
- target: string;
37
- byAmountIn: boolean;
38
- depth?: number;
39
- providers?: string[];
40
- froms: MergeSwapFromCoin[];
41
- }
42
- interface MergeSwapInputCoin {
43
- coinType: string;
44
- coin: TransactionObjectArgument;
45
- }
46
31
  interface MergeSwapInputCoin {
47
32
  coinType: string;
48
33
  coin: TransactionObjectArgument;
@@ -54,26 +39,13 @@ interface BuildMergeSwapParams {
54
39
  txb: Transaction;
55
40
  partner?: string;
56
41
  }
57
- interface BuildMergeSwapParams {
58
- router: MergeSwapRouterData;
59
- inputCoins: MergeSwapInputCoin[];
60
- slippage: number;
61
- txb: Transaction;
62
- partner?: string;
63
- }
64
- interface BuildFastMergeSwapParams {
65
- router: MergeSwapRouterData;
66
- slippage: number;
67
- txb: Transaction;
68
- partner?: string;
69
- payDeepFeeAmount?: number;
70
- }
71
42
  interface BuildFastMergeSwapParams {
72
43
  router: MergeSwapRouterData;
73
44
  slippage: number;
74
45
  txb: Transaction;
75
46
  partner?: string;
76
47
  payDeepFeeAmount?: number;
48
+ sponsored?: boolean;
77
49
  }
78
50
  interface PreSwapLpChangeParams {
79
51
  poolID: string;
@@ -386,6 +358,19 @@ type BuildFastRouterSwapParamsV3 = {
386
358
  cetusDlmmPartner?: string;
387
359
  refreshAllCoins?: boolean;
388
360
  payDeepFeeAmount?: number;
361
+ sponsored?: boolean;
362
+ };
363
+ type BuildSponsoredTransactionParams = {
364
+ txKindBytes: Uint8Array | string;
365
+ sender: string;
366
+ sponsor: string;
367
+ sponsorCoins: {
368
+ objectId: string;
369
+ version: string | number;
370
+ digest: string;
371
+ }[];
372
+ gasBudget?: number | bigint | string;
373
+ gasPrice?: number | bigint | string;
389
374
  };
390
375
  interface SwapInPoolsParams {
391
376
  from: string;
@@ -463,6 +448,7 @@ declare class AggregatorClient {
463
448
  maxAmountIn: BN;
464
449
  }): Promise<TransactionObjectArgument>;
465
450
  fastRouterSwap(params: BuildFastRouterSwapParamsV3): Promise<void>;
451
+ private deliverTargetCoin;
466
452
  mergeSwap(params: BuildMergeSwapParams): Promise<TransactionObjectArgument>;
467
453
  fastMergeSwap(params: BuildFastMergeSwapParams): Promise<void>;
468
454
  fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
@@ -477,6 +463,19 @@ declare class AggregatorClient {
477
463
  events: true;
478
464
  balanceChanges: true;
479
465
  }>>;
466
+ buildTransactionKind(txb: Transaction, sender?: string): Promise<Uint8Array>;
467
+ buildSponsoredTransaction(params: BuildSponsoredTransactionParams): Transaction;
468
+ buildTransactionBytes(txb: Transaction): Promise<Uint8Array>;
469
+ executeWithSignatures(bytes: Uint8Array, signatures: string[]): Promise<_mysten_sui_client.SuiClientTypes.TransactionResult<{
470
+ effects: true;
471
+ events: true;
472
+ balanceChanges: true;
473
+ }>>;
474
+ signAndExecuteSponsoredTransaction(txb: Transaction, userSigner: Signer, sponsorSigner: Signer): Promise<_mysten_sui_client.SuiClientTypes.TransactionResult<{
475
+ effects: true;
476
+ events: true;
477
+ balanceChanges: true;
478
+ }>>;
480
479
  }
481
480
 
482
481
  /**
@@ -1177,4 +1176,4 @@ declare class CoinUtils {
1177
1176
  static calculateTotalBalance(coins: CoinAsset[]): bigint;
1178
1177
  }
1179
1178
 
1180
- export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, BOLT, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAEDALPROPAMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAGMAPROPAMM, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, PYTH_PRELUDE_CALLS, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SWAP_GAS_BUDGET_TABLE, type SimulateTransactionResult, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiMoveObject, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, estimateSwapGasBudget, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, hasPythPrelude, isSortedSymbols, isValidDowngradeUuid6, lookupGasBudget, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
1179
+ export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, BOLT, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, type BuildSponsoredTransactionParams, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAEDALPROPAMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAGMAPROPAMM, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, PYTH_PRELUDE_CALLS, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SWAP_GAS_BUDGET_TABLE, type SimulateTransactionResult, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiMoveObject, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, estimateSwapGasBudget, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, hasPythPrelude, isSortedSymbols, isValidDowngradeUuid6, lookupGasBudget, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
package/dist/index.d.ts CHANGED
@@ -21,10 +21,6 @@ interface MergeSwapFromCoin {
21
21
  coinType: string;
22
22
  amount: BN | string | number | bigint;
23
23
  }
24
- interface MergeSwapFromCoin {
25
- coinType: string;
26
- amount: BN | string | number | bigint;
27
- }
28
24
  interface MergeSwapParams {
29
25
  target: string;
30
26
  byAmountIn: boolean;
@@ -32,17 +28,6 @@ interface MergeSwapParams {
32
28
  providers?: string[];
33
29
  froms: MergeSwapFromCoin[];
34
30
  }
35
- interface MergeSwapParams {
36
- target: string;
37
- byAmountIn: boolean;
38
- depth?: number;
39
- providers?: string[];
40
- froms: MergeSwapFromCoin[];
41
- }
42
- interface MergeSwapInputCoin {
43
- coinType: string;
44
- coin: TransactionObjectArgument;
45
- }
46
31
  interface MergeSwapInputCoin {
47
32
  coinType: string;
48
33
  coin: TransactionObjectArgument;
@@ -54,26 +39,13 @@ interface BuildMergeSwapParams {
54
39
  txb: Transaction;
55
40
  partner?: string;
56
41
  }
57
- interface BuildMergeSwapParams {
58
- router: MergeSwapRouterData;
59
- inputCoins: MergeSwapInputCoin[];
60
- slippage: number;
61
- txb: Transaction;
62
- partner?: string;
63
- }
64
- interface BuildFastMergeSwapParams {
65
- router: MergeSwapRouterData;
66
- slippage: number;
67
- txb: Transaction;
68
- partner?: string;
69
- payDeepFeeAmount?: number;
70
- }
71
42
  interface BuildFastMergeSwapParams {
72
43
  router: MergeSwapRouterData;
73
44
  slippage: number;
74
45
  txb: Transaction;
75
46
  partner?: string;
76
47
  payDeepFeeAmount?: number;
48
+ sponsored?: boolean;
77
49
  }
78
50
  interface PreSwapLpChangeParams {
79
51
  poolID: string;
@@ -386,6 +358,19 @@ type BuildFastRouterSwapParamsV3 = {
386
358
  cetusDlmmPartner?: string;
387
359
  refreshAllCoins?: boolean;
388
360
  payDeepFeeAmount?: number;
361
+ sponsored?: boolean;
362
+ };
363
+ type BuildSponsoredTransactionParams = {
364
+ txKindBytes: Uint8Array | string;
365
+ sender: string;
366
+ sponsor: string;
367
+ sponsorCoins: {
368
+ objectId: string;
369
+ version: string | number;
370
+ digest: string;
371
+ }[];
372
+ gasBudget?: number | bigint | string;
373
+ gasPrice?: number | bigint | string;
389
374
  };
390
375
  interface SwapInPoolsParams {
391
376
  from: string;
@@ -463,6 +448,7 @@ declare class AggregatorClient {
463
448
  maxAmountIn: BN;
464
449
  }): Promise<TransactionObjectArgument>;
465
450
  fastRouterSwap(params: BuildFastRouterSwapParamsV3): Promise<void>;
451
+ private deliverTargetCoin;
466
452
  mergeSwap(params: BuildMergeSwapParams): Promise<TransactionObjectArgument>;
467
453
  fastMergeSwap(params: BuildFastMergeSwapParams): Promise<void>;
468
454
  fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
@@ -477,6 +463,19 @@ declare class AggregatorClient {
477
463
  events: true;
478
464
  balanceChanges: true;
479
465
  }>>;
466
+ buildTransactionKind(txb: Transaction, sender?: string): Promise<Uint8Array>;
467
+ buildSponsoredTransaction(params: BuildSponsoredTransactionParams): Transaction;
468
+ buildTransactionBytes(txb: Transaction): Promise<Uint8Array>;
469
+ executeWithSignatures(bytes: Uint8Array, signatures: string[]): Promise<_mysten_sui_client.SuiClientTypes.TransactionResult<{
470
+ effects: true;
471
+ events: true;
472
+ balanceChanges: true;
473
+ }>>;
474
+ signAndExecuteSponsoredTransaction(txb: Transaction, userSigner: Signer, sponsorSigner: Signer): Promise<_mysten_sui_client.SuiClientTypes.TransactionResult<{
475
+ effects: true;
476
+ events: true;
477
+ balanceChanges: true;
478
+ }>>;
480
479
  }
481
480
 
482
481
  /**
@@ -1177,4 +1176,4 @@ declare class CoinUtils {
1177
1176
  static calculateTotalBalance(coins: CoinAsset[]): bigint;
1178
1177
  }
1179
1178
 
1180
- export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, BOLT, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAEDALPROPAMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAGMAPROPAMM, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, PYTH_PRELUDE_CALLS, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SWAP_GAS_BUDGET_TABLE, type SimulateTransactionResult, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiMoveObject, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, estimateSwapGasBudget, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, hasPythPrelude, isSortedSymbols, isValidDowngradeUuid6, lookupGasBudget, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
1179
+ export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, BOLT, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, type BuildSponsoredTransactionParams, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAEDALPROPAMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAGMAPROPAMM, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, PYTH_PRELUDE_CALLS, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SWAP_GAS_BUDGET_TABLE, type SimulateTransactionResult, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiMoveObject, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, estimateSwapGasBudget, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, hasPythPrelude, isSortedSymbols, isValidDowngradeUuid6, lookupGasBudget, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
package/dist/index.js CHANGED
@@ -3410,7 +3410,7 @@ var AGGREGATOR_V3_CONFIG = {
3410
3410
  };
3411
3411
 
3412
3412
  // src/api.ts
3413
- var SDK_VERSION = 1010509;
3413
+ var SDK_VERSION = 1010601;
3414
3414
  function parseRouterResponse(data, byAmountIn) {
3415
3415
  let packages = /* @__PURE__ */ new Map();
3416
3416
  if (data.packages) {
@@ -9583,7 +9583,15 @@ var _AggregatorClient = class _AggregatorClient {
9583
9583
  // auto build input coin
9584
9584
  // auto merge, transfer or destory target coin.
9585
9585
  async fastRouterSwap(params) {
9586
- const { router, slippage, txb, partner, cetusDlmmPartner, payDeepFeeAmount } = params;
9586
+ const {
9587
+ router,
9588
+ slippage,
9589
+ txb,
9590
+ partner,
9591
+ cetusDlmmPartner,
9592
+ payDeepFeeAmount,
9593
+ sponsored = false
9594
+ } = params;
9587
9595
  const fromCoinType = router.paths[0].from;
9588
9596
  const targetCoinType = router.paths[router.paths.length - 1].target;
9589
9597
  const byAmountIn = router.byAmountIn;
@@ -9608,7 +9616,7 @@ var _AggregatorClient = class _AggregatorClient {
9608
9616
  const amount = byAmountIn ? expectedAmountIn : amountLimit;
9609
9617
  let inputCoin = coinWithBalance({
9610
9618
  balance: BigInt(amount.toString()),
9611
- useGasCoin: true,
9619
+ useGasCoin: !sponsored,
9612
9620
  type: fromCoinType
9613
9621
  });
9614
9622
  let deepCoin;
@@ -9628,22 +9636,46 @@ var _AggregatorClient = class _AggregatorClient {
9628
9636
  deepbookv3DeepFee: deepCoin
9629
9637
  };
9630
9638
  const targetCoin = await this.routerSwap(routerSwapParams);
9639
+ await this.deliverTargetCoin(
9640
+ txb,
9641
+ targetCoin,
9642
+ targetCoinType,
9643
+ router.packages,
9644
+ sponsored
9645
+ );
9646
+ }
9647
+ // Delivers a swap's output coin. In sponsored mode the SDK must not query or touch
9648
+ // coins through `this.signer`, because the transaction sender may be different from
9649
+ // the SDK instance signer. Let the router transfer helper deliver the output to the
9650
+ // transaction sender instead.
9651
+ async deliverTargetCoin(txb, targetCoin, targetCoinType, packages, sponsored) {
9652
+ if (sponsored) {
9653
+ transferOrDestroyCoin(
9654
+ {
9655
+ coin: targetCoin,
9656
+ coinType: targetCoinType,
9657
+ packages
9658
+ },
9659
+ txb
9660
+ );
9661
+ return;
9662
+ }
9631
9663
  if (CoinUtils.isSuiCoin(targetCoinType)) {
9632
9664
  txb.mergeCoins(txb.gas, [targetCoin]);
9665
+ return;
9666
+ }
9667
+ const targetCoinObjID = await this.getOneCoinUsedToMerge(targetCoinType);
9668
+ if (targetCoinObjID != null) {
9669
+ txb.mergeCoins(txb.object(targetCoinObjID), [targetCoin]);
9633
9670
  } else {
9634
- const targetCoinObjID = await this.getOneCoinUsedToMerge(targetCoinType);
9635
- if (targetCoinObjID != null) {
9636
- txb.mergeCoins(txb.object(targetCoinObjID), [targetCoin]);
9637
- } else {
9638
- transferOrDestroyCoin(
9639
- {
9640
- coin: targetCoin,
9641
- coinType: targetCoinType,
9642
- packages: router.packages
9643
- },
9644
- txb
9645
- );
9646
- }
9671
+ transferOrDestroyCoin(
9672
+ {
9673
+ coin: targetCoin,
9674
+ coinType: targetCoinType,
9675
+ packages
9676
+ },
9677
+ txb
9678
+ );
9647
9679
  }
9648
9680
  }
9649
9681
  async mergeSwap(params) {
@@ -9692,7 +9724,7 @@ var _AggregatorClient = class _AggregatorClient {
9692
9724
  return finalOutputCoin;
9693
9725
  }
9694
9726
  async fastMergeSwap(params) {
9695
- const { router, slippage, txb, partner } = params;
9727
+ const { router, slippage, txb, partner, sponsored = false } = params;
9696
9728
  if (!router || !router.allRoutes || router.allRoutes.length === 0) {
9697
9729
  throw new Error("Invalid router: no routes found");
9698
9730
  }
@@ -9708,7 +9740,7 @@ var _AggregatorClient = class _AggregatorClient {
9708
9740
  coinTypeSet.add(firstCoinType);
9709
9741
  const coin = coinWithBalance({
9710
9742
  balance: BigInt(route.amountIn.toString()),
9711
- useGasCoin: CoinUtils.isSuiCoin(firstCoinType),
9743
+ useGasCoin: !sponsored && CoinUtils.isSuiCoin(firstCoinType),
9712
9744
  type: firstCoinType
9713
9745
  });
9714
9746
  inputCoins.push({ coinType: firstCoinType, coin });
@@ -9721,23 +9753,13 @@ var _AggregatorClient = class _AggregatorClient {
9721
9753
  partner: partner ?? this.partner
9722
9754
  };
9723
9755
  const targetCoin = await this.mergeSwap(mergeSwapParams);
9724
- if (CoinUtils.isSuiCoin(targetCoinType)) {
9725
- txb.mergeCoins(txb.gas, [targetCoin]);
9726
- } else {
9727
- const targetCoinObjID = await this.getOneCoinUsedToMerge(targetCoinType);
9728
- if (targetCoinObjID != null) {
9729
- txb.mergeCoins(txb.object(targetCoinObjID), [targetCoin]);
9730
- } else {
9731
- transferOrDestroyCoin(
9732
- {
9733
- coin: targetCoin,
9734
- coinType: targetCoinType,
9735
- packages: router.packages
9736
- },
9737
- txb
9738
- );
9739
- }
9740
- }
9756
+ await this.deliverTargetCoin(
9757
+ txb,
9758
+ targetCoin,
9759
+ targetCoinType,
9760
+ router.packages,
9761
+ sponsored
9762
+ );
9741
9763
  }
9742
9764
  async fixableRouterSwapV3(params) {
9743
9765
  const { router, inputCoin, slippage, txb, partner } = params;
@@ -9936,6 +9958,70 @@ var _AggregatorClient = class _AggregatorClient {
9936
9958
  });
9937
9959
  return res;
9938
9960
  }
9961
+ // ---------------------------------------------------------------------------
9962
+ // Sponsored transactions
9963
+ //
9964
+ // A sponsored transaction lets a sponsor (gas station) pay gas for a transaction
9965
+ // whose commands are authored by a different sender. The sender and the sponsor both
9966
+ // sign the same transaction bytes, and the transaction is submitted with both
9967
+ // signatures. See: https://docs.sui.io/concepts/transactions/sponsored-transactions
9968
+ //
9969
+ // Build the swap with `sponsored: true` (e.g. `fastRouterSwap`/`fastMergeSwap`) so the
9970
+ // gas coin is never used, then:
9971
+ // - Remote gas station: `buildTransactionKind(txb, sender)` -> station assembles gas
9972
+ // data with `buildSponsoredTransaction` -> station builds/signs full bytes -> user
9973
+ // signs the same bytes -> `executeWithSignatures`.
9974
+ // - Local sponsor (both keypairs available): `signAndExecuteSponsoredTransaction`.
9975
+ // ---------------------------------------------------------------------------
9976
+ // Builds the TransactionKind bytes (commands only, no gas data) to hand to a sponsor /
9977
+ // gas station. Pass `sender` when the transaction contains CoinWithBalance intents,
9978
+ // because those are resolved while building the kind.
9979
+ async buildTransactionKind(txb, sender) {
9980
+ if (sender) {
9981
+ txb.setSender(sender);
9982
+ }
9983
+ return txb.build({ client: this.client, onlyTransactionKind: true });
9984
+ }
9985
+ // Assembles a sponsored transaction from TransactionKind bytes plus the gas data
9986
+ // provided by the sponsor. The returned transaction is ready to be built and signed by
9987
+ // both the sender and the sponsor.
9988
+ buildSponsoredTransaction(params) {
9989
+ const { txKindBytes, sender, sponsor, sponsorCoins, gasBudget, gasPrice } = params;
9990
+ const tx = Transaction.fromKind(txKindBytes);
9991
+ tx.setSender(sender);
9992
+ tx.setGasOwner(sponsor);
9993
+ tx.setGasPayment(sponsorCoins);
9994
+ if (gasBudget != null) {
9995
+ tx.setGasBudget(gasBudget);
9996
+ }
9997
+ if (gasPrice != null) {
9998
+ tx.setGasPrice(gasPrice);
9999
+ }
10000
+ return tx;
10001
+ }
10002
+ // Builds the full transaction bytes (including gas data) that both parties must sign.
10003
+ // Returns the exact bytes the signatures must be produced over.
10004
+ async buildTransactionBytes(txb) {
10005
+ return txb.build({ client: this.client });
10006
+ }
10007
+ // Executes a transaction from pre-built bytes plus the collected signatures. The
10008
+ // signatures MUST be produced over exactly these `bytes` (see `buildTransactionBytes`).
10009
+ async executeWithSignatures(bytes, signatures) {
10010
+ return this.client.executeTransaction({
10011
+ transaction: bytes,
10012
+ signatures,
10013
+ include: { effects: true, events: true, balanceChanges: true }
10014
+ });
10015
+ }
10016
+ // Convenience for the local dual-key case: signs the transaction with both the user's
10017
+ // and the sponsor's signer and executes it. `txb` must already have its sender, gas
10018
+ // owner and gas payment set (e.g. via `buildSponsoredTransaction`).
10019
+ async signAndExecuteSponsoredTransaction(txb, userSigner, sponsorSigner) {
10020
+ const bytes = await txb.build({ client: this.client });
10021
+ const { signature: sponsorSig } = await sponsorSigner.signTransaction(bytes);
10022
+ const { signature: userSig } = await userSigner.signTransaction(bytes);
10023
+ return this.executeWithSignatures(bytes, [userSig, sponsorSig]);
10024
+ }
9939
10025
  };
9940
10026
  _AggregatorClient.CONFIG = {
9941
10027
  [1 /* Testnet */]: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "1.5.9",
3
+ "version": "1.6.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "dist/index.js",
@@ -18,9 +18,6 @@
18
18
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
19
19
  "publish:test": "node version.mjs && npm publish --tag experimental"
20
20
  },
21
- "peerDependencies": {
22
- "typescript": "^5.0.0"
23
- },
24
21
  "dependencies": {
25
22
  "@mysten/sui": "^2.16.3",
26
23
  "@pythnetwork/hermes-client": "^3.1.0",