@tradeport/sui-trading-sdk 0.4.43 → 0.4.44

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
@@ -6040,7 +6040,7 @@ async function createSwapTransaction({
6040
6040
  const {
6041
6041
  coinInType,
6042
6042
  coinInAmount = ZERO,
6043
- coinOutType,
6043
+ coinOutType = suiCoinType,
6044
6044
  slippage = 1,
6045
6045
  ttl = "15m",
6046
6046
  excludeSources = [import_sdk.Protocol.STEAMM, ...DexConstants.poolsToExclude],
@@ -6053,11 +6053,21 @@ async function createSwapTransaction({
6053
6053
  coinOut: coin
6054
6054
  };
6055
6055
  }
6056
+ if ((0, import_utils10.normalizeStructTag)(coinOutType) === (0, import_utils10.normalizeStructTag)(coinInType)) {
6057
+ const coin = (0, import_transactions18.coinWithBalance)({
6058
+ balance: BigInt(coinInAmount.toFixed()),
6059
+ type: coinInType
6060
+ })(tx);
6061
+ return {
6062
+ transaction: tx,
6063
+ coinOut: coin
6064
+ };
6065
+ }
6056
6066
  const amountInSwap = coinInAmount.minus(coinInAmount.div(100).toFixed(0));
6057
6067
  const commissionAmount = coinInAmount.div(100).toFixed(0);
6058
6068
  const { routes } = await aggregatorQuoter.getRoutes({
6059
6069
  tokenIn: coinInType,
6060
- tokenOut: coinOutType ?? suiCoinType,
6070
+ tokenOut: coinOutType,
6061
6071
  amountIn: amountInSwap.toFixed(),
6062
6072
  excludeSources
6063
6073
  });
@@ -6121,8 +6131,12 @@ async function calculateSwapInputAmountWithSlippage({
6121
6131
  limit: 2,
6122
6132
  coinTypes: [coinInType, coinOutType]
6123
6133
  });
6124
- const coinIn = coinQueryResult[0];
6125
- const coinOut = coinQueryResult[1];
6134
+ const coinIn = coinQueryResult?.find(
6135
+ (coin) => (0, import_utils10.normalizeStructTag)(coin.coinType) === (0, import_utils10.normalizeStructTag)(coinInType)
6136
+ );
6137
+ const coinOut = coinQueryResult?.find(
6138
+ (coin) => (0, import_utils10.normalizeStructTag)(coin.coinType) === (0, import_utils10.normalizeStructTag)(coinOutType)
6139
+ );
6126
6140
  const exchangeRate = new bigNumberConfig_default(coinOut.derivedPriceInUSD ?? 0)?.gt(0) ? new bigNumberConfig_default(coinIn?.derivedPriceInUSD ?? 1)?.div(coinOut?.derivedPriceInUSD ?? 1) : new bigNumberConfig_default(0);
6127
6141
  const amountSell = toDecimalValue(coinOutAmount.toString(), coinOut?.decimals).div(exchangeRate);
6128
6142
  const slippageMultiplier = 1 + parseInt(slippage.toString() || "0", 10) / 1e6;
@@ -6259,7 +6273,7 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
6259
6273
  });
6260
6274
  }
6261
6275
  sharedKioskState?.kioskTx?.finalize();
6262
- return import_transactions19.Transaction.from(tx);
6276
+ return tx instanceof import_transactions19.Transaction ? tx : import_transactions19.Transaction.from(tx);
6263
6277
  };
6264
6278
 
6265
6279
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts