@tradeport/sui-trading-sdk 0.4.63 → 0.4.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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,6 +17,14 @@ 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
@@ -168,6 +178,17 @@ var TRADEPORT_NFT_STRATEGY_PACKAGE_ID = "0xb7386fc8c6e64ea2b0079e293592b57e98498
168
178
  var TRADEPORT_NFT_STRATEGY_MANAGER_ID = "0xfb58ee62b3a62a8150f871da950dfdf923cd0d97b153caf99b5219cd4ddda5bd";
169
179
  var TRADEPORT_POOL_REGISTRY_ID = "0xcd0a614c4cbbf173f59dee2602c43a1717f283215ed7a0bb1d55d786af16fbcd";
170
180
  var TRADEPORT_POOL_VERSIONED_ID = "0x0309b66202e9aaf470081fffee7ffc0fbd50e3b7400d4f56fd06502e4dbbd676";
181
+ var DexConstants = {
182
+ commission: "0x24f5f2258ef80c0a3243088199faeb95ad50516ca1517dbd93be398d759057bb",
183
+ commissionManager: "0xd19a03d4ec3d12b0ce407b54eb676cc0f8e1403621deda77d9677bfcb9d738c1",
184
+ poolsToExclude: [
185
+ "0x3addbbc82866c0bbd93e51b6e2d75c0a4faaf270cc0e281d8f4de5df48bebfa4",
186
+ "0x19d614f421046cae90f5a3a976816063478f648087a12adc74e90ebd54dfaf19",
187
+ "0x514c74e28a9720366abc4a65a5688f47c72e784dbf035844d3f59059bfaed056",
188
+ "0x0854de4e9d64716b757b2f6f22258467f59cc1b4bc0cc64c70086549faaddedf"
189
+ ]
190
+ };
191
+ var USDC_COIN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
171
192
  var COLLECTION_IDS_WITH_ZERO_COMMISSION = [
172
193
  ""
173
194
  ];
@@ -3595,6 +3616,16 @@ var getCollectionChainState = async (collectionId) => {
3595
3616
  });
3596
3617
  return res?.collections?.[0]?.chain_state;
3597
3618
  };
3619
+ var getCollectionChainStateByFtType = async (ftType) => {
3620
+ const res = await gqlChainRequest({
3621
+ chain: "sui",
3622
+ query: fetchCollectionChainStateByFtType,
3623
+ variables: {
3624
+ ftType
3625
+ }
3626
+ });
3627
+ return res?.collections_by_ft_type?.[0]?.chain_state;
3628
+ };
3598
3629
 
3599
3630
  // src/methods/applyFtStrategy/applyFtStrategy.ts
