@tradeport/sui-trading-sdk 0.4.39 → 0.4.40

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 (34) hide show
  1. package/dist/index.d.mts +19 -2
  2. package/dist/index.d.ts +19 -2
  3. package/dist/index.js +310 -160
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +270 -130
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +7 -4
  8. package/src/SuiTradingClient.ts +18 -4
  9. package/src/helpers/kiosk/getKioskIdFromKioskTx.ts +1 -1
  10. package/src/helpers/kiosk/kioskTxWrapper.ts +3 -3
  11. package/src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts +1 -1
  12. package/src/helpers/kiosk/resolveRoyaltyRule.ts +5 -0
  13. package/src/helpers/kiosk/resolveTransferPolicies.ts +3 -0
  14. package/src/helpers/kiosk/takeLockedNftFromKiosk.ts +12 -4
  15. package/src/helpers/swap/swap.ts +147 -0
  16. package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +1 -1
  17. package/src/methods/acceptNftBids/acceptNftBids.ts +1 -1
  18. package/src/methods/buyListings/addBuyListingTxs.ts +5 -0
  19. package/src/methods/buyListings/buyListings.ts +20 -7
  20. package/src/methods/cancelNftTransfers/cancelNftTransfers.ts +1 -1
  21. package/src/methods/claimNfts/claimNfts.ts +1 -1
  22. package/src/methods/createMultiBid/createMultiBid.ts +6 -7
  23. package/src/methods/listNfts/listNfts.ts +1 -1
  24. package/src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts +1 -1
  25. package/src/methods/placeCollectionBids/placeCollectionBids.ts +28 -8
  26. package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +8 -7
  27. package/src/methods/placeNftBids/placeNftBids.ts +27 -8
  28. package/src/methods/removeCollectionBids/removeCollectionBids.ts +1 -1
  29. package/src/methods/removeNftBids/removeNftBids.ts +1 -1
  30. package/src/methods/transferNfts/transferNfts.ts +1 -1
  31. package/src/methods/unlistListings/unlistListings.ts +1 -2
  32. package/src/methods/updateMultiBid/updateMultiBid.ts +35 -4
  33. package/src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts +3 -3
  34. package/src/helpers/extractSwapResultCoin.ts +0 -17
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,14 +17,22 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
23
33
  SuiTradingClient: () => SuiTradingClient_default
24
34
  });
25
- module.exports = __toCommonJS(src_exports);
35
+ module.exports = __toCommonJS(index_exports);
26
36
 
27
37
  // src/SuiTradingClient.ts
28
38
  var import_client2 = require("@mysten/sui/client");
@@ -132,7 +142,7 @@ var fetchCollectionBidsAtSamePrice = import_graphql_request4.gql`
132
142
  `;
133
143
 
134
144
  // src/methods/acceptCollectionBid/acceptCollectionBid.ts
135
- var import_transactions2 = require("@mysten/sui/transactions");
145
+ var import_transactions3 = require("@mysten/sui/transactions");
136
146
 
137
147
  // src/constants.ts
138
148
  var MYSTEN_TRANFER_POLICY_RULES_PACKAGE_ID = "0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879";
@@ -1287,7 +1297,7 @@ var getSharedObjects = async (nftType) => {
1287
1297
  };
1288
1298
 
1289
1299
  // src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts
1290
- var import_utils4 = require("@mysten/sui/utils");
1300
+ var import_utils5 = require("@mysten/sui/utils");
1291
1301
 
1292
1302
  // src/utils/normalizeNftType.ts
1293
1303
  var normalizedNftType = (nftType) => {
@@ -1540,7 +1550,7 @@ var kioskTxWrapper = async ({
1540
1550
  variables: { kioskId: personalKiosk.id }
1541
1551
  })).personalCap.id;
1542
1552
  kioskTx = new import_kiosk3.KioskTransaction({
1543
- transactionBlock: tx,
1553
+ transaction: tx,
1544
1554
  kioskClient,
1545
1555
  cap: {
1546
1556
  isPersonal: true,
@@ -1557,7 +1567,7 @@ var kioskTxWrapper = async ({
1557
1567
  variables: { kioskId: kiosks[0].id }
1558
1568
  })).ownerCap?.id;
1559
1569
  kioskTx = new import_kiosk3.KioskTransaction({
1560
- transactionBlock: tx,
1570
+ transaction: tx,
1561
1571
  kioskClient,
1562
1572
  cap: {
1563
1573
  isPersonal: false,
@@ -1568,7 +1578,7 @@ var kioskTxWrapper = async ({
1568
1578
  }
1569
1579
  });
1570
1580
  } else {
1571
- kioskTx = new import_kiosk3.KioskTransaction({ transactionBlock: tx, kioskClient });
1581
+ kioskTx = new import_kiosk3.KioskTransaction({ transaction: tx, kioskClient });
1572
1582
  kioskTx.createPersonal(true);
1573
1583
  }
1574
1584
  if (shouldUseSharedKioskTx && sharedKioskState) {
@@ -1745,9 +1755,86 @@ function resolvePersonalKioskRule({ tx, packageId, nftType, kiosk, transferReque
1745
1755
  });
1746
1756
  }
1747
1757
 
1758
+ // src/helpers/swap/swap.ts
1759
+ var import_sdk = require("@flowx-finance/sdk");
1760
+ var import_transactions = require("@mysten/sui/transactions");
1761
+ var import_utils2 = require("@mysten/sui/utils");
1762
+ var import_ms = __toESM(require("ms"));
1763
+ var aggregatorQuoter = new import_sdk.AggregatorQuoter("mainnet");
1764
+ var suiCointType = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
1765
+ async function createBuyTransaction(client, walletAddress, suiAmount, options) {
1766
+ const transaction = options?.transaction ?? new import_transactions.Transaction();
1767
+ transaction.setSender((0, import_utils2.normalizeSuiAddress)(walletAddress));
1768
+ const {
1769
+ coinType,
1770
+ coinAmount = 0n,
1771
+ slippage = 1,
1772
+ ttl = "15m",
1773
+ excludeSources = [import_sdk.Protocol.STEAMM]
1774
+ } = options ?? {};
1775
+ if (!coinType || (0, import_utils2.normalizeStructTag)(coinType) === suiCointType) {
1776
+ const [coin] = transaction.splitCoins(transaction.gas, [suiAmount]);
1777
+ return {
1778
+ transaction,
1779
+ suiCoin: coin
1780
+ };
1781
+ }
1782
+ const { routes } = await aggregatorQuoter.getRoutes({
1783
+ tokenIn: coinType,
1784
+ tokenOut: suiCointType,
1785
+ amountIn: coinAmount.toString(),
1786
+ excludeSources
1787
+ });
1788
+ const tradeBuilder = new import_sdk.TradeBuilder("mainnet", routes);
1789
+ const trade = tradeBuilder.sender((0, import_utils2.normalizeSuiAddress)(walletAddress)).slippage(slippage).deadline(Date.now() + (0, import_ms.default)(ttl)).build();
1790
+ const swappedSuiCoin = await trade.swap({
1791
+ client,
1792
+ tx: transaction
1793
+ });
1794
+ if (!swappedSuiCoin) {
1795
+ throw new Error("Swap did not return a valid SUI coin.");
1796
+ }
1797
+ return { transaction, suiCoin: swappedSuiCoin };
1798
+ }
1799
+ async function handleSwapSetup(client, walletAddress, transaction, swapAndPayOptions) {
1800
+ if (!swapAndPayOptions?.coinType || !swapAndPayOptions?.coinAmount) {
1801
+ return { transaction };
1802
+ }
1803
+ const { transaction: updatedTx, suiCoin } = await createBuyTransaction(
1804
+ client,
1805
+ walletAddress,
1806
+ BigInt(swapAndPayOptions.coinAmount),
1807
+ {
1808
+ transaction,
1809
+ coinType: swapAndPayOptions.coinType,
1810
+ coinAmount: BigInt(swapAndPayOptions.coinAmount),
1811
+ slippage: swapAndPayOptions.slippage,
1812
+ ttl: swapAndPayOptions.ttl,
1813
+ excludeSources: swapAndPayOptions.excludeSources
1814
+ }
1815
+ );
1816
+ return {
1817
+ transaction: updatedTx,
1818
+ swapResultCoin: suiCoin
1819
+ };
1820
+ }
1821
+ function handleSwapCleanup(transaction, swapResultCoin, walletAddress) {
1822
+ if (swapResultCoin) {
1823
+ transaction.transferObjects([swapResultCoin], walletAddress);
1824
+ }
1825
+ }
1826
+ function mergeSwapCoinWithSuiBalance(transaction, coinToMergeInto, amountToSplitFromGas) {
1827
+ if (coinToMergeInto && amountToSplitFromGas && amountToSplitFromGas > 0n) {
1828
+ const [coinFromSuiBalance] = transaction.splitCoins(transaction.gas, [
1829
+ transaction.pure.u64(amountToSplitFromGas)
1830
+ ]);
1831
+ transaction.mergeCoins(coinToMergeInto, [coinFromSuiBalance]);
1832
+ }
1833
+ }
1834
+
1748
1835
  // src/helpers/kiosk/getKioskCollectionRoyaltyFeeAmount.ts
1749
1836
  var import_bcs = require("@mysten/sui/bcs");
1750
- var import_transactions = require("@mysten/sui/transactions");
1837
+ var import_transactions2 = require("@mysten/sui/transactions");
1751
1838
  async function getKioskCollectionRoyaltyFeeAmount({
1752
1839
  tx,
1753
1840
  suiClient,
@@ -1766,7 +1853,7 @@ async function getKioskCollectionRoyaltyFeeAmount({
1766
1853
  console.warn("Price is undefined or 0");
1767
1854
  return void 0;
1768
1855
  }
1769
- const feeTx = new import_transactions.Transaction();
1856
+ const feeTx = new import_transactions2.Transaction();
1770
1857
  feeTx.moveCall({
1771
1858
  target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
1772
1859
  arguments: [feeTx.object(transferPolicyId), feeTx.pure.u64(price)],
@@ -1805,7 +1892,8 @@ async function resolveRoyaltyRule({
1805
1892
  nftType,
1806
1893
  price,
1807
1894
  coinToSplit,
1808
- royaltyFeeAmount
1895
+ royaltyFeeAmount,
1896
+ amountToSplitFromSuiBalance
1809
1897
  }) {
1810
1898
  let feeAmount = royaltyFeeAmount;
1811
1899
  if (!feeAmount) {
@@ -1820,6 +1908,7 @@ async function resolveRoyaltyRule({
1820
1908
  nftType
1821
1909
  });
1822
1910
  }
1911
+ mergeSwapCoinWithSuiBalance(tx, coinToSplit, amountToSplitFromSuiBalance);
1823
1912
  const feeCoin = tx.splitCoins(coinToSplit ? coinToSplit : tx.gas, [feeAmount]);
1824
1913
  tx.moveCall({
1825
1914
  target: `${packageId}::${moduleName}::pay`,
@@ -1847,7 +1936,8 @@ var resolveTransferPolicies = async ({
1847
1936
  coinToSplit,
1848
1937
  beforeResolveKioskTransferRequest,
1849
1938
  transferPoliciesToResolve,
1850
- royaltyFeeAmount
1939
+ royaltyFeeAmount,
1940
+ amountToSplitFromSuiBalance
1851
1941
  }) => {
1852
1942
  const policies = transferPoliciesToResolve ?? await getTransferPoliciesToResolve({
1853
1943
  transferPolicies,
@@ -1897,7 +1987,8 @@ var resolveTransferPolicies = async ({
1897
1987
  nftType: policy.isCustom && policy.type ? policy.type : nftType,
1898
1988
  price,
1899
1989
  coinToSplit,
1900
- royaltyFeeAmount
1990
+ royaltyFeeAmount,
1991
+ amountToSplitFromSuiBalance
1901
1992
  });
1902
1993
  break;
1903
1994
  case "floor_price_rule":
@@ -1948,8 +2039,12 @@ var takeLockedNftFromKiosk = async ({
1948
2039
  const [purchase_cap] = tx.moveCall({
1949
2040
  target: "0x2::kiosk::list_with_purchase_cap",
1950
2041
  arguments: [
1951
- tx.object("value" in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk),
1952
- tx.object("value" in kioskTx.kioskCap ? kioskTx.kioskCap.value : kioskTx.kioskCap),
2042
+ tx.object(
2043
+ "value" in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk
2044
+ ),
2045
+ tx.object(
2046
+ "value" in kioskTx.kioskCap ? kioskTx.kioskCap.value : kioskTx.kioskCap
2047
+ ),
1953
2048
  tx.pure.address(nftTokenId),
1954
2049
  tx.pure.u64(0)
1955
2050
  ],
@@ -1963,7 +2058,9 @@ var takeLockedNftFromKiosk = async ({
1963
2058
  const [nft, transferRequest] = tx.moveCall({
1964
2059
  target: "0x2::kiosk::purchase_with_cap",
1965
2060
  arguments: [
1966
- tx.object("value" in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk),
2061
+ tx.object(
2062
+ "value" in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk
2063
+ ),
1967
2064
  purchase_cap,
1968
2065
  zeroCoin
1969
2066
  ],
@@ -2140,13 +2237,13 @@ var shareOriginByteKiosk = ({ tx, kiosk }) => {
2140
2237
  };
2141
2238
 
2142
2239
  // src/helpers/rpc/getObjectType.ts
2143
- var import_utils2 = require("@mysten/sui/utils");
2240
+ var import_utils3 = require("@mysten/sui/utils");
2144
2241
  var getObjectType = async ({
2145
2242
  suiClient,
2146
2243
  objectId
2147
2244
  }) => {
2148
2245
  const normalizedObjectId = objectId.startsWith("0x") ? addLeadingZerosAfter0x(objectId) : objectId;
2149
- if ((0, import_utils2.isValidSuiObjectId)(normalizedObjectId)) {
2246
+ if ((0, import_utils3.isValidSuiObjectId)(normalizedObjectId)) {
2150
2247
  const res = await suiClient.getObject({ id: normalizedObjectId, options: { showType: true } });
2151
2248
  return res.data.type;
2152
2249
  }
@@ -2154,7 +2251,7 @@ var getObjectType = async ({
2154
2251
  };
2155
2252
 
2156
2253
  // src/methods/acceptNftBids/addAcceptNftBidTxs.ts
2157
- var import_utils3 = require("@mysten/sui/utils");
2254
+ var import_utils4 = require("@mysten/sui/utils");
2158
2255
 
2159
2256
  // src/graphql/queries/fetchMultibidById.ts
2160
2257
  var import_graphql_request11 = require("graphql-request");
@@ -2226,7 +2323,7 @@ var lockNftInsideKioskIfNotLocked = async ({
2226
2323
  takenNftId = "value" in takenNft ? takenNft.value : takenNft;
2227
2324
  }
2228
2325
  kioskTx.lock({
2229
- itemId: takenNftId ?? nftTokenId,
2326
+ item: takenNftId ?? nftTokenId,
2230
2327
  itemType: nftType,
2231
2328
  policy: transferPolicyId
2232
2329
  });
@@ -2498,9 +2595,9 @@ async function addSingleBidAcceptNftBidTx(txData) {
2498
2595
  target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::accept_bid_with_transfer_policy`,
2499
2596
  typeArguments: [nftType],
2500
2597
  arguments: [
2501
- tx.object(import_utils3.SUI_CLOCK_OBJECT_ID),
2598
+ tx.object(import_utils4.SUI_CLOCK_OBJECT_ID),
2502
2599
  tx.object(TRADEPORT_MULTI_BID_STORE),
2503
- tx.pure.id((0, import_utils3.normalizeSuiObjectId)(bidNonce)),
2600
+ tx.pure.id((0, import_utils4.normalizeSuiObjectId)(bidNonce)),
2504
2601
  tx.pure.option("id", multiBidChainId),
2505
2602
  tx.object(kioskTx.getKiosk()),
2506
2603
  tx.object(kioskTx.getKioskCap()),
@@ -2523,7 +2620,7 @@ async function addSingleBidAcceptNftBidTx(txData) {
2523
2620
  target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::accept_bid_without_transfer_policy`,
2524
2621
  typeArguments: [nftType],
2525
2622
  arguments: [
2526
- tx.object(import_utils3.SUI_CLOCK_OBJECT_ID),
2623
+ tx.object(import_utils4.SUI_CLOCK_OBJECT_ID),
2527
2624
  tx.object(TRADEPORT_MULTI_BID_STORE),
2528
2625
  tx.pure.id(bidNonce),
2529
2626
  tx.pure.option("id", multiBidChainId),
@@ -2534,7 +2631,7 @@ async function addSingleBidAcceptNftBidTx(txData) {
2534
2631
  async function addTradePortAcceptNftBidTxHandler(txData) {
2535
2632
  const bidType = await getObjectType({
2536
2633
  suiClient: txData?.suiClient,
2537
- objectId: (0, import_utils3.normalizeSuiObjectId)(txData?.bidNonce)
2634
+ objectId: (0, import_utils4.normalizeSuiObjectId)(txData?.bidNonce)
2538
2635
  });
2539
2636
  if (isSingleBid(bidType)) {
2540
2637
  await addSingleBidAcceptNftBidTx(txData);
@@ -3009,7 +3106,7 @@ function addTocenAcceptCollectionBidTx({
3009
3106
  async function addTradePortAcceptCollectionBidTxHandler(txData) {
3010
3107
  const bidType = await getObjectType({
3011
3108
  suiClient: txData?.suiClient,
3012
- objectId: (0, import_utils4.normalizeSuiObjectId)(txData?.bidNonce)
3109
+ objectId: (0, import_utils5.normalizeSuiObjectId)(txData?.bidNonce)
3013
3110
  });
3014
3111
  if (isSingleBid(bidType)) {
3015
3112
  await addSingleBidAcceptNftBidTx(txData);
@@ -3173,7 +3270,7 @@ var acceptCollectionBid = async ({
3173
3270
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
3174
3271
  }
3175
3272
  const bidsForTracking = [];
3176
- const tx = existingTx ?? new import_transactions2.Transaction();
3273
+ const tx = existingTx ?? new import_transactions3.Transaction();
3177
3274
  const sharedKioskState = {
3178
3275
  kioskTx: kioskTx ?? void 0
3179
3276
  };
@@ -3243,11 +3340,11 @@ var acceptCollectionBid = async ({
3243
3340
  bidder: bid?.bidder
3244
3341
  });
3245
3342
  sharedKioskState?.kioskTx?.finalize();
3246
- return import_transactions2.Transaction.from(tx);
3343
+ return tx instanceof import_transactions3.Transaction ? tx : import_transactions3.Transaction.from(tx);
3247
3344
  };
3248
3345
 
3249
3346
  // src/methods/acceptNftBids/acceptNftBids.ts
3250
- var import_transactions3 = require("@mysten/sui/transactions");
3347
+ var import_transactions4 = require("@mysten/sui/transactions");
3251
3348
 
3252
3349
  // src/graphql/queries/fetchBidsById.ts
3253
3350
  var import_graphql_request12 = require("graphql-request");
@@ -3304,7 +3401,7 @@ var acceptNftBids = async ({
3304
3401
  throw new Error("No bids found");
3305
3402
  }
3306
3403
  const bidsForTracking = [];
3307
- const tx = existingTx ?? new import_transactions3.Transaction();
3404
+ const tx = existingTx ?? new import_transactions4.Transaction();
3308
3405
  const sharedKioskState = {
3309
3406
  kioskTx: kioskTx ?? void 0
3310
3407
  };
@@ -3377,15 +3474,15 @@ var acceptNftBids = async ({
3377
3474
  });
3378
3475
  }
3379
3476
  sharedKioskState?.kioskTx?.finalize();
3380
- return import_transactions3.Transaction.from(tx);
3477
+ return tx instanceof import_transactions4.Transaction ? tx : import_transactions4.Transaction.from(tx);
3381
3478
  };
3382
3479
 
3383
3480
  // src/methods/buyAndExerciseLongLocks/buyAndExerciseLongLocks.ts
3384
- var import_transactions6 = require("@mysten/sui/transactions");
3481
+ var import_transactions7 = require("@mysten/sui/transactions");
3385
3482
 
3386
3483
  // src/methods/buyLocks/buyLocks.ts
3387
- var import_utils5 = require("@mysten/sui.js/utils");
3388
- var import_transactions4 = require("@mysten/sui/transactions");
3484
+ var import_utils6 = require("@mysten/sui.js/utils");
3485
+ var import_transactions5 = require("@mysten/sui/transactions");
3389
3486
 
3390
3487
  // src/helpers/calculatePremium.ts
3391
3488
  function calculatePremium(price) {
@@ -3523,7 +3620,7 @@ var getNativeKioskTransferPoliciesByNftType = async (nftType) => {
3523
3620
 
3524
3621
  // src/methods/buyLocks/buyLocks.ts
3525
3622
  async function buyLocks({ lockIds, transaction }, context) {
3526
- const tx = transaction ?? new import_transactions4.Transaction();
3623
+ const tx = transaction ?? new import_transactions5.Transaction();
3527
3624
  for (const lockId of lockIds) {
3528
3625
  const lock = await getLockById(lockId);
3529
3626
  if (!lock) {
@@ -3550,7 +3647,7 @@ async function buyLocks({ lockIds, transaction }, context) {
3550
3647
  typeArguments: [lock.nft_type],
3551
3648
  arguments: [
3552
3649
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
3553
- tx.object(import_utils5.SUI_CLOCK_OBJECT_ID),
3650
+ tx.object(import_utils6.SUI_CLOCK_OBJECT_ID),
3554
3651
  tx.pure.id(lock.lock_id),
3555
3652
  tx.pure.u64(lock.maker_price),
3556
3653
  tx.pure.u64(marketplaceFee),
@@ -3564,10 +3661,10 @@ async function buyLocks({ lockIds, transaction }, context) {
3564
3661
  }
3565
3662
 
3566
3663
  // src/methods/exerciseLongLocks/exerciseLongLocks.ts
3567
- var import_utils6 = require("@mysten/sui.js/utils");
3568
- var import_transactions5 = require("@mysten/sui/transactions");
3664
+ var import_utils7 = require("@mysten/sui.js/utils");
3665
+ var import_transactions6 = require("@mysten/sui/transactions");
3569
3666
  async function exerciseLongLocks({ walletAddress, transaction, locks }, context) {
3570
- const tx = transaction ?? new import_transactions5.Transaction();
3667
+ const tx = transaction ?? new import_transactions6.Transaction();
3571
3668
  for (const { id: lockId, bidId } of locks) {
3572
3669
  const lock = await getLockById(lockId);
3573
3670
  if (!transaction && lock.state !== "bought") {
@@ -3622,7 +3719,7 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
3622
3719
  typeArguments: [lock.nft_type],
3623
3720
  arguments: [
3624
3721
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
3625
- tx.object(import_utils6.SUI_CLOCK_OBJECT_ID),
3722
+ tx.object(import_utils7.SUI_CLOCK_OBJECT_ID),
3626
3723
  tx.pure.id(lock.lock_id),
3627
3724
  tx.object(lock.chain_state.makerKioskId),
3628
3725
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
@@ -3719,18 +3816,18 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
3719
3816
 
3720
3817
  // src/methods/buyAndExerciseLongLocks/buyAndExerciseLongLocks.ts
3721
3818
  async function buyAndExerciseLongLocks({ walletAddress, locks, tx: existingTx }, context) {
3722
- const transaction = existingTx ?? new import_transactions6.Transaction();
3819
+ const transaction = existingTx ?? new import_transactions7.Transaction();
3723
3820
  await buyLocks({ lockIds: locks?.map((lock) => lock?.id), transaction }, context);
3724
3821
  await exerciseLongLocks({ locks, walletAddress, transaction }, context);
3725
3822
  return transaction;
3726
3823
  }
3727
3824
 
3728
3825
  // src/methods/buyAndExerciseShortLocks/buyAndExerciseShortLocks.ts
3729
- var import_transactions11 = require("@mysten/sui/transactions");
3826
+ var import_transactions12 = require("@mysten/sui/transactions");
3730
3827
 
3731
3828
  // src/methods/exerciseShortLocks/exerciseShortLocks.ts
3732
- var import_utils7 = require("@mysten/sui.js/utils");
3733
- var import_transactions10 = require("@mysten/sui/transactions");
3829
+ var import_utils8 = require("@mysten/sui.js/utils");
3830
+ var import_transactions11 = require("@mysten/sui/transactions");
3734
3831
 
3735
3832
  // src/graphql/queries/fetchListingsById.ts
3736
3833
  var import_graphql_request15 = require("graphql-request");
@@ -3763,7 +3860,7 @@ var fetchListingsById = import_graphql_request15.gql`
3763
3860
  `;
3764
3861
 
3765
3862
  // src/methods/buyListings/buyListings.ts
3766
- var import_transactions9 = require("@mysten/sui/transactions");
3863
+ var import_transactions10 = require("@mysten/sui/transactions");
3767
3864
 
3768
3865
  // src/helpers/addThirdPartyTxFee.ts
3769
3866
  var addThirdPartyTxFee = async (tx, price) => {
@@ -3777,31 +3874,19 @@ var addThirdPartyTxFee = async (tx, price) => {
3777
3874
  };
3778
3875
 
3779
3876
  // src/helpers/deserializeOrCreateTxBlock.ts
3780
- var import_transactions7 = require("@mysten/sui/transactions");
3877
+ var import_transactions8 = require("@mysten/sui/transactions");
3781
3878
  var deserializeOrCreateTxBlock = ({
3782
3879
  existingTx
3783
3880
  }) => {
3784
3881
  if (typeof existingTx === "string") {
3785
- return import_transactions7.Transaction.from(existingTx);
3882
+ return import_transactions8.Transaction.from(existingTx);
3786
3883
  }
3787
- return existingTx ?? new import_transactions7.Transaction();
3788
- };
3789
-
3790
- // src/helpers/extractSwapResultCoin.ts
3791
- var extractSwapResultCoinFromTxBlock = (txBlock) => {
3792
- if (!txBlock) return void 0;
3793
- const tx = typeof txBlock === "string" ? JSON.parse(txBlock) : txBlock?.getData();
3794
- const commands = tx.commands ?? [];
3795
- const index = commands.findIndex(
3796
- (cmd) => cmd?.MoveCall?.module === "universal_router" && cmd?.MoveCall?.function === "settle"
3797
- );
3798
- if (index === -1) return void 0;
3799
- return { $kind: "Result", Result: index };
3884
+ return existingTx ?? new import_transactions8.Transaction();
3800
3885
  };
3801
3886
 
3802
3887
  // src/helpers/kiosk/preProcessSharedBulkBuyingData.ts
3803
3888
  var import_bcs2 = require("@mysten/sui/bcs");
3804
- var import_transactions8 = require("@mysten/sui/transactions");
3889
+ var import_transactions9 = require("@mysten/sui/transactions");
3805
3890
  var preProcessSharedBulkBuyingData = async ({
3806
3891
  listings,
3807
3892
  suiClient,
@@ -3851,7 +3936,7 @@ var preProcessSharedBulkBuyingData = async ({
3851
3936
  (policy) => policy.moduleName === "royalty_rule" || policy.moduleName === "kiosk_royalty_rule"
3852
3937
  );
3853
3938
  if (royaltyRuleToResolve?.rulePackageId && royaltyRuleToResolve?.moduleName) {
3854
- const feeTx = new import_transactions8.Transaction();
3939
+ const feeTx = new import_transactions9.Transaction();
3855
3940
  for (const listing of tradeportKioskListings) {
3856
3941
  feeTx.moveCall({
3857
3942
  target: `${royaltyRuleToResolve.rulePackageId}::${royaltyRuleToResolve.moduleName}::fee_amount`,
@@ -3992,7 +4077,8 @@ var addTradeportKioskBuyTx = async ({
3992
4077
  coinToSplit,
3993
4078
  beforeResolveKioskTransferRequest,
3994
4079
  sharedBulkBuyingDataByNftType,
3995
- collectionId
4080
+ collectionId,
4081
+ amountToSplitFromSuiBalance
3996
4082
  }) => {
3997
4083
  let commissionFeeAmount = sharedBulkBuyingDataByNftType?.[nftType]?.commissionFeeAmountsByListingId?.[listingId] ?? 0;
3998
4084
  if (!commissionFeeAmount) {
@@ -4008,6 +4094,7 @@ var addTradeportKioskBuyTx = async ({
4008
4094
  if (commissionFeeAmount === 0) {
4009
4095
  commissionFeeAmount = getMarketFeePrice({ price, collectionId });
4010
4096
  }
4097
+ mergeSwapCoinWithSuiBalance(tx, coinToSplit, amountToSplitFromSuiBalance);
4011
4098
  const coin = tx.splitCoins(coinToSplit ? coinToSplit : tx.gas, [
4012
4099
  tx.pure.u64(price + commissionFeeAmount)
4013
4100
  ]);
@@ -4037,7 +4124,8 @@ var addTradeportKioskBuyTx = async ({
4037
4124
  coinToSplit,
4038
4125
  beforeResolveKioskTransferRequest,
4039
4126
  transferPoliciesToResolve: sharedBulkBuyingDataByNftType?.[nftType]?.transferPoliciesToResolve,
4040
- royaltyFeeAmount: sharedBulkBuyingDataByNftType?.[nftType]?.royaltyFeeAmountsByListingId?.[listingId]
4127
+ royaltyFeeAmount: sharedBulkBuyingDataByNftType?.[nftType]?.royaltyFeeAmountsByListingId?.[listingId],
4128
+ amountToSplitFromSuiBalance
4041
4129
  });
4042
4130
  destroyZeroCoin({ tx, coin });
4043
4131
  };
@@ -4441,7 +4529,8 @@ var buyListings = async ({
4441
4529
  tx: existingTx,
4442
4530
  kioskTx,
4443
4531
  coinToSplit,
4444
- beforeResolveKioskTransferRequest
4532
+ beforeResolveKioskTransferRequest,
4533
+ swapAndPayOptions
4445
4534
  }, context, marketFeeDecimalPercent) => {
4446
4535
  const res = await gqlChainRequest({
4447
4536
  chain: "sui",
@@ -4452,8 +4541,14 @@ var buyListings = async ({
4452
4541
  throw new Error("No listings found");
4453
4542
  }
4454
4543
  const listingsForTracking = [];
4455
- const tx = deserializeOrCreateTxBlock({ existingTx });
4456
- const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
4544
+ let tx = deserializeOrCreateTxBlock({ existingTx });
4545
+ const { transaction: updatedTx, swapResultCoin } = await handleSwapSetup(
4546
+ context.suiClient,
4547
+ walletAddress,
4548
+ tx,
4549
+ swapAndPayOptions
4550
+ );
4551
+ tx = updatedTx;
4457
4552
  const tocenTokenIds = [];
4458
4553
  let tocenNftType = "";
4459
4554
  let tocenTotalPrice = 0;
@@ -4502,7 +4597,8 @@ var buyListings = async ({
4502
4597
  marketFeeDecimalPercent,
4503
4598
  beforeResolveKioskTransferRequest,
4504
4599
  sharedKioskState,
4505
- sharedBulkBuyingDataByNftType
4600
+ sharedBulkBuyingDataByNftType,
4601
+ amountToSplitFromSuiBalance: BigInt(swapAndPayOptions?.amountToSplitFromSuiBalance ?? 0n)
4506
4602
  };
4507
4603
  switch (listing?.market_name) {
4508
4604
  case "tradeport":
@@ -4547,9 +4643,7 @@ var buyListings = async ({
4547
4643
  });
4548
4644
  }
4549
4645
  sharedKioskState?.kioskTx?.finalize();
4550
- if (swapResultCoin) {
4551
- tx.transferObjects([swapResultCoin], walletAddress);
4552
- }
4646
+ handleSwapCleanup(tx, swapResultCoin, walletAddress);
4553
4647
  if (tocenTokenIds?.length > 0) {
4554
4648
  addTocenBuyTxHandler({
4555
4649
  tx,
@@ -4558,12 +4652,12 @@ var buyListings = async ({
4558
4652
  price: tocenTotalPrice
4559
4653
  });
4560
4654
  }
4561
- return import_transactions9.Transaction.from(tx);
4655
+ return tx instanceof import_transactions10.Transaction ? tx : import_transactions10.Transaction.from(tx);
4562
4656
  };
4563
4657
 
4564
4658
  // src/methods/exerciseShortLocks/exerciseShortLocks.ts
4565
4659
  async function exerciseShortLocks({ walletAddress, transaction, locks }, context) {
4566
- const tx = transaction ?? new import_transactions10.Transaction();
4660
+ const tx = transaction ?? new import_transactions11.Transaction();
4567
4661
  for (const { id: lockId, listingId, nftId: nftIdArg } of locks) {
4568
4662
  const lock = await getLockById(lockId);
4569
4663
  if (!transaction && lock.state !== "bought") {
@@ -4626,7 +4720,7 @@ async function exerciseShortLocks({ walletAddress, transaction, locks }, context
4626
4720
  typeArguments: [lock.nft_type],
4627
4721
  arguments: [
4628
4722
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
4629
- tx.object(import_utils7.SUI_CLOCK_OBJECT_ID),
4723
+ tx.object(import_utils8.SUI_CLOCK_OBJECT_ID),
4630
4724
  tx.pure.id(lock.lock_id)
4631
4725
  ]
4632
4726
  });
@@ -4701,17 +4795,17 @@ async function exerciseShortLocks({ walletAddress, transaction, locks }, context
4701
4795
 
4702
4796
  // src/methods/buyAndExerciseShortLocks/buyAndExerciseShortLocks.ts
4703
4797
  async function buyAndExerciseShortLocks({ walletAddress, locks, tx: existingTx }, context) {
4704
- const transaction = existingTx ?? new import_transactions11.Transaction();
4798
+ const transaction = existingTx ?? new import_transactions12.Transaction();
4705
4799
  await buyLocks({ lockIds: locks?.map((lock) => lock?.id), transaction }, context);
4706
4800
  await exerciseShortLocks({ locks, walletAddress, transaction }, context);
4707
4801
  return transaction;
4708
4802
  }
4709
4803
 
4710
4804
  // src/methods/cancelLocks/cancelLocks.ts
4711
- var import_utils8 = require("@mysten/sui.js/utils");
4712
- var import_transactions12 = require("@mysten/sui/transactions");
4805
+ var import_utils9 = require("@mysten/sui.js/utils");
4806
+ var import_transactions13 = require("@mysten/sui/transactions");
4713
4807
  async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context) {
4714
- const tx = existingTx ?? new import_transactions12.Transaction();
4808
+ const tx = existingTx ?? new import_transactions13.Transaction();
4715
4809
  for (const lockId of lockIds) {
4716
4810
  const lock = await getLockById(lockId);
4717
4811
  if (!lock) {
@@ -4731,7 +4825,7 @@ async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context)
4731
4825
  typeArguments: [lock.nft_type],
4732
4826
  arguments: [
4733
4827
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
4734
- tx.object(import_utils8.SUI_CLOCK_OBJECT_ID),
4828
+ tx.object(import_utils9.SUI_CLOCK_OBJECT_ID),
4735
4829
  tx.pure.id(lock.lock_id),
4736
4830
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk)
4737
4831
  ]
@@ -4743,10 +4837,10 @@ async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context)
4743
4837
  }
4744
4838
 
4745
4839
  // src/methods/cancelMultiBid/cancelMultiBid.ts
4746
- var import_transactions13 = require("@mysten/sui/transactions");
4840
+ var import_transactions14 = require("@mysten/sui/transactions");
4747
4841
 
4748
4842
  // src/methods/removeNftBids/addRemoveNftBidTxs.ts
4749
- var import_utils9 = require("@mysten/sui/utils");
4843
+ var import_utils10 = require("@mysten/sui/utils");
4750
4844
  function addTradeportRemoveNftBidTx({ tx, bidNonce, nftType }) {
4751
4845
  tx.moveCall({
4752
4846
  target: "0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::biddings::cancel_bid",
@@ -4803,7 +4897,7 @@ function addCancelSingleBidForMultibidChainId(tx, bidNonce, multiBidChainId) {
4803
4897
  target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::cancel_bid`,
4804
4898
  arguments: [
4805
4899
  tx.object(TRADEPORT_MULTI_BID_STORE),
4806
- tx.pure.id((0, import_utils9.normalizeSuiObjectId)(bidNonce)),
4900
+ tx.pure.id((0, import_utils10.normalizeSuiObjectId)(bidNonce)),
4807
4901
  tx.pure.option("id", multiBidChainId)
4808
4902
  ]
4809
4903
  });
@@ -4811,7 +4905,7 @@ function addCancelSingleBidForMultibidChainId(tx, bidNonce, multiBidChainId) {
4811
4905
  async function addTradePortRemoveNftBidTxHandler(txData) {
4812
4906
  const bidType = await getObjectType({
4813
4907
  suiClient: txData?.suiClient,
4814
- objectId: (0, import_utils9.normalizeSuiObjectId)(txData?.bidNonce)
4908
+ objectId: (0, import_utils10.normalizeSuiObjectId)(txData?.bidNonce)
4815
4909
  });
4816
4910
  if (isSingleBid(bidType)) {
4817
4911
  await addSingleBidRemoveNftBidTx(txData);
@@ -4845,7 +4939,7 @@ async function cancelMultiBid({ multiBidId }) {
4845
4939
  if (cancelled_at) {
4846
4940
  throw new Error(`MultiBid ${multiBidId} already cancelled`);
4847
4941
  }
4848
- const tx = new import_transactions13.Transaction();
4942
+ const tx = new import_transactions14.Transaction();
4849
4943
  if (bids.length > 1022) {
4850
4944
  throw new Error(`Too many bids to cancel in one transaction`);
4851
4945
  }
@@ -4860,7 +4954,7 @@ async function cancelMultiBid({ multiBidId }) {
4860
4954
  }
4861
4955
 
4862
4956
  // src/methods/cancelNftTransfers/cancelNftTransfers.ts
4863
- var import_transactions14 = require("@mysten/sui/transactions");
4957
+ var import_transactions15 = require("@mysten/sui/transactions");
4864
4958
 
4865
4959
  // src/graphql/queries/fetchAccountKiosks.ts
4866
4960
  var import_graphql_request17 = require("graphql-request");
@@ -4914,7 +5008,7 @@ var cancelNftTransfers = async ({ nftIds, walletAddress }, context) => {
4914
5008
  throw new Error("No nfts found");
4915
5009
  }
4916
5010
  const nftsForTracking = [];
4917
- const tx = new import_transactions14.Transaction();
5011
+ const tx = new import_transactions15.Transaction();
4918
5012
  const sharedKioskState = {
4919
5013
  kioskTx: void 0
4920
5014
  };
@@ -4958,11 +5052,11 @@ var cancelNftTransfers = async ({ nftIds, walletAddress }, context) => {
4958
5052
  });
4959
5053
  }
4960
5054
  sharedKioskState?.kioskTx?.finalize();
4961
- return import_transactions14.Transaction.from(tx);
5055
+ return tx instanceof import_transactions15.Transaction ? tx : import_transactions15.Transaction.from(tx);
4962
5056
  };
4963
5057
 
4964
5058
  // src/methods/claimNfts/claimNfts.ts
4965
- var import_transactions15 = require("@mysten/sui/transactions");
5059
+ var import_transactions16 = require("@mysten/sui/transactions");
4966
5060
 
4967
5061
  // src/helpers/splitCoins.ts
4968
5062
  var splitCoins = ({ tx, amounts }) => {
@@ -5187,7 +5281,7 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
5187
5281
  throw new Error("No nfts found");
5188
5282
  }
5189
5283
  const nftsForTracking = [];
5190
- const tx = existingTx ?? new import_transactions15.Transaction();
5284
+ const tx = existingTx ?? new import_transactions16.Transaction();
5191
5285
  const sharedKioskState = {
5192
5286
  kioskTx: void 0
5193
5287
  };
@@ -5330,11 +5424,11 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
5330
5424
  }
5331
5425
  }
5332
5426
  sharedKioskState?.kioskTx?.finalize();
5333
- return import_transactions15.Transaction.from(tx);
5427
+ return tx instanceof import_transactions16.Transaction ? tx : import_transactions16.Transaction.from(tx);
5334
5428
  };
5335
5429
 
5336
5430
  // src/methods/createLongLocks/createLongLocks.ts
5337
- var import_transactions16 = require("@mysten/sui/transactions");
5431
+ var import_transactions17 = require("@mysten/sui/transactions");
5338
5432
 
5339
5433
  // src/graphql/queries/fetchActiveLockStateByNftId.ts
5340
5434
  var import_graphql_request18 = require("graphql-request");
@@ -5365,7 +5459,7 @@ var getActiveLockStateByNftId = async (nftId) => {
5365
5459
  // src/methods/createLongLocks/createLongLocks.ts
5366
5460
  async function createLongLocks({ walletAddress, nfts }, context) {
5367
5461
  const expireIn = 7 * 24 * 3600 * 1e3;
5368
- const tx = new import_transactions16.Transaction();
5462
+ const tx = new import_transactions17.Transaction();
5369
5463
  for (const argNft of nfts) {
5370
5464
  const existingLock = await getActiveLockStateByNftId(argNft.id);
5371
5465
  if (existingLock) {
@@ -5434,10 +5528,23 @@ async function updateMultiBid({
5434
5528
  amount,
5435
5529
  amountToWithdraw,
5436
5530
  tx: existingTx,
5437
- multiBidChainId
5531
+ multiBidChainId,
5532
+ swapAndPayOptions,
5533
+ suiClient,
5534
+ walletAddress
5438
5535
  }) {
5439
- const tx = deserializeOrCreateTxBlock({ existingTx });
5440
- const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
5536
+ let tx = deserializeOrCreateTxBlock({ existingTx });
5537
+ let swapResultCoin;
5538
+ if (suiClient) {
5539
+ const { transaction: updatedTx, swapResultCoin: coin2 } = await handleSwapSetup(
5540
+ suiClient,
5541
+ walletAddress,
5542
+ tx,
5543
+ swapAndPayOptions
5544
+ );
5545
+ tx = updatedTx;
5546
+ swapResultCoin = coin2;
5547
+ }
5441
5548
  if (!multiBidChainId) {
5442
5549
  const { chain_id: chainId, cancelled_at } = (await gqlChainRequest({
5443
5550
  chain: "sui",
@@ -5452,6 +5559,11 @@ async function updateMultiBid({
5452
5559
  }
5453
5560
  multiBidChainId = chainId;
5454
5561
  }
5562
+ mergeSwapCoinWithSuiBalance(
5563
+ tx,
5564
+ swapResultCoin,
5565
+ BigInt(swapAndPayOptions?.amountToSplitFromSuiBalance ?? 0n)
5566
+ );
5455
5567
  const [coin] = tx.splitCoins(swapResultCoin ? swapResultCoin : tx.gas, [amount ?? 0n]);
5456
5568
  tx.moveCall({
5457
5569
  target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::update_multi_bid`,
@@ -5463,16 +5575,14 @@ async function updateMultiBid({
5463
5575
  tx.pure.option("u64", amountToWithdraw)
5464
5576
  ]
5465
5577
  });
5578
+ if (suiClient) {
5579
+ handleSwapCleanup(tx, swapResultCoin, walletAddress);
5580
+ }
5466
5581
  return tx;
5467
5582
  }
5468
5583
 
5469
5584
  // src/methods/createMultiBid/createMultiBid.ts
5470
- async function createMultiBid({
5471
- walletAddress,
5472
- name,
5473
- amount,
5474
- tx: existingTx
5475
- }) {
5585
+ async function createMultiBid({ walletAddress, name, amount, tx: existingTx }, context) {
5476
5586
  const tx = deserializeOrCreateTxBlock({ existingTx });
5477
5587
  const multiBidChainId = tx.moveCall({
5478
5588
  target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
@@ -5484,17 +5594,18 @@ async function createMultiBid({
5484
5594
  multiBidChainId,
5485
5595
  amount,
5486
5596
  name,
5487
- tx
5597
+ tx,
5598
+ suiClient: context.suiClient
5488
5599
  });
5489
5600
  }
5490
5601
  return { multiBidChainId, tx };
5491
5602
  }
5492
5603
 
5493
5604
  // src/methods/createShortLocks/createShortLocks.ts
5494
- var import_transactions17 = require("@mysten/sui/transactions");
5605
+ var import_transactions18 = require("@mysten/sui/transactions");
5495
5606
  async function createShortLocks({ nfts }, context) {
5496
5607
  const expireIn = 7 * 24 * 3600 * 1e3;
5497
- const tx = new import_transactions17.Transaction();
5608
+ const tx = new import_transactions18.Transaction();
5498
5609
  for (const argNft of nfts) {
5499
5610
  const premium = calculatePremium(BigInt(argNft.priceInMist));
5500
5611
  if (!argNft.type) {
@@ -5532,8 +5643,8 @@ async function createShortLocks({ nfts }, context) {
5532
5643
  }
5533
5644
 
5534
5645
  // src/methods/listNfts/listNfts.ts
5535
- var import_transactions18 = require("@mysten/sui/transactions");
5536
- var import_utils10 = require("@mysten/sui/utils");
5646
+ var import_transactions19 = require("@mysten/sui/transactions");
5647
+ var import_utils11 = require("@mysten/sui/utils");
5537
5648
 
5538
5649
  // src/methods/listNfts/addListTxs.ts
5539
5650
  async function addOriginByteListTx({
@@ -5863,7 +5974,7 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
5863
5974
  throw new Error("No nfts found");
5864
5975
  }
5865
5976
  const nftsForTracking = [];
5866
- const tx = new import_transactions18.Transaction();
5977
+ const tx = new import_transactions19.Transaction();
5867
5978
  const sharedKioskState = {
5868
5979
  kioskTx: void 0
5869
5980
  };
@@ -5878,7 +5989,7 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
5878
5989
  });
5879
5990
  const transferPolicies = nft?.collection?.chain_state?.transfer_policies;
5880
5991
  if (nft?.listed || nft.listings.some(
5881
- (listing) => listing.nonce && listing.seller && (0, import_utils10.normalizeSuiAddress)(listing.seller) === (0, import_utils10.normalizeSuiAddress)(walletAddress)
5992
+ (listing) => listing.nonce && listing.seller && (0, import_utils11.normalizeSuiAddress)(listing.seller) === (0, import_utils11.normalizeSuiAddress)(walletAddress)
5882
5993
  )) {
5883
5994
  await relistNft({
5884
5995
  tx,
@@ -5916,11 +6027,11 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
5916
6027
  });
5917
6028
  }
5918
6029
  sharedKioskState?.kioskTx?.finalize();
5919
- return import_transactions18.Transaction.from(tx);
6030
+ return tx instanceof import_transactions19.Transaction ? tx : import_transactions19.Transaction.from(tx);
5920
6031
  };
5921
6032
 
5922
6033
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
5923
- var import_transactions19 = require("@mysten/sui/transactions");
6034
+ var import_transactions20 = require("@mysten/sui/transactions");
5924
6035
 
5925
6036
  // src/graphql/queries/fetchNftsByKioskId.ts
5926
6037
  var import_graphql_request19 = require("graphql-request");
@@ -6123,7 +6234,7 @@ async function getTransferPolicyForDirectTransfer(suiClient, collectionChainStat
6123
6234
 
6124
6235
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
6125
6236
  async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }, context) {
6126
- const tx = new import_transactions19.Transaction();
6237
+ const tx = new import_transactions20.Transaction();
6127
6238
  const res = await gqlChainRequest({
6128
6239
  chain: "sui",
6129
6240
  query: fetchKiosksByOwner,
@@ -6289,11 +6400,11 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }
6289
6400
  }
6290
6401
  }
6291
6402
  sharedKioskState?.kioskTx?.finalize();
6292
- return import_transactions19.Transaction.from(tx);
6403
+ return tx instanceof import_transactions20.Transaction ? tx : import_transactions20.Transaction.from(tx);
6293
6404
  }
6294
6405
 
6295
6406
  // src/methods/placeCollectionBids/placeCollectionBids.ts
6296
- var import_transactions20 = require("@mysten/sui/transactions");
6407
+ var import_transactions21 = require("@mysten/sui/transactions");
6297
6408
 
6298
6409
  // src/graphql/queries/fetchCollectionsById.ts
6299
6410
  var import_graphql_request20 = require("graphql-request");
@@ -6334,7 +6445,7 @@ var fetchCollectionsBySlug = import_graphql_request20.gql`
6334
6445
  `;
6335
6446
 
6336
6447
  // src/methods/placeNftBids/addPlaceNftBidTxs.ts
6337
- var import_utils11 = require("@mysten/sui/utils");
6448
+ var import_utils12 = require("@mysten/sui/utils");
6338
6449
  async function addTradePortPlaceNftBidTxHandler(txData) {
6339
6450
  if (isOriginByteCollection(txData?.transferPolicies) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
6340
6451
  throw new Error("OriginByte bidding not supported currently");
@@ -6348,14 +6459,15 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
6348
6459
  collectionId,
6349
6460
  bcsHex,
6350
6461
  expireAt,
6351
- coinToSplit
6462
+ coinToSplit,
6463
+ amountToSplitFromSuiBalance
6352
6464
  } = txData;
6353
6465
  let bcs4;
6354
6466
  if (nftTokenId && isDynamicCollection(collectionId)) {
6355
6467
  if (!bcsHex) {
6356
6468
  throw new Error(`No BCS found for token ${nftTokenId}`);
6357
6469
  }
6358
- bcs4 = (0, import_utils11.fromHex)(bcsHex);
6470
+ bcs4 = (0, import_utils12.fromHex)(bcsHex);
6359
6471
  }
6360
6472
  let multiBidChainId;
6361
6473
  let expiredBids;
@@ -6402,6 +6514,7 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
6402
6514
  }
6403
6515
  txWithState.hasCancelBidTransactions.set(multiBidChainId, true);
6404
6516
  }
6517
+ mergeSwapCoinWithSuiBalance(tx, coinToSplit, amountToSplitFromSuiBalance);
6405
6518
  const [coin] = tx.splitCoins(coinToSplit ? coinToSplit : tx.gas, [
6406
6519
  multiBidChainId ? 0n : price + fee + royalty
6407
6520
  ]);
@@ -6411,12 +6524,12 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
6411
6524
  arguments: [
6412
6525
  tx.object(TRADEPORT_MULTI_BID_STORE),
6413
6526
  tx.pure.u64(nftTokenId ? 1 : 0),
6414
- multiBidChainId ? typeof multiBidChainId === "string" ? tx.pure.option("id", (0, import_utils11.normalizeSuiObjectId)(multiBidChainId)) : tx.moveCall({
6527
+ multiBidChainId ? typeof multiBidChainId === "string" ? tx.pure.option("id", (0, import_utils12.normalizeSuiObjectId)(multiBidChainId)) : tx.moveCall({
6415
6528
  target: "0x1::option::some",
6416
6529
  typeArguments: ["0x2::object::ID"],
6417
6530
  arguments: [multiBidChainId]
6418
6531
  }) : void 0,
6419
- tx.pure.option("id", nftTokenId ? (0, import_utils11.normalizeSuiObjectId)(nftTokenId) : void 0),
6532
+ tx.pure.option("id", nftTokenId ? (0, import_utils12.normalizeSuiObjectId)(nftTokenId) : void 0),
6420
6533
  tx.pure.option("vector<u8>", bcs4 ? [...bcs4] : void 0),
6421
6534
  tx.pure.option("u64", expireAt?.getTime()),
6422
6535
  tx.pure.u64(price),
@@ -6507,7 +6620,14 @@ async function addOriginByteCollectionBidTx({
6507
6620
  }
6508
6621
 
6509
6622
  // src/methods/placeCollectionBids/placeCollectionBids.ts
6510
- var placeCollectionBids = async ({ collections, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
6623
+ var placeCollectionBids = async ({
6624
+ collections,
6625
+ walletAddress,
6626
+ multiBidId,
6627
+ multiBidChainId,
6628
+ tx: existingTx,
6629
+ swapAndPayOptions
6630
+ }, context) => {
6511
6631
  const res = await gqlChainRequest({
6512
6632
  chain: "sui",
6513
6633
  query: fetchCollectionsByIdWithOneNft,
@@ -6517,8 +6637,14 @@ var placeCollectionBids = async ({ collections, walletAddress, multiBidId, multi
6517
6637
  throw new Error("No collection found");
6518
6638
  }
6519
6639
  const collectionsForTracking = [];
6520
- const tx = deserializeOrCreateTxBlock({ existingTx });
6521
- const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
6640
+ let tx = deserializeOrCreateTxBlock({ existingTx });
6641
+ const { transaction: updatedTx, swapResultCoin } = await handleSwapSetup(
6642
+ context.suiClient,
6643
+ walletAddress,
6644
+ tx,
6645
+ swapAndPayOptions
6646
+ );
6647
+ tx = updatedTx;
6522
6648
  for (const collection of res.collections) {
6523
6649
  const nftType = getNftType({
6524
6650
  collectionId: collection?.id,
@@ -6538,7 +6664,8 @@ var placeCollectionBids = async ({ collections, walletAddress, multiBidId, multi
6538
6664
  multiBidId,
6539
6665
  multiBidChainId,
6540
6666
  expireAt: collections?.find((c) => c.id === collection?.id)?.expireAt,
6541
- coinToSplit: swapResultCoin
6667
+ coinToSplit: swapResultCoin,
6668
+ amountToSplitFromSuiBalance: BigInt(swapAndPayOptions?.amountToSplitFromSuiBalance ?? 0n)
6542
6669
  };
6543
6670
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
6544
6671
  if (isOriginByteCollection(txData?.transferPolicies) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
@@ -6565,17 +6692,28 @@ var placeCollectionBids = async ({ collections, walletAddress, multiBidId, multi
6565
6692
  bidder: walletAddress
6566
6693
  });
6567
6694
  }
6568
- if (swapResultCoin) {
6569
- tx.transferObjects([swapResultCoin], walletAddress);
6570
- }
6571
- return import_transactions20.Transaction.from(tx);
6695
+ handleSwapCleanup(tx, swapResultCoin, walletAddress);
6696
+ return tx instanceof import_transactions21.Transaction ? tx : import_transactions21.Transaction.from(tx);
6572
6697
  };
6573
6698
 
6574
6699
  // src/methods/placeNftBids/placeNftBids.ts
6575
- var import_transactions21 = require("@mysten/sui/transactions");
6576
- var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
6577
- const tx = deserializeOrCreateTxBlock({ existingTx });
6578
- const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
6700
+ var import_transactions22 = require("@mysten/sui/transactions");
6701
+ var placeNftBids = async ({
6702
+ bids,
6703
+ walletAddress,
6704
+ multiBidId,
6705
+ multiBidChainId,
6706
+ tx: existingTx,
6707
+ swapAndPayOptions
6708
+ }, context) => {
6709
+ let tx = deserializeOrCreateTxBlock({ existingTx });
6710
+ const { transaction: updatedTx, swapResultCoin } = await handleSwapSetup(
6711
+ context.suiClient,
6712
+ walletAddress,
6713
+ tx,
6714
+ swapAndPayOptions
6715
+ );
6716
+ tx = updatedTx;
6579
6717
  const res = await gqlChainRequest({
6580
6718
  chain: "sui",
6581
6719
  query: fetchNftsById,
@@ -6609,7 +6747,8 @@ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx
6609
6747
  multiBidId,
6610
6748
  multiBidChainId,
6611
6749
  expireAt: bid?.expireAt,
6612
- coinToSplit: swapResultCoin
6750
+ coinToSplit: swapResultCoin,
6751
+ amountToSplitFromSuiBalance: BigInt(swapAndPayOptions?.amountToSplitFromSuiBalance ?? 0n)
6613
6752
  };
6614
6753
  await addTradePortPlaceNftBidTxHandler(txData);
6615
6754
  nftsForTracking.push({
@@ -6619,17 +6758,15 @@ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx
6619
6758
  bidder: walletAddress
6620
6759
  });
6621
6760
  }
6622
- if (swapResultCoin) {
6623
- tx.transferObjects([swapResultCoin], walletAddress);
6624
- }
6625
- return import_transactions21.Transaction.from(tx);
6761
+ handleSwapCleanup(tx, swapResultCoin, walletAddress);
6762
+ return tx instanceof import_transactions22.Transaction ? tx : import_transactions22.Transaction.from(tx);
6626
6763
  };
6627
6764
 
6628
6765
  // src/methods/removeCollectionBids/removeCollectionBids.ts
6629
- var import_transactions22 = require("@mysten/sui/transactions");
6766
+ var import_transactions23 = require("@mysten/sui/transactions");
6630
6767
 
6631
6768
  // src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts
6632
- var import_utils12 = require("@mysten/sui/utils");
6769
+ var import_utils13 = require("@mysten/sui/utils");
6633
6770
  function addTradeportRemoveCollectionBidTx({
6634
6771
  tx,
6635
6772
  nftType,
@@ -6685,7 +6822,7 @@ function addBluemoveKioskRemoveCollectionBidTx({
6685
6822
  async function addTradePortRemoveCollectionBidTxHandler(txData) {
6686
6823
  const bidType = await getObjectType({
6687
6824
  suiClient: txData?.suiClient,
6688
- objectId: (0, import_utils12.normalizeSuiObjectId)(txData?.bidNonce)
6825
+ objectId: (0, import_utils13.normalizeSuiObjectId)(txData?.bidNonce)
6689
6826
  });
6690
6827
  if (isSingleBid(bidType)) {
6691
6828
  await addSingleBidRemoveNftBidTx(txData);
@@ -6705,7 +6842,7 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
6705
6842
  async function addBluemoveRemoveCollectionBidTxHandler(txData) {
6706
6843
  const bidType = await getObjectType({
6707
6844
  suiClient: txData?.suiClient,
6708
- objectId: (0, import_utils12.normalizeSuiObjectId)(txData?.bidNonce)
6845
+ objectId: (0, import_utils13.normalizeSuiObjectId)(txData?.bidNonce)
6709
6846
  });
6710
6847
  if (isOriginByteBid(bidType)) {
6711
6848
  const sharedObjects = await getSharedObjects(txData?.nftType);
@@ -6734,7 +6871,7 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
6734
6871
  throw new Error("No bids found");
6735
6872
  }
6736
6873
  const bidsForTracking = [];
6737
- const tx = existingTx ? import_transactions22.Transaction.from(existingTx) : new import_transactions22.Transaction();
6874
+ const tx = existingTx ? import_transactions23.Transaction.from(existingTx) : new import_transactions23.Transaction();
6738
6875
  for (const bid of res.bids) {
6739
6876
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
6740
6877
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6782,11 +6919,11 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
6782
6919
  bidder: bid?.bidder
6783
6920
  });
6784
6921
  }
6785
- return import_transactions22.Transaction.from(tx);
6922
+ return tx instanceof import_transactions23.Transaction ? tx : import_transactions23.Transaction.from(tx);
6786
6923
  };
6787
6924
 
6788
6925
  // src/methods/removeNftBids/removeNftBids.ts
6789
- var import_transactions23 = require("@mysten/sui/transactions");
6926
+ var import_transactions24 = require("@mysten/sui/transactions");
6790
6927
  var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6791
6928
  const res = await gqlChainRequest({
6792
6929
  chain: "sui",
@@ -6797,7 +6934,7 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6797
6934
  throw new Error("No bids found");
6798
6935
  }
6799
6936
  const bidsForTracking = [];
6800
- const tx = existingTx ? import_transactions23.Transaction.from(existingTx) : new import_transactions23.Transaction();
6937
+ const tx = existingTx ? import_transactions24.Transaction.from(existingTx) : new import_transactions24.Transaction();
6801
6938
  for (const bid of res.bids) {
6802
6939
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
6803
6940
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6842,11 +6979,11 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6842
6979
  bidder: bid?.bidder
6843
6980
  });
6844
6981
  }
6845
- return import_transactions23.Transaction.from(tx);
6982
+ return tx instanceof import_transactions24.Transaction ? tx : import_transactions24.Transaction.from(tx);
6846
6983
  };
6847
6984
 
6848
6985
  // src/methods/transferNfts/transferNfts.ts
6849
- var import_transactions24 = require("@mysten/sui/transactions");
6986
+ var import_transactions25 = require("@mysten/sui/transactions");
6850
6987
  var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context) => {
6851
6988
  if (addLeadingZerosAfter0x(recipientAddress) === addLeadingZerosAfter0x(walletAddress)) {
6852
6989
  throw new Error("Cannot transfer to self");
@@ -6864,7 +7001,7 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
6864
7001
  }
6865
7002
  const nftsForTracking = [];
6866
7003
  const nftsToTransferDirectly = [];
6867
- const tx = new import_transactions24.Transaction();
7004
+ const tx = new import_transactions25.Transaction();
6868
7005
  const sharedKioskState = {
6869
7006
  kioskTx: void 0
6870
7007
  };
@@ -6967,11 +7104,11 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
6967
7104
  context.suiClient
6968
7105
  );
6969
7106
  sharedKioskState?.kioskTx?.finalize();
6970
- return import_transactions24.Transaction.from(tx);
7107
+ return tx instanceof import_transactions25.Transaction ? tx : import_transactions25.Transaction.from(tx);
6971
7108
  };
6972
7109
 
6973
7110
  // src/methods/unlistListings/unlistListings.ts
6974
- var import_transactions25 = require("@mysten/sui/transactions");
7111
+ var import_transactions26 = require("@mysten/sui/transactions");
6975
7112
  var unlistListings = async ({ listingIds, walletAddress }, context) => {
6976
7113
  const res = await gqlChainRequest({
6977
7114
  chain: "sui",
@@ -6982,7 +7119,7 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
6982
7119
  throw new Error("No listings found");
6983
7120
  }
6984
7121
  const listingsForTracking = [];
6985
- const tx = new import_transactions25.Transaction();
7122
+ const tx = new import_transactions26.Transaction();
6986
7123
  const sharedKioskState = {
6987
7124
  kioskTx: void 0
6988
7125
  };
@@ -7051,12 +7188,12 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
7051
7188
  });
7052
7189
  }
7053
7190
  sharedKioskState?.kioskTx?.finalize();
7054
- return import_transactions25.Transaction.from(tx);
7191
+ return tx instanceof import_transactions26.Transaction ? tx : import_transactions26.Transaction.from(tx);
7055
7192
  };
7056
7193
 
7057
7194
  // src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts
7058
7195
  var import_kiosk5 = require("@mysten/kiosk");
7059
- var import_transactions26 = require("@mysten/sui/transactions");
7196
+ var import_transactions27 = require("@mysten/sui/transactions");
7060
7197
  async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7061
7198
  const res = await gqlChainRequest({
7062
7199
  chain: "sui",
@@ -7076,7 +7213,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7076
7213
  if (kiosksWithProfit.length === 0) {
7077
7214
  throw new Error(`No kiosks with profit to withdraw found for ${walletAddress}`);
7078
7215
  }
7079
- const tx = new import_transactions26.Transaction();
7216
+ const tx = new import_transactions27.Transaction();
7080
7217
  try {
7081
7218
  for (const kiosk of kiosksWithProfit) {
7082
7219
  let kioskTx;
@@ -7087,7 +7224,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7087
7224
  variables: { kioskId: kiosk.id }
7088
7225
  })).personalCap?.id;
7089
7226
  kioskTx = new import_kiosk5.KioskTransaction({
7090
- transactionBlock: tx,
7227
+ transaction: tx,
7091
7228
  kioskClient: context.kioskClient,
7092
7229
  cap: {
7093
7230
  isPersonal: true,
@@ -7104,7 +7241,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7104
7241
  variables: { kioskId: kiosk.id }
7105
7242
  })).ownerCap?.id;
7106
7243
  kioskTx = new import_kiosk5.KioskTransaction({
7107
- transactionBlock: tx,
7244
+ transaction: tx,
7108
7245
  kioskClient: context.kioskClient,
7109
7246
  cap: {
7110
7247
  isPersonal: false,
@@ -7122,7 +7259,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7122
7259
  } catch (err) {
7123
7260
  console.log("err", err);
7124
7261
  }
7125
- return import_transactions26.Transaction.from(tx);
7262
+ return tx instanceof import_transactions27.Transaction ? tx : import_transactions27.Transaction.from(tx);
7126
7263
  }
7127
7264
 
7128
7265
  // src/SuiTradingClient.ts
@@ -7141,14 +7278,19 @@ var SuiTradingClient = class {
7141
7278
  "x-api-key": apiKey
7142
7279
  });
7143
7280
  }
7144
- async buyListings({ listingIds, walletAddress, tx }) {
7281
+ async buyListings({
7282
+ listingIds,
7283
+ walletAddress,
7284
+ tx,
7285
+ swapAndPayOptions
7286
+ }) {
7145
7287
  const context = {
7146
7288
  apiUser: this.apiUser,
7147
7289
  apiKey: this.apiKey,
7148
7290
  suiClient: this.suiClient,
7149
7291
  kioskClient: this.kioskClient
7150
7292
  };
7151
- return buyListings({ listingIds, walletAddress, tx }, context);
7293
+ return buyListings({ listingIds, walletAddress, tx, swapAndPayOptions }, context);
7152
7294
  }
7153
7295
  async listNfts({ nfts, walletAddress }) {
7154
7296
  const context = {
@@ -7203,7 +7345,8 @@ var SuiTradingClient = class {
7203
7345
  multiBidId,
7204
7346
  multiBidChainId,
7205
7347
  expireAt,
7206
- tx
7348
+ tx,
7349
+ swapAndPayOptions
7207
7350
  }) {
7208
7351
  const context = {
7209
7352
  apiUser: this.apiUser,
@@ -7224,7 +7367,8 @@ var SuiTradingClient = class {
7224
7367
  walletAddress,
7225
7368
  multiBidId,
7226
7369
  multiBidChainId,
7227
- tx
7370
+ tx,
7371
+ swapAndPayOptions
7228
7372
  },
7229
7373
  context
7230
7374
  );
@@ -7450,13 +7594,19 @@ var SuiTradingClient = class {
7450
7594
  return migrateNftsFromUnsharedToSharedKiosks(args, context);
7451
7595
  }
7452
7596
  async createMultiBid(args) {
7453
- return createMultiBid(args);
7597
+ const context = {
7598
+ apiUser: this.apiUser,
7599
+ apiKey: this.apiKey,
7600
+ suiClient: this.suiClient,
7601
+ kioskClient: this.kioskClient
7602
+ };
7603
+ return createMultiBid(args, context);
7454
7604
  }
7455
7605
  async cancelMultiBid(args) {
7456
7606
  return cancelMultiBid(args);
7457
7607
  }
7458
7608
  async updateMultiBid(args) {
7459
- return updateMultiBid(args);
7609
+ return updateMultiBid({ ...args, suiClient: this.suiClient });
7460
7610
  }
7461
7611
  };
7462
7612
  var SuiTradingClient_default = SuiTradingClient;