@tradeport/sui-trading-sdk 0.4.43 → 0.4.45
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +21 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +0 -1
- package/src/helpers/swap.ts +20 -5
- package/src/methods/listNfts/listNfts.ts +1 -1
- package/src/methods/sponsorNftListing/addSponsorNftListingTx.ts +3 -3
- package/src/methods/sponsorNftListing/sponsorNftListing.ts +1 -0
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -175,7 +175,6 @@ var DexConstants = {
|
|
|
175
175
|
"0x0854de4e9d64716b757b2f6f22258467f59cc1b4bc0cc64c70086549faaddedf"
|
|
176
176
|
]
|
|
177
177
|
};
|
|
178
|
-
var TRADEPORT_SPONSOR_USDC_FEE_AMOUNT_PER_PERIOD = 2e7;
|
|
179
178
|
var USDC_COIN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
180
179
|
var COLLECTION_IDS_WITH_ZERO_COMMISSION = [
|
|
181
180
|
""
|
|
@@ -6040,7 +6039,7 @@ async function createSwapTransaction({
|
|
|
6040
6039
|
const {
|
|
6041
6040
|
coinInType,
|
|
6042
6041
|
coinInAmount = ZERO,
|
|
6043
|
-
coinOutType,
|
|
6042
|
+
coinOutType = suiCoinType,
|
|
6044
6043
|
slippage = 1,
|
|
6045
6044
|
ttl = "15m",
|
|
6046
6045
|
excludeSources = [import_sdk.Protocol.STEAMM, ...DexConstants.poolsToExclude],
|
|
@@ -6053,11 +6052,21 @@ async function createSwapTransaction({
|
|
|
6053
6052
|
coinOut: coin
|
|
6054
6053
|
};
|
|
6055
6054
|
}
|
|
6055
|
+
if ((0, import_utils10.normalizeStructTag)(coinOutType) === (0, import_utils10.normalizeStructTag)(coinInType)) {
|
|
6056
|
+
const coin = (0, import_transactions18.coinWithBalance)({
|
|
6057
|
+
balance: BigInt(coinInAmount.toFixed()),
|
|
6058
|
+
type: coinInType
|
|
6059
|
+
})(tx);
|
|
6060
|
+
return {
|
|
6061
|
+
transaction: tx,
|
|
6062
|
+
coinOut: coin
|
|
6063
|
+
};
|
|
6064
|
+
}
|
|
6056
6065
|
const amountInSwap = coinInAmount.minus(coinInAmount.div(100).toFixed(0));
|
|
6057
6066
|
const commissionAmount = coinInAmount.div(100).toFixed(0);
|
|
6058
6067
|
const { routes } = await aggregatorQuoter.getRoutes({
|
|
6059
6068
|
tokenIn: coinInType,
|
|
6060
|
-
tokenOut: coinOutType
|
|
6069
|
+
tokenOut: coinOutType,
|
|
6061
6070
|
amountIn: amountInSwap.toFixed(),
|
|
6062
6071
|
excludeSources
|
|
6063
6072
|
});
|
|
@@ -6121,8 +6130,12 @@ async function calculateSwapInputAmountWithSlippage({
|
|
|
6121
6130
|
limit: 2,
|
|
6122
6131
|
coinTypes: [coinInType, coinOutType]
|
|
6123
6132
|
});
|
|
6124
|
-
const coinIn = coinQueryResult
|
|
6125
|
-
|
|
6133
|
+
const coinIn = coinQueryResult?.find(
|
|
6134
|
+
(coin) => (0, import_utils10.normalizeStructTag)(coin.coinType) === (0, import_utils10.normalizeStructTag)(coinInType)
|
|
6135
|
+
);
|
|
6136
|
+
const coinOut = coinQueryResult?.find(
|
|
6137
|
+
(coin) => (0, import_utils10.normalizeStructTag)(coin.coinType) === (0, import_utils10.normalizeStructTag)(coinOutType)
|
|
6138
|
+
);
|
|
6126
6139
|
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
6140
|
const amountSell = toDecimalValue(coinOutAmount.toString(), coinOut?.decimals).div(exchangeRate);
|
|
6128
6141
|
const slippageMultiplier = 1 + parseInt(slippage.toString() || "0", 10) / 1e6;
|
|
@@ -6144,7 +6157,7 @@ var addSponsorListingTx = async ({
|
|
|
6144
6157
|
const coinInAmount = await calculateSwapInputAmountWithSlippage({
|
|
6145
6158
|
coinInType: sponsorOptions?.coinInType,
|
|
6146
6159
|
coinOutType: USDC_COIN_TYPE,
|
|
6147
|
-
coinOutAmount: new bigNumberConfig_default(
|
|
6160
|
+
coinOutAmount: new bigNumberConfig_default(sponsorOptions?.usdcFeeAmountPerPeriod)?.times(sponsorOptions?.numOfPeriods).toString(),
|
|
6148
6161
|
slippage: sponsorOptions?.slippage
|
|
6149
6162
|
});
|
|
6150
6163
|
const { coinOut } = await createSwapTransaction({
|
|
@@ -6160,7 +6173,7 @@ var addSponsorListingTx = async ({
|
|
|
6160
6173
|
});
|
|
6161
6174
|
const [sponsorFeeCoin] = tx.splitCoins(coinOut, [
|
|
6162
6175
|
tx.pure.u64(
|
|
6163
|
-
new bigNumberConfig_default(
|
|
6176
|
+
new bigNumberConfig_default(sponsorOptions?.usdcFeeAmountPerPeriod)?.times(sponsorOptions?.numOfPeriods).toString()
|
|
6164
6177
|
)
|
|
6165
6178
|
]);
|
|
6166
6179
|
tx.moveCall({
|
|
@@ -6259,7 +6272,7 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
|
|
|
6259
6272
|
});
|
|
6260
6273
|
}
|
|
6261
6274
|
sharedKioskState?.kioskTx?.finalize();
|
|
6262
|
-
return import_transactions19.Transaction.from(tx);
|
|
6275
|
+
return tx instanceof import_transactions19.Transaction ? tx : import_transactions19.Transaction.from(tx);
|
|
6263
6276
|
};
|
|
6264
6277
|
|
|
6265
6278
|
// src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
|