@tradeport/sui-trading-sdk 0.4.39 → 0.4.41
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 +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +534 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +518 -125
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
- package/src/SuiTradingClient.ts +15 -0
- package/src/bigNumberConfig.ts +10 -0
- package/src/constants.ts +17 -1
- package/src/graphql/queries/fetchNftCollectionChainState.ts +12 -0
- package/src/helpers/calculateRoyaltyFee.ts +12 -7
- package/src/helpers/isExpiredListing.ts +9 -0
- package/src/helpers/kiosk/preProcessSharedBulkBuyingData.ts +9 -8
- package/src/helpers/swap.ts +197 -0
- package/src/helpers/validateMinFloorPrice.ts +22 -0
- package/src/methods/buyListings/addBuyListingTxs.ts +111 -5
- package/src/methods/buyLocks/buyLocks.ts +2 -2
- package/src/methods/createLongLocks/createLongLocks.ts +2 -2
- package/src/methods/createShortLocks/createShortLocks.ts +3 -3
- package/src/methods/listNfts/addListTxs.ts +17 -37
- package/src/methods/listNfts/addRelistTxs.ts +26 -17
- package/src/methods/listNfts/listNfts.ts +27 -16
- package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +1 -1
- package/src/methods/relistNft/relistNft.ts +19 -28
- package/src/methods/sponsorNftListing/addSponsorNftListingTx.ts +71 -0
- package/src/methods/sponsorNftListing/sponsorNftListing.ts +62 -0
- package/src/methods/unlistListings/addUnlistListingTxs.ts +68 -5
- package/src/methods/unlistListings/unlistListings.ts +2 -6
- package/src/tests/SuiWallet.ts +4 -1
- package/src/utils/printTxBlockTxs.ts +7 -1
- package/src/utils/pureValues.ts +13 -0
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,14 +17,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
23
33
|
SuiTradingClient: () => SuiTradingClient_default
|
|
24
34
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
36
|
|
|
27
37
|
// src/SuiTradingClient.ts
|
|
28
38
|
var import_client2 = require("@mysten/sui/client");
|
|
@@ -139,8 +149,11 @@ var MYSTEN_TRANFER_POLICY_RULES_PACKAGE_ID = "0x434b5bd8f6a7b05fede0ff46c6e511d7
|
|
|
139
149
|
var TRADEPORT_BENEFICIARY_ADDRESS = "0xbca3b5c01c8d1a93aed3a036feff45145518292dd3c1db1d67cc99a699a7b517";
|
|
140
150
|
var TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT = 0.03;
|
|
141
151
|
var TRADEPORT_THIRD_PARTY_FEE_DECIMAL_PERCENT = 5e-3;
|
|
152
|
+
var TRADEPORT_LISTINGS_DEFAULT_COMMISSION_BPS = 300;
|
|
142
153
|
var TRADEPORT_LISTING_STORE = "0x47cba0b6309a12ce39f9306e28b899ed4b3698bce4f4911fd0c58ff2329a2ff6";
|
|
143
154
|
var TRADEPORT_BIDDING_STORE = "0x3d3b0c6e616fdc1a45b2b73d022bc085448e78bd729d28081c7a340abb33cba1";
|
|
155
|
+
var TRADEPORT_LISTINGS_PACKAGE = "0x318d9bbbbc65be1fe53f0de1af9fd93dcbcb8d57146aba9754cf7a3b55880f5c";
|
|
156
|
+
var TRADEPORT_LISTINGS_STORE = "0x90626186ce022b50109628f44ef09e183e55961972d9b1b79de53558103161ef";
|
|
144
157
|
var TRADEPORT_KIOSK_LISTING_STORE = "0xbff3161b047fb8b727883838c09b08afa9e0dd0f5488bde9e99e80643da9b9e0";
|
|
145
158
|
var TRADEPORT_KIOSK_TRANSFERS_STORE = "0xe0f61b6915d3fd4ec8bbe4618514e2152a82841605bfa00cde22ace434153a1b";
|
|
146
159
|
var TRADEPORT_KIOSK_TRANSFERS_ESCROW_KIOSK = "0xa677dab85a93bd8d6845b6cc7914f3bbb334fef7fbcbe0e997b5f75b5922d106";
|
|
@@ -152,6 +165,18 @@ var TRADEPORT_PRICE_LOCK_STORE = "0x4b705de46a79b29276baf45009bc7d6f70cc0f1407f0
|
|
|
152
165
|
var TRADEPORT_MULTI_BID_PACKAGE = "0xd1dedf8379f1781469e95cb92eed7e155c8ad141c8528c3855f59ce2a5d9d659";
|
|
153
166
|
var TRADEPORT_MULTI_BID_PACKAGE_ORIGINAL = "0x53134eb544c5a0b5085e99efaf7eab13b28ad123de35d61f941f8c8c40b72033";
|
|
154
167
|
var TRADEPORT_MULTI_BID_STORE = "0x8aaed7e884343fb8b222c721d02eaac2c6ae2abbb4ddcdf16cb55cf8754ee860";
|
|
168
|
+
var DexConstants = {
|
|
169
|
+
commission: "0x24f5f2258ef80c0a3243088199faeb95ad50516ca1517dbd93be398d759057bb",
|
|
170
|
+
commissionManager: "0xd19a03d4ec3d12b0ce407b54eb676cc0f8e1403621deda77d9677bfcb9d738c1",
|
|
171
|
+
poolsToExclude: [
|
|
172
|
+
"0x3addbbc82866c0bbd93e51b6e2d75c0a4faaf270cc0e281d8f4de5df48bebfa4",
|
|
173
|
+
"0x19d614f421046cae90f5a3a976816063478f648087a12adc74e90ebd54dfaf19",
|
|
174
|
+
"0x514c74e28a9720366abc4a65a5688f47c72e784dbf035844d3f59059bfaed056",
|
|
175
|
+
"0x0854de4e9d64716b757b2f6f22258467f59cc1b4bc0cc64c70086549faaddedf"
|
|
176
|
+
]
|
|
177
|
+
};
|
|
178
|
+
var TRADEPORT_SPONSOR_USDC_FEE_AMOUNT_PER_PERIOD = 2e7;
|
|
179
|
+
var USDC_COIN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
155
180
|
var COLLECTION_IDS_WITH_ZERO_COMMISSION = [
|
|
156
181
|
""
|
|
157
182
|
];
|
|
@@ -2603,14 +2628,14 @@ var isNonKioskListing = async ({
|
|
|
2603
2628
|
};
|
|
2604
2629
|
|
|
2605
2630
|
// src/methods/unlistListings/addUnlistListingTxs.ts
|
|
2606
|
-
function
|
|
2631
|
+
function addLegacyTradePortUnlistTx({ tx, listingNonce, nftType }) {
|
|
2607
2632
|
tx.moveCall({
|
|
2608
2633
|
target: "0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::listings::unlist",
|
|
2609
2634
|
arguments: [tx.object(TRADEPORT_LISTING_STORE), tx.pure.address(listingNonce)],
|
|
2610
2635
|
typeArguments: [nftType]
|
|
2611
2636
|
});
|
|
2612
2637
|
}
|
|
2613
|
-
async function
|
|
2638
|
+
async function addLegacyTradePortKioskUnlistTx({
|
|
2614
2639
|
tx,
|
|
2615
2640
|
kioskTx,
|
|
2616
2641
|
nftTokenId,
|
|
@@ -2627,6 +2652,30 @@ async function addTradePortKioskUnlistTx({
|
|
|
2627
2652
|
typeArguments: [nftType]
|
|
2628
2653
|
});
|
|
2629
2654
|
}
|
|
2655
|
+
function addTradePortUnlistTx({ tx, nftTokenId, nftType }) {
|
|
2656
|
+
tx.moveCall({
|
|
2657
|
+
target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::cancel_listing_without_transfer_policy`,
|
|
2658
|
+
arguments: [tx.object(TRADEPORT_LISTINGS_STORE), tx.pure.id(nftTokenId)],
|
|
2659
|
+
typeArguments: [nftType]
|
|
2660
|
+
});
|
|
2661
|
+
}
|
|
2662
|
+
async function addKioskTradePortUnlistTx({
|
|
2663
|
+
tx,
|
|
2664
|
+
kioskTx,
|
|
2665
|
+
nftTokenId,
|
|
2666
|
+
nftType
|
|
2667
|
+
}) {
|
|
2668
|
+
tx.moveCall({
|
|
2669
|
+
target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::cancel_listing_with_transfer_policy`,
|
|
2670
|
+
arguments: [
|
|
2671
|
+
tx.object(TRADEPORT_LISTINGS_STORE),
|
|
2672
|
+
tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
|
|
2673
|
+
tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
|
|
2674
|
+
tx.pure.id(nftTokenId)
|
|
2675
|
+
],
|
|
2676
|
+
typeArguments: [nftType]
|
|
2677
|
+
});
|
|
2678
|
+
}
|
|
2630
2679
|
function addOriginByteUnlistTx({
|
|
2631
2680
|
tx,
|
|
2632
2681
|
sharedObjects,
|
|
@@ -2731,10 +2780,36 @@ async function addTradePortUnlistTxHandler(txData) {
|
|
|
2731
2780
|
addOriginByteUnlistTx({ ...txData, sharedObjects });
|
|
2732
2781
|
return;
|
|
2733
2782
|
}
|
|
2734
|
-
if (txData?.listingNonce
|
|
2783
|
+
if (txData?.listingNonce?.startsWith("0::")) {
|
|
2735
2784
|
addTradePortUnlistTx(txData);
|
|
2736
2785
|
return;
|
|
2737
2786
|
}
|
|
2787
|
+
if (txData?.listingNonce?.startsWith("1::")) {
|
|
2788
|
+
return kioskTxWrapper({
|
|
2789
|
+
tx: txData?.tx,
|
|
2790
|
+
kioskClient: txData?.kioskClient,
|
|
2791
|
+
kioskOwner: txData?.seller,
|
|
2792
|
+
kiosk: txData?.sellerKiosk,
|
|
2793
|
+
shouldAllowNftUnsharedKiosk: true,
|
|
2794
|
+
sharedKioskState: txData?.sharedKioskState,
|
|
2795
|
+
shouldUseSharedKioskTx: false,
|
|
2796
|
+
async runCommands(kioskTx) {
|
|
2797
|
+
await addKioskTradePortUnlistTx({
|
|
2798
|
+
...txData,
|
|
2799
|
+
kioskTx
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
});
|
|
2803
|
+
}
|
|
2804
|
+
if (txData?.listingNonce && await isNonKioskListing({ suiClient: txData?.suiClient, listingNonce: txData?.listingNonce })) {
|
|
2805
|
+
if (txData?.isPartOfRelist) {
|
|
2806
|
+
throw new Error(
|
|
2807
|
+
"Cannot relist this non kiosk NFT in one transaction from legacy contract. You must unlist and list again"
|
|
2808
|
+
);
|
|
2809
|
+
}
|
|
2810
|
+
addLegacyTradePortUnlistTx(txData);
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2738
2813
|
if (txData?.sellerKiosk) {
|
|
2739
2814
|
return kioskTxWrapper({
|
|
2740
2815
|
tx: txData?.tx,
|
|
@@ -2745,7 +2820,7 @@ async function addTradePortUnlistTxHandler(txData) {
|
|
|
2745
2820
|
sharedKioskState: txData?.sharedKioskState,
|
|
2746
2821
|
shouldUseSharedKioskTx: false,
|
|
2747
2822
|
async runCommands(kioskTx) {
|
|
2748
|
-
await
|
|
2823
|
+
await addLegacyTradePortKioskUnlistTx({
|
|
2749
2824
|
...txData,
|
|
2750
2825
|
kioskTx
|
|
2751
2826
|
});
|
|
@@ -2768,7 +2843,7 @@ async function addTradePortUnlistTxHandler(txData) {
|
|
|
2768
2843
|
}
|
|
2769
2844
|
});
|
|
2770
2845
|
}
|
|
2771
|
-
|
|
2846
|
+
addLegacyTradePortUnlistTx(txData);
|
|
2772
2847
|
}
|
|
2773
2848
|
async function addHyperspaceUnlistTxHandler(txData) {
|
|
2774
2849
|
if (txData?.listingNonce && isOriginByteCollection(txData?.transferPolicies) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
|
|
@@ -3392,17 +3467,26 @@ function calculatePremium(price) {
|
|
|
3392
3467
|
return BigInt(price) * PREMIUM_NOMINATOR / 10000n;
|
|
3393
3468
|
}
|
|
3394
3469
|
|
|
3470
|
+
// src/bigNumberConfig.ts
|
|
3471
|
+
var import_bignumber = require("bignumber.js");
|
|
3472
|
+
import_bignumber.BigNumber.set({
|
|
3473
|
+
POW_PRECISION: 64
|
|
3474
|
+
});
|
|
3475
|
+
var ZERO = new import_bignumber.BigNumber(0);
|
|
3476
|
+
var ONE = new import_bignumber.BigNumber(1);
|
|
3477
|
+
var bigNumberConfig_default = import_bignumber.BigNumber;
|
|
3478
|
+
|
|
3395
3479
|
// src/helpers/calculateRoyaltyFee.ts
|
|
3396
3480
|
function calculateRoyaltyFee(transferPolicyRules, price) {
|
|
3397
3481
|
const royaltyRule = transferPolicyRules?.filter(
|
|
3398
|
-
(rule) => rule.type === "royalty_rule"
|
|
3482
|
+
(rule) => rule.type === "royalty_rule" || rule.type === "kiosk_royalty_rule"
|
|
3399
3483
|
)?.[0];
|
|
3400
3484
|
if (!royaltyRule || !royaltyRule.amount_bp && !royaltyRule.min_amount) {
|
|
3401
|
-
return
|
|
3485
|
+
return ZERO;
|
|
3402
3486
|
}
|
|
3403
|
-
const royaltyFee = royaltyRule.amount_bp ?
|
|
3404
|
-
if (royaltyRule.min_amount &&
|
|
3405
|
-
return
|
|
3487
|
+
const royaltyFee = royaltyRule.amount_bp ? new bigNumberConfig_default(royaltyRule.amount_bp).times(price).div(1e4) : ZERO;
|
|
3488
|
+
if (royaltyRule.min_amount && new bigNumberConfig_default(royaltyRule.min_amount).isGreaterThan(royaltyFee)) {
|
|
3489
|
+
return new bigNumberConfig_default(royaltyRule.min_amount);
|
|
3406
3490
|
}
|
|
3407
3491
|
return royaltyFee;
|
|
3408
3492
|
}
|
|
@@ -3542,7 +3626,7 @@ async function buyLocks({ lockIds, transaction }, context) {
|
|
|
3542
3626
|
collectionId: lock.collection_id
|
|
3543
3627
|
})
|
|
3544
3628
|
);
|
|
3545
|
-
const royalty = calculateRoyaltyFee(transferPolicy.rules,
|
|
3629
|
+
const royalty = calculateRoyaltyFee(transferPolicy.rules, new BigNumber(lock.maker_price));
|
|
3546
3630
|
const premiumAmount = calculatePremium(lock.maker_price);
|
|
3547
3631
|
const [premium] = tx.splitCoins(tx.gas, [premiumAmount]);
|
|
3548
3632
|
tx.moveCall({
|
|
@@ -3554,7 +3638,7 @@ async function buyLocks({ lockIds, transaction }, context) {
|
|
|
3554
3638
|
tx.pure.id(lock.lock_id),
|
|
3555
3639
|
tx.pure.u64(lock.maker_price),
|
|
3556
3640
|
tx.pure.u64(marketplaceFee),
|
|
3557
|
-
tx.pure.u64(royalty),
|
|
3641
|
+
tx.pure.u64(royalty.toNumber()),
|
|
3558
3642
|
tx.pure.u64(lock.expire_in),
|
|
3559
3643
|
premium
|
|
3560
3644
|
]
|
|
@@ -3833,10 +3917,10 @@ var preProcessSharedBulkBuyingData = async ({
|
|
|
3833
3917
|
sharedBulkBuyingDataByNftType[nftType].sharedObjects = await getSharedObjects(nftType);
|
|
3834
3918
|
continue;
|
|
3835
3919
|
}
|
|
3836
|
-
const
|
|
3837
|
-
(listing) => listing.market_name === "tradeport" && listing.price && listing.listed && !(listing?.nonce && isOriginByteCollection(transferPolicies)) && listing.nft?.chain_state?.kiosk_id
|
|
3920
|
+
const tradeportLegacyKioskListings = listingsByNftType[nftType]?.filter(
|
|
3921
|
+
(listing) => listing.market_name === "tradeport" && !listing.nonce?.startsWith("0::") && !listing.nonce?.startsWith("1::") && listing.price && listing.listed && !(listing?.nonce && isOriginByteCollection(transferPolicies)) && listing.nft?.chain_state?.kiosk_id
|
|
3838
3922
|
);
|
|
3839
|
-
if (
|
|
3923
|
+
if (tradeportLegacyKioskListings.length === 0) {
|
|
3840
3924
|
continue;
|
|
3841
3925
|
}
|
|
3842
3926
|
const transferPoliciesToResolve = await getTransferPoliciesToResolve({
|
|
@@ -3848,11 +3932,11 @@ var preProcessSharedBulkBuyingData = async ({
|
|
|
3848
3932
|
sharedBulkBuyingDataByNftType[nftType].transferPoliciesToResolve = transferPoliciesToResolve;
|
|
3849
3933
|
const transferPolicyToResolve = transferPoliciesToResolve.at(0);
|
|
3850
3934
|
const royaltyRuleToResolve = transferPolicyToResolve.rules.find(
|
|
3851
|
-
(
|
|
3935
|
+
(rule) => rule.moduleName === "royalty_rule" || rule.moduleName === "kiosk_royalty_rule"
|
|
3852
3936
|
);
|
|
3853
3937
|
if (royaltyRuleToResolve?.rulePackageId && royaltyRuleToResolve?.moduleName) {
|
|
3854
3938
|
const feeTx = new import_transactions8.Transaction();
|
|
3855
|
-
for (const listing of
|
|
3939
|
+
for (const listing of tradeportLegacyKioskListings) {
|
|
3856
3940
|
feeTx.moveCall({
|
|
3857
3941
|
target: `${royaltyRuleToResolve.rulePackageId}::${royaltyRuleToResolve.moduleName}::fee_amount`,
|
|
3858
3942
|
arguments: [feeTx.object(transferPolicyToResolve?.id), feeTx.pure.u64(listing.price)],
|
|
@@ -3870,13 +3954,13 @@ var preProcessSharedBulkBuyingData = async ({
|
|
|
3870
3954
|
if (!feeAmount && feeAmount !== 0n) {
|
|
3871
3955
|
continue;
|
|
3872
3956
|
}
|
|
3873
|
-
sharedBulkBuyingDataByNftType[nftType].royaltyFeeAmountsByListingId[
|
|
3957
|
+
sharedBulkBuyingDataByNftType[nftType].royaltyFeeAmountsByListingId[tradeportLegacyKioskListings[i].id] = feeAmount;
|
|
3874
3958
|
}
|
|
3875
3959
|
}
|
|
3876
3960
|
const batchSize = 10;
|
|
3877
3961
|
const commissionResults = [];
|
|
3878
|
-
for (let i = 0; i <
|
|
3879
|
-
const batch =
|
|
3962
|
+
for (let i = 0; i < tradeportLegacyKioskListings.length; i += batchSize) {
|
|
3963
|
+
const batch = tradeportLegacyKioskListings.slice(i, i + batchSize);
|
|
3880
3964
|
const batchPromises = batch.map(async (listing) => {
|
|
3881
3965
|
const response = await suiClient.getDynamicFieldObject({
|
|
3882
3966
|
parentId: TRADEPORT_KIOSK_LISTING_STORE,
|
|
@@ -3941,7 +4025,7 @@ var destroyZeroCoin = ({ tx, coin }) => {
|
|
|
3941
4025
|
};
|
|
3942
4026
|
|
|
3943
4027
|
// src/methods/buyListings/addBuyListingTxs.ts
|
|
3944
|
-
function
|
|
4028
|
+
function addLegacyTradePortBuyTx({
|
|
3945
4029
|
tx,
|
|
3946
4030
|
nftType,
|
|
3947
4031
|
listingNonce,
|
|
@@ -3977,7 +4061,7 @@ function addTradePortBuyTx({
|
|
|
3977
4061
|
}
|
|
3978
4062
|
destroyZeroCoin({ tx, coin });
|
|
3979
4063
|
}
|
|
3980
|
-
var
|
|
4064
|
+
var addLegacyTradeportKioskBuyTx = async ({
|
|
3981
4065
|
tx,
|
|
3982
4066
|
transferPolicies,
|
|
3983
4067
|
kioskTx,
|
|
@@ -4041,6 +4125,57 @@ var addTradeportKioskBuyTx = async ({
|
|
|
4041
4125
|
});
|
|
4042
4126
|
destroyZeroCoin({ tx, coin });
|
|
4043
4127
|
};
|
|
4128
|
+
async function addTradePortBuyTx({ tx, nftType, nftTokenId, price, coinToSplit }) {
|
|
4129
|
+
const marketFee = new bigNumberConfig_default(price).times(TRADEPORT_LISTINGS_DEFAULT_COMMISSION_BPS).div(1e4).integerValue(bigNumberConfig_default.ROUND_DOWN).toNumber();
|
|
4130
|
+
const totalAmount = new bigNumberConfig_default(price).plus(marketFee).toNumber();
|
|
4131
|
+
const [coin] = tx.splitCoins(coinToSplit ? coinToSplit : tx.gas, [tx.pure.u64(totalAmount)]);
|
|
4132
|
+
if (!coin) throw new Error("Coin could not be split");
|
|
4133
|
+
tx.moveCall({
|
|
4134
|
+
target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::buy_listing_without_transfer_policy`,
|
|
4135
|
+
arguments: [tx.object(TRADEPORT_LISTINGS_STORE), tx.pure.id(nftTokenId), tx.object(coin)],
|
|
4136
|
+
typeArguments: [nftType]
|
|
4137
|
+
});
|
|
4138
|
+
destroyZeroCoin({ tx, coin });
|
|
4139
|
+
}
|
|
4140
|
+
async function addKioskTradePortBuyTx({
|
|
4141
|
+
tx,
|
|
4142
|
+
transferPolicies,
|
|
4143
|
+
kioskTx,
|
|
4144
|
+
nftType,
|
|
4145
|
+
nftTokenId,
|
|
4146
|
+
price,
|
|
4147
|
+
sellerKiosk,
|
|
4148
|
+
coinToSplit
|
|
4149
|
+
}) {
|
|
4150
|
+
const transferPolicyId = getNativeKioskTransferPolicies(transferPolicies)?.at(0)?.id;
|
|
4151
|
+
const marketFee = new bigNumberConfig_default(price).times(TRADEPORT_LISTINGS_DEFAULT_COMMISSION_BPS).div(1e4).integerValue(bigNumberConfig_default.ROUND_DOWN);
|
|
4152
|
+
const royaltyFee = calculateRoyaltyFee(
|
|
4153
|
+
getNativeKioskTransferPolicies(transferPolicies)?.at(0)?.rules,
|
|
4154
|
+
new bigNumberConfig_default(price)
|
|
4155
|
+
);
|
|
4156
|
+
const totalAmount = new bigNumberConfig_default(price).plus(marketFee).plus(royaltyFee).toNumber();
|
|
4157
|
+
const [coin] = tx.splitCoins(coinToSplit ? coinToSplit : tx.gas, [tx.pure.u64(totalAmount)]);
|
|
4158
|
+
if (!coin) throw new Error("Coin could not be split");
|
|
4159
|
+
const transferRequest = tx.moveCall({
|
|
4160
|
+
target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::buy_listing_with_transfer_policy`,
|
|
4161
|
+
arguments: [
|
|
4162
|
+
tx.object(TRADEPORT_LISTINGS_STORE),
|
|
4163
|
+
tx.object(sellerKiosk),
|
|
4164
|
+
tx.object("value" in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk),
|
|
4165
|
+
tx.object("value" in kioskTx.kioskCap ? kioskTx.kioskCap.value : kioskTx.kioskCap),
|
|
4166
|
+
tx.pure.id(nftTokenId),
|
|
4167
|
+
tx.object(coin),
|
|
4168
|
+
tx.object(transferPolicyId)
|
|
4169
|
+
],
|
|
4170
|
+
typeArguments: [nftType]
|
|
4171
|
+
});
|
|
4172
|
+
tx.moveCall({
|
|
4173
|
+
target: "0x2::transfer_policy::confirm_request",
|
|
4174
|
+
arguments: [tx.object(transferPolicyId), transferRequest],
|
|
4175
|
+
typeArguments: [nftType]
|
|
4176
|
+
});
|
|
4177
|
+
destroyZeroCoin({ tx, coin });
|
|
4178
|
+
}
|
|
4044
4179
|
async function addOriginByteBuyTx({
|
|
4045
4180
|
tx,
|
|
4046
4181
|
sharedObjects,
|
|
@@ -4332,6 +4467,26 @@ async function addTradePortBuyTxHandler(txData) {
|
|
|
4332
4467
|
await addOriginByteBuyTx({ ...txData, sharedObjects: sharedObjects2 });
|
|
4333
4468
|
return;
|
|
4334
4469
|
}
|
|
4470
|
+
if (txData?.listingNonce?.startsWith("0::")) {
|
|
4471
|
+
await addTradePortBuyTx(txData);
|
|
4472
|
+
return;
|
|
4473
|
+
}
|
|
4474
|
+
if (txData?.listingNonce?.startsWith("1::")) {
|
|
4475
|
+
return kioskTxWrapper({
|
|
4476
|
+
tx: txData?.tx,
|
|
4477
|
+
kioskClient: txData?.kioskClient,
|
|
4478
|
+
kioskOwner: txData?.buyer,
|
|
4479
|
+
kiosk: txData?.sellerKiosk,
|
|
4480
|
+
shouldConvertToPersonalKiosk: true,
|
|
4481
|
+
sharedKioskState: txData?.sharedKioskState,
|
|
4482
|
+
async runCommands(kioskTx) {
|
|
4483
|
+
await addKioskTradePortBuyTx({
|
|
4484
|
+
...txData,
|
|
4485
|
+
kioskTx
|
|
4486
|
+
});
|
|
4487
|
+
}
|
|
4488
|
+
});
|
|
4489
|
+
}
|
|
4335
4490
|
if (txData.listingNonce?.startsWith("0x")) {
|
|
4336
4491
|
const response = await txData?.suiClient.getObject({
|
|
4337
4492
|
id: txData.listingNonce,
|
|
@@ -4342,7 +4497,7 @@ async function addTradePortBuyTxHandler(txData) {
|
|
|
4342
4497
|
}
|
|
4343
4498
|
if (response.data.type === NON_KIOSK_LISTING_NONCE_TYPE) {
|
|
4344
4499
|
const sharedObjects2 = txData?.sharedBulkBuyingDataByNftType?.[txData?.nftType]?.sharedObjects ?? await getSharedObjects(txData?.nftType);
|
|
4345
|
-
|
|
4500
|
+
addLegacyTradePortBuyTx({ ...txData, sharedObjects: sharedObjects2 });
|
|
4346
4501
|
return;
|
|
4347
4502
|
}
|
|
4348
4503
|
}
|
|
@@ -4355,7 +4510,7 @@ async function addTradePortBuyTxHandler(txData) {
|
|
|
4355
4510
|
shouldConvertToPersonalKiosk: true,
|
|
4356
4511
|
sharedKioskState: txData?.sharedKioskState,
|
|
4357
4512
|
async runCommands(kioskTx) {
|
|
4358
|
-
await
|
|
4513
|
+
await addLegacyTradeportKioskBuyTx({
|
|
4359
4514
|
...txData,
|
|
4360
4515
|
kioskTx
|
|
4361
4516
|
});
|
|
@@ -4363,7 +4518,7 @@ async function addTradePortBuyTxHandler(txData) {
|
|
|
4363
4518
|
});
|
|
4364
4519
|
}
|
|
4365
4520
|
const sharedObjects = txData?.sharedBulkBuyingDataByNftType?.[txData?.nftType]?.sharedObjects ?? await getSharedObjects(txData?.nftType);
|
|
4366
|
-
|
|
4521
|
+
addLegacyTradePortBuyTx({ ...txData, sharedObjects });
|
|
4367
4522
|
}
|
|
4368
4523
|
async function addHyperspaceBuyTxHandler(txData) {
|
|
4369
4524
|
if (txData?.listingNonce && isOriginByteCollection(txData?.transferPolicies)) {
|
|
@@ -5392,7 +5547,7 @@ async function createLongLocks({ walletAddress, nfts }, context) {
|
|
|
5392
5547
|
if (!transferPolicy) {
|
|
5393
5548
|
throw new Error(`Missing transfer policy for ${nftType}`);
|
|
5394
5549
|
}
|
|
5395
|
-
const royalty = calculateRoyaltyFee(transferPolicy.rules,
|
|
5550
|
+
const royalty = calculateRoyaltyFee(transferPolicy.rules, new BigNumber(argNft.priceInMist));
|
|
5396
5551
|
await kioskTxWrapper({
|
|
5397
5552
|
tx,
|
|
5398
5553
|
kioskClient: context.kioskClient,
|
|
@@ -5416,7 +5571,7 @@ async function createLongLocks({ walletAddress, nfts }, context) {
|
|
|
5416
5571
|
})
|
|
5417
5572
|
)
|
|
5418
5573
|
),
|
|
5419
|
-
tx.pure.u64(royalty),
|
|
5574
|
+
tx.pure.u64(royalty.toNumber()),
|
|
5420
5575
|
tx.pure.u64(premium),
|
|
5421
5576
|
tx.pure.u64(expireIn)
|
|
5422
5577
|
]
|
|
@@ -5510,9 +5665,9 @@ async function createShortLocks({ nfts }, context) {
|
|
|
5510
5665
|
collectionId: argNft.collectionId
|
|
5511
5666
|
})
|
|
5512
5667
|
);
|
|
5513
|
-
const royalty = calculateRoyaltyFee(transferPolicy.rules,
|
|
5668
|
+
const royalty = calculateRoyaltyFee(transferPolicy.rules, new BigNumber(argNft.priceInMist));
|
|
5514
5669
|
const [deposit] = tx.splitCoins(tx.gas, [
|
|
5515
|
-
|
|
5670
|
+
new BigNumber(argNft.priceInMist).plus(royalty).plus(marketplaceFee).toNumber()
|
|
5516
5671
|
]);
|
|
5517
5672
|
tx.moveCall({
|
|
5518
5673
|
target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::create_short_lock`,
|
|
@@ -5521,7 +5676,7 @@ async function createShortLocks({ nfts }, context) {
|
|
|
5521
5676
|
tx.object(TRADEPORT_PRICE_LOCK_STORE),
|
|
5522
5677
|
tx.pure.u64(BigInt(argNft.priceInMist)),
|
|
5523
5678
|
tx.pure.u64(marketplaceFee),
|
|
5524
|
-
tx.pure.u64(royalty),
|
|
5679
|
+
tx.pure.u64(royalty.toNumber()),
|
|
5525
5680
|
tx.pure.u64(premium),
|
|
5526
5681
|
tx.pure.u64(expireIn),
|
|
5527
5682
|
deposit
|
|
@@ -5532,8 +5687,23 @@ async function createShortLocks({ nfts }, context) {
|
|
|
5532
5687
|
}
|
|
5533
5688
|
|
|
5534
5689
|
// src/methods/listNfts/listNfts.ts
|
|
5535
|
-
var
|
|
5536
|
-
|
|
5690
|
+
var import_transactions19 = require("@mysten/sui/transactions");
|
|
5691
|
+
|
|
5692
|
+
// src/helpers/validateMinFloorPrice.ts
|
|
5693
|
+
function validateMinFloorPrice({ transferPolicies, listPrice }) {
|
|
5694
|
+
const transferPolicy = getNativeKioskTransferPolicies(transferPolicies)?.at(0);
|
|
5695
|
+
const minFloorPrice = transferPolicy?.rules?.filter(
|
|
5696
|
+
(rule) => rule?.type === "floor_price_rule"
|
|
5697
|
+
)?.[0]?.floor_price;
|
|
5698
|
+
if (minFloorPrice) {
|
|
5699
|
+
if (listPrice < minFloorPrice) {
|
|
5700
|
+
const formattedMinFloorPrice = Number(minFloorPrice) / 1e9;
|
|
5701
|
+
throw new Error(
|
|
5702
|
+
`NFT Transfer Policy has a miminum floor price rule. Item cannot be listed for less than ${formattedMinFloorPrice} SUI`
|
|
5703
|
+
);
|
|
5704
|
+
}
|
|
5705
|
+
}
|
|
5706
|
+
}
|
|
5537
5707
|
|
|
5538
5708
|
// src/methods/listNfts/addListTxs.ts
|
|
5539
5709
|
async function addOriginByteListTx({
|
|
@@ -5589,54 +5759,35 @@ function addTradePortListTx({
|
|
|
5589
5759
|
nftTokenId,
|
|
5590
5760
|
borrowedItem,
|
|
5591
5761
|
nftType,
|
|
5592
|
-
collectionId,
|
|
5593
5762
|
listPrice
|
|
5594
5763
|
}) {
|
|
5595
|
-
const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
|
|
5596
5764
|
tx.moveCall({
|
|
5597
|
-
target:
|
|
5765
|
+
target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::create_listing_without_transfer_policy`,
|
|
5598
5766
|
arguments: [
|
|
5599
|
-
tx.object(
|
|
5767
|
+
tx.object(TRADEPORT_LISTINGS_STORE),
|
|
5600
5768
|
borrowedItem ? tx.object(borrowedItem) : tx.object(nftTokenId),
|
|
5601
|
-
tx.pure.u64(listPrice)
|
|
5602
|
-
tx.pure.u64(marketFeePrice),
|
|
5603
|
-
tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
|
|
5769
|
+
tx.pure.u64(listPrice)
|
|
5604
5770
|
],
|
|
5605
5771
|
typeArguments: [nftType]
|
|
5606
5772
|
});
|
|
5607
5773
|
}
|
|
5608
|
-
async function
|
|
5774
|
+
async function addKioskTradePortListTx({
|
|
5609
5775
|
tx,
|
|
5610
5776
|
kioskTx,
|
|
5611
5777
|
transferPolicies,
|
|
5612
5778
|
nftTokenId,
|
|
5613
5779
|
nftType,
|
|
5614
|
-
collectionId,
|
|
5615
5780
|
listPrice
|
|
5616
5781
|
}) {
|
|
5617
|
-
|
|
5618
|
-
const minFloorPrice = transferPolicy?.rules?.filter(
|
|
5619
|
-
(rule) => rule?.type === "floor_price_rule"
|
|
5620
|
-
)?.[0]?.floor_price;
|
|
5621
|
-
if (minFloorPrice) {
|
|
5622
|
-
if (listPrice < minFloorPrice) {
|
|
5623
|
-
const formattedMinFloorPrice = Number(minFloorPrice) / 1e9;
|
|
5624
|
-
throw new Error(
|
|
5625
|
-
`NFT Transfer Policy has a miminum floor price rule. Item cannot be listed for less than ${formattedMinFloorPrice} SUI`
|
|
5626
|
-
);
|
|
5627
|
-
}
|
|
5628
|
-
}
|
|
5629
|
-
const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
|
|
5782
|
+
validateMinFloorPrice({ transferPolicies, listPrice });
|
|
5630
5783
|
tx.moveCall({
|
|
5631
|
-
target:
|
|
5784
|
+
target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::create_listing_with_transfer_policy`,
|
|
5632
5785
|
arguments: [
|
|
5633
|
-
tx.object(
|
|
5786
|
+
tx.object(TRADEPORT_LISTINGS_STORE),
|
|
5634
5787
|
tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
|
|
5635
5788
|
tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
|
|
5636
|
-
tx.pure.
|
|
5637
|
-
tx.pure.u64(listPrice
|
|
5638
|
-
tx.pure.u64(marketFeePrice),
|
|
5639
|
-
tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
|
|
5789
|
+
tx.pure.id(nftTokenId),
|
|
5790
|
+
tx.pure.u64(listPrice)
|
|
5640
5791
|
],
|
|
5641
5792
|
typeArguments: [nftType]
|
|
5642
5793
|
});
|
|
@@ -5681,7 +5832,7 @@ async function addTradePortListTxHandler(txData) {
|
|
|
5681
5832
|
sharedKioskState: txData?.sharedKioskState,
|
|
5682
5833
|
shouldUseSharedKioskTx: false,
|
|
5683
5834
|
async runCommands(kioskTx) {
|
|
5684
|
-
await
|
|
5835
|
+
await addKioskTradePortListTx({
|
|
5685
5836
|
...txData,
|
|
5686
5837
|
kioskTx
|
|
5687
5838
|
});
|
|
@@ -5701,7 +5852,7 @@ async function addTradePortListTxHandler(txData) {
|
|
|
5701
5852
|
item: txData?.nftTokenId,
|
|
5702
5853
|
itemType: txData?.nftType
|
|
5703
5854
|
});
|
|
5704
|
-
await
|
|
5855
|
+
await addKioskTradePortListTx({
|
|
5705
5856
|
...txData,
|
|
5706
5857
|
kioskTx
|
|
5707
5858
|
});
|
|
@@ -5712,43 +5863,53 @@ async function addTradePortListTxHandler(txData) {
|
|
|
5712
5863
|
}
|
|
5713
5864
|
|
|
5714
5865
|
// src/methods/listNfts/addRelistTxs.ts
|
|
5715
|
-
function addTradePortRelistTx({
|
|
5866
|
+
function addTradePortRelistTx({ tx, nftTokenId, nftType, listPrice }) {
|
|
5867
|
+
tx.moveCall({
|
|
5868
|
+
target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::relist_listing_without_transfer_policy`,
|
|
5869
|
+
arguments: [
|
|
5870
|
+
tx.object(TRADEPORT_LISTINGS_STORE),
|
|
5871
|
+
tx.pure.id(nftTokenId),
|
|
5872
|
+
tx.pure.u64(listPrice)
|
|
5873
|
+
],
|
|
5874
|
+
typeArguments: [nftType]
|
|
5875
|
+
});
|
|
5876
|
+
}
|
|
5877
|
+
async function addKioskTradePortRelistTx({
|
|
5716
5878
|
tx,
|
|
5879
|
+
kioskTx,
|
|
5880
|
+
nftTokenId,
|
|
5717
5881
|
nftType,
|
|
5718
|
-
collectionId,
|
|
5719
|
-
listingNonce,
|
|
5720
5882
|
listPrice
|
|
5721
5883
|
}) {
|
|
5722
|
-
const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
|
|
5723
5884
|
tx.moveCall({
|
|
5724
|
-
target:
|
|
5885
|
+
target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::relist_listing_with_transfer_policy`,
|
|
5725
5886
|
arguments: [
|
|
5726
|
-
tx.object(
|
|
5727
|
-
tx.
|
|
5728
|
-
tx.
|
|
5729
|
-
tx.pure.
|
|
5730
|
-
tx.pure.
|
|
5887
|
+
tx.object(TRADEPORT_LISTINGS_STORE),
|
|
5888
|
+
tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
|
|
5889
|
+
tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
|
|
5890
|
+
tx.pure.id(nftTokenId),
|
|
5891
|
+
tx.pure.u64(listPrice)
|
|
5731
5892
|
],
|
|
5732
5893
|
typeArguments: [nftType]
|
|
5733
5894
|
});
|
|
5734
5895
|
}
|
|
5735
5896
|
function addBlueMoveRelistTx(txData) {
|
|
5736
|
-
const { tx, nftTokenId, nftType, listPrice
|
|
5897
|
+
const { tx, nftTokenId, nftType, listPrice } = txData;
|
|
5737
5898
|
const borrowedItem = tx.moveCall({
|
|
5738
5899
|
target: "0xd5dd28cc24009752905689b2ba2bf90bfc8de4549b9123f93519bb8ba9bf9981::marketplace::delist",
|
|
5739
5900
|
arguments: [tx.object(BLUEMOVE_MARKET_CONFIG_OBJECT), tx.pure.address(nftTokenId)],
|
|
5740
5901
|
typeArguments: [nftType, nftType]
|
|
5741
5902
|
});
|
|
5742
|
-
addTradePortListTx({ ...txData, listPrice, borrowedItem
|
|
5903
|
+
addTradePortListTx({ ...txData, listPrice, borrowedItem });
|
|
5743
5904
|
}
|
|
5744
5905
|
function addTocenRelistTx(txData) {
|
|
5745
|
-
const { tx, nftTokenId, nftType, listPrice
|
|
5906
|
+
const { tx, nftTokenId, nftType, listPrice } = txData;
|
|
5746
5907
|
const borrowedItem = tx.moveCall({
|
|
5747
5908
|
target: "0x3605d91c559e80cf8fdeabae9abaccb0bc38f96eac0b32bf47e95a9159a5277f::tocen_marketplace::delist",
|
|
5748
5909
|
arguments: [tx.object(TOCEN_MARKETPLACE_OBJECT), tx.pure.address(nftTokenId)],
|
|
5749
5910
|
typeArguments: [nftType]
|
|
5750
5911
|
});
|
|
5751
|
-
addTradePortListTx({ ...txData, listPrice, borrowedItem
|
|
5912
|
+
addTradePortListTx({ ...txData, listPrice, borrowedItem });
|
|
5752
5913
|
}
|
|
5753
5914
|
|
|
5754
5915
|
// src/methods/relistNft/relistNft.ts
|
|
@@ -5786,20 +5947,19 @@ async function relistNft({
|
|
|
5786
5947
|
};
|
|
5787
5948
|
switch (firstListedOrExpiredListing.market_name) {
|
|
5788
5949
|
case "tradeport":
|
|
5789
|
-
if (
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5950
|
+
if (txData?.listingNonce && isOriginByteCollection(txData?.transferPolicies) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
|
|
5951
|
+
await addTradePortUnlistTxHandler(txData);
|
|
5952
|
+
await addTradePortListTxHandler({
|
|
5953
|
+
...txData,
|
|
5954
|
+
listPrice
|
|
5955
|
+
});
|
|
5956
|
+
return;
|
|
5957
|
+
}
|
|
5958
|
+
if (txData?.listingNonce?.startsWith("0::")) {
|
|
5793
5959
|
addTradePortRelistTx({ ...txData, listPrice });
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
await addTradePortListTxHandler({
|
|
5798
|
-
...txData,
|
|
5799
|
-
listPrice
|
|
5800
|
-
});
|
|
5801
|
-
return;
|
|
5802
|
-
}
|
|
5960
|
+
return;
|
|
5961
|
+
}
|
|
5962
|
+
if (txData?.listingNonce?.startsWith("1::")) {
|
|
5803
5963
|
return kioskTxWrapper({
|
|
5804
5964
|
tx: txData?.tx,
|
|
5805
5965
|
kioskClient: txData?.kioskClient,
|
|
@@ -5809,11 +5969,7 @@ async function relistNft({
|
|
|
5809
5969
|
sharedKioskState: txData?.sharedKioskState,
|
|
5810
5970
|
shouldUseSharedKioskTx: false,
|
|
5811
5971
|
async runCommands(kioskTx) {
|
|
5812
|
-
await
|
|
5813
|
-
...txData,
|
|
5814
|
-
kioskTx
|
|
5815
|
-
});
|
|
5816
|
-
await addTradePortKioskListTx({
|
|
5972
|
+
await addKioskTradePortRelistTx({
|
|
5817
5973
|
...txData,
|
|
5818
5974
|
kioskTx,
|
|
5819
5975
|
listPrice
|
|
@@ -5821,6 +5977,8 @@ async function relistNft({
|
|
|
5821
5977
|
}
|
|
5822
5978
|
});
|
|
5823
5979
|
}
|
|
5980
|
+
await addTradePortUnlistTxHandler({ ...txData, isPartOfRelist: true });
|
|
5981
|
+
await addTradePortListTxHandler({ ...txData, listPrice });
|
|
5824
5982
|
break;
|
|
5825
5983
|
case "hyperspace":
|
|
5826
5984
|
await addHyperspaceUnlistTxHandler(txData);
|
|
@@ -5852,6 +6010,177 @@ async function relistNft({
|
|
|
5852
6010
|
}
|
|
5853
6011
|
}
|
|
5854
6012
|
|
|
6013
|
+
// src/helpers/swap.ts
|
|
6014
|
+
var import_sdk = require("@flowx-finance/sdk");
|
|
6015
|
+
var import_transactions18 = require("@mysten/sui/transactions");
|
|
6016
|
+
var import_utils10 = require("@mysten/sui/utils");
|
|
6017
|
+
var import_ms = __toESM(require("ms"));
|
|
6018
|
+
var import_bcs4 = require("@mysten/sui/bcs");
|
|
6019
|
+
|
|
6020
|
+
// src/utils/pureValues.ts
|
|
6021
|
+
var toDecimalValue = (value, decimals) => {
|
|
6022
|
+
if (!value || decimals === void 0) return new bigNumberConfig_default(0);
|
|
6023
|
+
return new bigNumberConfig_default(value).div(10 ** decimals);
|
|
6024
|
+
};
|
|
6025
|
+
var toPureValue = (value, decimals) => {
|
|
6026
|
+
if (!value || decimals === void 0) return new bigNumberConfig_default(0);
|
|
6027
|
+
return new bigNumberConfig_default(new bigNumberConfig_default(value).multipliedBy(10 ** decimals).toFixed(0));
|
|
6028
|
+
};
|
|
6029
|
+
|
|
6030
|
+
// src/helpers/swap.ts
|
|
6031
|
+
var aggregatorQuoter = new import_sdk.AggregatorQuoter("mainnet");
|
|
6032
|
+
var suiCoinType = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
6033
|
+
async function createSwapTransaction({
|
|
6034
|
+
suiClient,
|
|
6035
|
+
walletAddress,
|
|
6036
|
+
options
|
|
6037
|
+
}) {
|
|
6038
|
+
const tx = options?.transaction ?? new import_transactions18.Transaction();
|
|
6039
|
+
tx.setSender((0, import_utils10.normalizeSuiAddress)(walletAddress));
|
|
6040
|
+
const {
|
|
6041
|
+
coinInType,
|
|
6042
|
+
coinInAmount = ZERO,
|
|
6043
|
+
coinOutType,
|
|
6044
|
+
slippage = 1,
|
|
6045
|
+
ttl = "15m",
|
|
6046
|
+
excludeSources = [import_sdk.Protocol.STEAMM, ...DexConstants.poolsToExclude],
|
|
6047
|
+
rewardNftType
|
|
6048
|
+
} = options ?? {};
|
|
6049
|
+
if ((0, import_utils10.normalizeStructTag)(coinOutType) === suiCoinType && (0, import_utils10.normalizeStructTag)(coinInType) === suiCoinType) {
|
|
6050
|
+
const [coin] = tx.splitCoins(tx.gas, [coinInAmount.toFixed()]);
|
|
6051
|
+
return {
|
|
6052
|
+
transaction: tx,
|
|
6053
|
+
coinOut: coin
|
|
6054
|
+
};
|
|
6055
|
+
}
|
|
6056
|
+
const amountInSwap = coinInAmount.minus(coinInAmount.div(100).toFixed(0));
|
|
6057
|
+
const commissionAmount = coinInAmount.div(100).toFixed(0);
|
|
6058
|
+
const { routes } = await aggregatorQuoter.getRoutes({
|
|
6059
|
+
tokenIn: coinInType,
|
|
6060
|
+
tokenOut: coinOutType ?? suiCoinType,
|
|
6061
|
+
amountIn: amountInSwap.toFixed(),
|
|
6062
|
+
excludeSources
|
|
6063
|
+
});
|
|
6064
|
+
const tradeBuilder = new import_sdk.TradeBuilder("mainnet", routes);
|
|
6065
|
+
const trade = tradeBuilder.sender((0, import_utils10.normalizeSuiAddress)(walletAddress)).slippage(slippage).deadline(Date.now() + (0, import_ms.default)(ttl)).build();
|
|
6066
|
+
let coinIn;
|
|
6067
|
+
if ((0, import_utils10.normalizeStructTag)(coinInType) === suiCoinType) {
|
|
6068
|
+
[coinIn] = tx.splitCoins(tx.gas, [
|
|
6069
|
+
tx.pure.u64((BigInt(amountInSwap.toFixed()) + BigInt(commissionAmount)).toString())
|
|
6070
|
+
]);
|
|
6071
|
+
} else {
|
|
6072
|
+
coinIn = (0, import_transactions18.coinWithBalance)({
|
|
6073
|
+
balance: BigInt(amountInSwap.toFixed()) + BigInt(commissionAmount),
|
|
6074
|
+
type: coinInType
|
|
6075
|
+
})(tx);
|
|
6076
|
+
}
|
|
6077
|
+
const [commissionCoin] = tx.splitCoins(coinIn, [tx.pure.u64(commissionAmount.toString())]);
|
|
6078
|
+
tx.moveCall({
|
|
6079
|
+
target: `${DexConstants.commission}::commission::pay`,
|
|
6080
|
+
arguments: [
|
|
6081
|
+
tx.object(DexConstants.commissionManager),
|
|
6082
|
+
tx.pure.string("swap"),
|
|
6083
|
+
tx.object(commissionCoin),
|
|
6084
|
+
tx.pure(import_bcs4.bcs.option(import_bcs4.bcs.String).serialize(rewardNftType).toBytes())
|
|
6085
|
+
],
|
|
6086
|
+
typeArguments: [coinInType]
|
|
6087
|
+
});
|
|
6088
|
+
const coinOut = await trade.swap({ client: suiClient, tx, coinIn });
|
|
6089
|
+
if (!coinOut) {
|
|
6090
|
+
throw new Error("Swap did not return a valid coin out.");
|
|
6091
|
+
}
|
|
6092
|
+
if (coinOut && options?.amountToSplitFromSuiBalance > 0n) {
|
|
6093
|
+
mergeSwapCoinWithSuiBalance(tx, coinOut, options?.amountToSplitFromSuiBalance);
|
|
6094
|
+
}
|
|
6095
|
+
return { transaction: tx, coinOut };
|
|
6096
|
+
}
|
|
6097
|
+
function mergeSwapCoinWithSuiBalance(transaction, coinToMergeInto, amountToSplitFromSuiBalance) {
|
|
6098
|
+
if (coinToMergeInto && amountToSplitFromSuiBalance > 0n) {
|
|
6099
|
+
const [coinFromSuiBalance] = transaction.splitCoins(transaction.gas, [
|
|
6100
|
+
transaction.pure.u64(amountToSplitFromSuiBalance)
|
|
6101
|
+
]);
|
|
6102
|
+
transaction.mergeCoins(coinToMergeInto, [coinFromSuiBalance]);
|
|
6103
|
+
}
|
|
6104
|
+
}
|
|
6105
|
+
function transferBackExtraSwappedCoin(transaction, swapResultCoin, walletAddress) {
|
|
6106
|
+
if (swapResultCoin) {
|
|
6107
|
+
transaction.transferObjects([swapResultCoin], walletAddress);
|
|
6108
|
+
}
|
|
6109
|
+
}
|
|
6110
|
+
async function calculateSwapInputAmountWithSlippage({
|
|
6111
|
+
coinInType,
|
|
6112
|
+
coinOutType,
|
|
6113
|
+
coinOutAmount,
|
|
6114
|
+
slippage = 0
|
|
6115
|
+
}) {
|
|
6116
|
+
if (coinInType === coinOutType) {
|
|
6117
|
+
return new bigNumberConfig_default(coinOutAmount);
|
|
6118
|
+
}
|
|
6119
|
+
const provider = new import_sdk.CoinProvider("mainnet");
|
|
6120
|
+
const coinQueryResult = await provider.getCoins({
|
|
6121
|
+
limit: 2,
|
|
6122
|
+
coinTypes: [coinInType, coinOutType]
|
|
6123
|
+
});
|
|
6124
|
+
const coinIn = coinQueryResult[0];
|
|
6125
|
+
const coinOut = coinQueryResult[1];
|
|
6126
|
+
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
|
+
const amountSell = toDecimalValue(coinOutAmount.toString(), coinOut?.decimals).div(exchangeRate);
|
|
6128
|
+
const slippageMultiplier = 1 + parseInt(slippage.toString() || "0", 10) / 1e6;
|
|
6129
|
+
const amountWithSlippage = amountSell.times(slippageMultiplier);
|
|
6130
|
+
const coinInAmount = toPureValue(amountWithSlippage, coinIn?.decimals);
|
|
6131
|
+
return coinInAmount;
|
|
6132
|
+
}
|
|
6133
|
+
|
|
6134
|
+
// src/methods/sponsorNftListing/addSponsorNftListingTx.ts
|
|
6135
|
+
var import_utils11 = require("@mysten/sui.js/utils");
|
|
6136
|
+
var addSponsorListingTx = async ({
|
|
6137
|
+
tx,
|
|
6138
|
+
nftTokenId,
|
|
6139
|
+
nftType,
|
|
6140
|
+
suiClient,
|
|
6141
|
+
walletAddress,
|
|
6142
|
+
sponsorOptions
|
|
6143
|
+
}) => {
|
|
6144
|
+
const coinInAmount = await calculateSwapInputAmountWithSlippage({
|
|
6145
|
+
coinInType: sponsorOptions?.coinInType,
|
|
6146
|
+
coinOutType: USDC_COIN_TYPE,
|
|
6147
|
+
coinOutAmount: new bigNumberConfig_default(TRADEPORT_SPONSOR_USDC_FEE_AMOUNT_PER_PERIOD)?.times(sponsorOptions?.numOfPeriods).toString(),
|
|
6148
|
+
slippage: sponsorOptions?.slippage
|
|
6149
|
+
});
|
|
6150
|
+
const { coinOut } = await createSwapTransaction({
|
|
6151
|
+
suiClient,
|
|
6152
|
+
walletAddress,
|
|
6153
|
+
options: {
|
|
6154
|
+
transaction: tx,
|
|
6155
|
+
coinInType: sponsorOptions?.coinInType,
|
|
6156
|
+
coinInAmount,
|
|
6157
|
+
coinOutType: USDC_COIN_TYPE,
|
|
6158
|
+
slippage: sponsorOptions?.slippage
|
|
6159
|
+
}
|
|
6160
|
+
});
|
|
6161
|
+
const [sponsorFeeCoin] = tx.splitCoins(coinOut, [
|
|
6162
|
+
tx.pure.u64(
|
|
6163
|
+
new bigNumberConfig_default(TRADEPORT_SPONSOR_USDC_FEE_AMOUNT_PER_PERIOD)?.times(sponsorOptions?.numOfPeriods).toString()
|
|
6164
|
+
)
|
|
6165
|
+
]);
|
|
6166
|
+
tx.moveCall({
|
|
6167
|
+
target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::add_sponsored_listing`,
|
|
6168
|
+
arguments: [
|
|
6169
|
+
tx.object(TRADEPORT_LISTINGS_STORE),
|
|
6170
|
+
tx.object(import_utils11.SUI_CLOCK_OBJECT_ID),
|
|
6171
|
+
tx.pure.id(nftTokenId),
|
|
6172
|
+
tx.pure.u64(sponsorOptions?.numOfPeriods),
|
|
6173
|
+
tx.object(sponsorFeeCoin)
|
|
6174
|
+
],
|
|
6175
|
+
typeArguments: [nftType]
|
|
6176
|
+
});
|
|
6177
|
+
transferBackExtraSwappedCoin(tx, coinOut, walletAddress);
|
|
6178
|
+
};
|
|
6179
|
+
|
|
6180
|
+
// src/helpers/isExpiredListing.ts
|
|
6181
|
+
var import_utils12 = require("@mysten/sui/utils");
|
|
6182
|
+
var isExpiredListing = (listing, walletAddress) => listing.nonce && listing.seller && (0, import_utils12.normalizeSuiAddress)(listing.seller) === (0, import_utils12.normalizeSuiAddress)(walletAddress);
|
|
6183
|
+
|
|
5855
6184
|
// src/methods/listNfts/listNfts.ts
|
|
5856
6185
|
var listNfts = async ({ nfts, walletAddress }, context) => {
|
|
5857
6186
|
const res = await gqlChainRequest({
|
|
@@ -5863,11 +6192,12 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
|
|
|
5863
6192
|
throw new Error("No nfts found");
|
|
5864
6193
|
}
|
|
5865
6194
|
const nftsForTracking = [];
|
|
5866
|
-
const tx = new
|
|
6195
|
+
const tx = new import_transactions19.Transaction();
|
|
5867
6196
|
const sharedKioskState = {
|
|
5868
6197
|
kioskTx: void 0
|
|
5869
6198
|
};
|
|
5870
6199
|
for (const nft of res.nfts) {
|
|
6200
|
+
const inputNft = nfts?.find((n) => n.id === nft?.id);
|
|
5871
6201
|
if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
|
|
5872
6202
|
throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
|
|
5873
6203
|
}
|
|
@@ -5877,8 +6207,11 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
|
|
|
5877
6207
|
nft
|
|
5878
6208
|
});
|
|
5879
6209
|
const transferPolicies = nft?.collection?.chain_state?.transfer_policies;
|
|
6210
|
+
if (inputNft?.sponsorOptions?.shouldSponsor && isOriginByteCollection(transferPolicies)) {
|
|
6211
|
+
throw new Error(`You cannot sponsor an Origin Byte NFT. Nft Token Id: ${nft?.token_id}`);
|
|
6212
|
+
}
|
|
5880
6213
|
if (nft?.listed || nft.listings.some(
|
|
5881
|
-
(listing) =>
|
|
6214
|
+
(listing) => isExpiredListing(listing, walletAddress)
|
|
5882
6215
|
)) {
|
|
5883
6216
|
await relistNft({
|
|
5884
6217
|
tx,
|
|
@@ -5887,7 +6220,7 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
|
|
|
5887
6220
|
sharedKioskState,
|
|
5888
6221
|
transferPolicies,
|
|
5889
6222
|
nft,
|
|
5890
|
-
listPrice:
|
|
6223
|
+
listPrice: inputNft?.listPriceInMist,
|
|
5891
6224
|
walletAddress
|
|
5892
6225
|
});
|
|
5893
6226
|
} else {
|
|
@@ -5901,26 +6234,36 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
|
|
|
5901
6234
|
collectionId: nft?.collection_id,
|
|
5902
6235
|
nftTokenId: nft?.token_id,
|
|
5903
6236
|
nftType,
|
|
5904
|
-
listPrice:
|
|
6237
|
+
listPrice: inputNft?.listPriceInMist,
|
|
5905
6238
|
sellerKiosk: nft?.chain_state?.kiosk_id
|
|
5906
6239
|
};
|
|
5907
6240
|
await addTradePortListTxHandler(listTxData);
|
|
5908
6241
|
}
|
|
6242
|
+
if (inputNft?.sponsorOptions?.shouldSponsor) {
|
|
6243
|
+
await addSponsorListingTx({
|
|
6244
|
+
tx,
|
|
6245
|
+
suiClient: context.suiClient,
|
|
6246
|
+
nftTokenId: nft?.token_id,
|
|
6247
|
+
nftType,
|
|
6248
|
+
walletAddress,
|
|
6249
|
+
sponsorOptions: inputNft?.sponsorOptions
|
|
6250
|
+
});
|
|
6251
|
+
}
|
|
5909
6252
|
nftsForTracking.push({
|
|
5910
6253
|
walletAddress,
|
|
5911
6254
|
nftType,
|
|
5912
6255
|
collectionId: nft?.collection_id,
|
|
5913
|
-
listPrice:
|
|
6256
|
+
listPrice: inputNft?.listPriceInMist,
|
|
5914
6257
|
isRelist: nft?.listed,
|
|
5915
6258
|
marketRelistedFrom: nft?.listings?.[0]?.market_name
|
|
5916
6259
|
});
|
|
5917
6260
|
}
|
|
5918
6261
|
sharedKioskState?.kioskTx?.finalize();
|
|
5919
|
-
return
|
|
6262
|
+
return import_transactions19.Transaction.from(tx);
|
|
5920
6263
|
};
|
|
5921
6264
|
|
|
5922
6265
|
// src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
|
|
5923
|
-
var
|
|
6266
|
+
var import_transactions20 = require("@mysten/sui/transactions");
|
|
5924
6267
|
|
|
5925
6268
|
// src/graphql/queries/fetchNftsByKioskId.ts
|
|
5926
6269
|
var import_graphql_request19 = require("graphql-request");
|
|
@@ -6123,7 +6466,7 @@ async function getTransferPolicyForDirectTransfer(suiClient, collectionChainStat
|
|
|
6123
6466
|
|
|
6124
6467
|
// src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
|
|
6125
6468
|
async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }, context) {
|
|
6126
|
-
const tx = new
|
|
6469
|
+
const tx = new import_transactions20.Transaction();
|
|
6127
6470
|
const res = await gqlChainRequest({
|
|
6128
6471
|
chain: "sui",
|
|
6129
6472
|
query: fetchKiosksByOwner,
|
|
@@ -6289,11 +6632,11 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }
|
|
|
6289
6632
|
}
|
|
6290
6633
|
}
|
|
6291
6634
|
sharedKioskState?.kioskTx?.finalize();
|
|
6292
|
-
return
|
|
6635
|
+
return import_transactions20.Transaction.from(tx);
|
|
6293
6636
|
}
|
|
6294
6637
|
|
|
6295
6638
|
// src/methods/placeCollectionBids/placeCollectionBids.ts
|
|
6296
|
-
var
|
|
6639
|
+
var import_transactions21 = require("@mysten/sui/transactions");
|
|
6297
6640
|
|
|
6298
6641
|
// src/graphql/queries/fetchCollectionsById.ts
|
|
6299
6642
|
var import_graphql_request20 = require("graphql-request");
|
|
@@ -6334,7 +6677,7 @@ var fetchCollectionsBySlug = import_graphql_request20.gql`
|
|
|
6334
6677
|
`;
|
|
6335
6678
|
|
|
6336
6679
|
// src/methods/placeNftBids/addPlaceNftBidTxs.ts
|
|
6337
|
-
var
|
|
6680
|
+
var import_utils13 = require("@mysten/sui/utils");
|
|
6338
6681
|
async function addTradePortPlaceNftBidTxHandler(txData) {
|
|
6339
6682
|
if (isOriginByteCollection(txData?.transferPolicies) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
|
|
6340
6683
|
throw new Error("OriginByte bidding not supported currently");
|
|
@@ -6350,12 +6693,12 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
|
|
|
6350
6693
|
expireAt,
|
|
6351
6694
|
coinToSplit
|
|
6352
6695
|
} = txData;
|
|
6353
|
-
let
|
|
6696
|
+
let bcs5;
|
|
6354
6697
|
if (nftTokenId && isDynamicCollection(collectionId)) {
|
|
6355
6698
|
if (!bcsHex) {
|
|
6356
6699
|
throw new Error(`No BCS found for token ${nftTokenId}`);
|
|
6357
6700
|
}
|
|
6358
|
-
|
|
6701
|
+
bcs5 = (0, import_utils13.fromHex)(bcsHex);
|
|
6359
6702
|
}
|
|
6360
6703
|
let multiBidChainId;
|
|
6361
6704
|
let expiredBids;
|
|
@@ -6411,13 +6754,13 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
|
|
|
6411
6754
|
arguments: [
|
|
6412
6755
|
tx.object(TRADEPORT_MULTI_BID_STORE),
|
|
6413
6756
|
tx.pure.u64(nftTokenId ? 1 : 0),
|
|
6414
|
-
multiBidChainId ? typeof multiBidChainId === "string" ? tx.pure.option("id", (0,
|
|
6757
|
+
multiBidChainId ? typeof multiBidChainId === "string" ? tx.pure.option("id", (0, import_utils13.normalizeSuiObjectId)(multiBidChainId)) : tx.moveCall({
|
|
6415
6758
|
target: "0x1::option::some",
|
|
6416
6759
|
typeArguments: ["0x2::object::ID"],
|
|
6417
6760
|
arguments: [multiBidChainId]
|
|
6418
6761
|
}) : void 0,
|
|
6419
|
-
tx.pure.option("id", nftTokenId ? (0,
|
|
6420
|
-
tx.pure.option("vector<u8>",
|
|
6762
|
+
tx.pure.option("id", nftTokenId ? (0, import_utils13.normalizeSuiObjectId)(nftTokenId) : void 0),
|
|
6763
|
+
tx.pure.option("vector<u8>", bcs5 ? [...bcs5] : void 0),
|
|
6421
6764
|
tx.pure.option("u64", expireAt?.getTime()),
|
|
6422
6765
|
tx.pure.u64(price),
|
|
6423
6766
|
...transferPolicy ? [tx.object(transferPolicy.id)] : [],
|
|
@@ -6568,11 +6911,11 @@ var placeCollectionBids = async ({ collections, walletAddress, multiBidId, multi
|
|
|
6568
6911
|
if (swapResultCoin) {
|
|
6569
6912
|
tx.transferObjects([swapResultCoin], walletAddress);
|
|
6570
6913
|
}
|
|
6571
|
-
return
|
|
6914
|
+
return import_transactions21.Transaction.from(tx);
|
|
6572
6915
|
};
|
|
6573
6916
|
|
|
6574
6917
|
// src/methods/placeNftBids/placeNftBids.ts
|
|
6575
|
-
var
|
|
6918
|
+
var import_transactions22 = require("@mysten/sui/transactions");
|
|
6576
6919
|
var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
|
|
6577
6920
|
const tx = deserializeOrCreateTxBlock({ existingTx });
|
|
6578
6921
|
const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
|
|
@@ -6622,14 +6965,14 @@ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx
|
|
|
6622
6965
|
if (swapResultCoin) {
|
|
6623
6966
|
tx.transferObjects([swapResultCoin], walletAddress);
|
|
6624
6967
|
}
|
|
6625
|
-
return
|
|
6968
|
+
return import_transactions22.Transaction.from(tx);
|
|
6626
6969
|
};
|
|
6627
6970
|
|
|
6628
6971
|
// src/methods/removeCollectionBids/removeCollectionBids.ts
|
|
6629
|
-
var
|
|
6972
|
+
var import_transactions23 = require("@mysten/sui/transactions");
|
|
6630
6973
|
|
|
6631
6974
|
// src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts
|
|
6632
|
-
var
|
|
6975
|
+
var import_utils14 = require("@mysten/sui/utils");
|
|
6633
6976
|
function addTradeportRemoveCollectionBidTx({
|
|
6634
6977
|
tx,
|
|
6635
6978
|
nftType,
|
|
@@ -6685,7 +7028,7 @@ function addBluemoveKioskRemoveCollectionBidTx({
|
|
|
6685
7028
|
async function addTradePortRemoveCollectionBidTxHandler(txData) {
|
|
6686
7029
|
const bidType = await getObjectType({
|
|
6687
7030
|
suiClient: txData?.suiClient,
|
|
6688
|
-
objectId: (0,
|
|
7031
|
+
objectId: (0, import_utils14.normalizeSuiObjectId)(txData?.bidNonce)
|
|
6689
7032
|
});
|
|
6690
7033
|
if (isSingleBid(bidType)) {
|
|
6691
7034
|
await addSingleBidRemoveNftBidTx(txData);
|
|
@@ -6705,7 +7048,7 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
|
|
|
6705
7048
|
async function addBluemoveRemoveCollectionBidTxHandler(txData) {
|
|
6706
7049
|
const bidType = await getObjectType({
|
|
6707
7050
|
suiClient: txData?.suiClient,
|
|
6708
|
-
objectId: (0,
|
|
7051
|
+
objectId: (0, import_utils14.normalizeSuiObjectId)(txData?.bidNonce)
|
|
6709
7052
|
});
|
|
6710
7053
|
if (isOriginByteBid(bidType)) {
|
|
6711
7054
|
const sharedObjects = await getSharedObjects(txData?.nftType);
|
|
@@ -6734,7 +7077,7 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
|
6734
7077
|
throw new Error("No bids found");
|
|
6735
7078
|
}
|
|
6736
7079
|
const bidsForTracking = [];
|
|
6737
|
-
const tx = existingTx ?
|
|
7080
|
+
const tx = existingTx ? import_transactions23.Transaction.from(existingTx) : new import_transactions23.Transaction();
|
|
6738
7081
|
for (const bid of res.bids) {
|
|
6739
7082
|
if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
|
|
6740
7083
|
throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
|
|
@@ -6782,11 +7125,11 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
|
6782
7125
|
bidder: bid?.bidder
|
|
6783
7126
|
});
|
|
6784
7127
|
}
|
|
6785
|
-
return
|
|
7128
|
+
return import_transactions23.Transaction.from(tx);
|
|
6786
7129
|
};
|
|
6787
7130
|
|
|
6788
7131
|
// src/methods/removeNftBids/removeNftBids.ts
|
|
6789
|
-
var
|
|
7132
|
+
var import_transactions24 = require("@mysten/sui/transactions");
|
|
6790
7133
|
var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
6791
7134
|
const res = await gqlChainRequest({
|
|
6792
7135
|
chain: "sui",
|
|
@@ -6797,7 +7140,7 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
|
6797
7140
|
throw new Error("No bids found");
|
|
6798
7141
|
}
|
|
6799
7142
|
const bidsForTracking = [];
|
|
6800
|
-
const tx = existingTx ?
|
|
7143
|
+
const tx = existingTx ? import_transactions24.Transaction.from(existingTx) : new import_transactions24.Transaction();
|
|
6801
7144
|
for (const bid of res.bids) {
|
|
6802
7145
|
if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
|
|
6803
7146
|
throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
|
|
@@ -6842,11 +7185,11 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
|
6842
7185
|
bidder: bid?.bidder
|
|
6843
7186
|
});
|
|
6844
7187
|
}
|
|
6845
|
-
return
|
|
7188
|
+
return import_transactions24.Transaction.from(tx);
|
|
6846
7189
|
};
|
|
6847
7190
|
|
|
6848
7191
|
// src/methods/transferNfts/transferNfts.ts
|
|
6849
|
-
var
|
|
7192
|
+
var import_transactions25 = require("@mysten/sui/transactions");
|
|
6850
7193
|
var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context) => {
|
|
6851
7194
|
if (addLeadingZerosAfter0x(recipientAddress) === addLeadingZerosAfter0x(walletAddress)) {
|
|
6852
7195
|
throw new Error("Cannot transfer to self");
|
|
@@ -6864,7 +7207,7 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
|
|
|
6864
7207
|
}
|
|
6865
7208
|
const nftsForTracking = [];
|
|
6866
7209
|
const nftsToTransferDirectly = [];
|
|
6867
|
-
const tx = new
|
|
7210
|
+
const tx = new import_transactions25.Transaction();
|
|
6868
7211
|
const sharedKioskState = {
|
|
6869
7212
|
kioskTx: void 0
|
|
6870
7213
|
};
|
|
@@ -6967,11 +7310,11 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
|
|
|
6967
7310
|
context.suiClient
|
|
6968
7311
|
);
|
|
6969
7312
|
sharedKioskState?.kioskTx?.finalize();
|
|
6970
|
-
return
|
|
7313
|
+
return import_transactions25.Transaction.from(tx);
|
|
6971
7314
|
};
|
|
6972
7315
|
|
|
6973
7316
|
// src/methods/unlistListings/unlistListings.ts
|
|
6974
|
-
var
|
|
7317
|
+
var import_transactions26 = require("@mysten/sui/transactions");
|
|
6975
7318
|
var unlistListings = async ({ listingIds, walletAddress }, context) => {
|
|
6976
7319
|
const res = await gqlChainRequest({
|
|
6977
7320
|
chain: "sui",
|
|
@@ -6982,7 +7325,7 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
|
|
|
6982
7325
|
throw new Error("No listings found");
|
|
6983
7326
|
}
|
|
6984
7327
|
const listingsForTracking = [];
|
|
6985
|
-
const tx = new
|
|
7328
|
+
const tx = new import_transactions26.Transaction();
|
|
6986
7329
|
const sharedKioskState = {
|
|
6987
7330
|
kioskTx: void 0
|
|
6988
7331
|
};
|
|
@@ -7051,12 +7394,12 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
|
|
|
7051
7394
|
});
|
|
7052
7395
|
}
|
|
7053
7396
|
sharedKioskState?.kioskTx?.finalize();
|
|
7054
|
-
return
|
|
7397
|
+
return import_transactions26.Transaction.from(tx);
|
|
7055
7398
|
};
|
|
7056
7399
|
|
|
7057
7400
|
// src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts
|
|
7058
7401
|
var import_kiosk5 = require("@mysten/kiosk");
|
|
7059
|
-
var
|
|
7402
|
+
var import_transactions27 = require("@mysten/sui/transactions");
|
|
7060
7403
|
async function withdrawProfitsFromKiosks({ walletAddress }, context) {
|
|
7061
7404
|
const res = await gqlChainRequest({
|
|
7062
7405
|
chain: "sui",
|
|
@@ -7076,7 +7419,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
|
|
|
7076
7419
|
if (kiosksWithProfit.length === 0) {
|
|
7077
7420
|
throw new Error(`No kiosks with profit to withdraw found for ${walletAddress}`);
|
|
7078
7421
|
}
|
|
7079
|
-
const tx = new
|
|
7422
|
+
const tx = new import_transactions27.Transaction();
|
|
7080
7423
|
try {
|
|
7081
7424
|
for (const kiosk of kiosksWithProfit) {
|
|
7082
7425
|
let kioskTx;
|
|
@@ -7122,9 +7465,57 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
|
|
|
7122
7465
|
} catch (err) {
|
|
7123
7466
|
console.log("err", err);
|
|
7124
7467
|
}
|
|
7125
|
-
return
|
|
7468
|
+
return import_transactions27.Transaction.from(tx);
|
|
7126
7469
|
}
|
|
7127
7470
|
|
|
7471
|
+
// src/methods/sponsorNftListing/sponsorNftListing.ts
|
|
7472
|
+
var import_transactions28 = require("@mysten/sui/transactions");
|
|
7473
|
+
|
|
7474
|
+
// src/graphql/queries/fetchNftCollectionChainState.ts
|
|
7475
|
+
var import_graphql_request22 = require("graphql-request");
|
|
7476
|
+
var fetchNftCollectionChainState = import_graphql_request22.gql`
|
|
7477
|
+
query fetchNftCollectionChainState($nftTokenId: String!) {
|
|
7478
|
+
nfts(where: { token_id: { _eq: $nftTokenId } }) {
|
|
7479
|
+
collection {
|
|
7480
|
+
id
|
|
7481
|
+
chain_state
|
|
7482
|
+
}
|
|
7483
|
+
}
|
|
7484
|
+
}
|
|
7485
|
+
`;
|
|
7486
|
+
|
|
7487
|
+
// src/methods/sponsorNftListing/sponsorNftListing.ts
|
|
7488
|
+
var sponsorNftListing = async ({ nftTokenId, walletAddress, options }, context) => {
|
|
7489
|
+
const res = await gqlChainRequest({
|
|
7490
|
+
chain: "sui",
|
|
7491
|
+
query: fetchNftCollectionChainState,
|
|
7492
|
+
variables: { nftTokenId }
|
|
7493
|
+
});
|
|
7494
|
+
if (res?.nfts?.length === 0) {
|
|
7495
|
+
throw new Error(`No nft found with token id ${nftTokenId}`);
|
|
7496
|
+
}
|
|
7497
|
+
const nft = res?.nfts?.[0];
|
|
7498
|
+
const nftType = getNftType({
|
|
7499
|
+
collectionId: nft?.collection?.id,
|
|
7500
|
+
collectionChainState: nft?.collection?.chain_state,
|
|
7501
|
+
nft
|
|
7502
|
+
});
|
|
7503
|
+
const transferPolicies = nft?.collection?.chain_state?.transfer_policies;
|
|
7504
|
+
if (isOriginByteCollection(transferPolicies)) {
|
|
7505
|
+
throw new Error(`You cannot sponsor an Origin Byte NFT. Nft Token Id: ${nftTokenId}`);
|
|
7506
|
+
}
|
|
7507
|
+
const tx = new import_transactions28.Transaction();
|
|
7508
|
+
await addSponsorListingTx({
|
|
7509
|
+
tx,
|
|
7510
|
+
suiClient: context.suiClient,
|
|
7511
|
+
nftTokenId,
|
|
7512
|
+
nftType,
|
|
7513
|
+
walletAddress,
|
|
7514
|
+
sponsorOptions: options
|
|
7515
|
+
});
|
|
7516
|
+
return import_transactions28.Transaction.from(tx);
|
|
7517
|
+
};
|
|
7518
|
+
|
|
7128
7519
|
// src/SuiTradingClient.ts
|
|
7129
7520
|
var SuiTradingClient = class {
|
|
7130
7521
|
constructor({ apiUser, apiKey, suiNodeUrl, graphQLClient }) {
|
|
@@ -7458,6 +7849,15 @@ var SuiTradingClient = class {
|
|
|
7458
7849
|
async updateMultiBid(args) {
|
|
7459
7850
|
return updateMultiBid(args);
|
|
7460
7851
|
}
|
|
7852
|
+
async sponsorNftListing(args) {
|
|
7853
|
+
const context = {
|
|
7854
|
+
apiUser: this.apiUser,
|
|
7855
|
+
apiKey: this.apiKey,
|
|
7856
|
+
suiClient: this.suiClient,
|
|
7857
|
+
kioskClient: this.kioskClient
|
|
7858
|
+
};
|
|
7859
|
+
return sponsorNftListing(args, context);
|
|
7860
|
+
}
|
|
7461
7861
|
};
|
|
7462
7862
|
var SuiTradingClient_default = SuiTradingClient;
|
|
7463
7863
|
// Annotate the CommonJS export names for ESM import in node:
|