@tradeport/sui-trading-sdk 0.4.64 → 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,16 @@ 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
+ };
171
191
  var USDC_COIN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
172
192
  var COLLECTION_IDS_WITH_ZERO_COMMISSION = [
173
193
  ""
@@ -3596,6 +3616,16 @@ var getCollectionChainState = async (collectionId) => {
3596
3616
  });
3597
3617
  return res?.collections?.[0]?.chain_state;
3598
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
+ };
3599
3629
 
3600
3630
  // src/methods/applyFtStrategy/applyFtStrategy.ts
3601
3631
  async function applyFtStrategy({
@@ -3630,105 +3660,12 @@ async function applyFtStrategy({
3630
3660
  return tx;
3631
3661
  }
3632
3662
 
3633
- // src/methods/applyNftStrategy/applyNftStrategy.ts
3634
- var import_transactions5 = require("@mysten/sui/transactions");
3635
-
3636
- // src/graphql/queries/fetchCollectionFloorListingForMarket.ts
3637
- var import_graphql_request13 = require("graphql-request");
3638
- var fetchCollectionFloorListingsForMarket = import_graphql_request13.gql`
3639
- query fetchCollectionFloorListingsForMarket(
3640
- $collectionId: uuid!
3641
- $marketAddress: String!
3642
- $totalPrice: numeric
3643
- ) {
3644
- listings(
3645
- where: {
3646
- collection_id: { _eq: $collectionId }
3647
- listed: { _eq: true }
3648
- market_name: { _eq: "tradeport" }
3649
- seller: { _neq: $marketAddress }
3650
- nonce: { _like: "1::0x%" }
3651
- price: { _lte: $totalPrice }
3652
- }
3653
- order_by: [{ price: asc_nulls_last }, { block_height: asc }, { tx_index: asc }]
3654
- ) {
3655
- id
3656
- price
3657
- nft {
3658
- token_id
3659
- delegated_owner
3660
- }
3661
- }
3662
- }
3663
- `;
3664
-
3665
- // src/methods/applyNftStrategy/applyNftStrategy.ts
3666
- async function applyTradeportNftStrategy({
3667
- collectionId,
3668
- strategyFtType,
3669
- tx: existingTx
3670
- }) {
3671
- const tx = existingTx ?? new import_transactions5.Transaction();
3672
- const chainState = await getCollectionChainState(collectionId);
3673
- const nftStrategies = chainState?.nft_strategies ?? {};
3674
- const nftStrategyKeys = Object.keys(nftStrategies);
3675
- if (nftStrategyKeys.length === 0) {
3676
- throw new Error("No NFT strategies found for collection");
3677
- }
3678
- strategyFtType = strategyFtType ?? nftStrategyKeys[0];
3679
- if (!nftStrategyKeys.includes(strategyFtType)) {
3680
- throw new Error(`Specified FT type ${strategyFtType} is not supported for this collection`);
3681
- }
3682
- const transferPolicy = getNativeKioskTransferPolicies(chainState?.transfer_policies ?? [])?.at(0);
3683
- if (!transferPolicy) {
3684
- throw new Error("No transfer policy found for collection");
3685
- }
3686
- const nftType = chainState?.nft_type;
3687
- let suiBalance = BigInt(
3688
- nftStrategies[strategyFtType].sui_balance ?? 0n
3689
- );
3690
- const result = await gqlChainRequest({
3691
- chain: "sui",
3692
- query: fetchCollectionFloorListingsForMarket,
3693
- variables: {
3694
- collectionId,
3695
- marketAddress: TRADEPORT_NFT_STRATEGY_MANAGER_ID,
3696
- totalPrice: suiBalance.toString()
3697
- }
3698
- });
3699
- if ((result?.listings?.length ?? 0) === 0) {
3700
- throw new Error(
3701
- `No floor listing found for collection with price bellow or equal to ${suiBalance} MIST`
3702
- );
3703
- }
3704
- for (const floorListing of result.listings) {
3705
- suiBalance -= BigInt(floorListing.price);
3706
- if (suiBalance < 0n) {
3707
- break;
3708
- }
3709
- tx.moveCall({
3710
- target: `${TRADEPORT_NFT_STRATEGY_PACKAGE_ID}::tradeport_nft_strategy::apply_tradeport_nft_strategy_confirm_request`,
3711
- typeArguments: [nftType, strategyFtType],
3712
- arguments: [
3713
- tx.object(TRADEPORT_NFT_STRATEGY_MANAGER_ID),
3714
- tx.object(nftStrategies[strategyFtType].kiosk_id),
3715
- tx.object(TRADEPORT_LISTINGS_STORE),
3716
- tx.object(TRADEPORT_ORDERBOOK_STORE),
3717
- tx.object(floorListing.nft.delegated_owner),
3718
- tx.object(floorListing.nft.token_id),
3719
- tx.object(transferPolicy.id)
3720
- ]
3721
- });
3722
- }
3723
- return tx;
3724
- }
3725
-
3726
3663
  // src/methods/buyListings/buyListings.ts
3727
3664
  var import_transactions7 = require("@mysten/sui/transactions");
3728
3665
 
3729
3666
  // src/graphql/queries/fetchListingsById.ts
3730
- var import_graphql_request14 = require("graphql-request");
3731
- var fetchListingsById = import_graphql_request14.gql`
3667
+ var import_graphql_request13 = require("graphql-request");
3668
+ var fetchListingsById = import_graphql_request13.gql`
3732
3669
  query fetchListingsById($listingIds: [uuid!]) {
3733
3670
  listings(where: { id: { _in: $listingIds } }) {
3734
3671
  id
@@ -3767,6 +3704,29 @@ var addThirdPartyTxFee = async (tx, price) => {
3767
3704
  );
3768
3705
  };
3769
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
+
3770
3730
  // src/helpers/kiosk/preProcessSharedBulkBuyingData.ts
3771
3731
  var import_bcs2 = require("@mysten/sui/bcs");
3772
3732
  var import_transactions6 = require("@mysten/sui/transactions");
@@ -3872,8 +3832,8 @@ var preProcessSharedBulkBuyingData = async ({
3872
3832
  var import_bcs3 = require("@mysten/sui/bcs");
3873
3833
 
3874
3834
  // src/graphql/queries/fetchCommissionByListingId.ts
3875
- var import_graphql_request15 = require("graphql-request");
3876
- var fetchCommissionByNftContractId = import_graphql_request15.gql`
3835
+ var import_graphql_request14 = require("graphql-request");
3836
+ var fetchCommissionByNftContractId = import_graphql_request14.gql`
3877
3837
  query fetchCommissionByNftContractId($nftContractId: uuid!) {
3878
3838
  commissions(where: { contract_id: { _eq: $nftContractId } }) {
3879
3839
  is_custodial
@@ -4623,7 +4583,8 @@ var buyListings = async ({
4623
4583
  throw new Error("No listings found");
4624
4584
  }
4625
4585
  const listingsForTracking = [];
4626
- const tx = existingTx ?? new import_transactions7.Transaction();
4586
+ const tx = deserializeOrCreateTxBlock({ existingTx });
4587
+ const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
4627
4588
  const tocenTokenIds = [];
4628
4589
  let tocenNftType = "";
4629
4590
  let tocenTotalPrice = 0;
@@ -4668,7 +4629,7 @@ var buyListings = async ({
4668
4629
  sellerKiosk: listing.nft?.chain_state?.kiosk_id,
4669
4630
  collectionId: listing?.nft?.collection_id,
4670
4631
  nftContractId: listing?.nft?.contract_id,
4671
- coinToSplit,
4632
+ coinToSplit: swapResultCoin ? swapResultCoin : coinToSplit,
4672
4633
  marketFeeDecimalPercent,
4673
4634
  beforeResolveKioskTransferRequest,
4674
4635
  sharedKioskState,
@@ -4717,6 +4678,9 @@ var buyListings = async ({
4717
4678
  });
4718
4679
  }
4719
4680
  sharedKioskState?.kioskTx?.finalize();
4681
+ if (swapResultCoin) {
4682
+ tx.transferObjects([swapResultCoin], walletAddress);
4683
+ }
4720
4684
  if (tocenTokenIds?.length > 0) {
4721
4685
  addTocenBuyTxHandler({
4722
4686
  tx,
@@ -4725,7 +4689,7 @@ var buyListings = async ({
4725
4689
  price: tocenTotalPrice
4726
4690
  });
4727
4691
  }
4728
- return tx;
4692
+ return import_transactions7.Transaction.from(tx);
4729
4693
  };
4730
4694
 
4731
4695
  // src/methods/cancelMultiBid/cancelMultiBid.ts
@@ -4849,8 +4813,8 @@ async function cancelMultiBid({ multiBidId }) {
4849
4813
  var import_transactions9 = require("@mysten/sui/transactions");
4850
4814
 
4851
4815
  // src/graphql/queries/fetchAccountKiosks.ts
4852
- var import_graphql_request16 = require("graphql-request");
4853
- var fetchAccountKiosks = import_graphql_request16.gql`
4816
+ var import_graphql_request15 = require("graphql-request");
4817
+ var fetchAccountKiosks = import_graphql_request15.gql`
4854
4818
  query fetchAccountKiosks($accountAddress: String!) {
4855
4819
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
4856
4820
  id
@@ -5319,22 +5283,17 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
5319
5283
  return import_transactions10.Transaction.from(tx);
5320
5284
  };
5321
5285
 
5322
- // src/methods/createMultiBid/createMultiBid.ts
5323
- var import_transactions12 = require("@mysten/sui/transactions");
5324
-
5325
5286
  // src/methods/updateMultiBid/updateMultiBid.ts
5326
- var import_transactions11 = require("@mysten/sui/transactions");
5327
5287
  async function updateMultiBid({
5328
- walletAddress,
5329
5288
  multiBidId,
5330
5289
  name,
5331
5290
  amount,
5332
5291
  amountToWithdraw,
5333
5292
  tx: existingTx,
5334
- multiBidChainId,
5335
- coinToSplit
5336
- }, context) {
5337
- const tx = existingTx ?? new import_transactions11.Transaction();
5293
+ multiBidChainId
5294
+ }) {
5295
+ const tx = deserializeOrCreateTxBlock({ existingTx });
5296
+ const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
5338
5297
  if (!multiBidChainId) {
5339
5298
  const { chain_id: chainId, cancelled_at } = (await gqlChainRequest({
5340
5299
  chain: "sui",
@@ -5349,7 +5308,7 @@ async function updateMultiBid({
5349
5308
  }
5350
5309
  multiBidChainId = chainId;
5351
5310
  }
5352
- const [coin] = tx.splitCoins(coinToSplit ? coinToSplit : tx.gas, [amount ?? 0n]);
5311
+ const [coin] = tx.splitCoins(swapResultCoin ? swapResultCoin : tx.gas, [amount ?? 0n]);
5353
5312
  tx.moveCall({
5354
5313
  target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::update_multi_bid`,
5355
5314
  arguments: [
@@ -5370,7 +5329,7 @@ async function createMultiBid({
5370
5329
  amount,
5371
5330
  tx: existingTx
5372
5331
  }) {
5373
- const tx = existingTx ?? new import_transactions12.Transaction();
5332
+ const tx = deserializeOrCreateTxBlock({ existingTx });
5374
5333
  const multiBidChainId = tx.moveCall({
5375
5334
  target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
5376
5335
  arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.option("string", name)]
@@ -5388,11 +5347,7 @@ async function createMultiBid({
5388
5347
  }
5389
5348
 
5390
5349
  // src/methods/listNfts/listNfts.ts
5391
- var import_transactions14 = require("@mysten/sui/transactions");
5392
-
5393
- // src/helpers/isExpiredListing.ts
5394
- var import_utils7 = require("@mysten/sui/utils");
5395
- 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");
5396
5351
 
5397
5352
  // src/helpers/validateMinFloorPrice.ts
5398
5353
  function validateMinFloorPrice({ transferPolicies, listPrice }) {
@@ -5721,16 +5676,323 @@ async function relistNft({
5721
5676
  }
5722
5677
  }
5723
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
+
5724
5964
  // src/methods/sponsorNftListing/addSponsorNftListingTx.ts
5725
- var import_transactions13 = require("@mysten/sui/transactions");
5726
5965
  var addSponsorListingTx = async ({
5727
5966
  tx,
5728
5967
  nftTokenId,
5729
5968
  nftType,
5730
- sponsorOptions
5969
+ suiClient,
5970
+ walletAddress,
5971
+ sponsorOptions,
5972
+ defiRouterUrl
5731
5973
  }) => {
5732
- const totalFee = new bigNumberConfig_default(sponsorOptions?.usdcFeeAmountPerPeriod)?.times(sponsorOptions?.numOfPeriods).toString();
5733
- const sponsorCoin = sponsorOptions.coinToSplit ? tx.splitCoins(sponsorOptions.coinToSplit, [tx.pure.u64(totalFee)])[0] : (0, import_transactions13.coinWithBalance)({ type: USDC_COIN_TYPE, balance: BigInt(totalFee) });
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, [
5992
+ tx.pure.u64(
5993
+ new bigNumberConfig_default(sponsorOptions?.usdcFeeAmountPerPeriod)?.times(sponsorOptions?.numOfPeriods).toString()
5994
+ )
5995
+ ]);
5734
5996
  tx.moveCall({
5735
5997
  target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::add_sponsored_listing`,
5736
5998
  arguments: [
@@ -5738,14 +6000,19 @@ var addSponsorListingTx = async ({
5738
6000
  tx.object.clock(),
5739
6001
  tx.pure.id(nftTokenId),
5740
6002
  tx.pure.u64(sponsorOptions?.numOfPeriods),
5741
- tx.object(sponsorCoin)
6003
+ tx.object(sponsorFeeCoin)
5742
6004
  ],
5743
6005
  typeArguments: [nftType]
5744
6006
  });
6007
+ tx.transferObjects([coinOut], walletAddress);
5745
6008
  };
5746
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
+
5747
6014
  // src/methods/listNfts/listNfts.ts
5748
- var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
6015
+ var listNfts = async ({ nfts, walletAddress }, context) => {
5749
6016
  const res = await gqlChainRequest({
5750
6017
  chain: "sui",
5751
6018
  query: fetchNftsWithListingsById,
@@ -5755,7 +6022,7 @@ var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
5755
6022
  throw new Error("No nfts found");
5756
6023
  }
5757
6024
  const nftsForTracking = [];
5758
- const tx = existingTx ?? new import_transactions14.Transaction();
6025
+ const tx = new import_transactions12.Transaction();
5759
6026
  const sharedKioskState = {
5760
6027
  kioskTx: void 0
5761
6028
  };
@@ -5805,9 +6072,12 @@ var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
5805
6072
  if (inputNft?.sponsorOptions?.shouldSponsor) {
5806
6073
  await addSponsorListingTx({
5807
6074
  tx,
6075
+ suiClient: context.suiClient,
5808
6076
  nftTokenId: nft?.token_id,
5809
6077
  nftType,
5810
- sponsorOptions: inputNft?.sponsorOptions
6078
+ walletAddress,
6079
+ sponsorOptions: inputNft?.sponsorOptions,
6080
+ defiRouterUrl: context.defiRouterUrl
5811
6081
  });
5812
6082
  }
5813
6083
  nftsForTracking.push({
@@ -5820,15 +6090,15 @@ var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
5820
6090
  });
5821
6091
  }
5822
6092
  sharedKioskState?.kioskTx?.finalize();
5823
- return tx;
6093
+ return tx instanceof import_transactions12.Transaction ? tx : import_transactions12.Transaction.from(tx);
5824
6094
  };
5825
6095
 
5826
6096
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
5827
- var import_transactions15 = require("@mysten/sui/transactions");
6097
+ var import_transactions13 = require("@mysten/sui/transactions");
5828
6098
 
5829
6099
  // src/graphql/queries/fetchNftsByKioskId.ts
5830
- var import_graphql_request17 = require("graphql-request");
5831
- var fetchNftsByKioskId = import_graphql_request17.gql`
6100
+ var import_graphql_request16 = require("graphql-request");
6101
+ var fetchNftsByKioskId = import_graphql_request16.gql`
5832
6102
  query fetchNftsByKioskId($jsonFilter: jsonb) {
5833
6103
  nfts(where: { chain_state: { _contains: $jsonFilter } }) {
5834
6104
  id
@@ -5849,7 +6119,7 @@ var fetchNftsByKioskId = import_graphql_request17.gql`
5849
6119
  }
5850
6120
  }
5851
6121
  `;
5852
- var fetchBulkNftsByKioskId = import_graphql_request17.gql`
6122
+ var fetchBulkNftsByKioskId = import_graphql_request16.gql`
5853
6123
  query fetchNftsByKioskId($where: nfts_bool_exp) {
5854
6124
  nfts(where: $where) {
5855
6125
  id
@@ -5872,8 +6142,8 @@ var fetchBulkNftsByKioskId = import_graphql_request17.gql`
5872
6142
  `;
5873
6143
 
5874
6144
  // src/graphql/queries/fetchTransferPoliciesByType.ts
5875
- var import_graphql_request18 = require("graphql-request");
5876
- var fetchTransferPoliciesByType = import_graphql_request18.gql`
6145
+ var import_graphql_request17 = require("graphql-request");
6146
+ var fetchTransferPoliciesByType = import_graphql_request17.gql`
5877
6147
  query fetchTransferPoliciesByType($type: String!) {
5878
6148
  transfer_policies_by_type(type: $type) {
5879
6149
  id
@@ -6032,7 +6302,7 @@ async function getTransferPolicyForDirectTransfer(suiClient, collectionChainStat
6032
6302
 
6033
6303
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
6034
6304
  async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }, context) {
6035
- const tx = new import_transactions15.Transaction();
6305
+ const tx = new import_transactions13.Transaction();
6036
6306
  const res = await gqlChainRequest({
6037
6307
  chain: "sui",
6038
6308
  query: fetchKiosksByOwner,
@@ -6198,15 +6468,15 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }
6198
6468
  }
6199
6469
  }
6200
6470
  sharedKioskState?.kioskTx?.finalize();
6201
- return import_transactions15.Transaction.from(tx);
6471
+ return import_transactions13.Transaction.from(tx);
6202
6472
  }
6203
6473
 
6204
6474
  // src/methods/placeCollectionBids/placeCollectionBids.ts
6205
- var import_transactions16 = require("@mysten/sui/transactions");
6475
+ var import_transactions14 = require("@mysten/sui/transactions");
6206
6476
 
6207
6477
  // src/graphql/queries/fetchCollectionsById.ts
6208
- var import_graphql_request19 = require("graphql-request");
6209
- var fetchCollectionsById = import_graphql_request19.gql`
6478
+ var import_graphql_request18 = require("graphql-request");
6479
+ var fetchCollectionsById = import_graphql_request18.gql`
6210
6480
  query fetchCollectionsById($collectionIds: [uuid!]) {
6211
6481
  collections(where: { id: { _in: $collectionIds } }) {
6212
6482
  id
@@ -6216,7 +6486,7 @@ var fetchCollectionsById = import_graphql_request19.gql`
6216
6486
  }
6217
6487
  }
6218
6488
  `;
6219
- var fetchCollectionsByIdWithOneNft = import_graphql_request19.gql`
6489
+ var fetchCollectionsByIdWithOneNft = import_graphql_request18.gql`
6220
6490
  query fetchCollectionsByIdWithOneNft($collectionIds: [uuid!]) {
6221
6491
  collections(where: { id: { _in: $collectionIds } }) {
6222
6492
  id
@@ -6234,7 +6504,7 @@ var fetchCollectionsByIdWithOneNft = import_graphql_request19.gql`
6234
6504
  }
6235
6505
  }
6236
6506
  `;
6237
- var fetchCollectionsBySlug = import_graphql_request19.gql`
6507
+ var fetchCollectionsBySlug = import_graphql_request18.gql`
6238
6508
  query fetchCollectionsBySlug($slug: String!) {
6239
6509
  collections(where: { slug: { _eq: $slug } }) {
6240
6510
  id
@@ -6243,7 +6513,7 @@ var fetchCollectionsBySlug = import_graphql_request19.gql`
6243
6513
  `;
6244
6514
 
6245
6515
  // src/methods/placeNftBids/addPlaceNftBidTxs.ts
6246
- var import_utils8 = require("@mysten/sui/utils");
6516
+ var import_utils9 = require("@mysten/sui/utils");
6247
6517
  async function addTradePortPlaceNftBidTxHandler(txData) {
6248
6518
  if (isOriginByteCollection(txData?.transferPolicies) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
6249
6519
  throw new Error("OriginByte bidding not supported currently");
@@ -6264,7 +6534,7 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
6264
6534
  if (!bcsHex) {
6265
6535
  throw new Error(`No BCS found for token ${nftTokenId}`);
6266
6536
  }
6267
- bcs4 = (0, import_utils8.fromHex)(bcsHex);
6537
+ bcs4 = (0, import_utils9.fromHex)(bcsHex);
6268
6538
  }
6269
6539
  let multiBidChainId;
6270
6540
  let expiredBids;
@@ -6320,12 +6590,12 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
6320
6590
  arguments: [
6321
6591
  tx.object(TRADEPORT_MULTI_BID_STORE),
6322
6592
  tx.pure.u64(nftTokenId ? 1 : 0),
6323
- 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({
6324
6594
  target: "0x1::option::some",
6325
6595
  typeArguments: ["0x2::object::ID"],
6326
6596
  arguments: [multiBidChainId]
6327
6597
  }) : void 0,
6328
- 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),
6329
6599
  tx.pure.option("vector<u8>", bcs4 ? [...bcs4] : void 0),
6330
6600
  tx.pure.option("u64", expireAt?.getTime()),
6331
6601
  tx.pure.u64(price),
@@ -6356,8 +6626,8 @@ function isDynamicCollection(collectionId) {
6356
6626
  }
6357
6627
 
6358
6628
  // src/graphql/queries/fetchCollectionFloorListings.ts
6359
- var import_graphql_request20 = require("graphql-request");
6360
- var fetchCollectionFloorListings = import_graphql_request20.gql`
6629
+ var import_graphql_request19 = require("graphql-request");
6630
+ var fetchCollectionFloorListings = import_graphql_request19.gql`
6361
6631
  query fetchCollectionFloorListings($collectionId: uuid!) {
6362
6632
  listings(
6363
6633
  where: { collection_id: { _eq: $collectionId }, listed: { _eq: true }, nft: {} }
@@ -6416,14 +6686,7 @@ async function addOriginByteCollectionBidTx({
6416
6686
  }
6417
6687
 
6418
6688
  // src/methods/placeCollectionBids/placeCollectionBids.ts
6419
- var placeCollectionBids = async ({
6420
- collections,
6421
- walletAddress,
6422
- multiBidId,
6423
- multiBidChainId,
6424
- tx: existingTx,
6425
- coinToSplit
6426
- }, context) => {
6689
+ var placeCollectionBids = async ({ collections, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
6427
6690
  const res = await gqlChainRequest({
6428
6691
  chain: "sui",
6429
6692
  query: fetchCollectionsByIdWithOneNft,
@@ -6433,7 +6696,8 @@ var placeCollectionBids = async ({
6433
6696
  throw new Error("No collection found");
6434
6697
  }
6435
6698
  const collectionsForTracking = [];
6436
- const tx = existingTx ?? new import_transactions16.Transaction();
6699
+ const tx = deserializeOrCreateTxBlock({ existingTx });
6700
+ const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
6437
6701
  for (const collection of res.collections) {
6438
6702
  const nftType = getNftType({
6439
6703
  collectionId: collection?.id,
@@ -6453,7 +6717,7 @@ var placeCollectionBids = async ({
6453
6717
  multiBidId,
6454
6718
  multiBidChainId,
6455
6719
  expireAt: collections?.find((c) => c.id === collection?.id)?.expireAt,
6456
- coinToSplit
6720
+ coinToSplit: swapResultCoin
6457
6721
  };
6458
6722
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
6459
6723
  if (isOriginByteCollection(txData?.transferPolicies) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
@@ -6480,13 +6744,17 @@ var placeCollectionBids = async ({
6480
6744
  bidder: walletAddress
6481
6745
  });
6482
6746
  }
6483
- return tx;
6747
+ if (swapResultCoin) {
6748
+ tx.transferObjects([swapResultCoin], walletAddress);
6749
+ }
6750
+ return import_transactions14.Transaction.from(tx);
6484
6751
  };
6485
6752
 
6486
6753
  // src/methods/placeNftBids/placeNftBids.ts
6487
- var import_transactions17 = require("@mysten/sui/transactions");
6488
- var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx, coinToSplit }, context) => {
6489
- const tx = existingTx ?? new import_transactions17.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);
6490
6758
  const res = await gqlChainRequest({
6491
6759
  chain: "sui",
6492
6760
  query: fetchNftsById,
@@ -6520,7 +6788,7 @@ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx
6520
6788
  multiBidId,
6521
6789
  multiBidChainId,
6522
6790
  expireAt: bid?.expireAt,
6523
- coinToSplit
6791
+ coinToSplit: swapResultCoin
6524
6792
  };
6525
6793
  await addTradePortPlaceNftBidTxHandler(txData);
6526
6794
  nftsForTracking.push({
@@ -6530,14 +6798,17 @@ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx
6530
6798
  bidder: walletAddress
6531
6799
  });
6532
6800
  }
6533
- return tx;
6801
+ if (swapResultCoin) {
6802
+ tx.transferObjects([swapResultCoin], walletAddress);
6803
+ }
6804
+ return import_transactions15.Transaction.from(tx);
6534
6805
  };
6535
6806
 
6536
6807
  // src/methods/removeCollectionBids/removeCollectionBids.ts
6537
- var import_transactions18 = require("@mysten/sui/transactions");
6808
+ var import_transactions16 = require("@mysten/sui/transactions");
6538
6809
 
6539
6810
  // src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts
6540
- var import_utils9 = require("@mysten/sui/utils");
6811
+ var import_utils10 = require("@mysten/sui/utils");
6541
6812
  function addTradeportRemoveCollectionBidTx({
6542
6813
  tx,
6543
6814
  nftType,
@@ -6593,7 +6864,7 @@ function addBluemoveKioskRemoveCollectionBidTx({
6593
6864
  async function addTradePortRemoveCollectionBidTxHandler(txData) {
6594
6865
  const bidType = await getObjectType({
6595
6866
  suiClient: txData?.suiClient,
6596
- objectId: (0, import_utils9.normalizeSuiObjectId)(txData?.bidNonce)
6867
+ objectId: (0, import_utils10.normalizeSuiObjectId)(txData?.bidNonce)
6597
6868
  });
6598
6869
  if (isSingleBid(bidType)) {
6599
6870
  await addSingleBidRemoveNftBidTx(txData);
@@ -6613,7 +6884,7 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
6613
6884
  async function addBluemoveRemoveCollectionBidTxHandler(txData) {
6614
6885
  const bidType = await getObjectType({
6615
6886
  suiClient: txData?.suiClient,
6616
- objectId: (0, import_utils9.normalizeSuiObjectId)(txData?.bidNonce)
6887
+ objectId: (0, import_utils10.normalizeSuiObjectId)(txData?.bidNonce)
6617
6888
  });
6618
6889
  if (isOriginByteBid(bidType)) {
6619
6890
  const sharedObjects = await getSharedObjects(txData?.nftType);
@@ -6642,7 +6913,7 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
6642
6913
  throw new Error("No bids found");
6643
6914
  }
6644
6915
  const bidsForTracking = [];
6645
- const tx = existingTx ? import_transactions18.Transaction.from(existingTx) : new import_transactions18.Transaction();
6916
+ const tx = existingTx ? import_transactions16.Transaction.from(existingTx) : new import_transactions16.Transaction();
6646
6917
  for (const bid of res.bids) {
6647
6918
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
6648
6919
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6690,11 +6961,11 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
6690
6961
  bidder: bid?.bidder
6691
6962
  });
6692
6963
  }
6693
- return import_transactions18.Transaction.from(tx);
6964
+ return import_transactions16.Transaction.from(tx);
6694
6965
  };
6695
6966
 
6696
6967
  // src/methods/removeNftBids/removeNftBids.ts
6697
- var import_transactions19 = require("@mysten/sui/transactions");
6968
+ var import_transactions17 = require("@mysten/sui/transactions");
6698
6969
  var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6699
6970
  const res = await gqlChainRequest({
6700
6971
  chain: "sui",
@@ -6705,7 +6976,7 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6705
6976
  throw new Error("No bids found");
6706
6977
  }
6707
6978
  const bidsForTracking = [];
6708
- const tx = existingTx ? import_transactions19.Transaction.from(existingTx) : new import_transactions19.Transaction();
6979
+ const tx = existingTx ? import_transactions17.Transaction.from(existingTx) : new import_transactions17.Transaction();
6709
6980
  for (const bid of res.bids) {
6710
6981
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
6711
6982
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6750,61 +7021,11 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6750
7021
  bidder: bid?.bidder
6751
7022
  });
6752
7023
  }
6753
- return import_transactions19.Transaction.from(tx);
6754
- };
6755
-
6756
- // src/methods/sponsorNftListing/sponsorNftListing.ts
6757
- var import_transactions20 = require("@mysten/sui/transactions");
6758
-
6759
- // src/graphql/queries/fetchNftCollectionChainState.ts
6760
- var import_graphql_request21 = require("graphql-request");
6761
- var fetchNftCollectionChainState = import_graphql_request21.gql`
6762
- query fetchNftCollectionChainState($nftTokenId: String!) {
6763
- nfts(where: { token_id: { _eq: $nftTokenId } }) {
6764
- collection {
6765
- id
6766
- chain_state
6767
- }
6768
- }
6769
- }
6770
- `;
6771
-
6772
- // src/methods/sponsorNftListing/sponsorNftListing.ts
6773
- var sponsorNftListing = async ({
6774
- tx: existingTx,
6775
- nftTokenId,
6776
- options
6777
- }) => {
6778
- const res = await gqlChainRequest({
6779
- chain: "sui",
6780
- query: fetchNftCollectionChainState,
6781
- variables: { nftTokenId }
6782
- });
6783
- if (res?.nfts?.length === 0) {
6784
- throw new Error(`No nft found with token id ${nftTokenId}`);
6785
- }
6786
- const nft = res?.nfts?.[0];
6787
- const nftType = getNftType({
6788
- collectionId: nft?.collection?.id,
6789
- collectionChainState: nft?.collection?.chain_state,
6790
- nft
6791
- });
6792
- const transferPolicies = nft?.collection?.chain_state?.transfer_policies;
6793
- if (isOriginByteCollection(transferPolicies)) {
6794
- throw new Error(`You cannot sponsor an Origin Byte NFT. Nft Token Id: ${nftTokenId}`);
6795
- }
6796
- const tx = existingTx ?? new import_transactions20.Transaction();
6797
- await addSponsorListingTx({
6798
- tx,
6799
- nftTokenId,
6800
- nftType,
6801
- sponsorOptions: options
6802
- });
6803
- return tx;
7024
+ return import_transactions17.Transaction.from(tx);
6804
7025
  };
6805
7026
 
6806
7027
  // src/methods/transferNfts/transferNfts.ts
6807
- var import_transactions21 = require("@mysten/sui/transactions");
7028
+ var import_transactions18 = require("@mysten/sui/transactions");
6808
7029
  var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context) => {
6809
7030
  if (addLeadingZerosAfter0x(recipientAddress) === addLeadingZerosAfter0x(walletAddress)) {
6810
7031
  throw new Error("Cannot transfer to self");
@@ -6822,7 +7043,7 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
6822
7043
  }
6823
7044
  const nftsForTracking = [];
6824
7045
  const nftsToTransferDirectly = [];
6825
- const tx = new import_transactions21.Transaction();
7046
+ const tx = new import_transactions18.Transaction();
6826
7047
  const sharedKioskState = {
6827
7048
  kioskTx: void 0
6828
7049
  };
@@ -6925,11 +7146,11 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
6925
7146
  context.suiClient
6926
7147
  );
6927
7148
  sharedKioskState?.kioskTx?.finalize();
6928
- return import_transactions21.Transaction.from(tx);
7149
+ return import_transactions18.Transaction.from(tx);
6929
7150
  };
6930
7151
 
6931
7152
  // src/methods/unlistListings/unlistListings.ts
6932
- var import_transactions22 = require("@mysten/sui/transactions");
7153
+ var import_transactions19 = require("@mysten/sui/transactions");
6933
7154
  var unlistListings = async ({ listingIds, walletAddress }, context) => {
6934
7155
  const res = await gqlChainRequest({
6935
7156
  chain: "sui",
@@ -6940,7 +7161,7 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
6940
7161
  throw new Error("No listings found");
6941
7162
  }
6942
7163
  const listingsForTracking = [];
6943
- const tx = new import_transactions22.Transaction();
7164
+ const tx = new import_transactions19.Transaction();
6944
7165
  const sharedKioskState = {
6945
7166
  kioskTx: void 0
6946
7167
  };
@@ -7009,12 +7230,12 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
7009
7230
  });
7010
7231
  }
7011
7232
  sharedKioskState?.kioskTx?.finalize();
7012
- return import_transactions22.Transaction.from(tx);
7233
+ return import_transactions19.Transaction.from(tx);
7013
7234
  };
7014
7235
 
7015
7236
  // src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts
7016
7237
  var import_kiosk5 = require("@mysten/kiosk");
7017
- var import_transactions23 = require("@mysten/sui/transactions");
7238
+ var import_transactions20 = require("@mysten/sui/transactions");
7018
7239
  async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7019
7240
  const res = await gqlChainRequest({
7020
7241
  chain: "sui",
@@ -7034,7 +7255,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7034
7255
  if (kiosksWithProfit.length === 0) {
7035
7256
  throw new Error(`No kiosks with profit to withdraw found for ${walletAddress}`);
7036
7257
  }
7037
- const tx = new import_transactions23.Transaction();
7258
+ const tx = new import_transactions20.Transaction();
7038
7259
  try {
7039
7260
  for (const kiosk of kiosksWithProfit) {
7040
7261
  let kioskTx;
@@ -7080,7 +7301,149 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
7080
7301
  } catch (err) {
7081
7302
  console.log("err", err);
7082
7303
  }
7083
- return import_transactions23.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;
7084
7447
  }
7085
7448
 
7086
7449
  // src/SuiTradingClient.ts
@@ -7090,14 +7453,14 @@ var SuiTradingClient = class {
7090
7453
  apiKey,
7091
7454
  apiVercelId,
7092
7455
  apiUrl,
7093
- tradeportRouterUrl,
7456
+ defiRouterUrl,
7094
7457
  suiNodeUrl,
7095
7458
  graphQLClient
7096
7459
  }) {
7097
7460
  this.allowedApiUsersForUnsharedKiosksMigration = ["tradeport.xyz", "mercato.xyz"];
7098
7461
  this.apiUser = apiUser;
7099
7462
  this.apiKey = apiKey;
7100
- this.tradeportRouterUrl = tradeportRouterUrl;
7463
+ this.defiRouterUrl = defiRouterUrl ?? "https://api.indexer.xyz/router";
7101
7464
  this.suiClient = createSuiClient_default(suiNodeUrl ?? (0, import_client2.getFullnodeUrl)("mainnet"));
7102
7465
  this.kioskClient = createKioskClient_default(this.suiClient);
7103
7466
  if (graphQLClient) {
@@ -7111,31 +7474,31 @@ var SuiTradingClient = class {
7111
7474
  ...apiVercelId && { "x-vercel-id": apiVercelId }
7112
7475
  });
7113
7476
  }
7114
- async buyListings(args) {
7477
+ async buyListings({ listingIds, walletAddress, tx }) {
7115
7478
  const context = {
7116
7479
  apiUser: this.apiUser,
7117
7480
  apiKey: this.apiKey,
7118
- tradeportRouterUrl: this.tradeportRouterUrl,
7481
+ defiRouterUrl: this.defiRouterUrl,
7119
7482
  suiClient: this.suiClient,
7120
7483
  kioskClient: this.kioskClient
7121
7484
  };
7122
- return buyListings(args, context);
7485
+ return buyListings({ listingIds, walletAddress, tx }, context);
7123
7486
  }
7124
- async listNfts({ nfts, walletAddress, tx }) {
7487
+ async listNfts({ nfts, walletAddress }) {
7125
7488
  const context = {
7126
7489
  apiUser: this.apiUser,
7127
7490
  apiKey: this.apiKey,
7128
- tradeportRouterUrl: this.tradeportRouterUrl,
7491
+ defiRouterUrl: this.defiRouterUrl,
7129
7492
  suiClient: this.suiClient,
7130
7493
  kioskClient: this.kioskClient
7131
7494
  };
7132
- return listNfts({ nfts, walletAddress, tx }, context);
7495
+ return listNfts({ nfts, walletAddress }, context);
7133
7496
  }
7134
7497
  async unlistListings({ listingIds, walletAddress }) {
7135
7498
  const context = {
7136
7499
  apiUser: this.apiUser,
7137
7500
  apiKey: this.apiKey,
7138
- tradeportRouterUrl: this.tradeportRouterUrl,
7501
+ defiRouterUrl: this.defiRouterUrl,
7139
7502
  suiClient: this.suiClient,
7140
7503
  kioskClient: this.kioskClient
7141
7504
  };
@@ -7145,7 +7508,7 @@ var SuiTradingClient = class {
7145
7508
  const context = {
7146
7509
  apiUser: this.apiUser,
7147
7510
  apiKey: this.apiKey,
7148
- tradeportRouterUrl: this.tradeportRouterUrl,
7511
+ defiRouterUrl: this.defiRouterUrl,
7149
7512
  suiClient: this.suiClient,
7150
7513
  kioskClient: this.kioskClient
7151
7514
  };
@@ -7154,7 +7517,7 @@ var SuiTradingClient = class {
7154
7517
  async removeNftBids({ bidIds, tx }) {
7155
7518
  const context = {
7156
7519
  apiUser: this.apiUser,
7157
- tradeportRouterUrl: this.tradeportRouterUrl,
7520
+ defiRouterUrl: this.defiRouterUrl,
7158
7521
  apiKey: this.apiKey,
7159
7522
  suiClient: this.suiClient,
7160
7523
  kioskClient: this.kioskClient
@@ -7165,7 +7528,7 @@ var SuiTradingClient = class {
7165
7528
  const context = {
7166
7529
  apiUser: this.apiUser,
7167
7530
  apiKey: this.apiKey,
7168
- tradeportRouterUrl: this.tradeportRouterUrl,
7531
+ defiRouterUrl: this.defiRouterUrl,
7169
7532
  suiClient: this.suiClient,
7170
7533
  kioskClient: this.kioskClient
7171
7534
  };
@@ -7184,7 +7547,7 @@ var SuiTradingClient = class {
7184
7547
  const context = {
7185
7548
  apiUser: this.apiUser,
7186
7549
  apiKey: this.apiKey,
7187
- tradeportRouterUrl: this.tradeportRouterUrl,
7550
+ defiRouterUrl: this.defiRouterUrl,
7188
7551
  suiClient: this.suiClient,
7189
7552
  kioskClient: this.kioskClient
7190
7553
  };
@@ -7210,7 +7573,7 @@ var SuiTradingClient = class {
7210
7573
  const context = {
7211
7574
  apiUser: this.apiUser,
7212
7575
  apiKey: this.apiKey,
7213
- tradeportRouterUrl: this.tradeportRouterUrl,
7576
+ defiRouterUrl: this.defiRouterUrl,
7214
7577
  suiClient: this.suiClient,
7215
7578
  kioskClient: this.kioskClient
7216
7579
  };
@@ -7286,7 +7649,7 @@ var SuiTradingClient = class {
7286
7649
  const context = {
7287
7650
  apiUser: this.apiUser,
7288
7651
  apiKey: this.apiKey,
7289
- tradeportRouterUrl: this.tradeportRouterUrl,
7652
+ defiRouterUrl: this.defiRouterUrl,
7290
7653
  suiClient: this.suiClient,
7291
7654
  kioskClient: this.kioskClient
7292
7655
  };
@@ -7296,7 +7659,7 @@ var SuiTradingClient = class {
7296
7659
  const context = {
7297
7660
  apiUser: this.apiUser,
7298
7661
  apiKey: this.apiKey,
7299
- tradeportRouterUrl: this.tradeportRouterUrl,
7662
+ defiRouterUrl: this.defiRouterUrl,
7300
7663
  suiClient: this.suiClient,
7301
7664
  kioskClient: this.kioskClient
7302
7665
  };
@@ -7306,7 +7669,7 @@ var SuiTradingClient = class {
7306
7669
  const context = {
7307
7670
  apiUser: this.apiUser,
7308
7671
  apiKey: this.apiKey,
7309
- tradeportRouterUrl: this.tradeportRouterUrl,
7672
+ defiRouterUrl: this.defiRouterUrl,
7310
7673
  suiClient: this.suiClient,
7311
7674
  kioskClient: this.kioskClient
7312
7675
  };
@@ -7322,7 +7685,7 @@ var SuiTradingClient = class {
7322
7685
  const context = {
7323
7686
  apiUser: this.apiUser,
7324
7687
  apiKey: this.apiKey,
7325
- tradeportRouterUrl: this.tradeportRouterUrl,
7688
+ defiRouterUrl: this.defiRouterUrl,
7326
7689
  suiClient: this.suiClient,
7327
7690
  kioskClient: this.kioskClient
7328
7691
  };
@@ -7342,7 +7705,7 @@ var SuiTradingClient = class {
7342
7705
  const context = {
7343
7706
  apiUser: this.apiUser,
7344
7707
  apiKey: this.apiKey,
7345
- tradeportRouterUrl: this.tradeportRouterUrl,
7708
+ defiRouterUrl: this.defiRouterUrl,
7346
7709
  suiClient: this.suiClient,
7347
7710
  kioskClient: this.kioskClient
7348
7711
  };
@@ -7355,7 +7718,7 @@ var SuiTradingClient = class {
7355
7718
  const context = {
7356
7719
  apiUser: this.apiUser,
7357
7720
  apiKey: this.apiKey,
7358
- tradeportRouterUrl: this.tradeportRouterUrl,
7721
+ defiRouterUrl: this.defiRouterUrl,
7359
7722
  suiClient: this.suiClient,
7360
7723
  kioskClient: this.kioskClient
7361
7724
  };
@@ -7368,13 +7731,17 @@ var SuiTradingClient = class {
7368
7731
  return cancelMultiBid(args);
7369
7732
  }
7370
7733
  async updateMultiBid(args) {
7371
- return updateMultiBid(args, {
7372
- suiClient: this.suiClient,
7373
- tradeportRouterUrl: this.tradeportRouterUrl
7374
- });
7734
+ return updateMultiBid(args);
7375
7735
  }
7376
7736
  async sponsorNftListing(args) {
7377
- 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);
7378
7745
  }
7379
7746
  async applyFtStrategy(args) {
7380
7747
  return applyFtStrategy(args);
@@ -7382,6 +7749,15 @@ var SuiTradingClient = class {
7382
7749
  async applyTradeportNftStrategy(args) {
7383
7750
  return applyTradeportNftStrategy(args);
7384
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
+ }
7385
7761
  };
7386
7762
  var SuiTradingClient_default = SuiTradingClient;
7387
7763
  // Annotate the CommonJS export names for ESM import in node: