@tradeport/sui-trading-sdk 0.4.40 → 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.
Files changed (54) hide show
  1. package/dist/index.d.mts +16 -19
  2. package/dist/index.d.ts +16 -19
  3. package/dist/index.js +627 -377
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +604 -351
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +4 -3
  8. package/src/SuiTradingClient.ts +19 -18
  9. package/src/bigNumberConfig.ts +10 -0
  10. package/src/constants.ts +17 -1
  11. package/src/graphql/queries/fetchNftCollectionChainState.ts +12 -0
  12. package/src/helpers/calculateRoyaltyFee.ts +12 -7
  13. package/src/helpers/extractSwapResultCoin.ts +17 -0
  14. package/src/helpers/isExpiredListing.ts +9 -0
  15. package/src/helpers/kiosk/getKioskIdFromKioskTx.ts +1 -1
  16. package/src/helpers/kiosk/kioskTxWrapper.ts +3 -3
  17. package/src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts +1 -1
  18. package/src/helpers/kiosk/preProcessSharedBulkBuyingData.ts +9 -8
  19. package/src/helpers/kiosk/resolveRoyaltyRule.ts +0 -5
  20. package/src/helpers/kiosk/resolveTransferPolicies.ts +0 -3
  21. package/src/helpers/kiosk/takeLockedNftFromKiosk.ts +4 -12
  22. package/src/helpers/swap.ts +197 -0
  23. package/src/helpers/validateMinFloorPrice.ts +22 -0
  24. package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +1 -1
  25. package/src/methods/acceptNftBids/acceptNftBids.ts +1 -1
  26. package/src/methods/buyListings/addBuyListingTxs.ts +111 -10
  27. package/src/methods/buyListings/buyListings.ts +7 -20
  28. package/src/methods/buyLocks/buyLocks.ts +2 -2
  29. package/src/methods/cancelNftTransfers/cancelNftTransfers.ts +1 -1
  30. package/src/methods/claimNfts/claimNfts.ts +1 -1
  31. package/src/methods/createLongLocks/createLongLocks.ts +2 -2
  32. package/src/methods/createMultiBid/createMultiBid.ts +7 -6
  33. package/src/methods/createShortLocks/createShortLocks.ts +3 -3
  34. package/src/methods/listNfts/addListTxs.ts +17 -37
  35. package/src/methods/listNfts/addRelistTxs.ts +26 -17
  36. package/src/methods/listNfts/listNfts.ts +28 -17
  37. package/src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts +1 -1
  38. package/src/methods/placeCollectionBids/placeCollectionBids.ts +8 -28
  39. package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +6 -7
  40. package/src/methods/placeNftBids/placeNftBids.ts +8 -27
  41. package/src/methods/relistNft/relistNft.ts +19 -28
  42. package/src/methods/removeCollectionBids/removeCollectionBids.ts +1 -1
  43. package/src/methods/removeNftBids/removeNftBids.ts +1 -1
  44. package/src/methods/sponsorNftListing/addSponsorNftListingTx.ts +71 -0
  45. package/src/methods/sponsorNftListing/sponsorNftListing.ts +62 -0
  46. package/src/methods/transferNfts/transferNfts.ts +1 -1
  47. package/src/methods/unlistListings/addUnlistListingTxs.ts +68 -5
  48. package/src/methods/unlistListings/unlistListings.ts +4 -7
  49. package/src/methods/updateMultiBid/updateMultiBid.ts +4 -35
  50. package/src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts +3 -3
  51. package/src/tests/SuiWallet.ts +4 -1
  52. package/src/utils/printTxBlockTxs.ts +7 -1
  53. package/src/utils/pureValues.ts +13 -0
  54. package/src/helpers/swap/swap.ts +0 -147
package/dist/index.d.mts CHANGED
@@ -1,9 +1,6 @@
1
1
  import { Transaction } from '@mysten/sui/transactions';
2
2
  import { GraphQLClient } from 'graphql-request';
3
3
  import { KioskTransaction } from '@mysten/kiosk';
4
- import { Protocol } from '@flowx-finance/sdk';
5
- import { StringValue } from 'ms';
6
- import { SuiClient } from '@mysten/sui/client';
7
4
 
8
5
  type AcceptCollectionBid = {
9
6
  bidId: string;
@@ -37,22 +34,12 @@ type BuyAndExerciseShortLocks = {
37
34
  tx?: Transaction;
38
35
  };
39
36
 
40
- interface SwapAndPayOptions {
41
- coinType?: string;
42
- coinAmount?: string;
43
- slippage?: number;
44
- ttl?: StringValue;
45
- excludeSources?: Protocol[];
46
- amountToSplitFromSuiBalance?: string;
47
- }
48
-
49
37
  type BuyListings = {
50
38
  listingIds: string[];
51
39
  walletAddress: string;
52
40
  tx?: Transaction | string;
53
41
  kioskTx?: KioskTransaction;
54
42
  coinToSplit?: any;
55
- swapAndPayOptions?: SwapAndPayOptions;
56
43
  beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
57
44
  };
58
45
 
@@ -125,10 +112,23 @@ type ExerciseShortLocks = {
125
112
  }>;
126
113
  };
127
114
 
115
+ type SponsorNftListingOptions = {
116
+ shouldSponsor?: boolean;
117
+ numOfPeriods?: number;
118
+ slippage?: number;
119
+ coinInType?: string;
120
+ };
121
+ type SponsorNftListing = {
122
+ nftTokenId: string;
123
+ walletAddress: string;
124
+ options: SponsorNftListingOptions;
125
+ };
126
+
128
127
  type ListNfts = {
129
128
  nfts: Array<{
130
129
  id: string;
131
130
  listPriceInMist: number;
131
+ sponsorOptions?: SponsorNftListingOptions;
132
132
  }>;
133
133
  walletAddress: string;
134
134
  };
@@ -147,7 +147,6 @@ type PlaceCollectionBid = {
147
147
  multiBidChainId?: any;
148
148
  expireAt?: Date;
149
149
  tx?: Transaction | string;
150
- swapAndPayOptions?: SwapAndPayOptions;
151
150
  };
152
151
 
153
152
  type PlaceNftBids = {
@@ -160,7 +159,6 @@ type PlaceNftBids = {
160
159
  multiBidId?: string;
161
160
  multiBidChainId?: any;
162
161
  tx?: Transaction | string;
163
- swapAndPayOptions?: SwapAndPayOptions;
164
162
  };
165
163
 
166
164
  type RemoveCollectionBids = {
@@ -192,8 +190,6 @@ interface UpdateMultiBid {
192
190
  amountToWithdraw?: bigint;
193
191
  tx?: Transaction | string;
194
192
  multiBidChainId?: any;
195
- swapAndPayOptions?: SwapAndPayOptions;
196
- suiClient?: SuiClient;
197
193
  }
198
194
 
199
195
  type WithdrawProfitsFromKiosks = {
@@ -213,13 +209,13 @@ declare class SuiTradingClient {
213
209
  private readonly kioskClient;
214
210
  private readonly allowedApiUsersForUnsharedKiosksMigration;
215
211
  constructor({ apiUser, apiKey, suiNodeUrl, graphQLClient }: ApiConfig);
216
- buyListings({ listingIds, walletAddress, tx, swapAndPayOptions, }: BuyListings): Promise<Transaction>;
212
+ buyListings({ listingIds, walletAddress, tx }: BuyListings): Promise<Transaction>;
217
213
  listNfts({ nfts, walletAddress }: ListNfts): Promise<Transaction>;
218
214
  unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<Transaction>;
219
215
  placeNftBids(data: PlaceNftBids): Promise<Transaction>;
220
216
  removeNftBids({ bidIds, tx }: RemoveNftBids): Promise<Transaction>;
221
217
  acceptNftBids({ bidIds, walletAddress }: AcceptNftBids): Promise<Transaction>;
222
- placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, multiBidId, multiBidChainId, expireAt, tx, swapAndPayOptions, }: PlaceCollectionBid): Promise<Transaction>;
218
+ placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, multiBidId, multiBidChainId, expireAt, tx, }: PlaceCollectionBid): Promise<Transaction>;
223
219
  acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<Transaction>;
224
220
  removeCollectionBids({ bidIds, tx }: RemoveCollectionBids): Promise<Transaction>;
225
221
  transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<Transaction>;
@@ -241,6 +237,7 @@ declare class SuiTradingClient {
241
237
  }>;
242
238
  cancelMultiBid(args: CancelMultiBid): Promise<Transaction>;
243
239
  updateMultiBid(args: UpdateMultiBid): Promise<Transaction>;
240
+ sponsorNftListing(args: SponsorNftListing): Promise<Transaction>;
244
241
  }
245
242
 
246
243
  export { SuiTradingClient };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  import { Transaction } from '@mysten/sui/transactions';
2
2
  import { GraphQLClient } from 'graphql-request';
3
3
  import { KioskTransaction } from '@mysten/kiosk';
4
- import { Protocol } from '@flowx-finance/sdk';
5
- import { StringValue } from 'ms';
6
- import { SuiClient } from '@mysten/sui/client';
7
4
 
8
5
  type AcceptCollectionBid = {
9
6
  bidId: string;
@@ -37,22 +34,12 @@ type BuyAndExerciseShortLocks = {
37
34
  tx?: Transaction;
38
35
  };
39
36
 
40
- interface SwapAndPayOptions {
41
- coinType?: string;
42
- coinAmount?: string;
43
- slippage?: number;
44
- ttl?: StringValue;
45
- excludeSources?: Protocol[];
46
- amountToSplitFromSuiBalance?: string;
47
- }
48
-
49
37
  type BuyListings = {
50
38
  listingIds: string[];
51
39
  walletAddress: string;
52
40
  tx?: Transaction | string;
53
41
  kioskTx?: KioskTransaction;
54
42
  coinToSplit?: any;
55
- swapAndPayOptions?: SwapAndPayOptions;
56
43
  beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
57
44
  };
58
45
 
@@ -125,10 +112,23 @@ type ExerciseShortLocks = {
125
112
  }>;
126
113
  };
127
114
 
115
+ type SponsorNftListingOptions = {
116
+ shouldSponsor?: boolean;
117
+ numOfPeriods?: number;
118
+ slippage?: number;
119
+ coinInType?: string;
120
+ };
121
+ type SponsorNftListing = {
122
+ nftTokenId: string;
123
+ walletAddress: string;
124
+ options: SponsorNftListingOptions;
125
+ };
126
+
128
127
  type ListNfts = {
129
128
  nfts: Array<{
130
129
  id: string;
131
130
  listPriceInMist: number;
131
+ sponsorOptions?: SponsorNftListingOptions;
132
132
  }>;
133
133
  walletAddress: string;
134
134
  };
@@ -147,7 +147,6 @@ type PlaceCollectionBid = {
147
147
  multiBidChainId?: any;
148
148
  expireAt?: Date;
149
149
  tx?: Transaction | string;
150
- swapAndPayOptions?: SwapAndPayOptions;
151
150
  };
152
151
 
153
152
  type PlaceNftBids = {
@@ -160,7 +159,6 @@ type PlaceNftBids = {
160
159
  multiBidId?: string;
161
160
  multiBidChainId?: any;
162
161
  tx?: Transaction | string;
163
- swapAndPayOptions?: SwapAndPayOptions;
164
162
  };
165
163
 
166
164
  type RemoveCollectionBids = {
@@ -192,8 +190,6 @@ interface UpdateMultiBid {
192
190
  amountToWithdraw?: bigint;
193
191
  tx?: Transaction | string;
194
192
  multiBidChainId?: any;
195
- swapAndPayOptions?: SwapAndPayOptions;
196
- suiClient?: SuiClient;
197
193
  }
198
194
 
199
195
  type WithdrawProfitsFromKiosks = {
@@ -213,13 +209,13 @@ declare class SuiTradingClient {
213
209
  private readonly kioskClient;
214
210
  private readonly allowedApiUsersForUnsharedKiosksMigration;
215
211
  constructor({ apiUser, apiKey, suiNodeUrl, graphQLClient }: ApiConfig);
216
- buyListings({ listingIds, walletAddress, tx, swapAndPayOptions, }: BuyListings): Promise<Transaction>;
212
+ buyListings({ listingIds, walletAddress, tx }: BuyListings): Promise<Transaction>;
217
213
  listNfts({ nfts, walletAddress }: ListNfts): Promise<Transaction>;
218
214
  unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<Transaction>;
219
215
  placeNftBids(data: PlaceNftBids): Promise<Transaction>;
220
216
  removeNftBids({ bidIds, tx }: RemoveNftBids): Promise<Transaction>;
221
217
  acceptNftBids({ bidIds, walletAddress }: AcceptNftBids): Promise<Transaction>;
222
- placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, multiBidId, multiBidChainId, expireAt, tx, swapAndPayOptions, }: PlaceCollectionBid): Promise<Transaction>;
218
+ placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, multiBidId, multiBidChainId, expireAt, tx, }: PlaceCollectionBid): Promise<Transaction>;
223
219
  acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<Transaction>;
224
220
  removeCollectionBids({ bidIds, tx }: RemoveCollectionBids): Promise<Transaction>;
225
221
  transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<Transaction>;
@@ -241,6 +237,7 @@ declare class SuiTradingClient {
241
237
  }>;
242
238
  cancelMultiBid(args: CancelMultiBid): Promise<Transaction>;
243
239
  updateMultiBid(args: UpdateMultiBid): Promise<Transaction>;
240
+ sponsorNftListing(args: SponsorNftListing): Promise<Transaction>;
244
241
  }
245
242
 
246
243
  export { SuiTradingClient };