@tradeport/sui-trading-sdk 0.4.63 → 0.4.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +5 -0
- package/dist/index.d.mts +50 -22
- package/dist/index.d.ts +50 -22
- package/dist/index.js +627 -256
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +615 -249
- package/dist/index.mjs.map +1 -1
- package/package.json +65 -59
- package/src/helpers/kiosk/getRulePackageId.ts +2 -1
- package/src/helpers/kiosk/getTransferPoliciesToResolve.ts +3 -0
- package/src/helpers/kiosk/upgradeKioskRulesPackageId.ts +17 -0
- package/src/methods/listNfts/listNfts.ts +0 -1
- package/src/methods/sponsorNftListing/addSponsorNftListingTx.ts +14 -12
- package/src/methods/sponsorNftListing/sponsorNftListing.ts +0 -3
package/dist/index.mjs
CHANGED
|
@@ -142,6 +142,17 @@ var TRADEPORT_NFT_STRATEGY_PACKAGE_ID = "0xb7386fc8c6e64ea2b0079e293592b57e98498
|
|
|
142
142
|
var TRADEPORT_NFT_STRATEGY_MANAGER_ID = "0xfb58ee62b3a62a8150f871da950dfdf923cd0d97b153caf99b5219cd4ddda5bd";
|
|
143
143
|
var TRADEPORT_POOL_REGISTRY_ID = "0xcd0a614c4cbbf173f59dee2602c43a1717f283215ed7a0bb1d55d786af16fbcd";
|
|
144
144
|
var TRADEPORT_POOL_VERSIONED_ID = "0x0309b66202e9aaf470081fffee7ffc0fbd50e3b7400d4f56fd06502e4dbbd676";
|
|
145
|
+
var DexConstants = {
|
|
146
|
+
commission: "0x24f5f2258ef80c0a3243088199faeb95ad50516ca1517dbd93be398d759057bb",
|
|
147
|
+
commissionManager: "0xd19a03d4ec3d12b0ce407b54eb676cc0f8e1403621deda77d9677bfcb9d738c1",
|
|
148
|
+
poolsToExclude: [
|
|
149
|
+
"0x3addbbc82866c0bbd93e51b6e2d75c0a4faaf270cc0e281d8f4de5df48bebfa4",
|
|
150
|
+
"0x19d614f421046cae90f5a3a976816063478f648087a12adc74e90ebd54dfaf19",
|
|
151
|
+
"0x514c74e28a9720366abc4a65a5688f47c72e784dbf035844d3f59059bfaed056",
|
|
152
|
+
"0x0854de4e9d64716b757b2f6f22258467f59cc1b4bc0cc64c70086549faaddedf"
|
|
153
|
+
]
|
|
154
|
+
};
|
|
155
|
+
var USDC_COIN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
145
156
|
var COLLECTION_IDS_WITH_ZERO_COMMISSION = [
|
|
146
157
|
""
|
|
147
158
|
];
|
|
@@ -3571,6 +3582,16 @@ var getCollectionChainState = async (collectionId) => {
|
|
|
3571
3582
|
});
|
|
3572
3583
|
return res?.collections?.[0]?.chain_state;
|
|
3573
3584
|
};
|
|
3585
|
+
var getCollectionChainStateByFtType = async (ftType) => {
|
|
3586
|
+
const res = await gqlChainRequest({
|
|
3587
|
+
chain: "sui",
|
|
3588
|
+
query: fetchCollectionChainStateByFtType,
|
|
3589
|
+
variables: {
|
|
3590
|
+
ftType
|
|
3591
|
+
}
|
|
3592
|
+
});
|
|
3593
|
+
return res?.collections_by_ft_type?.[0]?.chain_state;
|
|
3594
|
+
};
|
|
3574
3595
|
|
|
3575
3596
|
// src/methods/applyFtStrategy/applyFtStrategy.ts
|
|
3576
3597
|
async function applyFtStrategy({
|
|
@@ -3605,105 +3626,12 @@ async function applyFtStrategy({
|
|
|
3605
3626
|
return tx;
|
|
3606
3627
|
}
|
|
3607
3628
|
|
|
3608
|
-
// src/methods/applyNftStrategy/applyNftStrategy.ts
|
|
3609
|
-
import { Transaction as Transaction5 } from "@mysten/sui/transactions";
|
|
3610
|
-
|
|
3611
|
-
// src/graphql/queries/fetchCollectionFloorListingForMarket.ts
|
|
3612
|
-
import { gql as gql13 } from "graphql-request";
|
|
3613
|
-
var fetchCollectionFloorListingsForMarket = gql13`
|
|
3614
|
-
query fetchCollectionFloorListingsForMarket(
|
|
3615
|
-
$collectionId: uuid!
|
|
3616
|
-
$marketAddress: String!
|
|
3617
|
-
$totalPrice: numeric
|
|
3618
|
-
) {
|
|
3619
|
-
listings(
|
|
3620
|
-
where: {
|
|
3621
|
-
collection_id: { _eq: $collectionId }
|
|
3622
|
-
listed: { _eq: true }
|
|
3623
|
-
market_name: { _eq: "tradeport" }
|
|
3624
|
-
seller: { _neq: $marketAddress }
|
|
3625
|
-
nonce: { _like: "1::0x%" }
|
|
3626
|
-
price: { _lte: $totalPrice }
|
|
3627
|
-
}
|
|
3628
|
-
order_by: [{ price: asc_nulls_last }, { block_height: asc }, { tx_index: asc }]
|
|
3629
|
-
) {
|
|
3630
|
-
id
|
|
3631
|
-
price
|
|
3632
|
-
nft {
|
|
3633
|
-
token_id
|
|
3634
|
-
delegated_owner
|
|
3635
|
-
}
|
|
3636
|
-
}
|
|
3637
|
-
}
|
|
3638
|
-
`;
|
|
3639
|
-
|
|
3640
|
-
// src/methods/applyNftStrategy/applyNftStrategy.ts
|
|
3641
|
-
async function applyTradeportNftStrategy({
|
|
3642
|
-
collectionId,
|
|
3643
|
-
strategyFtType,
|
|
3644
|
-
tx: existingTx
|
|
3645
|
-
}) {
|
|
3646
|
-
const tx = existingTx ?? new Transaction5();
|
|
3647
|
-
const chainState = await getCollectionChainState(collectionId);
|
|
3648
|
-
const nftStrategies = chainState?.nft_strategies ?? {};
|
|
3649
|
-
const nftStrategyKeys = Object.keys(nftStrategies);
|
|
3650
|
-
if (nftStrategyKeys.length === 0) {
|
|
3651
|
-
throw new Error("No NFT strategies found for collection");
|
|
3652
|
-
}
|
|
3653
|
-
strategyFtType = strategyFtType ?? nftStrategyKeys[0];
|
|
3654
|
-
if (!nftStrategyKeys.includes(strategyFtType)) {
|
|
3655
|
-
throw new Error(`Specified FT type ${strategyFtType} is not supported for this collection`);
|
|
3656
|
-
}
|
|
3657
|
-
const transferPolicy = getNativeKioskTransferPolicies(chainState?.transfer_policies ?? [])?.at(0);
|
|
3658
|
-
if (!transferPolicy) {
|
|
3659
|
-
throw new Error("No transfer policy found for collection");
|
|
3660
|
-
}
|
|
3661
|
-
const nftType = chainState?.nft_type;
|
|
3662
|
-
let suiBalance = BigInt(
|
|
3663
|
-
nftStrategies[strategyFtType].sui_balance ?? 0n
|
|
3664
|
-
);
|
|
3665
|
-
const result = await gqlChainRequest({
|
|
3666
|
-
chain: "sui",
|
|
3667
|
-
query: fetchCollectionFloorListingsForMarket,
|
|
3668
|
-
variables: {
|
|
3669
|
-
collectionId,
|
|
3670
|
-
marketAddress: TRADEPORT_NFT_STRATEGY_MANAGER_ID,
|
|
3671
|
-
totalPrice: suiBalance.toString()
|
|
3672
|
-
}
|
|
3673
|
-
});
|
|
3674
|
-
if ((result?.listings?.length ?? 0) === 0) {
|
|
3675
|
-
throw new Error(
|
|
3676
|
-
`No floor listing found for collection with price bellow or equal to ${suiBalance} MIST`
|
|
3677
|
-
);
|
|
3678
|
-
}
|
|
3679
|
-
for (const floorListing of result.listings) {
|
|
3680
|
-
suiBalance -= BigInt(floorListing.price);
|
|
3681
|
-
if (suiBalance < 0n) {
|
|
3682
|
-
break;
|
|
3683
|
-
}
|
|
3684
|
-
tx.moveCall({
|
|
3685
|
-
target: `${TRADEPORT_NFT_STRATEGY_PACKAGE_ID}::tradeport_nft_strategy::apply_tradeport_nft_strategy_confirm_request`,
|
|
3686
|
-
typeArguments: [nftType, strategyFtType],
|
|
3687
|
-
arguments: [
|
|
3688
|
-
tx.object(TRADEPORT_NFT_STRATEGY_MANAGER_ID),
|
|
3689
|
-
tx.object(nftStrategies[strategyFtType].kiosk_id),
|
|
3690
|
-
tx.object(TRADEPORT_LISTINGS_STORE),
|
|
3691
|
-
tx.object(TRADEPORT_ORDERBOOK_STORE),
|
|
3692
|
-
tx.object(floorListing.nft.delegated_owner),
|
|
3693
|
-
tx.object(floorListing.nft.token_id),
|
|
3694
|
-
tx.object(transferPolicy.id)
|
|
3695
|
-
]
|
|
3696
|
-
});
|
|
3697
|
-
}
|
|
3698
|
-
return tx;
|
|
3699
|
-
}
|
|
3700
|
-
|
|
3701
3629
|
// src/methods/buyListings/buyListings.ts
|
|
3702
3630
|
import { Transaction as Transaction7 } from "@mysten/sui/transactions";
|
|
3703
3631
|
|
|
3704
3632
|
// src/graphql/queries/fetchListingsById.ts
|
|
3705
|
-
import { gql as
|
|
3706
|
-
var fetchListingsById =
|
|
3633
|
+
import { gql as gql13 } from "graphql-request";
|
|
3634
|
+
var fetchListingsById = gql13`
|
|
3707
3635
|
query fetchListingsById($listingIds: [uuid!]) {
|
|
3708
3636
|
listings(where: { id: { _in: $listingIds } }) {
|
|
3709
3637
|
id
|
|
@@ -3742,6 +3670,29 @@ var addThirdPartyTxFee = async (tx, price) => {
|
|
|
3742
3670
|
);
|
|
3743
3671
|
};
|
|
3744
3672
|
|
|
3673
|
+
// src/helpers/deserializeOrCreateTxBlock.ts
|
|
3674
|
+
import { Transaction as Transaction5 } from "@mysten/sui/transactions";
|
|
3675
|
+
var deserializeOrCreateTxBlock = ({
|
|
3676
|
+
existingTx
|
|
3677
|
+
}) => {
|
|
3678
|
+
if (typeof existingTx === "string") {
|
|
3679
|
+
return Transaction5.from(existingTx);
|
|
3680
|
+
}
|
|
3681
|
+
return existingTx ?? new Transaction5();
|
|
3682
|
+
};
|
|
3683
|
+
|
|
3684
|
+
// src/helpers/extractSwapResultCoin.ts
|
|
3685
|
+
var extractSwapResultCoinFromTxBlock = (txBlock) => {
|
|
3686
|
+
if (!txBlock) return void 0;
|
|
3687
|
+
const tx = typeof txBlock === "string" ? JSON.parse(txBlock) : txBlock?.getData();
|
|
3688
|
+
const commands = tx.commands ?? [];
|
|
3689
|
+
const index = commands.findIndex(
|
|
3690
|
+
(cmd) => cmd?.MoveCall?.module === "universal_router" && cmd?.MoveCall?.function === "settle"
|
|
3691
|
+
);
|
|
3692
|
+
if (index === -1) return void 0;
|
|
3693
|
+
return { $kind: "Result", Result: index };
|
|
3694
|
+
};
|
|
3695
|
+
|
|
3745
3696
|
// src/helpers/kiosk/preProcessSharedBulkBuyingData.ts
|
|
3746
3697
|
import { bcs as bcs2 } from "@mysten/sui/bcs";
|
|
3747
3698
|
import { Transaction as Transaction6 } from "@mysten/sui/transactions";
|
|
@@ -3847,8 +3798,8 @@ var preProcessSharedBulkBuyingData = async ({
|
|
|
3847
3798
|
import { bcs as bcs3 } from "@mysten/sui/bcs";
|
|
3848
3799
|
|
|
3849
3800
|
// src/graphql/queries/fetchCommissionByListingId.ts
|
|
3850
|
-
import { gql as
|
|
3851
|
-
var fetchCommissionByNftContractId =
|
|
3801
|
+
import { gql as gql14 } from "graphql-request";
|
|
3802
|
+
var fetchCommissionByNftContractId = gql14`
|
|
3852
3803
|
query fetchCommissionByNftContractId($nftContractId: uuid!) {
|
|
3853
3804
|
commissions(where: { contract_id: { _eq: $nftContractId } }) {
|
|
3854
3805
|
is_custodial
|
|
@@ -4598,7 +4549,8 @@ var buyListings = async ({
|
|
|
4598
4549
|
throw new Error("No listings found");
|
|
4599
4550
|
}
|
|
4600
4551
|
const listingsForTracking = [];
|
|
4601
|
-
const tx = existingTx
|
|
4552
|
+
const tx = deserializeOrCreateTxBlock({ existingTx });
|
|
4553
|
+
const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
|
|
4602
4554
|
const tocenTokenIds = [];
|
|
4603
4555
|
let tocenNftType = "";
|
|
4604
4556
|
let tocenTotalPrice = 0;
|
|
@@ -4643,7 +4595,7 @@ var buyListings = async ({
|
|
|
4643
4595
|
sellerKiosk: listing.nft?.chain_state?.kiosk_id,
|
|
4644
4596
|
collectionId: listing?.nft?.collection_id,
|
|
4645
4597
|
nftContractId: listing?.nft?.contract_id,
|
|
4646
|
-
coinToSplit,
|
|
4598
|
+
coinToSplit: swapResultCoin ? swapResultCoin : coinToSplit,
|
|
4647
4599
|
marketFeeDecimalPercent,
|
|
4648
4600
|
beforeResolveKioskTransferRequest,
|
|
4649
4601
|
sharedKioskState,
|
|
@@ -4692,6 +4644,9 @@ var buyListings = async ({
|
|
|
4692
4644
|
});
|
|
4693
4645
|
}
|
|
4694
4646
|
sharedKioskState?.kioskTx?.finalize();
|
|
4647
|
+
if (swapResultCoin) {
|
|
4648
|
+
tx.transferObjects([swapResultCoin], walletAddress);
|
|
4649
|
+
}
|
|
4695
4650
|
if (tocenTokenIds?.length > 0) {
|
|
4696
4651
|
addTocenBuyTxHandler({
|
|
4697
4652
|
tx,
|
|
@@ -4700,7 +4655,7 @@ var buyListings = async ({
|
|
|
4700
4655
|
price: tocenTotalPrice
|
|
4701
4656
|
});
|
|
4702
4657
|
}
|
|
4703
|
-
return tx;
|
|
4658
|
+
return Transaction7.from(tx);
|
|
4704
4659
|
};
|
|
4705
4660
|
|
|
4706
4661
|
// src/methods/cancelMultiBid/cancelMultiBid.ts
|
|
@@ -4824,8 +4779,8 @@ async function cancelMultiBid({ multiBidId }) {
|
|
|
4824
4779
|
import { Transaction as Transaction9 } from "@mysten/sui/transactions";
|
|
4825
4780
|
|
|
4826
4781
|
// src/graphql/queries/fetchAccountKiosks.ts
|
|
4827
|
-
import { gql as
|
|
4828
|
-
var fetchAccountKiosks =
|
|
4782
|
+
import { gql as gql15 } from "graphql-request";
|
|
4783
|
+
var fetchAccountKiosks = gql15`
|
|
4829
4784
|
query fetchAccountKiosks($accountAddress: String!) {
|
|
4830
4785
|
kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
|
|
4831
4786
|
id
|
|
@@ -5294,22 +5249,17 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
|
|
|
5294
5249
|
return Transaction10.from(tx);
|
|
5295
5250
|
};
|
|
5296
5251
|
|
|
5297
|
-
// src/methods/createMultiBid/createMultiBid.ts
|
|
5298
|
-
import { Transaction as Transaction12 } from "@mysten/sui/transactions";
|
|
5299
|
-
|
|
5300
5252
|
// src/methods/updateMultiBid/updateMultiBid.ts
|
|
5301
|
-
import { Transaction as Transaction11 } from "@mysten/sui/transactions";
|
|
5302
5253
|
async function updateMultiBid({
|
|
5303
|
-
walletAddress,
|
|
5304
5254
|
multiBidId,
|
|
5305
5255
|
name,
|
|
5306
5256
|
amount,
|
|
5307
5257
|
amountToWithdraw,
|
|
5308
5258
|
tx: existingTx,
|
|
5309
|
-
multiBidChainId
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
const
|
|
5259
|
+
multiBidChainId
|
|
5260
|
+
}) {
|
|
5261
|
+
const tx = deserializeOrCreateTxBlock({ existingTx });
|
|
5262
|
+
const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
|
|
5313
5263
|
if (!multiBidChainId) {
|
|
5314
5264
|
const { chain_id: chainId, cancelled_at } = (await gqlChainRequest({
|
|
5315
5265
|
chain: "sui",
|
|
@@ -5324,7 +5274,7 @@ async function updateMultiBid({
|
|
|
5324
5274
|
}
|
|
5325
5275
|
multiBidChainId = chainId;
|
|
5326
5276
|
}
|
|
5327
|
-
const [coin] = tx.splitCoins(
|
|
5277
|
+
const [coin] = tx.splitCoins(swapResultCoin ? swapResultCoin : tx.gas, [amount ?? 0n]);
|
|
5328
5278
|
tx.moveCall({
|
|
5329
5279
|
target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::update_multi_bid`,
|
|
5330
5280
|
arguments: [
|
|
@@ -5345,7 +5295,7 @@ async function createMultiBid({
|
|
|
5345
5295
|
amount,
|
|
5346
5296
|
tx: existingTx
|
|
5347
5297
|
}) {
|
|
5348
|
-
const tx = existingTx
|
|
5298
|
+
const tx = deserializeOrCreateTxBlock({ existingTx });
|
|
5349
5299
|
const multiBidChainId = tx.moveCall({
|
|
5350
5300
|
target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
|
|
5351
5301
|
arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.option("string", name)]
|
|
@@ -5363,11 +5313,7 @@ async function createMultiBid({
|
|
|
5363
5313
|
}
|
|
5364
5314
|
|
|
5365
5315
|
// src/methods/listNfts/listNfts.ts
|
|
5366
|
-
import { Transaction as
|
|
5367
|
-
|
|
5368
|
-
// src/helpers/isExpiredListing.ts
|
|
5369
|
-
import { normalizeSuiAddress } from "@mysten/sui/utils";
|
|
5370
|
-
var isExpiredListing = (listing, walletAddress) => listing.nonce && listing.seller && normalizeSuiAddress(listing.seller) === normalizeSuiAddress(walletAddress);
|
|
5316
|
+
import { Transaction as Transaction12 } from "@mysten/sui/transactions";
|
|
5371
5317
|
|
|
5372
5318
|
// src/helpers/validateMinFloorPrice.ts
|
|
5373
5319
|
function validateMinFloorPrice({ transferPolicies, listPrice }) {
|
|
@@ -5696,15 +5642,324 @@ async function relistNft({
|
|
|
5696
5642
|
}
|
|
5697
5643
|
}
|
|
5698
5644
|
|
|
5645
|
+
// src/methods/swapCoins/swapCoins.ts
|
|
5646
|
+
import {
|
|
5647
|
+
AggregatorQuoter,
|
|
5648
|
+
CoinProvider,
|
|
5649
|
+
Protocol,
|
|
5650
|
+
TradeBuilder
|
|
5651
|
+
} from "@flowx-finance/sdk";
|
|
5652
|
+
import { coinWithBalance, Transaction as Transaction11 } from "@mysten/sui/transactions";
|
|
5653
|
+
import { normalizeStructTag as normalizeStructTag2, normalizeSuiAddress, SUI_TYPE_ARG } from "@mysten/sui/utils";
|
|
5654
|
+
import ms from "ms";
|
|
5655
|
+
|
|
5656
|
+
// src/utils/pureValues.ts
|
|
5657
|
+
var toDecimalValue = (value, decimals) => {
|
|
5658
|
+
if (!value || decimals === void 0) return new bigNumberConfig_default(0);
|
|
5659
|
+
return new bigNumberConfig_default(value).div(10 ** decimals);
|
|
5660
|
+
};
|
|
5661
|
+
var toPureValue = (value, decimals) => {
|
|
5662
|
+
if (!value || decimals === void 0) return new bigNumberConfig_default(0);
|
|
5663
|
+
return new bigNumberConfig_default(new bigNumberConfig_default(value).multipliedBy(10 ** decimals).toFixed(0));
|
|
5664
|
+
};
|
|
5665
|
+
|
|
5666
|
+
// src/methods/swapCoins/swapCoins.ts
|
|
5667
|
+
async function swapCoins({
|
|
5668
|
+
walletAddress,
|
|
5669
|
+
coinInType,
|
|
5670
|
+
coinInAmount,
|
|
5671
|
+
coinOutType,
|
|
5672
|
+
slippage = 1e3,
|
|
5673
|
+
// 0.1%
|
|
5674
|
+
ttl = "5m",
|
|
5675
|
+
excludeSources = [Protocol.STEAMM, Protocol.BOLT],
|
|
5676
|
+
routes,
|
|
5677
|
+
commission,
|
|
5678
|
+
tx: existingTx
|
|
5679
|
+
}, { suiClient, defiRouterUrl }) {
|
|
5680
|
+
const inAmount = BigInt(coinInAmount);
|
|
5681
|
+
const tx = existingTx ?? new Transaction11();
|
|
5682
|
+
coinInType = normalizeStructTag2(coinInType);
|
|
5683
|
+
coinOutType = normalizeStructTag2(coinOutType);
|
|
5684
|
+
walletAddress = normalizeSuiAddress(walletAddress);
|
|
5685
|
+
tx.setSenderIfNotSet(normalizeSuiAddress(walletAddress));
|
|
5686
|
+
if (inAmount === 0n) {
|
|
5687
|
+
const zeroCoin = tx.moveCall({
|
|
5688
|
+
target: "0x2::coin::zero",
|
|
5689
|
+
typeArguments: [coinOutType]
|
|
5690
|
+
});
|
|
5691
|
+
return {
|
|
5692
|
+
tx,
|
|
5693
|
+
coinOut: zeroCoin
|
|
5694
|
+
};
|
|
5695
|
+
}
|
|
5696
|
+
if (coinInType === coinOutType) {
|
|
5697
|
+
const getCoin = coinWithBalance({
|
|
5698
|
+
type: coinInType,
|
|
5699
|
+
balance: inAmount
|
|
5700
|
+
});
|
|
5701
|
+
return {
|
|
5702
|
+
tx,
|
|
5703
|
+
coinOut: getCoin(tx)
|
|
5704
|
+
};
|
|
5705
|
+
}
|
|
5706
|
+
const types = await getAffectedNftAndFtTypes(coinInType, coinOutType);
|
|
5707
|
+
const { feeAndReward, amountToSwap } = calculateSwapAmounts(types.length, inAmount);
|
|
5708
|
+
if (!routes) {
|
|
5709
|
+
routes = (await buildSwapRoutes(
|
|
5710
|
+
{
|
|
5711
|
+
walletAddress,
|
|
5712
|
+
coinInType,
|
|
5713
|
+
coinOutType,
|
|
5714
|
+
amountToSwap,
|
|
5715
|
+
excludeSources,
|
|
5716
|
+
commission
|
|
5717
|
+
},
|
|
5718
|
+
{ defiRouterUrl }
|
|
5719
|
+
)).routes;
|
|
5720
|
+
}
|
|
5721
|
+
const tradeBuilder = new TradeBuilder("mainnet", routes);
|
|
5722
|
+
if (commission) {
|
|
5723
|
+
tradeBuilder.commission(commission);
|
|
5724
|
+
}
|
|
5725
|
+
const trade = tradeBuilder.sender(walletAddress).slippage(slippage).deadline(Date.now() + ms(ttl)).build();
|
|
5726
|
+
const coinOut = await trade.swap({ client: suiClient, tx });
|
|
5727
|
+
let suiFeeAndRewardCoin;
|
|
5728
|
+
if (coinInType === normalizeStructTag2(SUI_TYPE_ARG)) {
|
|
5729
|
+
suiFeeAndRewardCoin = tx.splitCoins(tx.gas, [
|
|
5730
|
+
tx.pure.u64(feeAndReward)
|
|
5731
|
+
])[0];
|
|
5732
|
+
} else {
|
|
5733
|
+
const suiFeeAndRewardRoutes = await buildSwapRoutes(
|
|
5734
|
+
{
|
|
5735
|
+
walletAddress,
|
|
5736
|
+
coinInType,
|
|
5737
|
+
coinOutType: SUI_TYPE_ARG,
|
|
5738
|
+
amountToSwap: feeAndReward,
|
|
5739
|
+
excludeSources
|
|
5740
|
+
},
|
|
5741
|
+
{ defiRouterUrl }
|
|
5742
|
+
);
|
|
5743
|
+
const suiFeeTradeBuilder = new TradeBuilder("mainnet", suiFeeAndRewardRoutes.routes);
|
|
5744
|
+
const suiFeeTrade = suiFeeTradeBuilder.sender(walletAddress).slippage(slippage).deadline(Date.now() + ms(ttl)).build();
|
|
5745
|
+
suiFeeAndRewardCoin = await suiFeeTrade.swap({ client: suiClient, tx });
|
|
5746
|
+
}
|
|
5747
|
+
if (types.length > 0) {
|
|
5748
|
+
if (types.length > 2) {
|
|
5749
|
+
throw new Error("Unexpected affected types count greater than 2");
|
|
5750
|
+
}
|
|
5751
|
+
let usedSuiCoin = suiFeeAndRewardCoin;
|
|
5752
|
+
if (types.length === 2) {
|
|
5753
|
+
const suiFeeAndRewardCoinBalance = tx.moveCall({
|
|
5754
|
+
target: "0x2::coin::value",
|
|
5755
|
+
typeArguments: [SUI_TYPE_ARG],
|
|
5756
|
+
arguments: [suiFeeAndRewardCoin]
|
|
5757
|
+
});
|
|
5758
|
+
const halfSuiCoinAmount = tx.moveCall({
|
|
5759
|
+
target: "0x2::math::divide_and_round_up",
|
|
5760
|
+
arguments: [suiFeeAndRewardCoinBalance, tx.pure.u64(2)]
|
|
5761
|
+
});
|
|
5762
|
+
const [coin] = tx.splitCoins(usedSuiCoin, [halfSuiCoinAmount]);
|
|
5763
|
+
usedSuiCoin = coin;
|
|
5764
|
+
}
|
|
5765
|
+
for (const data of types) {
|
|
5766
|
+
const { nftType, ftType, type } = data;
|
|
5767
|
+
switch (type) {
|
|
5768
|
+
case "liquidNft": {
|
|
5769
|
+
tx.moveCall({
|
|
5770
|
+
target: `${DexConstants.commission}::commission::pay`,
|
|
5771
|
+
arguments: [
|
|
5772
|
+
tx.object(DexConstants.commissionManager),
|
|
5773
|
+
tx.pure.string("swap"),
|
|
5774
|
+
usedSuiCoin,
|
|
5775
|
+
tx.pure.option("string", nftType)
|
|
5776
|
+
],
|
|
5777
|
+
typeArguments: [SUI_TYPE_ARG]
|
|
5778
|
+
});
|
|
5779
|
+
break;
|
|
5780
|
+
}
|
|
5781
|
+
case "nftStrategy": {
|
|
5782
|
+
const suiFeeAndRewardCoinBalance = tx.moveCall({
|
|
5783
|
+
target: "0x2::coin::value",
|
|
5784
|
+
typeArguments: [SUI_TYPE_ARG],
|
|
5785
|
+
arguments: [usedSuiCoin]
|
|
5786
|
+
});
|
|
5787
|
+
const feeAmount = tx.moveCall({
|
|
5788
|
+
target: "0x2::math::divide_and_round_up",
|
|
5789
|
+
arguments: [suiFeeAndRewardCoinBalance, tx.pure.u64(4)]
|
|
5790
|
+
});
|
|
5791
|
+
const [feeCoin] = tx.splitCoins(usedSuiCoin, [feeAmount]);
|
|
5792
|
+
tx.moveCall({
|
|
5793
|
+
target: `${DexConstants.commission}::commission::pay`,
|
|
5794
|
+
arguments: [
|
|
5795
|
+
tx.object(DexConstants.commissionManager),
|
|
5796
|
+
tx.pure.string("swap"),
|
|
5797
|
+
feeCoin,
|
|
5798
|
+
tx.pure.option("string", void 0)
|
|
5799
|
+
],
|
|
5800
|
+
typeArguments: [SUI_TYPE_ARG]
|
|
5801
|
+
});
|
|
5802
|
+
tx.moveCall({
|
|
5803
|
+
target: `${TRADEPORT_NFT_STRATEGY_PACKAGE_ID}::tradeport_nft_strategy::reward_strategy`,
|
|
5804
|
+
arguments: [
|
|
5805
|
+
tx.object(TRADEPORT_NFT_STRATEGY_MANAGER_ID),
|
|
5806
|
+
usedSuiCoin
|
|
5807
|
+
// 3/4 retained coin for reward
|
|
5808
|
+
],
|
|
5809
|
+
typeArguments: [nftType, ftType]
|
|
5810
|
+
});
|
|
5811
|
+
break;
|
|
5812
|
+
}
|
|
5813
|
+
default: {
|
|
5814
|
+
throw new Error(`Unexpected type ${type}`);
|
|
5815
|
+
}
|
|
5816
|
+
}
|
|
5817
|
+
usedSuiCoin = suiFeeAndRewardCoin;
|
|
5818
|
+
}
|
|
5819
|
+
} else {
|
|
5820
|
+
tx.moveCall({
|
|
5821
|
+
target: `${DexConstants.commission}::commission::pay`,
|
|
5822
|
+
arguments: [
|
|
5823
|
+
tx.object(DexConstants.commissionManager),
|
|
5824
|
+
tx.pure.string("swap"),
|
|
5825
|
+
suiFeeAndRewardCoin,
|
|
5826
|
+
tx.pure.option("string", void 0)
|
|
5827
|
+
],
|
|
5828
|
+
typeArguments: [SUI_TYPE_ARG]
|
|
5829
|
+
});
|
|
5830
|
+
}
|
|
5831
|
+
return {
|
|
5832
|
+
tx,
|
|
5833
|
+
coinOut
|
|
5834
|
+
};
|
|
5835
|
+
}
|
|
5836
|
+
async function calculateAmountToSwap({
|
|
5837
|
+
coinInType,
|
|
5838
|
+
coinOutType,
|
|
5839
|
+
coinInAmount
|
|
5840
|
+
}) {
|
|
5841
|
+
const types = await getAffectedNftAndFtTypes(coinInType, coinOutType);
|
|
5842
|
+
const { amountToSwap } = calculateSwapAmounts(types.length, BigInt(coinInAmount));
|
|
5843
|
+
return amountToSwap;
|
|
5844
|
+
}
|
|
5845
|
+
async function calculateSwapInputAmountWithSlippage({
|
|
5846
|
+
coinInType,
|
|
5847
|
+
coinOutType,
|
|
5848
|
+
coinOutAmount,
|
|
5849
|
+
slippage = 0
|
|
5850
|
+
}) {
|
|
5851
|
+
if (coinInType === coinOutType) {
|
|
5852
|
+
return new bigNumberConfig_default(coinOutAmount);
|
|
5853
|
+
}
|
|
5854
|
+
const provider = new CoinProvider("mainnet");
|
|
5855
|
+
const coinQueryResult = await provider.getCoins({
|
|
5856
|
+
limit: 2,
|
|
5857
|
+
coinTypes: [coinInType, coinOutType]
|
|
5858
|
+
});
|
|
5859
|
+
const coinIn = coinQueryResult?.find(
|
|
5860
|
+
(coin) => normalizeStructTag2(coin.coinType) === normalizeStructTag2(coinInType)
|
|
5861
|
+
);
|
|
5862
|
+
const coinOut = coinQueryResult?.find(
|
|
5863
|
+
(coin) => normalizeStructTag2(coin.coinType) === normalizeStructTag2(coinOutType)
|
|
5864
|
+
);
|
|
5865
|
+
const exchangeRate = new bigNumberConfig_default(coinOut.derivedPriceInUSD ?? 0)?.gt(0) ? new bigNumberConfig_default(coinIn?.derivedPriceInUSD ?? 1)?.div(coinOut?.derivedPriceInUSD ?? 1) : new bigNumberConfig_default(0);
|
|
5866
|
+
const amountSell = toDecimalValue(coinOutAmount.toString(), coinOut?.decimals).div(exchangeRate);
|
|
5867
|
+
const slippageMultiplier = 1 + parseInt(slippage.toString() || "0", 10) / 1e6;
|
|
5868
|
+
const amountWithSlippage = amountSell.times(slippageMultiplier);
|
|
5869
|
+
const coinInAmount = toPureValue(amountWithSlippage, coinIn?.decimals);
|
|
5870
|
+
return coinInAmount;
|
|
5871
|
+
}
|
|
5872
|
+
async function buildSwapRoutes(options, { defiRouterUrl }) {
|
|
5873
|
+
const aggregatorQuoter = new AggregatorQuoter("mainnet");
|
|
5874
|
+
const routes = await aggregatorQuoter.getRoutes({
|
|
5875
|
+
tokenIn: options.coinInType,
|
|
5876
|
+
tokenOut: options.coinOutType,
|
|
5877
|
+
amountIn: options.amountToSwap.toString(),
|
|
5878
|
+
commission: options.commission,
|
|
5879
|
+
excludeSources: options.excludeSources
|
|
5880
|
+
});
|
|
5881
|
+
if (defiRouterUrl && options.walletAddress) {
|
|
5882
|
+
await makeDefiRouterRequest(`${defiRouterUrl}/start`, {
|
|
5883
|
+
walletId: options.walletAddress,
|
|
5884
|
+
coinTypeIn: options.coinInType,
|
|
5885
|
+
coinTypeOut: options.coinOutType,
|
|
5886
|
+
amountIn: options.amountToSwap.toString()
|
|
5887
|
+
});
|
|
5888
|
+
}
|
|
5889
|
+
return routes;
|
|
5890
|
+
}
|
|
5891
|
+
function calculateSwapAmounts(affectedTypesCount, inAmount) {
|
|
5892
|
+
const feeAndReward = affectedTypesCount > 0 ? BigInt(affectedTypesCount) * inAmount / 25n : inAmount / 100n;
|
|
5893
|
+
const amountToSwap = inAmount - feeAndReward;
|
|
5894
|
+
if (amountToSwap <= 0n) {
|
|
5895
|
+
throw new Error("Amount to swap is too small");
|
|
5896
|
+
}
|
|
5897
|
+
return { feeAndReward, amountToSwap };
|
|
5898
|
+
}
|
|
5899
|
+
async function getAffectedNftAndFtTypes(coinInType, coinOutType) {
|
|
5900
|
+
const normalizedSuiType = normalizeStructTag2(SUI_TYPE_ARG);
|
|
5901
|
+
const coinTypes = [coinInType, coinOutType].filter((type) => type !== normalizedSuiType);
|
|
5902
|
+
const types = await Promise.all(
|
|
5903
|
+
coinTypes.map(async (type) => {
|
|
5904
|
+
const chainState = await getCollectionChainStateByFtType(type);
|
|
5905
|
+
return chainState ? {
|
|
5906
|
+
nftType: chainState.nft_type,
|
|
5907
|
+
ftType: type,
|
|
5908
|
+
type: chainState.ft_type ? "liquidNft" : "nftStrategy"
|
|
5909
|
+
} : void 0;
|
|
5910
|
+
})
|
|
5911
|
+
);
|
|
5912
|
+
return types.filter(Boolean);
|
|
5913
|
+
}
|
|
5914
|
+
async function makeDefiRouterRequest(url, body, defaultResponse = void 0) {
|
|
5915
|
+
try {
|
|
5916
|
+
const response = await fetch(url, {
|
|
5917
|
+
method: "POST",
|
|
5918
|
+
headers: { "Content-Type": "application/json" },
|
|
5919
|
+
body: JSON.stringify(body)
|
|
5920
|
+
});
|
|
5921
|
+
if (!response.ok) {
|
|
5922
|
+
console.warn(`DeFi router request failed with status ${response.status}`);
|
|
5923
|
+
return defaultResponse;
|
|
5924
|
+
}
|
|
5925
|
+
if (response.headers.get("Content-Type")?.includes("application/json")) {
|
|
5926
|
+
return await response.json();
|
|
5927
|
+
}
|
|
5928
|
+
return defaultResponse;
|
|
5929
|
+
} catch (error) {
|
|
5930
|
+
console.warn(`DeFi router request error: ${error.message}`);
|
|
5931
|
+
return defaultResponse;
|
|
5932
|
+
}
|
|
5933
|
+
}
|
|
5934
|
+
|
|
5699
5935
|
// src/methods/sponsorNftListing/addSponsorNftListingTx.ts
|
|
5700
5936
|
var addSponsorListingTx = async ({
|
|
5701
5937
|
tx,
|
|
5702
|
-
coinToSplit,
|
|
5703
5938
|
nftTokenId,
|
|
5704
5939
|
nftType,
|
|
5705
|
-
|
|
5940
|
+
suiClient,
|
|
5941
|
+
walletAddress,
|
|
5942
|
+
sponsorOptions,
|
|
5943
|
+
defiRouterUrl
|
|
5706
5944
|
}) => {
|
|
5707
|
-
const
|
|
5945
|
+
const coinInAmount = sponsorOptions?.coinInAmount ?? await calculateSwapInputAmountWithSlippage({
|
|
5946
|
+
coinInType: sponsorOptions?.coinInType,
|
|
5947
|
+
coinOutType: USDC_COIN_TYPE,
|
|
5948
|
+
coinOutAmount: new bigNumberConfig_default(sponsorOptions?.usdcFeeAmountPerPeriod)?.times(sponsorOptions?.numOfPeriods).toString(),
|
|
5949
|
+
slippage: sponsorOptions?.slippage
|
|
5950
|
+
});
|
|
5951
|
+
const { coinOut } = await swapCoins(
|
|
5952
|
+
{
|
|
5953
|
+
walletAddress,
|
|
5954
|
+
coinInType: sponsorOptions?.coinInType,
|
|
5955
|
+
coinInAmount: coinInAmount.toString(),
|
|
5956
|
+
coinOutType: USDC_COIN_TYPE,
|
|
5957
|
+
slippage: sponsorOptions?.slippage,
|
|
5958
|
+
tx
|
|
5959
|
+
},
|
|
5960
|
+
{ suiClient, defiRouterUrl }
|
|
5961
|
+
);
|
|
5962
|
+
const [sponsorFeeCoin] = tx.splitCoins(coinOut, [
|
|
5708
5963
|
tx.pure.u64(
|
|
5709
5964
|
new bigNumberConfig_default(sponsorOptions?.usdcFeeAmountPerPeriod)?.times(sponsorOptions?.numOfPeriods).toString()
|
|
5710
5965
|
)
|
|
@@ -5720,10 +5975,15 @@ var addSponsorListingTx = async ({
|
|
|
5720
5975
|
],
|
|
5721
5976
|
typeArguments: [nftType]
|
|
5722
5977
|
});
|
|
5978
|
+
tx.transferObjects([coinOut], walletAddress);
|
|
5723
5979
|
};
|
|
5724
5980
|
|
|
5981
|
+
// src/helpers/isExpiredListing.ts
|
|
5982
|
+
import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui/utils";
|
|
5983
|
+
var isExpiredListing = (listing, walletAddress) => listing.nonce && listing.seller && normalizeSuiAddress2(listing.seller) === normalizeSuiAddress2(walletAddress);
|
|
5984
|
+
|
|
5725
5985
|
// src/methods/listNfts/listNfts.ts
|
|
5726
|
-
var listNfts = async ({ nfts, walletAddress
|
|
5986
|
+
var listNfts = async ({ nfts, walletAddress }, context) => {
|
|
5727
5987
|
const res = await gqlChainRequest({
|
|
5728
5988
|
chain: "sui",
|
|
5729
5989
|
query: fetchNftsWithListingsById,
|
|
@@ -5733,7 +5993,7 @@ var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
|
|
|
5733
5993
|
throw new Error("No nfts found");
|
|
5734
5994
|
}
|
|
5735
5995
|
const nftsForTracking = [];
|
|
5736
|
-
const tx =
|
|
5996
|
+
const tx = new Transaction12();
|
|
5737
5997
|
const sharedKioskState = {
|
|
5738
5998
|
kioskTx: void 0
|
|
5739
5999
|
};
|
|
@@ -5783,10 +6043,12 @@ var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
|
|
|
5783
6043
|
if (inputNft?.sponsorOptions?.shouldSponsor) {
|
|
5784
6044
|
await addSponsorListingTx({
|
|
5785
6045
|
tx,
|
|
5786
|
-
|
|
6046
|
+
suiClient: context.suiClient,
|
|
5787
6047
|
nftTokenId: nft?.token_id,
|
|
5788
6048
|
nftType,
|
|
5789
|
-
|
|
6049
|
+
walletAddress,
|
|
6050
|
+
sponsorOptions: inputNft?.sponsorOptions,
|
|
6051
|
+
defiRouterUrl: context.defiRouterUrl
|
|
5790
6052
|
});
|
|
5791
6053
|
}
|
|
5792
6054
|
nftsForTracking.push({
|
|
@@ -5799,15 +6061,15 @@ var listNfts = async ({ nfts, walletAddress, tx: existingTx }, context) => {
|
|
|
5799
6061
|
});
|
|
5800
6062
|
}
|
|
5801
6063
|
sharedKioskState?.kioskTx?.finalize();
|
|
5802
|
-
return tx;
|
|
6064
|
+
return tx instanceof Transaction12 ? tx : Transaction12.from(tx);
|
|
5803
6065
|
};
|
|
5804
6066
|
|
|
5805
6067
|
// src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
|
|
5806
|
-
import { Transaction as
|
|
6068
|
+
import { Transaction as Transaction13 } from "@mysten/sui/transactions";
|
|
5807
6069
|
|
|
5808
6070
|
// src/graphql/queries/fetchNftsByKioskId.ts
|
|
5809
|
-
import { gql as
|
|
5810
|
-
var fetchNftsByKioskId =
|
|
6071
|
+
import { gql as gql16 } from "graphql-request";
|
|
6072
|
+
var fetchNftsByKioskId = gql16`
|
|
5811
6073
|
query fetchNftsByKioskId($jsonFilter: jsonb) {
|
|
5812
6074
|
nfts(where: { chain_state: { _contains: $jsonFilter } }) {
|
|
5813
6075
|
id
|
|
@@ -5828,7 +6090,7 @@ var fetchNftsByKioskId = gql17`
|
|
|
5828
6090
|
}
|
|
5829
6091
|
}
|
|
5830
6092
|
`;
|
|
5831
|
-
var fetchBulkNftsByKioskId =
|
|
6093
|
+
var fetchBulkNftsByKioskId = gql16`
|
|
5832
6094
|
query fetchNftsByKioskId($where: nfts_bool_exp) {
|
|
5833
6095
|
nfts(where: $where) {
|
|
5834
6096
|
id
|
|
@@ -5851,8 +6113,8 @@ var fetchBulkNftsByKioskId = gql17`
|
|
|
5851
6113
|
`;
|
|
5852
6114
|
|
|
5853
6115
|
// src/graphql/queries/fetchTransferPoliciesByType.ts
|
|
5854
|
-
import { gql as
|
|
5855
|
-
var fetchTransferPoliciesByType =
|
|
6116
|
+
import { gql as gql17 } from "graphql-request";
|
|
6117
|
+
var fetchTransferPoliciesByType = gql17`
|
|
5856
6118
|
query fetchTransferPoliciesByType($type: String!) {
|
|
5857
6119
|
transfer_policies_by_type(type: $type) {
|
|
5858
6120
|
id
|
|
@@ -6011,7 +6273,7 @@ async function getTransferPolicyForDirectTransfer(suiClient, collectionChainStat
|
|
|
6011
6273
|
|
|
6012
6274
|
// src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
|
|
6013
6275
|
async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }, context) {
|
|
6014
|
-
const tx = new
|
|
6276
|
+
const tx = new Transaction13();
|
|
6015
6277
|
const res = await gqlChainRequest({
|
|
6016
6278
|
chain: "sui",
|
|
6017
6279
|
query: fetchKiosksByOwner,
|
|
@@ -6177,15 +6439,15 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }
|
|
|
6177
6439
|
}
|
|
6178
6440
|
}
|
|
6179
6441
|
sharedKioskState?.kioskTx?.finalize();
|
|
6180
|
-
return
|
|
6442
|
+
return Transaction13.from(tx);
|
|
6181
6443
|
}
|
|
6182
6444
|
|
|
6183
6445
|
// src/methods/placeCollectionBids/placeCollectionBids.ts
|
|
6184
|
-
import { Transaction as
|
|
6446
|
+
import { Transaction as Transaction14 } from "@mysten/sui/transactions";
|
|
6185
6447
|
|
|
6186
6448
|
// src/graphql/queries/fetchCollectionsById.ts
|
|
6187
|
-
import { gql as
|
|
6188
|
-
var fetchCollectionsById =
|
|
6449
|
+
import { gql as gql18 } from "graphql-request";
|
|
6450
|
+
var fetchCollectionsById = gql18`
|
|
6189
6451
|
query fetchCollectionsById($collectionIds: [uuid!]) {
|
|
6190
6452
|
collections(where: { id: { _in: $collectionIds } }) {
|
|
6191
6453
|
id
|
|
@@ -6195,7 +6457,7 @@ var fetchCollectionsById = gql19`
|
|
|
6195
6457
|
}
|
|
6196
6458
|
}
|
|
6197
6459
|
`;
|
|
6198
|
-
var fetchCollectionsByIdWithOneNft =
|
|
6460
|
+
var fetchCollectionsByIdWithOneNft = gql18`
|
|
6199
6461
|
query fetchCollectionsByIdWithOneNft($collectionIds: [uuid!]) {
|
|
6200
6462
|
collections(where: { id: { _in: $collectionIds } }) {
|
|
6201
6463
|
id
|
|
@@ -6213,7 +6475,7 @@ var fetchCollectionsByIdWithOneNft = gql19`
|
|
|
6213
6475
|
}
|
|
6214
6476
|
}
|
|
6215
6477
|
`;
|
|
6216
|
-
var fetchCollectionsBySlug =
|
|
6478
|
+
var fetchCollectionsBySlug = gql18`
|
|
6217
6479
|
query fetchCollectionsBySlug($slug: String!) {
|
|
6218
6480
|
collections(where: { slug: { _eq: $slug } }) {
|
|
6219
6481
|
id
|
|
@@ -6335,8 +6597,8 @@ function isDynamicCollection(collectionId) {
|
|
|
6335
6597
|
}
|
|
6336
6598
|
|
|
6337
6599
|
// src/graphql/queries/fetchCollectionFloorListings.ts
|
|
6338
|
-
import { gql as
|
|
6339
|
-
var fetchCollectionFloorListings =
|
|
6600
|
+
import { gql as gql19 } from "graphql-request";
|
|
6601
|
+
var fetchCollectionFloorListings = gql19`
|
|
6340
6602
|
query fetchCollectionFloorListings($collectionId: uuid!) {
|
|
6341
6603
|
listings(
|
|
6342
6604
|
where: { collection_id: { _eq: $collectionId }, listed: { _eq: true }, nft: {} }
|
|
@@ -6395,14 +6657,7 @@ async function addOriginByteCollectionBidTx({
|
|
|
6395
6657
|
}
|
|
6396
6658
|
|
|
6397
6659
|
// src/methods/placeCollectionBids/placeCollectionBids.ts
|
|
6398
|
-
var placeCollectionBids = async ({
|
|
6399
|
-
collections,
|
|
6400
|
-
walletAddress,
|
|
6401
|
-
multiBidId,
|
|
6402
|
-
multiBidChainId,
|
|
6403
|
-
tx: existingTx,
|
|
6404
|
-
coinToSplit
|
|
6405
|
-
}, context) => {
|
|
6660
|
+
var placeCollectionBids = async ({ collections, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
|
|
6406
6661
|
const res = await gqlChainRequest({
|
|
6407
6662
|
chain: "sui",
|
|
6408
6663
|
query: fetchCollectionsByIdWithOneNft,
|
|
@@ -6412,7 +6667,8 @@ var placeCollectionBids = async ({
|
|
|
6412
6667
|
throw new Error("No collection found");
|
|
6413
6668
|
}
|
|
6414
6669
|
const collectionsForTracking = [];
|
|
6415
|
-
const tx = existingTx
|
|
6670
|
+
const tx = deserializeOrCreateTxBlock({ existingTx });
|
|
6671
|
+
const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
|
|
6416
6672
|
for (const collection of res.collections) {
|
|
6417
6673
|
const nftType = getNftType({
|
|
6418
6674
|
collectionId: collection?.id,
|
|
@@ -6432,7 +6688,7 @@ var placeCollectionBids = async ({
|
|
|
6432
6688
|
multiBidId,
|
|
6433
6689
|
multiBidChainId,
|
|
6434
6690
|
expireAt: collections?.find((c) => c.id === collection?.id)?.expireAt,
|
|
6435
|
-
coinToSplit
|
|
6691
|
+
coinToSplit: swapResultCoin
|
|
6436
6692
|
};
|
|
6437
6693
|
const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
|
|
6438
6694
|
if (isOriginByteCollection(txData?.transferPolicies) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
|
|
@@ -6459,13 +6715,17 @@ var placeCollectionBids = async ({
|
|
|
6459
6715
|
bidder: walletAddress
|
|
6460
6716
|
});
|
|
6461
6717
|
}
|
|
6462
|
-
|
|
6718
|
+
if (swapResultCoin) {
|
|
6719
|
+
tx.transferObjects([swapResultCoin], walletAddress);
|
|
6720
|
+
}
|
|
6721
|
+
return Transaction14.from(tx);
|
|
6463
6722
|
};
|
|
6464
6723
|
|
|
6465
6724
|
// src/methods/placeNftBids/placeNftBids.ts
|
|
6466
|
-
import { Transaction as
|
|
6467
|
-
var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx
|
|
6468
|
-
const tx = existingTx
|
|
6725
|
+
import { Transaction as Transaction15 } from "@mysten/sui/transactions";
|
|
6726
|
+
var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
|
|
6727
|
+
const tx = deserializeOrCreateTxBlock({ existingTx });
|
|
6728
|
+
const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
|
|
6469
6729
|
const res = await gqlChainRequest({
|
|
6470
6730
|
chain: "sui",
|
|
6471
6731
|
query: fetchNftsById,
|
|
@@ -6499,7 +6759,7 @@ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx
|
|
|
6499
6759
|
multiBidId,
|
|
6500
6760
|
multiBidChainId,
|
|
6501
6761
|
expireAt: bid?.expireAt,
|
|
6502
|
-
coinToSplit
|
|
6762
|
+
coinToSplit: swapResultCoin
|
|
6503
6763
|
};
|
|
6504
6764
|
await addTradePortPlaceNftBidTxHandler(txData);
|
|
6505
6765
|
nftsForTracking.push({
|
|
@@ -6509,11 +6769,14 @@ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx
|
|
|
6509
6769
|
bidder: walletAddress
|
|
6510
6770
|
});
|
|
6511
6771
|
}
|
|
6512
|
-
|
|
6772
|
+
if (swapResultCoin) {
|
|
6773
|
+
tx.transferObjects([swapResultCoin], walletAddress);
|
|
6774
|
+
}
|
|
6775
|
+
return Transaction15.from(tx);
|
|
6513
6776
|
};
|
|
6514
6777
|
|
|
6515
6778
|
// src/methods/removeCollectionBids/removeCollectionBids.ts
|
|
6516
|
-
import { Transaction as
|
|
6779
|
+
import { Transaction as Transaction16 } from "@mysten/sui/transactions";
|
|
6517
6780
|
|
|
6518
6781
|
// src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts
|
|
6519
6782
|
import { normalizeSuiObjectId as normalizeSuiObjectId7 } from "@mysten/sui/utils";
|
|
@@ -6621,7 +6884,7 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
|
6621
6884
|
throw new Error("No bids found");
|
|
6622
6885
|
}
|
|
6623
6886
|
const bidsForTracking = [];
|
|
6624
|
-
const tx = existingTx ?
|
|
6887
|
+
const tx = existingTx ? Transaction16.from(existingTx) : new Transaction16();
|
|
6625
6888
|
for (const bid of res.bids) {
|
|
6626
6889
|
if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
|
|
6627
6890
|
throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
|
|
@@ -6669,11 +6932,11 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
|
6669
6932
|
bidder: bid?.bidder
|
|
6670
6933
|
});
|
|
6671
6934
|
}
|
|
6672
|
-
return
|
|
6935
|
+
return Transaction16.from(tx);
|
|
6673
6936
|
};
|
|
6674
6937
|
|
|
6675
6938
|
// src/methods/removeNftBids/removeNftBids.ts
|
|
6676
|
-
import { Transaction as
|
|
6939
|
+
import { Transaction as Transaction17 } from "@mysten/sui/transactions";
|
|
6677
6940
|
var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
6678
6941
|
const res = await gqlChainRequest({
|
|
6679
6942
|
chain: "sui",
|
|
@@ -6684,7 +6947,7 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
|
6684
6947
|
throw new Error("No bids found");
|
|
6685
6948
|
}
|
|
6686
6949
|
const bidsForTracking = [];
|
|
6687
|
-
const tx = existingTx ?
|
|
6950
|
+
const tx = existingTx ? Transaction17.from(existingTx) : new Transaction17();
|
|
6688
6951
|
for (const bid of res.bids) {
|
|
6689
6952
|
if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
|
|
6690
6953
|
throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
|
|
@@ -6729,63 +6992,11 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
|
6729
6992
|
bidder: bid?.bidder
|
|
6730
6993
|
});
|
|
6731
6994
|
}
|
|
6732
|
-
return
|
|
6733
|
-
};
|
|
6734
|
-
|
|
6735
|
-
// src/methods/sponsorNftListing/sponsorNftListing.ts
|
|
6736
|
-
import { Transaction as Transaction19 } from "@mysten/sui/transactions";
|
|
6737
|
-
|
|
6738
|
-
// src/graphql/queries/fetchNftCollectionChainState.ts
|
|
6739
|
-
import { gql as gql21 } from "graphql-request";
|
|
6740
|
-
var fetchNftCollectionChainState = gql21`
|
|
6741
|
-
query fetchNftCollectionChainState($nftTokenId: String!) {
|
|
6742
|
-
nfts(where: { token_id: { _eq: $nftTokenId } }) {
|
|
6743
|
-
collection {
|
|
6744
|
-
id
|
|
6745
|
-
chain_state
|
|
6746
|
-
}
|
|
6747
|
-
}
|
|
6748
|
-
}
|
|
6749
|
-
`;
|
|
6750
|
-
|
|
6751
|
-
// src/methods/sponsorNftListing/sponsorNftListing.ts
|
|
6752
|
-
var sponsorNftListing = async ({
|
|
6753
|
-
tx: existingTx,
|
|
6754
|
-
coinToSplit,
|
|
6755
|
-
nftTokenId,
|
|
6756
|
-
options
|
|
6757
|
-
}) => {
|
|
6758
|
-
const res = await gqlChainRequest({
|
|
6759
|
-
chain: "sui",
|
|
6760
|
-
query: fetchNftCollectionChainState,
|
|
6761
|
-
variables: { nftTokenId }
|
|
6762
|
-
});
|
|
6763
|
-
if (res?.nfts?.length === 0) {
|
|
6764
|
-
throw new Error(`No nft found with token id ${nftTokenId}`);
|
|
6765
|
-
}
|
|
6766
|
-
const nft = res?.nfts?.[0];
|
|
6767
|
-
const nftType = getNftType({
|
|
6768
|
-
collectionId: nft?.collection?.id,
|
|
6769
|
-
collectionChainState: nft?.collection?.chain_state,
|
|
6770
|
-
nft
|
|
6771
|
-
});
|
|
6772
|
-
const transferPolicies = nft?.collection?.chain_state?.transfer_policies;
|
|
6773
|
-
if (isOriginByteCollection(transferPolicies)) {
|
|
6774
|
-
throw new Error(`You cannot sponsor an Origin Byte NFT. Nft Token Id: ${nftTokenId}`);
|
|
6775
|
-
}
|
|
6776
|
-
const tx = existingTx ?? new Transaction19();
|
|
6777
|
-
await addSponsorListingTx({
|
|
6778
|
-
tx,
|
|
6779
|
-
coinToSplit,
|
|
6780
|
-
nftTokenId,
|
|
6781
|
-
nftType,
|
|
6782
|
-
sponsorOptions: options
|
|
6783
|
-
});
|
|
6784
|
-
return tx;
|
|
6995
|
+
return Transaction17.from(tx);
|
|
6785
6996
|
};
|
|
6786
6997
|
|
|
6787
6998
|
// src/methods/transferNfts/transferNfts.ts
|
|
6788
|
-
import { Transaction as
|
|
6999
|
+
import { Transaction as Transaction18 } from "@mysten/sui/transactions";
|
|
6789
7000
|
var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context) => {
|
|
6790
7001
|
if (addLeadingZerosAfter0x(recipientAddress) === addLeadingZerosAfter0x(walletAddress)) {
|
|
6791
7002
|
throw new Error("Cannot transfer to self");
|
|
@@ -6803,7 +7014,7 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
|
|
|
6803
7014
|
}
|
|
6804
7015
|
const nftsForTracking = [];
|
|
6805
7016
|
const nftsToTransferDirectly = [];
|
|
6806
|
-
const tx = new
|
|
7017
|
+
const tx = new Transaction18();
|
|
6807
7018
|
const sharedKioskState = {
|
|
6808
7019
|
kioskTx: void 0
|
|
6809
7020
|
};
|
|
@@ -6906,11 +7117,11 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
|
|
|
6906
7117
|
context.suiClient
|
|
6907
7118
|
);
|
|
6908
7119
|
sharedKioskState?.kioskTx?.finalize();
|
|
6909
|
-
return
|
|
7120
|
+
return Transaction18.from(tx);
|
|
6910
7121
|
};
|
|
6911
7122
|
|
|
6912
7123
|
// src/methods/unlistListings/unlistListings.ts
|
|
6913
|
-
import { Transaction as
|
|
7124
|
+
import { Transaction as Transaction19 } from "@mysten/sui/transactions";
|
|
6914
7125
|
var unlistListings = async ({ listingIds, walletAddress }, context) => {
|
|
6915
7126
|
const res = await gqlChainRequest({
|
|
6916
7127
|
chain: "sui",
|
|
@@ -6921,7 +7132,7 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
|
|
|
6921
7132
|
throw new Error("No listings found");
|
|
6922
7133
|
}
|
|
6923
7134
|
const listingsForTracking = [];
|
|
6924
|
-
const tx = new
|
|
7135
|
+
const tx = new Transaction19();
|
|
6925
7136
|
const sharedKioskState = {
|
|
6926
7137
|
kioskTx: void 0
|
|
6927
7138
|
};
|
|
@@ -6990,12 +7201,12 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
|
|
|
6990
7201
|
});
|
|
6991
7202
|
}
|
|
6992
7203
|
sharedKioskState?.kioskTx?.finalize();
|
|
6993
|
-
return
|
|
7204
|
+
return Transaction19.from(tx);
|
|
6994
7205
|
};
|
|
6995
7206
|
|
|
6996
7207
|
// src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts
|
|
6997
7208
|
import { KioskTransaction as KioskTransaction2 } from "@mysten/kiosk";
|
|
6998
|
-
import { Transaction as
|
|
7209
|
+
import { Transaction as Transaction20 } from "@mysten/sui/transactions";
|
|
6999
7210
|
async function withdrawProfitsFromKiosks({ walletAddress }, context) {
|
|
7000
7211
|
const res = await gqlChainRequest({
|
|
7001
7212
|
chain: "sui",
|
|
@@ -7015,7 +7226,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
|
|
|
7015
7226
|
if (kiosksWithProfit.length === 0) {
|
|
7016
7227
|
throw new Error(`No kiosks with profit to withdraw found for ${walletAddress}`);
|
|
7017
7228
|
}
|
|
7018
|
-
const tx = new
|
|
7229
|
+
const tx = new Transaction20();
|
|
7019
7230
|
try {
|
|
7020
7231
|
for (const kiosk of kiosksWithProfit) {
|
|
7021
7232
|
let kioskTx;
|
|
@@ -7061,7 +7272,149 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
|
|
|
7061
7272
|
} catch (err) {
|
|
7062
7273
|
console.log("err", err);
|
|
7063
7274
|
}
|
|
7064
|
-
return
|
|
7275
|
+
return Transaction20.from(tx);
|
|
7276
|
+
}
|
|
7277
|
+
|
|
7278
|
+
// src/methods/sponsorNftListing/sponsorNftListing.ts
|
|
7279
|
+
import { Transaction as Transaction21 } from "@mysten/sui/transactions";
|
|
7280
|
+
|
|
7281
|
+
// src/graphql/queries/fetchNftCollectionChainState.ts
|
|
7282
|
+
import { gql as gql20 } from "graphql-request";
|
|
7283
|
+
var fetchNftCollectionChainState = gql20`
|
|
7284
|
+
query fetchNftCollectionChainState($nftTokenId: String!) {
|
|
7285
|
+
nfts(where: { token_id: { _eq: $nftTokenId } }) {
|
|
7286
|
+
collection {
|
|
7287
|
+
id
|
|
7288
|
+
chain_state
|
|
7289
|
+
}
|
|
7290
|
+
}
|
|
7291
|
+
}
|
|
7292
|
+
`;
|
|
7293
|
+
|
|
7294
|
+
// src/methods/sponsorNftListing/sponsorNftListing.ts
|
|
7295
|
+
var sponsorNftListing = async ({ nftTokenId, walletAddress, options }, context) => {
|
|
7296
|
+
const res = await gqlChainRequest({
|
|
7297
|
+
chain: "sui",
|
|
7298
|
+
query: fetchNftCollectionChainState,
|
|
7299
|
+
variables: { nftTokenId }
|
|
7300
|
+
});
|
|
7301
|
+
if (res?.nfts?.length === 0) {
|
|
7302
|
+
throw new Error(`No nft found with token id ${nftTokenId}`);
|
|
7303
|
+
}
|
|
7304
|
+
const nft = res?.nfts?.[0];
|
|
7305
|
+
const nftType = getNftType({
|
|
7306
|
+
collectionId: nft?.collection?.id,
|
|
7307
|
+
collectionChainState: nft?.collection?.chain_state,
|
|
7308
|
+
nft
|
|
7309
|
+
});
|
|
7310
|
+
const transferPolicies = nft?.collection?.chain_state?.transfer_policies;
|
|
7311
|
+
if (isOriginByteCollection(transferPolicies)) {
|
|
7312
|
+
throw new Error(`You cannot sponsor an Origin Byte NFT. Nft Token Id: ${nftTokenId}`);
|
|
7313
|
+
}
|
|
7314
|
+
const tx = new Transaction21();
|
|
7315
|
+
await addSponsorListingTx({
|
|
7316
|
+
tx,
|
|
7317
|
+
suiClient: context.suiClient,
|
|
7318
|
+
nftTokenId,
|
|
7319
|
+
nftType,
|
|
7320
|
+
walletAddress,
|
|
7321
|
+
sponsorOptions: options,
|
|
7322
|
+
defiRouterUrl: context.defiRouterUrl
|
|
7323
|
+
});
|
|
7324
|
+
return tx instanceof Transaction21 ? tx : Transaction21.from(tx);
|
|
7325
|
+
};
|
|
7326
|
+
|
|
7327
|
+
// src/methods/applyNftStrategy/applyNftStrategy.ts
|
|
7328
|
+
import { Transaction as Transaction22 } from "@mysten/sui/transactions";
|
|
7329
|
+
|
|
7330
|
+
// src/graphql/queries/fetchCollectionFloorListingForMarket.ts
|
|
7331
|
+
import { gql as gql21 } from "graphql-request";
|
|
7332
|
+
var fetchCollectionFloorListingsForMarket = gql21`
|
|
7333
|
+
query fetchCollectionFloorListingsForMarket(
|
|
7334
|
+
$collectionId: uuid!
|
|
7335
|
+
$marketAddress: String!
|
|
7336
|
+
$totalPrice: numeric
|
|
7337
|
+
) {
|
|
7338
|
+
listings(
|
|
7339
|
+
where: {
|
|
7340
|
+
collection_id: { _eq: $collectionId }
|
|
7341
|
+
listed: { _eq: true }
|
|
7342
|
+
market_name: { _eq: "tradeport" }
|
|
7343
|
+
seller: { _neq: $marketAddress }
|
|
7344
|
+
nonce: { _like: "1::0x%" }
|
|
7345
|
+
price: { _lte: $totalPrice }
|
|
7346
|
+
}
|
|
7347
|
+
order_by: [{ price: asc_nulls_last }, { block_height: asc }, { tx_index: asc }]
|
|
7348
|
+
) {
|
|
7349
|
+
id
|
|
7350
|
+
price
|
|
7351
|
+
nft {
|
|
7352
|
+
token_id
|
|
7353
|
+
delegated_owner
|
|
7354
|
+
}
|
|
7355
|
+
}
|
|
7356
|
+
}
|
|
7357
|
+
`;
|
|
7358
|
+
|
|
7359
|
+
// src/methods/applyNftStrategy/applyNftStrategy.ts
|
|
7360
|
+
async function applyTradeportNftStrategy({
|
|
7361
|
+
collectionId,
|
|
7362
|
+
strategyFtType,
|
|
7363
|
+
tx: existingTx
|
|
7364
|
+
}) {
|
|
7365
|
+
const tx = existingTx ?? new Transaction22();
|
|
7366
|
+
const chainState = await getCollectionChainState(collectionId);
|
|
7367
|
+
const nftStrategies = chainState?.nft_strategies ?? {};
|
|
7368
|
+
const nftStrategyKeys = Object.keys(nftStrategies);
|
|
7369
|
+
if (nftStrategyKeys.length === 0) {
|
|
7370
|
+
throw new Error("No NFT strategies found for collection");
|
|
7371
|
+
}
|
|
7372
|
+
strategyFtType = strategyFtType ?? nftStrategyKeys[0];
|
|
7373
|
+
if (!nftStrategyKeys.includes(strategyFtType)) {
|
|
7374
|
+
throw new Error(`Specified FT type ${strategyFtType} is not supported for this collection`);
|
|
7375
|
+
}
|
|
7376
|
+
const transferPolicy = getNativeKioskTransferPolicies(chainState?.transfer_policies ?? [])?.at(0);
|
|
7377
|
+
if (!transferPolicy) {
|
|
7378
|
+
throw new Error("No transfer policy found for collection");
|
|
7379
|
+
}
|
|
7380
|
+
const nftType = chainState?.nft_type;
|
|
7381
|
+
let suiBalance = BigInt(
|
|
7382
|
+
nftStrategies[strategyFtType].sui_balance ?? 0n
|
|
7383
|
+
);
|
|
7384
|
+
const result = await gqlChainRequest({
|
|
7385
|
+
chain: "sui",
|
|
7386
|
+
query: fetchCollectionFloorListingsForMarket,
|
|
7387
|
+
variables: {
|
|
7388
|
+
collectionId,
|
|
7389
|
+
marketAddress: TRADEPORT_NFT_STRATEGY_MANAGER_ID,
|
|
7390
|
+
totalPrice: suiBalance.toString()
|
|
7391
|
+
}
|
|
7392
|
+
});
|
|
7393
|
+
if ((result?.listings?.length ?? 0) === 0) {
|
|
7394
|
+
throw new Error(
|
|
7395
|
+
`No floor listing found for collection with price bellow or equal to ${suiBalance} MIST`
|
|
7396
|
+
);
|
|
7397
|
+
}
|
|
7398
|
+
for (const floorListing of result.listings) {
|
|
7399
|
+
suiBalance -= BigInt(floorListing.price);
|
|
7400
|
+
if (suiBalance < 0n) {
|
|
7401
|
+
break;
|
|
7402
|
+
}
|
|
7403
|
+
tx.moveCall({
|
|
7404
|
+
target: `${TRADEPORT_NFT_STRATEGY_PACKAGE_ID}::tradeport_nft_strategy::apply_tradeport_nft_strategy_confirm_request`,
|
|
7405
|
+
typeArguments: [nftType, strategyFtType],
|
|
7406
|
+
arguments: [
|
|
7407
|
+
tx.object(TRADEPORT_NFT_STRATEGY_MANAGER_ID),
|
|
7408
|
+
tx.object(nftStrategies[strategyFtType].kiosk_id),
|
|
7409
|
+
tx.object(TRADEPORT_LISTINGS_STORE),
|
|
7410
|
+
tx.object(TRADEPORT_ORDERBOOK_STORE),
|
|
7411
|
+
tx.object(floorListing.nft.delegated_owner),
|
|
7412
|
+
tx.object(floorListing.nft.token_id),
|
|
7413
|
+
tx.object(transferPolicy.id)
|
|
7414
|
+
]
|
|
7415
|
+
});
|
|
7416
|
+
}
|
|
7417
|
+
return tx;
|
|
7065
7418
|
}
|
|
7066
7419
|
|
|
7067
7420
|
// src/SuiTradingClient.ts
|
|
@@ -7071,14 +7424,14 @@ var SuiTradingClient = class {
|
|
|
7071
7424
|
apiKey,
|
|
7072
7425
|
apiVercelId,
|
|
7073
7426
|
apiUrl,
|
|
7074
|
-
|
|
7427
|
+
defiRouterUrl,
|
|
7075
7428
|
suiNodeUrl,
|
|
7076
7429
|
graphQLClient
|
|
7077
7430
|
}) {
|
|
7078
7431
|
this.allowedApiUsersForUnsharedKiosksMigration = ["tradeport.xyz", "mercato.xyz"];
|
|
7079
7432
|
this.apiUser = apiUser;
|
|
7080
7433
|
this.apiKey = apiKey;
|
|
7081
|
-
this.
|
|
7434
|
+
this.defiRouterUrl = defiRouterUrl ?? "https://api.indexer.xyz/router";
|
|
7082
7435
|
this.suiClient = createSuiClient_default(suiNodeUrl ?? getFullnodeUrl("mainnet"));
|
|
7083
7436
|
this.kioskClient = createKioskClient_default(this.suiClient);
|
|
7084
7437
|
if (graphQLClient) {
|
|
@@ -7092,31 +7445,31 @@ var SuiTradingClient = class {
|
|
|
7092
7445
|
...apiVercelId && { "x-vercel-id": apiVercelId }
|
|
7093
7446
|
});
|
|
7094
7447
|
}
|
|
7095
|
-
async buyListings(
|
|
7448
|
+
async buyListings({ listingIds, walletAddress, tx }) {
|
|
7096
7449
|
const context = {
|
|
7097
7450
|
apiUser: this.apiUser,
|
|
7098
7451
|
apiKey: this.apiKey,
|
|
7099
|
-
|
|
7452
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7100
7453
|
suiClient: this.suiClient,
|
|
7101
7454
|
kioskClient: this.kioskClient
|
|
7102
7455
|
};
|
|
7103
|
-
return buyListings(
|
|
7456
|
+
return buyListings({ listingIds, walletAddress, tx }, context);
|
|
7104
7457
|
}
|
|
7105
|
-
async listNfts({ nfts, walletAddress
|
|
7458
|
+
async listNfts({ nfts, walletAddress }) {
|
|
7106
7459
|
const context = {
|
|
7107
7460
|
apiUser: this.apiUser,
|
|
7108
7461
|
apiKey: this.apiKey,
|
|
7109
|
-
|
|
7462
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7110
7463
|
suiClient: this.suiClient,
|
|
7111
7464
|
kioskClient: this.kioskClient
|
|
7112
7465
|
};
|
|
7113
|
-
return listNfts({ nfts, walletAddress
|
|
7466
|
+
return listNfts({ nfts, walletAddress }, context);
|
|
7114
7467
|
}
|
|
7115
7468
|
async unlistListings({ listingIds, walletAddress }) {
|
|
7116
7469
|
const context = {
|
|
7117
7470
|
apiUser: this.apiUser,
|
|
7118
7471
|
apiKey: this.apiKey,
|
|
7119
|
-
|
|
7472
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7120
7473
|
suiClient: this.suiClient,
|
|
7121
7474
|
kioskClient: this.kioskClient
|
|
7122
7475
|
};
|
|
@@ -7126,7 +7479,7 @@ var SuiTradingClient = class {
|
|
|
7126
7479
|
const context = {
|
|
7127
7480
|
apiUser: this.apiUser,
|
|
7128
7481
|
apiKey: this.apiKey,
|
|
7129
|
-
|
|
7482
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7130
7483
|
suiClient: this.suiClient,
|
|
7131
7484
|
kioskClient: this.kioskClient
|
|
7132
7485
|
};
|
|
@@ -7135,7 +7488,7 @@ var SuiTradingClient = class {
|
|
|
7135
7488
|
async removeNftBids({ bidIds, tx }) {
|
|
7136
7489
|
const context = {
|
|
7137
7490
|
apiUser: this.apiUser,
|
|
7138
|
-
|
|
7491
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7139
7492
|
apiKey: this.apiKey,
|
|
7140
7493
|
suiClient: this.suiClient,
|
|
7141
7494
|
kioskClient: this.kioskClient
|
|
@@ -7146,7 +7499,7 @@ var SuiTradingClient = class {
|
|
|
7146
7499
|
const context = {
|
|
7147
7500
|
apiUser: this.apiUser,
|
|
7148
7501
|
apiKey: this.apiKey,
|
|
7149
|
-
|
|
7502
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7150
7503
|
suiClient: this.suiClient,
|
|
7151
7504
|
kioskClient: this.kioskClient
|
|
7152
7505
|
};
|
|
@@ -7165,7 +7518,7 @@ var SuiTradingClient = class {
|
|
|
7165
7518
|
const context = {
|
|
7166
7519
|
apiUser: this.apiUser,
|
|
7167
7520
|
apiKey: this.apiKey,
|
|
7168
|
-
|
|
7521
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7169
7522
|
suiClient: this.suiClient,
|
|
7170
7523
|
kioskClient: this.kioskClient
|
|
7171
7524
|
};
|
|
@@ -7191,7 +7544,7 @@ var SuiTradingClient = class {
|
|
|
7191
7544
|
const context = {
|
|
7192
7545
|
apiUser: this.apiUser,
|
|
7193
7546
|
apiKey: this.apiKey,
|
|
7194
|
-
|
|
7547
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7195
7548
|
suiClient: this.suiClient,
|
|
7196
7549
|
kioskClient: this.kioskClient
|
|
7197
7550
|
};
|
|
@@ -7267,7 +7620,7 @@ var SuiTradingClient = class {
|
|
|
7267
7620
|
const context = {
|
|
7268
7621
|
apiUser: this.apiUser,
|
|
7269
7622
|
apiKey: this.apiKey,
|
|
7270
|
-
|
|
7623
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7271
7624
|
suiClient: this.suiClient,
|
|
7272
7625
|
kioskClient: this.kioskClient
|
|
7273
7626
|
};
|
|
@@ -7277,7 +7630,7 @@ var SuiTradingClient = class {
|
|
|
7277
7630
|
const context = {
|
|
7278
7631
|
apiUser: this.apiUser,
|
|
7279
7632
|
apiKey: this.apiKey,
|
|
7280
|
-
|
|
7633
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7281
7634
|
suiClient: this.suiClient,
|
|
7282
7635
|
kioskClient: this.kioskClient
|
|
7283
7636
|
};
|
|
@@ -7287,7 +7640,7 @@ var SuiTradingClient = class {
|
|
|
7287
7640
|
const context = {
|
|
7288
7641
|
apiUser: this.apiUser,
|
|
7289
7642
|
apiKey: this.apiKey,
|
|
7290
|
-
|
|
7643
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7291
7644
|
suiClient: this.suiClient,
|
|
7292
7645
|
kioskClient: this.kioskClient
|
|
7293
7646
|
};
|
|
@@ -7303,7 +7656,7 @@ var SuiTradingClient = class {
|
|
|
7303
7656
|
const context = {
|
|
7304
7657
|
apiUser: this.apiUser,
|
|
7305
7658
|
apiKey: this.apiKey,
|
|
7306
|
-
|
|
7659
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7307
7660
|
suiClient: this.suiClient,
|
|
7308
7661
|
kioskClient: this.kioskClient
|
|
7309
7662
|
};
|
|
@@ -7323,7 +7676,7 @@ var SuiTradingClient = class {
|
|
|
7323
7676
|
const context = {
|
|
7324
7677
|
apiUser: this.apiUser,
|
|
7325
7678
|
apiKey: this.apiKey,
|
|
7326
|
-
|
|
7679
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7327
7680
|
suiClient: this.suiClient,
|
|
7328
7681
|
kioskClient: this.kioskClient
|
|
7329
7682
|
};
|
|
@@ -7336,7 +7689,7 @@ var SuiTradingClient = class {
|
|
|
7336
7689
|
const context = {
|
|
7337
7690
|
apiUser: this.apiUser,
|
|
7338
7691
|
apiKey: this.apiKey,
|
|
7339
|
-
|
|
7692
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7340
7693
|
suiClient: this.suiClient,
|
|
7341
7694
|
kioskClient: this.kioskClient
|
|
7342
7695
|
};
|
|
@@ -7349,13 +7702,17 @@ var SuiTradingClient = class {
|
|
|
7349
7702
|
return cancelMultiBid(args);
|
|
7350
7703
|
}
|
|
7351
7704
|
async updateMultiBid(args) {
|
|
7352
|
-
return updateMultiBid(args
|
|
7353
|
-
suiClient: this.suiClient,
|
|
7354
|
-
tradeportRouterUrl: this.tradeportRouterUrl
|
|
7355
|
-
});
|
|
7705
|
+
return updateMultiBid(args);
|
|
7356
7706
|
}
|
|
7357
7707
|
async sponsorNftListing(args) {
|
|
7358
|
-
|
|
7708
|
+
const context = {
|
|
7709
|
+
apiUser: this.apiUser,
|
|
7710
|
+
apiKey: this.apiKey,
|
|
7711
|
+
defiRouterUrl: this.defiRouterUrl,
|
|
7712
|
+
suiClient: this.suiClient,
|
|
7713
|
+
kioskClient: this.kioskClient
|
|
7714
|
+
};
|
|
7715
|
+
return sponsorNftListing(args, context);
|
|
7359
7716
|
}
|
|
7360
7717
|
async applyFtStrategy(args) {
|
|
7361
7718
|
return applyFtStrategy(args);
|
|
@@ -7363,6 +7720,15 @@ var SuiTradingClient = class {
|
|
|
7363
7720
|
async applyTradeportNftStrategy(args) {
|
|
7364
7721
|
return applyTradeportNftStrategy(args);
|
|
7365
7722
|
}
|
|
7723
|
+
async swapCoins(args) {
|
|
7724
|
+
return swapCoins(args, { suiClient: this.suiClient, defiRouterUrl: this.defiRouterUrl });
|
|
7725
|
+
}
|
|
7726
|
+
async buildSwapRoutes(args) {
|
|
7727
|
+
return buildSwapRoutes(args, { defiRouterUrl: this.defiRouterUrl });
|
|
7728
|
+
}
|
|
7729
|
+
async calculateAmountToSwap(args) {
|
|
7730
|
+
return calculateAmountToSwap(args);
|
|
7731
|
+
}
|
|
7366
7732
|
};
|
|
7367
7733
|
var SuiTradingClient_default = SuiTradingClient;
|
|
7368
7734
|
export {
|