3600
3631
  async function applyFtStrategy({
@@ -3629,105 +3660,12 @@ async function applyFtStrategy({
3629
3660
  return tx;
3630
3661
  }
3631
3662
 
3632
- // src/methods/applyNftStrategy/applyNftStrategy.ts
3633
- var import_transactions5 = require("@mysten/sui/transactions");
3634
-
3635
- // src/graphql/queries/fetchCollectionFloorListingForMarket.ts
3636
- var import_graphql_request13 = require("graphql-request");
3637
- var fetchCollectionFloorListingsForMarket = import_graphql_request13.gql`
3638
- query fetchCollectionFloorListingsForMarket(
3639
- $collectionId: uuid!
3640
- $marketAddress: String!
3641
- $totalPrice: numeric
3642
- ) {
3643
- listings(
3644
- where: {
3645
- collection_id: { _eq: $collectionId }
3646
- listed: { _eq: true }
3647
- market_name: { _eq: "tradeport" }
3648
- seller: { _neq: $marketAddress }
3649
- nonce: { _like: "1::0x%" }
3650
- price: { _lte: $totalPrice }
3651
- }
3652
- order_by: [{ price: asc_nulls_last }, { block_height: asc }, { tx_index: asc }]
3653
- ) {
3654
- id
3655
- price
3656
- nft {
3657
- token_id
3658
- delegated_owner
3659
- }
3660
- }
3661
- }
3662
- `;
3663
-
3664
- // src/methods/applyNftStrategy/applyNftStrategy.ts
3665
- async function applyTradeportNftStrategy({
3666
- collectionId,
3667
- strategyFtType,
3668
- tx: existingTx
3669
- }) {
3670
- const tx = existingTx ?? new import_transactions5.Transaction();
3671
- const chainState = await getCollectionChainState(collectionId);
3672
- const nftStrategies = chainState?.nft_strategies ?? {};
3673
- const nftStrategyKeys = Object.keys(nftStrategies);
3674
- if (nftStrategyKeys.length === 0) {
3675
- throw new Error("No NFT strategies found for collection");
3676
- }
3677
- strategyFtType = strategyFtType ?? nftStrategyKeys[0];
3678
- if (!nftStrategyKeys.includes(strategyFtType)) {
3679
- throw new Error(`Specified FT type ${strategyFtType} is not supported for this collection`);
3680
- }
3681
- const transferPolicy = getNativeKioskTransferPolicies(chainState?.transfer_policies ?? [])?.at(0);
3682
- if (!transferPolicy) {
3683
- throw new Error("No transfer policy found for collection");
3684
- }
3685
- const nftType = chainState?.nft_type;
3686
- let suiBalance = BigInt(
3687
- nftStrategies[strategyFtType].sui_balance ?? 0n
3688
- );
3689
- const result = await gqlChainRequest({
3690
- chain: "sui",
3691
- query: fetchCollectionFloorListingsForMarket,
3692
- variables: {
3693
- collectionId,
3694
- marketAddress: TRADEPORT_NFT_STRATEGY_MANAGER_ID,
3695
- totalPrice: suiBalance.toString()
3696
- }
3697
- });
3698
- if ((result?.listings?.length ?? 0) === 0) {
3699
- throw new Error(
3700
- `No floor listing found for collection with price bellow or equal to ${suiBalance} MIST`
3701
- );
3702
- }
3703
- for (const floorListing of result.listings) {
3704
- suiBalance -= BigInt(floorListing.price);
3705
- if (suiBalance < 0n) {
3706
- break;
3707
- }
3708
- tx.moveCall({
3709
- target: `${TRADEPORT_NFT_STRATEGY_PACKAGE_ID}::tradeport_nft_strategy::apply_tradeport_nft_strategy_confirm_request`,
3710
- typeArguments: [nftType, strategyFtType],
3711
- arguments: [
3712
- tx.object(TRADEPORT_NFT_STRATEGY_MANAGER_ID),
3713
- tx.object(nftStrategies[strategyFtType].kiosk_id),
3714
- tx.object(TRADEPORT_LISTINGS_STORE),
3715
- tx.object(TRADEPORT_ORDERBOOK_STORE),
3716
- tx.object(floorListing.nft.delegated_owner),
3717
- tx.object(floorListing.nft.token_id),
3718
- tx.object(transferPolicy.id)
3719
- ]
3720
- });
3721
- }
3722
- return tx;
3723
- }
3724
-
3725
3663
  // src/methods/buyListings/buyListings.ts
3726
3664
  var import_transactions7 = require("@mysten/sui/transactions");
3727
3665
 
3728
3666
  // src/graphql/queries/fetchListingsById.ts
3729
- var import_graphql_request14 = require("graphql-request");
3730
- var fetchListingsById = import_graphql_request14.gql`
3667
+ var import_graphql_request13 = require("graphql-request");
3668
+ var fetchListingsById = import_graphql_request13.gql`
3731
3669
  query fetchListingsById($listingIds: [uuid!]) {
3732
3670
  listings(where: { id: { _in: $listingIds } }) {
3733
3671
  id
@@ -3766,6 +3704,29 @@ var addThirdPartyTxFee = async (tx, price) => {
3766
3704
  );
3767
3705
  };
3768
3706
 
3707
+ // src/helpers/deserializeOrCreateTxBlock.ts
3708
+ var import_transactions5 = require("@mysten/sui/transactions");
3709
+ var deserializeOrCreateTxBlock = ({
3710
+ existingTx
3711
+ }) => {
3712
+ if (typeof existingTx === "string") {
3713
+ return import_transactions5.Transaction.from(existingTx);
3714
+ }
3715
+ return existingTx ?? new import_transactions5.Transaction();
3716
+ };
3717
+
3718
+ // src/helpers/extractSwapResultCoin.ts
3719
+ var extractSwapResultCoinFromTxBlock = (txBlock) => {
3720
+ if (!txBlock) return void 0;
3721
+ const tx = typeof txBlock === "string" ? JSON.parse(txBlock) : txBlock?.getData();
3722
+ const commands = tx.commands ?? [];
3723
+ const index = commands.findIndex(
3724
+ (cmd) => cmd?.MoveCall?.module === "universal_router" && cmd?.MoveCall?.function === "settle"
3725
+ );
3726
+ if (index === -1) return void 0;
3727
+ return { $kind: "Result", Result: index };
3728
+ };
3729
+
3769
3730
  // src/helpers/kiosk/preProcessSharedBulkBuyingData.ts
3770
3731
  var import_bcs2 = require("@mysten/sui/bcs");
3771
3732
  var import_transactions6 = require("@mysten/sui/transactions");
@@ -3871,8 +3832,8 @@ var preProcessSharedBulkBuyingData = async ({
3871
3832
  var import_bcs3 = require("@mysten/sui/bcs");
3872
3833
 
3873
3834
  // src/graphql/queries/fetchCommissionByListingId.ts
3874
- var import_graphql_request15 = require("graphql-request");
3875
- var fetchCommissionByNftContractId = import_graphql_request15.gql`
3835
+ var import_graphql_request14 = require("graphql-request");
3836
+ var fetchCommissionByNftContractId = import_graphql_request14.gql`
3876
3837
  query fetchCommissionByNftContractId($nftContractId: uuid!) {
3877
3838
  commissions(where: { contract_id: { _eq: $nftContractId } }) {
3878
3839
  is_custodial
@@ -4622,7 +4583,8 @@ var buyListings = async ({
4622
4583
  throw new Error("No listings found");
4623
4584
  }
4624
4585
  const listingsForTracking = [];
4625
- const tx = existingTx ?? new import_transactions7.Transaction();
4586
+ const tx = deserializeOrCreateTxBlock({ existingTx });
4587
+ const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
4626
4588
  const tocenTokenIds = [];
4627
4589
  let tocenNftType = "";
4628
4590
  let tocenTotalPrice = 0;
@@ -4667,7 +4629,7 @@ var buyListings = async ({
4667
4629
  sellerKiosk: listing.nft?.chain_state?.kiosk_id,
4668
4630
  collectionId: listing?.nft?.collection_id,
4669
4631
  nftContractId: listing?.nft?.contract_id,
4670
- coinToSplit,
4632
+ coinToSplit: swapResultCoin ? swapResultCoin : coinToSplit,
4671
4633
  marketFeeDecimalPercent,
4672
4634
  beforeResolveKioskTransferRequest,
4673
4635
  sharedKioskState,
@@ -4716,6 +4678,9 @@ var buyListings = async ({
4716
4678
  });
4717
4679
  }
4718
4680
  sharedKioskState?.kioskTx?.finalize();
4681
+ if (swapResultCoin) {
4682
+ tx.transferObjects([swapResultCoin], walletAddress);
4683
+ }
4719
4684
  if (tocenTokenIds?.length > 0) {
4720
4685
  addTocenBuyTxHandler({
4721
4686
  tx,
@@ -4724,7 +4689,7 @@ var buyListings = async ({
4724
4689
  price: tocenTotalPrice
4725
4690
  });
4726
4691
  }
4727
- return tx;
4692
+ return import_transactions7.Transaction.from(tx);
4728
4693
  };
4729
4694
 
4730
4695
  // src/methods/cancelMultiBid/cancelMultiBid.ts
@@ -4848,8 +4813,8 @@ async function cancelMultiBid({ multiBidId }) {
4848
4813
  var import_transactions9 = require("@mysten/sui/transactions");
4849
4814
 
4850
4815
  // src/graphql/queries/fetchAccountKiosks.ts
4851
- var import_graphql_request16 = require("graphql-request");
4852
- var fetchAccountKiosks = import_graphql_request16.gql`
4816
+ var import_graphql_request15 = require("graphql-request");
4817
+ var fetchAccountKiosks = import_graphql_request15.gql`
4853
4818
  query fetchAccountKiosks($accountAddress: String!) {
4854
4819
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
4855
4820
  id
@@ -5318,22 +5283,17 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
5318
5283
  return import_transactions10.Transaction.from(tx);
5319
5284
  };
5320
5285
 
5321
- // src/methods/createMultiBid/createMultiBid.ts
5322
- var import_transactions12 = require("@mysten/sui/transactions");
5323
-
5324
5286
  // src/methods/updateMultiBid/updateMultiBid.ts
5325
- var import_transactions11 = require("@mysten/sui/transactions");
5326
5287
  async function updateMultiBid({
5327
- walletAddress,
5328
5288
  multiBidId,
5329
5289
  name,
5330
5290
  amount,
5331
5291
  amountToWithdraw,
5332
5292
  tx: existingTx,
5333
- multiBidChainId,
5334
- coinToSplit
5335
- }, context) {
5336
- const tx = existingTx ?? new import_transactions11.Transaction();
5293
+ multiBidChainId
5294
+ }) {
5295
+ const tx = deserializeOrCreateTxBlock({ existingTx });
5296
+ const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
5337
5297
  if (!multiBidChainId) {
5338
5298
  const { chain_id: chainId, cancelled_at } = (await gqlChainRequest({
5339
5299
  chain: "sui",
@@ -5348,7 +5308,7 @@ async function updateMultiBid({
5348
5308
  }
5349
5309
  multiBidChainId = chainId;
5350
5310
  }
5351
- const [coin] = tx.splitCoins(coinToSplit ? coinToSplit : tx.gas, [amount ?? 0n]);
5311
+ const [coin] = tx.splitCoins(swapResultCoin ? swapResultCoin : tx.gas, [amount ?? 0n]);
5352
5312
  tx.moveCall({
5353
5313
  target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::update_multi_bid`,
5354
5314
  arguments: [
@@ -5369,7 +5329,7 @@ async function createMultiBid({
5369
5329
  amount,
5370
5330
  tx: existingTx
5371
5331
  }) {
5372
- const tx = existingTx ?? new import_transactions12.Transaction();
5332
+ const tx = deserializeOrCreateTxBlock({ existingTx });
5373
5333
  const multiBidChainId = tx.moveCall({
5374
5334
  target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
5375
5335
  arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.option("string", name)]
@@ -5387,11 +5347,7 @@ async function createMultiBid({
5387
5347
  }
5388
5348
 
5389
5349
  // src/methods/listNfts/listNfts.ts
5390
- var import_transactions13 = require("@mysten/sui/transactions");
5391
-
5392
- // src/helpers/isExpiredListing.ts
5393
- var import_utils7 = require("@mysten/sui/utils");
5394
- var isExpiredListing = (listing, walletAddress) => listing.nonce && listing.seller && (0, import_utils7.normalizeSuiAddress)(listing.seller) === (0, import_utils7.normalizeSuiAddress)(walletAddress);
5350
+ var import_transactions12 = require("@mysten/sui/transactions");
5395
5351
 
5396
5352
  // src/helpers/validateMinFloorPrice.ts
5397
5353
  function validateMinFloorPrice({ transferPolicies, listPrice }) {
@@ -5720,15 +5676,319 @@ async function relistNft({
5720
5676
  }
5721
5677
  }
5722
5678
 
5679
+ // src/methods/swapCoins/swapCoins.ts
5680
+ var import_sdk = require("@flowx-finance/sdk");
5681
+ var import_transactions11 = require("@mysten/sui/transactions");
5682
+ var import_utils7 = require("@mysten/sui/utils");
5683
+ var import_ms = __toESM(require("ms"));
5684
+
5685
+ // src/utils/pureValues.ts
5686
+ var toDecimalValue = (value, decimals) => {
5687
+ if (!value || decimals === void 0) return new bigNumberConfig_default(0);
5688
+ return new bigNumberConfig_default(value).div(10 ** decimals);
5689
+ };
5690
+ var toPureValue = (value, decimals) => {
5691
+ if (!value || decimals === void 0) return new bigNumberConfig_default(0);
5692
+ return new bigNumberConfig_default(new bigNumberConfig_default(value).multipliedBy(10 ** decimals).toFixed(0));
5693
+ };
5694
+
5695
+ // src/methods/swapCoins/swapCoins.ts
5696
+ async function swapCoins({
5697
+ walletAddress,
5698
+ coinInType,
5699
+ coinInAmount,
5700
+ coinOutType,
5701
+ slippage = 1e3,
5702
+ // 0.1%
5703
+ ttl = "5m",
5704
+ excludeSources = [import_sdk.Protocol.STEAMM, import_sdk.Protocol.BOLT],
5705
+ routes,
5706
+ commission,
5707
+ tx: existingTx
5708
+ }, { suiClient, defiRouterUrl }) {
5709
+ const inAmount = BigInt(coinInAmount);
5710
+ const tx = existingTx ?? new import_transactions11.Transaction();
5711
+ coinInType = (0, import_utils7.normalizeStructTag)(coinInType);
5712
+ coinOutType = (0, import_utils7.normalizeStructTag)(coinOutType);
5713
+ walletAddress = (0, import_utils7.normalizeSuiAddress)(walletAddress);
5714
+ tx.setSenderIfNotSet((0, import_utils7.normalizeSuiAddress)(walletAddress));
5715
+ if (inAmount === 0n) {
5716
+ const zeroCoin = tx.moveCall({
5717
+ target: "0x2::coin::zero",
5718
+ typeArguments: [coinOutType]
5719
+ });
5720
+ return {
5721
+ tx,
5722
+ coinOut: zeroCoin
5723
+ };
5724
+ }
5725
+ if (coinInType === coinOutType) {
5726
+ const getCoin = (0, import_transactions11.coinWithBalance)({
5727
+ type: coinInType,
5728
+ balance: inAmount
5729
+ });
5730
+ return {
5731
+ tx,
5732
+ coinOut: getCoin(tx)
5733
+ };
5734
+ }
5735
+ const types = await getAffectedNftAndFtTypes(coinInType, coinOutType);
5736
+ const { feeAndReward, amountToSwap } = calculateSwapAmounts(types.length, inAmount);
5737
+ if (!routes) {
5738
+ routes = (await buildSwapRoutes(
5739
+ {
5740
+ walletAddress,
5741
+ coinInType,
5742
+ coinOutType,
5743
+ amountToSwap,
5744
+ excludeSources,
5745
+ commission
5746
+ },
5747
+ { defiRouterUrl }
5748
+ )).routes;
5749
+ }
5750
+ const tradeBuilder = new import_sdk.TradeBuilder("mainnet", routes);
5751
+ if (commission) {
5752
+ tradeBuilder.commission(commission);
5753
+ }
5754
+ const trade = tradeBuilder.sender(walletAddress).slippage(slippage).deadline(Date.now() + (0, import_ms.default)(ttl)).build();
5755
+ const coinOut = await trade.swap({ client: suiClient, tx });
5756
+ let suiFeeAndRewardCoin;
5757
+ if (coinInType === (0, import_utils7.normalizeStructTag)(import_utils7.SUI_TYPE_ARG)) {
5758
+ suiFeeAndRewardCoin = tx.splitCoins(tx.gas, [
5759
+ tx.pure.u64(feeAndReward)
5760
+ ])[0];
5761
+ } else {
5762
+ const suiFeeAndRewardRoutes = await buildSwapRoutes(
5763
+ {
5764
+ walletAddress,
5765
+ coinInType,
5766
+ coinOutType: import_utils7.SUI_TYPE_ARG,
5767
+ amountToSwap: feeAndReward,
5768
+ excludeSources
5769
+ },
5770
+ { defiRouterUrl }
5771
+ );
5772
+ const suiFeeTradeBuilder = new import_sdk.TradeBuilder("mainnet", suiFeeAndRewardRoutes.routes);
5773
+ const suiFeeTrade = suiFeeTradeBuilder.sender(walletAddress).slippage(slippage).deadline(Date.now() + (0, import_ms.default)(ttl)).build();
5774
+ suiFeeAndRewardCoin = await suiFeeTrade.swap({ client: suiClient, tx });
5775
+ }
5776
+ if (types.length > 0) {
5777
+ if (types.length > 2) {
5778
+ throw new Error("Unexpected affected types count greater than 2");
5779
+ }
5780
+ let usedSuiCoin = suiFeeAndRewardCoin;
5781
+ if (types.length === 2) {
5782
+ const suiFeeAndRewardCoinBalance = tx.moveCall({
5783
+ target: "0x2::coin::value",
5784
+ typeArguments: [import_utils7.SUI_TYPE_ARG],
5785
+ arguments: [suiFeeAndRewardCoin]
5786
+ });
5787
+ const halfSuiCoinAmount = tx.moveCall({
5788
+ target: "0x2::math::divide_and_round_up",
5789
+ arguments: [suiFeeAndRewardCoinBalance, tx.pure.u64(2)]
5790
+ });
5791
+ const [coin] = tx.splitCoins(usedSuiCoin, [halfSuiCoinAmount]);
5792
+ usedSuiCoin = coin;
5793
+ }
5794
+ for (const data of types) {
5795
+ const { nftType, ftType, type } = data;
5796
+ switch (type) {
5797
+ case "liquidNft": {
5798
+ tx.moveCall({
5799
+ target: `${DexConstants.commission}::commission::pay`,
5800
+ arguments: [
5801
+ tx.object(DexConstants.commissionManager),
5802
+ tx.pure.string("swap"),
5803
+ usedSuiCoin,
5804
+ tx.pure.option("string", nftType)
5805
+ ],
5806
+ typeArguments: [import_utils7.SUI_TYPE_ARG]
5807
+ });
5808
+ break;
5809
+ }
5810
+ case "nftStrategy": {
5811
+ const suiFeeAndRewardCoinBalance = tx.moveCall({
5812
+ target: "0x2::coin::value",
5813
+ typeArguments: [import_utils7.SUI_TYPE_ARG],
5814
+ arguments: [usedSuiCoin]
5815
+ });
5816
+ const feeAmount = tx.moveCall({
5817
+ target: "0x2::math::divide_and_round_up",
5818
+ arguments: [suiFeeAndRewardCoinBalance, tx.pure.u64(4)]
5819
+ });
5820
+ const [feeCoin] = tx.splitCoins(usedSuiCoin, [feeAmount]);
5821
+ tx.moveCall({
5822
+ target: `${DexConstants.commission}::commission::pay`,
5823
+ arguments: [
5824
+ tx.object(DexConstants.commissionManager),
5825
+ tx.pure.string("swap"),
5826
+ feeCoin,
5827
+ tx.pure.option("string", void 0)
5828
+ ],
5829
+ typeArguments: [import_utils7.SUI_TYPE_ARG]
5830
+ });
5831
+ tx.moveCall({
5832
+ target: `${TRADEPORT_NFT_STRATEGY_PACKAGE_ID}::tradeport_nft_strategy::reward_strategy`,
5833
+ arguments: [
5834
+ tx.object(TRADEPORT_NFT_STRATEGY_MANAGER_ID),
5835
+ usedSuiCoin
5836
+ // 3/4 retained coin for reward
5837
+ ],
5838
+ typeArguments: [nftType, ftType]
5839
+ });
5840
+ break;
5841
+ }
5842
+ default: {
5843
+ throw new Error(`Unexpected type ${type}`);
5844
+ }
5845
+ }
5846
+ usedSuiCoin = suiFeeAndRewardCoin;
5847
+ }
5848
+ } else {
5849
+ tx.moveCall({
5850
+ target: `${DexConstants.commission}::commission::pay`,
5851
+ arguments: [
5852
+ tx.object(DexConstants.commissionManager),
5853
+ tx.pure.string("swap"),
5854
+ suiFeeAndRewardCoin,
5855
+ tx.pure.option("string", void 0)
5856
+ ],
5857
+ typeArguments: [import_utils7.SUI_TYPE_ARG]
5858
+ });
5859
+ }
5860
+ return {
5861
+ tx,
5862
+ coinOut
5863
+ };
5864
+ }
5865
+ async function calculateAmountToSwap({
5866
+ coinInType,
5867
+ coinOutType,
5868
+ coinInAmount
5869
+ }) {
5870
+ const types = await getAffectedNftAndFtTypes(coinInType, coinOutType);
5871
+ const { amountToSwap } = calculateSwapAmounts(types.length, BigInt(coinInAmount));
5872
+ return amountToSwap;
5873
+ }
5874
+ async function calculateSwapInputAmountWithSlippage({
5875
+ coinInType,
5876
+ coinOutType,
5877
+ coinOutAmount,
5878
+ slippage = 0
5879
+ }) {
5880
+ if (coinInType === coinOutType) {
5881
+ return new bigNumberConfig_default(coinOutAmount);
5882
+ }
5883
+ const provider = new import_sdk.CoinProvider("mainnet");
5884
+ const coinQueryResult = await provider.getCoins({
5885
+ limit: 2,
5886
+ coinTypes: [coinInType, coinOutType]
5887
+ });
5888
+ const coinIn = coinQueryResult?.find(
5889
+ (coin) => (0, import_utils7.normalizeStructTag)(coin.coinType) === (0, import_utils7.normalizeStructTag)(coinInType)
5890
+ );
5891
+ const coinOut = coinQueryResult?.find(
5892
+ (coin) => (0, import_utils7.normalizeStructTag)(coin.coinType) === (0, import_utils7.normalizeStructTag)(coinOutType)
5893
+ );
5894
+ const exchangeRate = new bigNumberConfig_default(coinOut.derivedPriceInUSD ?? 0)?.gt(0) ? new bigNumberConfig_default(coinIn?.derivedPriceInUSD ?? 1)?.div(coinOut?.derivedPriceInUSD ?? 1) : new bigNumberConfig_default(0);
5895
+ const amountSell = toDecimalValue(coinOutAmount.toString(), coinOut?.decimals).div(exchangeRate);
5896
+ const slippageMultiplier = 1 + parseInt(slippage.toString() || "0", 10) / 1e6;
5897
+ const amountWithSlippage = amountSell.times(slippageMultiplier);
5898
+ const coinInAmount = toPureValue(amountWithSlippage, coinIn?.decimals);
5899
+ return coinInAmount;
5900
+ }
5901
+ async function buildSwapRoutes(options, { defiRouterUrl }) {
5902
+ const aggregatorQuoter = new import_sdk.AggregatorQuoter("mainnet");
5903
+ const routes = await aggregatorQuoter.getRoutes({
5904
+ tokenIn: options.coinInType,
5905
+ tokenOut: options.coinOutType,
5906
+ amountIn: options.amountToSwap.toString(),
5907
+ commission: options.commission,
5908
+ excludeSources: options.excludeSources
5909
+ });
5910
+ if (defiRouterUrl && options.walletAddress) {
5911
+ await makeDefiRouterRequest(`${defiRouterUrl}/start`, {
5912
+ walletId: options.walletAddress,
5913
+ coinTypeIn: options.coinInType,
5914
+ coinTypeOut: options.coinOutType,
5915
+ amountIn: options.amountToSwap.toString()
5916
+ });
5917
+ }
5918
+ return routes;
5919
+ }
5920
+ function calculateSwapAmounts(affectedTypesCount, inAmount) {
5921
+ const feeAndReward = affectedTypesCount > 0 ? BigInt(affectedTypesCount) * inAmount / 25n : inAmount / 100n;
5922
+ const amountToSwap = inAmount - feeAndReward;
5923
+ if (amountToSwap <= 0n) {
5924
+ throw new Error("Amount to swap is too small");
5925
+ }
5926
+ return { feeAndReward, amountToSwap };
5927
+ }
5928
+ async function getAffectedNftAndFtTypes(coinInType, coinOutType) {
5929
+ const normalizedSuiType = (0, import_utils7.normalizeStructTag)(import_utils7.SUI_TYPE_ARG);
5930
+ const coinTypes = [coinInType, coinOutType].filter((type) => type !== normalizedSuiType);
5931
+ const types = await Promise.all(
5932
+ coinTypes.map(async (type) => {
5933
+ const chainState = await getCollectionChainStateByFtType(type);
5934
+ return chainState ? {
5935
+ nftType: chainState.nft_type,
5936
+ ftType: type,
5937
+ type: chainState.ft_type ? "liquidNft" : "nftStrategy"
5938
+ } : void 0;
5939
+ })
5940
+ );
5941
+ return types.filter(Boolean);
5942
+ }
5943
+ async function makeDefiRouterRequest(url, body, defaultResponse = void 0) {
5944
+ try {
5945
+ const response = await fetch(url, {
5946
+ method: "POST",
5947
+ headers: { "Content-Type": "application/json" },
5948
+ body: JSON.stringify(body)
5949
+ });
5950
+ if (!response.ok) {
5951
+ console.warn(`DeFi router request failed with status ${response.status}`);
5952
+ return defaultResponse;
5953
+ }
5954
+ if (response.headers.get("Content-Type")?.includes("application/json")) {
5955
+ return await response.json();
5956
+ }
5957
+ return defaultResponse;
5958
+ } catch (error) {
5959
+ console.warn(`DeFi router request error: ${error.message}`);
5960
+ return defaultResponse;
5961
+ }
5962
+ }
5963
+
5723
5964
  // src/methods/sponsorNftListing/addSponsorNftListingTx.ts
5724
5965
  var addSponsorListingTx = async ({
5725
5966
  tx,
5726
- coinToSplit,
5727
5967
  nftTokenId,
5728
5968
  nftType,
5729
- sponsorOptions
5969
+ suiClient,
5970
+ walletAddress,
5971
+ sponsorOptions,
5972
+ defiRouterUrl
5730
5973
  }) => {
5731
- const [sponsorFeeCoin] = tx.splitCoins(coinToSplit, [
5974
+ const coinInAmount = sponsorOptions?.coinInAmount ?? await calculateSwapInputAmountWithSlippage({
5975
+ coinInType: sponsorOptions?.coinInType,
5976
+ coinOutType: USDC_COIN_TYPE,
5977
+ coinOutAmount: new bigNumberConfig_default(sponsorOptions?.usdcFeeAmountPerPeriod)?.times(sponsorOptions?.numOfPeriods).toString(),
5978
+ slippage: sponsorOptions?.slippage
5979
+ });
5980
+ const { coinOut } = await swapCoins(
5981
+ {
5982
+ walletAddress,
5983
+ coinInType: sponsorOptions?.coinInType,
5984
+ coinInAmount: coinInAmount.toString(),
5985
+ coinOutType: USDC_COIN_TYPE,
5986
+ slippage: sponsorOptions?.slippage,
5987
+ tx
5988
+ },
5989
+ { suiClient, defiRouterUrl }
5990
+ );
5991
+ const [sponsorFeeCoin] = tx.splitCoins(coinOut, [
5732
5992
  tx.pure.u64(
5733
5993
  new bigNumberConfig_default(sponsorOptions?.usdcFeeAmountPerPeriod)?.times(sponsorOptions?.numOfPeriods).toString()
5734
5994
  )
@@ -5744,10 +6004,15 @@ var addSponsorListingTx = async ({
5744
6004
  ],
5745
6005
  typeArguments: [nftType]
5746
6006
  });
6007
+ tx.transferObjects([coinOut], walletAddress);
5747
6008
  };
5748
6009
 
6010
+ // src/helpers/isExpiredListing.ts
6011
+ var import_utils8 = require("@mysten/sui/utils");
6012
+ var isExpiredListing = (listing, walletAddress) => listing.nonce && listing.seller && (0, import_utils8.normalizeSuiAddress)(listing.seller) === (0, import_utils8.normalizeSuiAddress)(walletAddress);
6013
+
5749
6014
  // src/methods/listNfts/listNfts.ts
5750
- var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
6015
+ var listNfts = async ({ nfts, walletAddress }, context) => {
5751
6016
  const res = await gqlChainRequest({
5752
6017
  chain: "sui",
5753
6018
  query: fetchNftsWithListingsById,
@@ -5757,7 +6022,7 @@ var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
5757
6022
  throw new Error("No nfts found");
5758
6023
  }
5759
6024
  const nftsForTracking = [];
5760
- const tx = existingTx ?? new import_transactions13.Transaction();
6025
+ const tx = new import_transactions12.Transaction();
5761
6026
  const sharedKioskState = {
5762
6027
  kioskTx: void 0
5763
6028
  };
@@ -5807,10 +6072,12 @@ var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
5807
6072
  if (inputNft?.sponsorOptions?.shouldSponsor) {
5808
6073
  await addSponsorListingTx({
5809
6074
  tx,
5810
- coinToSplit: inputNft?.sponsorOptions?.coinToSplit,
6075
+ suiClient: context.suiClient,
5811
6076
  nftTokenId: nft?.token_id,
5812
6077
  nftType,
5813
- sponsorOptions: inputNft?.sponsorOptions
6078
+ walletAddress,
6079
+ sponsorOptions: inputNft?.sponsorOptions,
6080
+ defiRouterUrl: context.defiRouterUrl
5814
6081
  });
5815
6082
  }
5816
6083
  nftsForTracking.push({
@@ -5823,15 +6090,15 @@ var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
5823
6090
  });
5824
6091
  }
5825
6092
  sharedKioskState?.kioskTx?.finalize();
5826
- return tx;
6093
+ return tx instanceof import_transactions12.Transaction ? tx : import_transactions12.Transaction.from(tx);
5827
6094
  };
5828
6095
 
5829
6096
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
5830
- var import_transactions14 = require("@mysten/sui/transactions");
6097
+ var import_transactions13 = require("@mysten/sui/transactions");
5831
6098
 
5832
6099
  // src/graphql/queries/fetchNftsByKioskId.ts
5833
- var import_graphql_request17 = require("graphql-request");
5834
- var fetchNftsByKioskId = import_graphql_request17.gql`
6100
+ var import_graphql_request16 = require("graphql-request");
6101
+ var fetchNftsByKioskId = import_graphql_request16.gql`
5835
6102
  query fetchNftsByKioskId($jsonFilter: jsonb) {
5836
6103
  nfts(where: { chain_state: { _contains: $jsonFilter } }) {
5837
6104
  id
@@ -5852,7 +6119,7 @@ var fetchNftsByKioskId = import_graphql_request17.gql`
5852
6119
  }
5853
6120
  }
5854
6121
  `;
5855
- var fetchBulkNftsByKioskId = import_graphql_request17.gql`
6122
+ var fetchBulkNftsByKioskId = import_graphql_request16.gql`
5856
6123
  query fetchNftsByKioskId($where: nfts_bool_exp) {
5857
6124
  nfts(where: $where) {
5858
6125
  id
@@ -5875,8 +6142,8 @@ var fetchBulkNftsByKioskId = import_graphql_request17.gql`
5875
6142
  `;
5876
6143
 
5877
6144
  // src/graphql/queries/fetchTransferPoliciesByType.ts
5878
- var import_graphql_request18 = require("graphql-request");
5879
- var fetchTransferPoliciesByType = import_graphql_request18.gql`
6145
+ var import_graphql_request17 = require("graphql-request");
6146
+ var fetchTransferPoliciesByType = import_graphql_request17.gql`
5880
6147
  query fetchTransferPoliciesByType($type: String!) {
5881
6148
  transfer_policies_by_type(type: $type) {
5882
6149
  id
@@ -6035,7 +6302,7 @@ async function getTransferPolicyForDirectTransfer(suiClient, collectionChainStat
6035
6302
 
6036
6303
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
6037
6304
  async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }, context) {
6038
- const tx = new import_transactions14.Transaction();
6305
+ const tx = new import_transactions13.Transaction();
6039
6306
  const res = await gqlChainRequest({
6040
6307
  chain: "sui",
6041
6308
  query: fetchKiosksByOwner,
@@ -6201,15 +6468,15 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }
6201
6468
  }
6202
6469
  }
6203
6470
  sharedKioskState?.kioskTx?.finalize();
6204
- return import_transactions14.Transaction.from(tx);
6471
+ return import_transactions13.Transaction.from(tx);
6205
6472
  }
6206
6473
 
6207
6474
  // src/methods/placeCollectionBids/placeCollectionBids.ts
6208
- var import_transactions15 = require("@mysten/sui/transactions");
6475
+ var import_transactions14 = require("@mysten/sui/transactions");
6209
6476
 
6210
6477
  // src/graphql/queries/fetchCollectionsById.ts
6211
- var import_graphql_request19 = require("graphql-request");
6212
- var fetchCollectionsById = import_graphql_request19.gql`
6478
+ var import_graphql_request18 = require("graphql-request");
6479
+ var fetchCollectionsById = import_graphql_request18.gql`
6213
6480
  query fetchCollectionsById($collectionIds: [uuid!]) {
6214
6481
  collections(where: { id: { _in: $collectionIds } }) {
6215
6482
  id
@@ -6219,7 +6486,7 @@ var fetchCollectionsById = import_graphql_request19.gql`
6219
6486
  }
6220
6487
  }
6221
6488
  `;
6222
- var fetchCollectionsByIdWithOneNft = import_graphql_request19.gql`
6489
+ var fetchCollectionsByIdWithOneNft = import_graphql_request18.gql`
6223
6490
  query fetchCollectionsByIdWithOneNft($collectionIds: [uuid!]) {
6224
6491
  collections(where: { id: { _in: $collectionIds } }) {
6225
6492
  id
@@ -6237,7 +6504,7 @@ var fetchCollectionsByIdWithOneNft = import_graphql_request19.gql`
6237
6504
  }
6238
6505
  }
6239
6506
  `;
6240
- var fetchCollectionsBySlug = import_graphql_request19.gql`
6507
+ var fetchCollectionsBySlug = import_graphql_request18.gql`
6241
6508
  query fetchCollectionsBySlug($slug: String!) {
6242
6509
  collections(where: { slug: { _eq: $slug } }) {
6243
6510
  id
@@ -6246,7 +6513,7 @@ var fetchCollectionsBySlug = import_graphql_request19.gql`
6246
6513
  `;
6247
6514
 
6248
6515
  // src/methods/placeNftBids/addPlaceNftBidTxs.ts
6249
- var import_utils8 = require("@mysten/sui/utils");
6516
+ var import_utils9 = require("@mysten/sui/utils");
6250
6517
  async function addTradePortPlaceNftBidTxHandler(txData) {
6251
6518
  if (isOriginByteCollection(txData?.transferPolicies) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
6252
6519
  throw new Error("OriginByte bidding not supported currently");
@@ -6267,7 +6534,7 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
6267
6534
  if (!bcsHex) {
6268
6535
  throw new Error(`No BCS found for token ${nftTokenId}`);
6269
6536
  }
6270
- bcs4 = (0, import_utils8.fromHex)(bcsHex);
6537
+ bcs4 = (0, import_utils9.fromHex)(bcsHex);
6271
6538
  }
6272
6539
  let multiBidChainId;
6273
6540
  let expiredBids;
@@ -6323,12 +6590,12 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
6323
6590
  arguments: [
6324
6591
  tx.object(TRADEPORT_MULTI_BID_STORE),
6325
6592
  tx.pure.u64(nftTokenId ? 1 : 0),
6326
- multiBidChainId ? typeof multiBidChainId === "string" ? tx.pure.option("id", (0, import_utils8.normalizeSuiObjectId)(multiBidChainId)) : tx.moveCall({
6593
+ multiBidChainId ? typeof multiBidChainId === "string" ? tx.pure.option("id", (0, import_utils9.normalizeSuiObjectId)(multiBidChainId)) : tx.moveCall({
6327
6594
  target: "0x1::option::some",
6328
6595
  typeArguments: ["0x2::object::ID"],
6329
6596
  arguments: [multiBidChainId]
6330
6597
  }) : void 0,
6331
- tx.pure.option("id", nftTokenId ? (0, import_utils8.normalizeSuiObjectId)(nftTokenId) : void 0),
6598
+ tx.pure.option("id", nftTokenId ? (0, import_utils9.normalizeSuiObjectId)(nftTokenId) : void 0),
6332
6599
  tx.pure.option("vector<u8>", bcs4 ? [...bcs4] : void 0),
6333
6600
  tx.pure.option("u64", expireAt?.getTime()),
6334
6601
  tx.pure.u64(price),
@@ -6359,8 +6626,8 @@ function isDynamicCollection(collectionId) {
6359
6626
  }
6360
6627
 
6361
6628
  // src/graphql/queries/fetchCollectionFloorListings.ts
6362
- var import_graphql_request20 = require("graphql-request");
6363
- var fetchCollectionFloorListings = import_graphql_request20.gql`
6629
+ var import_graphql_request19 = require("graphql-request");
6630
+ var fetchCollectionFloorListings = import_graphql_request19.gql`
6364
6631
  query fetchCollectionFloorListings($collectionId: uuid!) {
6365
6632
  listings(
6366
6633
  where: { collection_id: { _eq: $collectionId }, listed: { _eq: true }, nft: {} }
@@ -6419,14 +6686,7 @@ async function addOriginByteCollectionBidTx({
6419
6686
  }
6420
6687
 
6421
6688
  // src/methods/placeCollectionBids/placeCollectionBids.ts
6422
- var placeCollectionBids = async ({
6423
- collections,
6424
- walletAddress,
6425
- multiBidId,
6426
- multiBidChainId,
6427
- tx: existingTx,
6428
- coinToSplit
6429
- }, context) => {
6689
+ var placeCollectionBids = async ({ collections, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
6430
6690
  const res = await gqlChainRequest({
6431
6691
  chain: "sui",
6432
6692
  query: fetchCollectionsByIdWithOneNft,
@@ -6436,7 +6696,8 @@ var placeCollectionBids = async ({
6436
6696
  throw new Error("No collection found");
6437
6697
  }
6438
6698
  const collectionsForTracking = [];
6439
- const tx = existingTx ?? new import_transactions15.Transaction();
6699
+ const tx = deserializeOrCreateTxBlock({ existingTx });
6700
+ const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
6440
6701
  for (const collection of res.collections) {
6441
6702
  const nftType = getNftType({
6442
6703
  collectionId: collection?.id,
@@ -6456,7 +6717,7 @@ var placeCollectionBids = async ({
6456
6717
  multiBidId,
6457
6718
  multiBidChainId,
6458
6719
  expireAt: collections?.find((c) => c.id === collection?.id)?.expireAt,
6459
- coinToSplit
6720
+ coinToSplit: swapResultCoin
6460
6721
  };
6461
6722
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
6462
6723
  if (isOriginByteCollection(txData?.transferPolicies) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
@@ -6483,13 +6744,17 @@ var placeCollectionBids = async ({
6483
6744
  bidder: walletAddress
6484
6745
  });
6485
6746
  }
6486
- return tx;
6747
+ if (swapResultCoin) {
6748
+ tx.transferObjects([swapResultCoin], walletAddress);
6749
+ }
6750
+ return import_transactions14.Transaction.from(tx);
6487
6751
  };
6488
6752
 
6489
6753
  // src/methods/placeNftBids/placeNftBids.ts
6490
- var import_transactions16 = require("@mysten/sui/transactions");
6491
- var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx, coinToSplit }, context) => {
6492
- const tx = existingTx ?? new import_transactions16.Transaction();
6754
+ var import_transactions15 = require("@mysten/sui/transactions");
6755
+ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
6756
+ const tx = deserializeOrCreateTxBlock({ existingTx });
6757
+ const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
6493
6758
  const res = await gqlChainRequest({
6494
6759
  chain: "sui",
6495
6760
  query: fetchNftsById,
@@ -6523,7 +6788,7 @@ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx
6523
6788
  multiBidId,
6524
6789
  multiBidChainId,
6525
6790
  expireAt: bid?.expireAt,
6526
- coinToSplit
6791
+ coinToSplit: swapResultCoin
6527
6792
  };
6528
6793
  await addTradePortPlaceNftBidTxHandler(txData);
6529
6794
  nftsForTracking.push({
@@ -6533,14 +6798,17 @@ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx
6533
6798
  bidder: walletAddress
6534
6799
  });
6535
6800
  }
6536
- return tx;
6801
+ if (swapResultCoin) {
6802
+ tx.transferObjects([swapResultCoin], walletAddress);
6803
+ }
6804
+ return import_transactions15.Transaction.from(tx);
6537
6805
  };
6538
6806
 
6539
6807
  // src/methods/removeCollectionBids/removeCollectionBids.ts
6540
- var import_transactions17 = require("@mysten/sui/transactions");
6808
+ var import_transactions16 = require("@mysten/sui/transactions");
6541
6809
 
6542
6810
  // src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts
6543
- var import_utils9 = require("@mysten/sui/utils");
6811
+ var import_utils10 = require("@mysten/sui/utils");
6544
6812
  function addTradeportRemoveCollectionBidTx({
6545
6813
  tx,
6546
6814
  nftType,
@@ -6596,7 +6864,7 @@ function addBluemoveKioskRemoveCollectionBidTx({
6596
6864
  async function addTradePortRemoveCollectionBidTxHandler(txData) {
6597
6865
  const bidType = await getObjectType({
6598
6866
  suiClient: txData?.suiClient,
6599
- objectId: (0, import_utils9.normalizeSuiObjectId)(txData?.bidNonce)
6867
+ objectId: (0, import_utils10.normalizeSuiObjectId)(txData?.bidNonce)
6600
6868
  });
6601
6869
  if (isSingleBid(bidType)) {
6602
6870
  await addSingleBidRemoveNftBidTx(txData);
@@ -6616,7 +6884,7 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
6616
6884
  async function addBluemoveRemoveCollectionBidTxHandler(txData) {
6617
6885
  const bidType = await getObjectType({
6618
6886
  suiClient: txData?.suiClient,
6619
- objectId: (0, import_utils9.normalizeSuiObjectId)(txData?.bidNonce)
6887
+ objectId: (0, import_utils10.normalizeSuiObjectId)(txData?.bidNonce)
6620
6888
  });
6621
6889
  if (isOriginByteBid(bidType)) {
6622
6890
  const sharedObjects = await getSharedObjects(txData?.nftType);
@@ -6645,7 +6913,7 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
6645
6913
  throw new Error("No bids found");
6646
6914
  }
6647
6915
  const bidsForTracking = [];
6648
- const tx = existingTx ? import_transactions17.Transaction.from(existingTx) : new import_transactions17.Transaction();
6916
+ const tx = existingTx ? import_transactions16.Transaction.from(existingTx) : new import_transactions16.Transaction();
6649
6917
  for (const bid of res.bids) {
6650
6918
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
6651
6919
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6693,11 +6961,11 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
6693
6961
  bidder: bid?.bidder
6694
6962
  });
6695
6963
  }
6696
- return import_transactions17.Transaction.from(tx);
6964
+ return import_transactions16.Transaction.from(tx);
6697
6965
  };
6698
6966
 
6699
6967
  // src/methods/removeNftBids/removeNftBids.ts
6700
- var import_transactions18 = require("@mysten/sui/transactions");
6968
+ var import_transactions17 = require("@mysten/sui/transactions");
6701
6969
  var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6702
6970
  const res = await gqlChainRequest({
6703
6971
  chain: "sui",
@@ -6708,7 +6976,7 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6708
6976
  throw new Error("No bids found");
6709
6977
  }
6710
6978
  const bidsForTracking = [];
6711
- const tx = existingTx ? import_transactions18.Transaction.from(existingTx) : new import_transactions18.Transaction();
6979
+ const tx = existingTx ? import_transactions17.Transaction.from(existingTx) : new import_transactions17.Transaction();
6712
6980
  for (const bid of res.bids) {
6713
6981
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
6714
6982
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6753,63 +7021,11 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6753
7021
  bidder: bid?.bidder
6754
7022
  });
6755
7023
  }
6756
- return import_transactions18.Transaction.from(tx);
6757
- };
6758
-
6759
- // src/methods/sponsorNftListing/sponsorNftListing.ts
6760
- var import_transactions19 = require("@mysten/sui/transactions");
6761
-
6762
- // src/graphql/queries/fetchNftCollectionChainState.ts
6763
- var import_graphql_request21 = require("graphql-request");
6764
- var fetchNftCollectionChainState = import_graphql_request21.gql`
6765
- query fetchNftCollectionChainState($nftTokenId: String!) {
6766
- nfts(where: { token_id: { _eq: $nftTokenId } }) {
6767
- collection {
6768
- id
6769
- chain_state
6770
- }
6771
- }
6772
- }
6773
- `;
6774
-
6775
- // src/methods/sponsorNftListing/sponsorNftListing.ts
6776
- var sponsorNftListing = async ({
6777
- tx: existingTx,
6778
- coinToSplit,
6779
- nftTokenId,
6780
- options
6781
- }) => {
6782
- const res = await gqlChainRequest({
6783
- chain: "sui",
6784
- query: fetchNftCollectionChainState,
6785
- variables: { nftTokenId }
6786
- });
6787
- if (res?.nfts?.length === 0) {
6788
- throw new Error(`No nft found with token id ${nftTokenId}`);
6789
- }
6790
- const nft = res?.nfts?.[0];
6791
- const nftType = getNftType({
6792
- collectionId: nft?.collection?.id,
6793
- collectionChainState: nft?.collection?.chain_state,
6794
- nft
6795
- });
6796
- const transferPolicies = nft?.collection?.chain_state?.transfer_policies;
6797
- if (isOriginByteCollection(transferPolicies)) {
6798
- throw new Error(`You cannot sponsor an Origin Byte NFT. Nft Token Id: ${nftTokenId}`);
6799
- }
6800
- const tx = existingTx ?? new import_transactions19.Transaction();
6801
- await addSponsorListingTx({
6802
- tx,
6803
- coinToSplit,
6804
- nftTokenId,
6805
- nftType,
6806
- sponsorOptions: options
6807
- });
6808
- return tx;
7024
+ return import_transactions17.Transaction.from(tx);
6809
7025
  };
6810
7026
 
6811
7027
  // src/methods/transferNfts/transferNfts.ts
6812
- var import_transactions20 = require("@mysten/sui/transactions");
7028
+ var import_transactions18 = require("@mysten/sui/transactions");
6813
7029
  var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context) => {
6814
7030
  if (addLeadingZerosAfter0x(recipientAddress) === addLeadingZerosAfter0x(walletAddress)) {
6815
7031
  throw new Error("Cannot transfer to self");
@@ -6827,7 +7043,7 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
6827
7043
  }
6828
7044
  const nftsForTracking = [];
6829
7045
  const nftsToTransferDirectly = [];
6830
- const tx = new import_transactions20.Transaction();
7046
+ const tx = new import_transactions18.Transaction();
6831
7047
  const sharedKioskState = {
6832
7048
  kioskTx: void 0
6833
7049
  };
@@ -6930,11 +7146,11 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
6930
7146
  context.suiClient
6931
7147
  );
6932
7148
  sharedKioskState?.kioskTx?.finalize();
6933
- return import_transactions20.Transaction.from(tx);
7149
+ return import_transactions18.Transaction.from(tx);
6934
7150
  };
6935
7151
 
6936
7152
  // src/methods/unlistListings/unlistListings.ts
6937
- var import_transactions21 = require("@mysten/sui/transactions");
7153
+ var import_transactions19 = require("@mysten/sui/transactions");
6938
7154
  var unlistListings = async ({ listingIds, walletAddress }, context) => {
6939
7155
  const res = await gqlChainRequest({
6940
7156
  chain: "sui",
@@ -6945,7 +7161,7 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
6945
7161
  throw new Error("No listings found");
6946
7162
  }
6947
7163
  const listingsForTracking = [];
6948
- const tx = new import_transactions21.Transaction();
7164
+ const tx = new import_transactions19.Transaction();
6949
7165
  const sharedKioskState = {
6950
7166
  kioskTx: void 0
6951
7167
  };
@@ -7014,12 +7230,12 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
7014
7230
  });
7015
7231
  }
7016
7232
  sharedKioskState?.kioskTx?.finalize();
7017
- return import_transactions21.Transaction.from(tx);
7233
+ return import_transactions19.Transaction.from(tx);
7018
7234
  };
7019
7235
 
7020
7236
  // src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts
7021
7237
  var import_kiosk5 = require("@mysten/kiosk");
7022
- var import_transactions22 = require("@mysten/sui/transactions");
7238
+ var import_transactions20 = require("@mysten/sui/transactions");
7023
7239
  async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7024
7240
  const res = await gqlChainRequest({
7025
7241
  chain: "sui",
@@ -7039,7 +7255,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7039
7255
  if (kiosksWithProfit.length === 0) {
7040
7256
  throw new Error(`No kiosks with profit to withdraw found for ${walletAddress}`);
7041
7257
  }
7042
- const tx = new import_transactions22.Transaction();
7258
+ const tx = new import_transactions20.Transaction();
7043
7259
  try {
7044
7260
  for (const kiosk of kiosksWithProfit) {
7045
7261
  let kioskTx;
@@ -7085,7 +7301,149 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7085
7301
  } catch (err) {
7086
7302
  console.log("err", err);
7087
7303
  }
7088
- return import_transactions22.Transaction.from(tx);
7304
+ return import_transactions20.Transaction.from(tx);
7305
+ }
7306
+
7307
+ // src/methods/sponsorNftListing/sponsorNftListing.ts
7308
+ var import_transactions21 = require("@mysten/sui/transactions");
7309
+
7310
+ // src/graphql/queries/fetchNftCollectionChainState.ts
7311
+ var import_graphql_request20 = require("graphql-request");
7312
+ var fetchNftCollectionChainState = import_graphql_request20.gql`
7313
+ query fetchNftCollectionChainState($nftTokenId: String!) {
7314
+ nfts(where: { token_id: { _eq: $nftTokenId } }) {
7315
+ collection {
7316
+ id
7317
+ chain_state
7318
+ }
7319
+ }
7320
+ }
7321
+ `;
7322
+
7323
+ // src/methods/sponsorNftListing/sponsorNftListing.ts
7324
+ var sponsorNftListing = async ({ nftTokenId, walletAddress, options }, context) => {
7325
+ const res = await gqlChainRequest({
7326
+ chain: "sui",
7327
+ query: fetchNftCollectionChainState,
7328
+ variables: { nftTokenId }
7329
+ });
7330
+ if (res?.nfts?.length === 0) {
7331
+ throw new Error(`No nft found with token id ${nftTokenId}`);
7332
+ }
7333
+ const nft = res?.nfts?.[0];
7334
+ const nftType = getNftType({
7335
+ collectionId: nft?.collection?.id,
7336
+ collectionChainState: nft?.collection?.chain_state,
7337
+ nft
7338
+ });
7339
+ const transferPolicies = nft?.collection?.chain_state?.transfer_policies;
7340
+ if (isOriginByteCollection(transferPolicies)) {
7341
+ throw new Error(`You cannot sponsor an Origin Byte NFT. Nft Token Id: ${nftTokenId}`);
7342
+ }
7343
+ const tx = new import_transactions21.Transaction();
7344
+ await addSponsorListingTx({
7345
+ tx,
7346
+ suiClient: context.suiClient,
7347
+ nftTokenId,
7348
+ nftType,
7349
+ walletAddress,
7350
+ sponsorOptions: options,
7351
+ defiRouterUrl: context.defiRouterUrl
7352
+ });
7353
+ return tx instanceof import_transactions21.Transaction ? tx : import_transactions21.Transaction.from(tx);
7354
+ };
7355
+
7356
+ // src/methods/applyNftStrategy/applyNftStrategy.ts
7357
+ var import_transactions22 = require("@mysten/sui/transactions");
7358
+
7359
+ // src/graphql/queries/fetchCollectionFloorListingForMarket.ts
7360
+ var import_graphql_request21 = require("graphql-request");
7361
+ var fetchCollectionFloorListingsForMarket = import_graphql_request21.gql`
7362
+ query fetchCollectionFloorListingsForMarket(
7363
+ $collectionId: uuid!
7364
+ $marketAddress: String!
7365
+ $totalPrice: numeric
7366
+ ) {
7367
+ listings(
7368
+ where: {
7369
+ collection_id: { _eq: $collectionId }
7370
+ listed: { _eq: true }
7371
+ market_name: { _eq: "tradeport" }
7372
+ seller: { _neq: $marketAddress }
7373
+ nonce: { _like: "1::0x%" }
7374
+ price: { _lte: $totalPrice }
7375
+ }
7376
+ order_by: [{ price: asc_nulls_last }, { block_height: asc }, { tx_index: asc }]
7377
+ ) {
7378
+ id
7379
+ price
7380
+ nft {
7381
+ token_id
7382
+ delegated_owner
7383
+ }
7384
+ }
7385
+ }
7386
+ `;
7387
+
7388
+ // src/methods/applyNftStrategy/applyNftStrategy.ts
7389
+ async function applyTradeportNftStrategy({
7390
+ collectionId,
7391
+ strategyFtType,
7392
+ tx: existingTx
7393
+ }) {
7394
+ const tx = existingTx ?? new import_transactions22.Transaction();
7395
+ const chainState = await getCollectionChainState(collectionId);
7396
+ const nftStrategies = chainState?.nft_strategies ?? {};
7397
+ const nftStrategyKeys = Object.keys(nftStrategies);
7398
+ if (nftStrategyKeys.length === 0) {
7399
+ throw new Error("No NFT strategies found for collection");
7400
+ }
7401
+ strategyFtType = strategyFtType ?? nftStrategyKeys[0];
7402
+ if (!nftStrategyKeys.includes(strategyFtType)) {
7403
+ throw new Error(`Specified FT type ${strategyFtType} is not supported for this collection`);
7404
+ }
7405
+ const transferPolicy = getNativeKioskTransferPolicies(chainState?.transfer_policies ?? [])?.at(0);
7406
+ if (!transferPolicy) {
7407
+ throw new Error("No transfer policy found for collection");
7408
+ }
7409
+ const nftType = chainState?.nft_type;
7410
+ let suiBalance = BigInt(
7411
+ nftStrategies[strategyFtType].sui_balance ?? 0n
7412
+ );
7413
+ const result = await gqlChainRequest({
7414
+ chain: "sui",
7415
+ query: fetchCollectionFloorListingsForMarket,
7416
+ variables: {
7417
+ collectionId,
7418
+ marketAddress: TRADEPORT_NFT_STRATEGY_MANAGER_ID,
7419
+ totalPrice: suiBalance.toString()
7420
+ }
7421
+ });
7422
+ if ((result?.listings?.length ?? 0) === 0) {
7423
+ throw new Error(
7424
+ `No floor listing found for collection with price bellow or equal to ${suiBalance} MIST`
7425
+ );
7426
+ }
7427
+ for (const floorListing of result.listings) {
7428
+ suiBalance -= BigInt(floorListing.price);
7429
+ if (suiBalance < 0n) {
7430
+ break;
7431
+ }
7432
+ tx.moveCall({
7433
+ target: `${TRADEPORT_NFT_STRATEGY_PACKAGE_ID}::tradeport_nft_strategy::apply_tradeport_nft_strategy_confirm_request`,
7434
+ typeArguments: [nftType, strategyFtType],
7435
+ arguments: [
7436
+ tx.object(TRADEPORT_NFT_STRATEGY_MANAGER_ID),
7437
+ tx.object(nftStrategies[strategyFtType].kiosk_id),
7438
+ tx.object(TRADEPORT_LISTINGS_STORE),
7439
+ tx.object(TRADEPORT_ORDERBOOK_STORE),
7440
+ tx.object(floorListing.nft.delegated_owner),
7441
+ tx.object(floorListing.nft.token_id),
7442
+ tx.object(transferPolicy.id)
7443
+ ]
7444
+ });
7445
+ }
7446
+ return tx;
7089
7447
  }
7090
7448
 
7091
7449
  // src/SuiTradingClient.ts
@@ -7095,14 +7453,14 @@ var SuiTradingClient = class {
7095
7453
  apiKey,
7096
7454
  apiVercelId,
7097
7455
  apiUrl,
7098
- tradeportRouterUrl,
7456
+ defiRouterUrl,
7099
7457
  suiNodeUrl,
7100
7458
  graphQLClient
7101
7459
  }) {
7102
7460
  this.allowedApiUsersForUnsharedKiosksMigration = ["tradeport.xyz", "mercato.xyz"];
7103
7461
  this.apiUser = apiUser;
7104
7462
  this.apiKey = apiKey;
7105
- this.tradeportRouterUrl = tradeportRouterUrl;
7463
+ this.defiRouterUrl = defiRouterUrl ?? "https://api.indexer.xyz/router";
7106
7464
  this.suiClient = createSuiClient_default(suiNodeUrl ?? (0, import_client2.getFullnodeUrl)("mainnet"));
7107
7465
  this.kioskClient = createKioskClient_default(this.suiClient);
7108
7466
  if (graphQLClient) {
@@ -7116,31 +7474,31 @@ var SuiTradingClient = class {
7116
7474
  ...apiVercelId && { "x-vercel-id": apiVercelId }
7117
7475
  });
7118
7476
  }
7119
- async buyListings(args) {
7477
+ async buyListings({ listingIds, walletAddress, tx }) {
7120
7478
  const context = {
7121
7479
  apiUser: this.apiUser,
7122
7480
  apiKey: this.apiKey,
7123
- tradeportRouterUrl: this.tradeportRouterUrl,
7481
+ defiRouterUrl: this.defiRouterUrl,
7124
7482
  suiClient: this.suiClient,
7125
7483
  kioskClient: this.kioskClient
7126
7484
  };
7127
- return buyListings(args, context);
7485
+ return buyListings({ listingIds, walletAddress, tx }, context);
7128
7486
  }
7129
- async listNfts({ nfts, walletAddress, tx }) {
7487
+ async listNfts({ nfts, walletAddress }) {
7130
7488
  const context = {
7131
7489
  apiUser: this.apiUser,
7132
7490
  apiKey: this.apiKey,
7133
- tradeportRouterUrl: this.tradeportRouterUrl,
7491
+ defiRouterUrl: this.defiRouterUrl,
7134
7492
  suiClient: this.suiClient,
7135
7493
  kioskClient: this.kioskClient
7136
7494
  };
7137
- return listNfts({ nfts, walletAddress, tx }, context);
7495
+ return listNfts({ nfts, walletAddress }, context);
7138
7496
  }
7139
7497
  async unlistListings({ listingIds, walletAddress }) {
7140
7498
  const context = {
7141
7499
  apiUser: this.apiUser,
7142
7500
  apiKey: this.apiKey,
7143
- tradeportRouterUrl: this.tradeportRouterUrl,
7501
+ defiRouterUrl: this.defiRouterUrl,
7144
7502
  suiClient: this.suiClient,
7145
7503
  kioskClient: this.kioskClient
7146
7504
  };
@@ -7150,7 +7508,7 @@ var SuiTradingClient = class {
7150
7508
  const context = {
7151
7509
  apiUser: this.apiUser,
7152
7510
  apiKey: this.apiKey,
7153
- tradeportRouterUrl: this.tradeportRouterUrl,
7511
+ defiRouterUrl: this.defiRouterUrl,
7154
7512
  suiClient: this.suiClient,
7155
7513
  kioskClient: this.kioskClient
7156
7514
  };
@@ -7159,7 +7517,7 @@ var SuiTradingClient = class {
7159
7517
  async removeNftBids({ bidIds, tx }) {
7160
7518
  const context = {
7161
7519
  apiUser: this.apiUser,
7162
- tradeportRouterUrl: this.tradeportRouterUrl,
7520
+ defiRouterUrl: this.defiRouterUrl,
7163
7521
  apiKey: this.apiKey,
7164
7522
  suiClient: this.suiClient,
7165
7523
  kioskClient: this.kioskClient
@@ -7170,7 +7528,7 @@ var SuiTradingClient = class {
7170
7528
  const context = {
7171
7529
  apiUser: this.apiUser,
7172
7530
  apiKey: this.apiKey,
7173
- tradeportRouterUrl: this.tradeportRouterUrl,
7531
+ defiRouterUrl: this.defiRouterUrl,
7174
7532
  suiClient: this.suiClient,
7175
7533
  kioskClient: this.kioskClient
7176
7534
  };
@@ -7189,7 +7547,7 @@ var SuiTradingClient = class {
7189
7547
  const context = {
7190
7548
  apiUser: this.apiUser,
7191
7549
  apiKey: this.apiKey,
7192
- tradeportRouterUrl: this.tradeportRouterUrl,
7550
+ defiRouterUrl: this.defiRouterUrl,
7193
7551
  suiClient: this.suiClient,
7194
7552
  kioskClient: this.kioskClient
7195
7553
  };
@@ -7215,7 +7573,7 @@ var SuiTradingClient = class {
7215
7573
  const context = {
7216
7574
  apiUser: this.apiUser,
7217
7575
  apiKey: this.apiKey,
7218
- tradeportRouterUrl: this.tradeportRouterUrl,
7576
+ defiRouterUrl: this.defiRouterUrl,
7219
7577
  suiClient: this.suiClient,
7220
7578
  kioskClient: this.kioskClient
7221
7579
  };
@@ -7291,7 +7649,7 @@ var SuiTradingClient = class {
7291
7649
  const context = {
7292
7650
  apiUser: this.apiUser,
7293
7651
  apiKey: this.apiKey,
7294
- tradeportRouterUrl: this.tradeportRouterUrl,
7652
+ defiRouterUrl: this.defiRouterUrl,
7295
7653
  suiClient: this.suiClient,
7296
7654
  kioskClient: this.kioskClient
7297
7655
  };
@@ -7301,7 +7659,7 @@ var SuiTradingClient = class {
7301
7659
  const context = {
7302
7660
  apiUser: this.apiUser,
7303
7661
  apiKey: this.apiKey,
7304
- tradeportRouterUrl: this.tradeportRouterUrl,
7662
+ defiRouterUrl: this.defiRouterUrl,
7305
7663
  suiClient: this.suiClient,
7306
7664
  kioskClient: this.kioskClient
7307
7665
  };
@@ -7311,7 +7669,7 @@ var SuiTradingClient = class {
7311
7669
  const context = {
7312
7670
  apiUser: this.apiUser,
7313
7671
  apiKey: this.apiKey,
7314
- tradeportRouterUrl: this.tradeportRouterUrl,
7672
+ defiRouterUrl: this.defiRouterUrl,
7315
7673
  suiClient: this.suiClient,
7316
7674
  kioskClient: this.kioskClient
7317
7675
  };
@@ -7327,7 +7685,7 @@ var SuiTradingClient = class {
7327
7685
  const context = {
7328
7686
  apiUser: this.apiUser,
7329
7687
  apiKey: this.apiKey,
7330
- tradeportRouterUrl: this.tradeportRouterUrl,
7688
+ defiRouterUrl: this.defiRouterUrl,
7331
7689
  suiClient: this.suiClient,
7332
7690
  kioskClient: this.kioskClient
7333
7691
  };
@@ -7347,7 +7705,7 @@ var SuiTradingClient = class {
7347
7705
  const context = {
7348
7706
  apiUser: this.apiUser,
7349
7707
  apiKey: this.apiKey,
7350
- tradeportRouterUrl: this.tradeportRouterUrl,
7708
+ defiRouterUrl: this.defiRouterUrl,
7351
7709
  suiClient: this.suiClient,
7352
7710
  kioskClient: this.kioskClient
7353
7711
  };
@@ -7360,7 +7718,7 @@ var SuiTradingClient = class {
7360
7718
  const context = {
7361
7719
  apiUser: this.apiUser,
7362
7720
  apiKey: this.apiKey,
7363
- tradeportRouterUrl: this.tradeportRouterUrl,
7721
+ defiRouterUrl: this.defiRouterUrl,
7364
7722
  suiClient: this.suiClient,
7365
7723
  kioskClient: this.kioskClient
7366
7724
  };
@@ -7373,13 +7731,17 @@ var SuiTradingClient = class {
7373
7731
  return cancelMultiBid(args);
7374
7732
  }
7375
7733
  async updateMultiBid(args) {
7376
- return updateMultiBid(args, {
7377
- suiClient: this.suiClient,
7378
- tradeportRouterUrl: this.tradeportRouterUrl
7379
- });
7734
+ return updateMultiBid(args);
7380
7735
  }
7381
7736
  async sponsorNftListing(args) {
7382
- return sponsorNftListing(args);
7737
+ const context = {
7738
+ apiUser: this.apiUser,
7739
+ apiKey: this.apiKey,
7740
+ defiRouterUrl: this.defiRouterUrl,
7741
+ suiClient: this.suiClient,
7742
+ kioskClient: this.kioskClient
7743
+ };
7744
+ return sponsorNftListing(args, context);
7383
7745
  }
7384
7746
  async applyFtStrategy(args) {
7385
7747
  return applyFtStrategy(args);
@@ -7387,6 +7749,15 @@ var SuiTradingClient = class {
7387
7749
  async applyTradeportNftStrategy(args) {
7388
7750
  return applyTradeportNftStrategy(args);
7389
7751
  }
7752
+ async swapCoins(args) {
7753
+ return swapCoins(args, { suiClient: this.suiClient, defiRouterUrl: this.defiRouterUrl });
7754
+ }
7755
+ async buildSwapRoutes(args) {
7756
+ return buildSwapRoutes(args, { defiRouterUrl: this.defiRouterUrl });
7757
+ }
7758
+ async calculateAmountToSwap(args) {
7759
+ return calculateAmountToSwap(args);
7760
+ }
7390
7761
  };
7391
7762
  var SuiTradingClient_default = SuiTradingClient;
7392
7763
  // Annotate the CommonJS export names for ESM import in node: