@tradeport/sui-trading-sdk 0.4.53 → 0.4.55
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 +33 -73
- package/dist/index.d.ts +33 -73
- package/dist/index.js +630 -865
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +618 -848
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
- package/src/SuiTradingClient.ts +35 -112
- package/src/constants.ts +22 -1
- package/src/graphql/createChainGQLQuery.ts +6 -4
- package/src/graphql/queries/fetchCollectionChainState.ts +17 -0
- package/src/helpers/getCollectionChainState.ts +31 -0
- package/src/helpers/kiosk/resolveCustomTransferPolicyRules.ts +75 -0
- package/src/helpers/kiosk/resolveTableAllowlistRule.ts +34 -0
- package/src/helpers/kiosk/resolveTransferPolicies.ts +16 -2
- package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +29 -4
- package/src/methods/buyListings/addBuyListingTxs.ts +20 -0
- package/src/methods/sponsorNftListing/addSponsorNftListingTx.ts +1 -2
- package/src/methods/swapCoins/swapCoins.ts +400 -0
- package/src/methods/buyAndExerciseLongLocks/buyAndExerciseLongLocks.ts +0 -25
- package/src/methods/buyAndExerciseShortLocks/buyAndExerciseShortLocks.ts +0 -25
- package/src/methods/buyLocks/buyLocks.ts +0 -67
- package/src/methods/cancelLocks/cancelLocks.ts +0 -51
- package/src/methods/createLongLocks/createLongLocks.ts +0 -101
- package/src/methods/createShortLocks/createShortLocks.ts +0 -67
- package/src/methods/exerciseLongLocks/exerciseLongLocks.ts +0 -197
- package/src/methods/exerciseShortLocks/exerciseShortLocks.ts +0 -198
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import * as _mysten_sui_dist_cjs_transactions from '@mysten/sui/dist/cjs/transactions';
|
|
1
2
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
3
|
import { GraphQLClient } from 'graphql-request';
|
|
3
4
|
import { KioskTransaction } from '@mysten/kiosk';
|
|
5
|
+
import { Protocol, Route, Coin, Commission, GetRoutesResult } from '@flowx-finance/sdk';
|
|
6
|
+
import { StringValue } from 'ms';
|
|
4
7
|
|
|
5
8
|
type AcceptCollectionBid = {
|
|
6
9
|
bidId: string;
|
|
@@ -16,24 +19,6 @@ type AcceptNftBids = {
|
|
|
16
19
|
beforeResolveKioskTransferRequest?: (coin: any, transferRequest: any) => void | Promise<void>;
|
|
17
20
|
};
|
|
18
21
|
|
|
19
|
-
type BuyAndExerciseLongLocks = {
|
|
20
|
-
walletAddress: string;
|
|
21
|
-
locks: Array<{
|
|
22
|
-
id: string;
|
|
23
|
-
bidId?: string;
|
|
24
|
-
}>;
|
|
25
|
-
tx?: Transaction;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type BuyAndExerciseShortLocks = {
|
|
29
|
-
walletAddress: string;
|
|
30
|
-
locks: Array<{
|
|
31
|
-
id: string;
|
|
32
|
-
nftId: string;
|
|
33
|
-
}>;
|
|
34
|
-
tx?: Transaction;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
22
|
type BuyListings = {
|
|
38
23
|
listingIds: string[];
|
|
39
24
|
walletAddress: string;
|
|
@@ -43,17 +28,6 @@ type BuyListings = {
|
|
|
43
28
|
beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
|
|
44
29
|
};
|
|
45
30
|
|
|
46
|
-
type BuyLocks = {
|
|
47
|
-
lockIds: string[];
|
|
48
|
-
transaction?: Transaction;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
type CancelLocks = {
|
|
52
|
-
lockIds: string[];
|
|
53
|
-
walletAddress: string;
|
|
54
|
-
tx?: Transaction;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
31
|
interface CancelMultiBid {
|
|
58
32
|
walletAddress: string;
|
|
59
33
|
multiBidId: string;
|
|
@@ -70,14 +44,6 @@ type ClaimNfts = {
|
|
|
70
44
|
tx?: Transaction;
|
|
71
45
|
};
|
|
72
46
|
|
|
73
|
-
interface CreateLongLocks {
|
|
74
|
-
walletAddress: string;
|
|
75
|
-
nfts: Array<{
|
|
76
|
-
id: string;
|
|
77
|
-
priceInMist: number;
|
|
78
|
-
}>;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
47
|
interface CreateMultiBid {
|
|
82
48
|
walletAddress: string;
|
|
83
49
|
name?: string;
|
|
@@ -85,33 +51,6 @@ interface CreateMultiBid {
|
|
|
85
51
|
tx?: Transaction | string;
|
|
86
52
|
}
|
|
87
53
|
|
|
88
|
-
interface CreateShortLocks {
|
|
89
|
-
nfts: Array<{
|
|
90
|
-
type: string;
|
|
91
|
-
collectionId: string;
|
|
92
|
-
priceInMist: number;
|
|
93
|
-
}>;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
type ExerciseLongLocks = {
|
|
97
|
-
walletAddress: string;
|
|
98
|
-
transaction?: Transaction;
|
|
99
|
-
locks: Array<{
|
|
100
|
-
id: string;
|
|
101
|
-
bidId?: string;
|
|
102
|
-
}>;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
type ExerciseShortLocks = {
|
|
106
|
-
walletAddress: string;
|
|
107
|
-
transaction?: Transaction;
|
|
108
|
-
locks: Array<{
|
|
109
|
-
id: string;
|
|
110
|
-
listingId?: string;
|
|
111
|
-
nftId?: string;
|
|
112
|
-
}>;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
54
|
type SponsorNftListingOptions = {
|
|
116
55
|
shouldSponsor?: boolean;
|
|
117
56
|
numOfPeriods?: number;
|
|
@@ -197,10 +136,32 @@ type WithdrawProfitsFromKiosks = {
|
|
|
197
136
|
walletAddress: string;
|
|
198
137
|
};
|
|
199
138
|
|
|
139
|
+
type SwapCoins = {
|
|
140
|
+
walletAddress: string;
|
|
141
|
+
coinInType: string;
|
|
142
|
+
coinInAmount: string;
|
|
143
|
+
coinOutType: string;
|
|
144
|
+
slippage?: number;
|
|
145
|
+
ttl?: StringValue;
|
|
146
|
+
excludeSources?: Protocol[];
|
|
147
|
+
routes?: Array<Route<Coin, Coin>>;
|
|
148
|
+
commission?: Commission;
|
|
149
|
+
tx?: Transaction;
|
|
150
|
+
};
|
|
151
|
+
type SwapRoutesArgs = {
|
|
152
|
+
walletAddress: string;
|
|
153
|
+
coinInType: string;
|
|
154
|
+
coinOutType: string;
|
|
155
|
+
amountToSwap: bigint;
|
|
156
|
+
excludeSources?: Protocol[];
|
|
157
|
+
commission?: Commission;
|
|
158
|
+
};
|
|
159
|
+
|
|
200
160
|
type ApiConfig = {
|
|
201
161
|
apiUser: string;
|
|
202
162
|
apiKey: string;
|
|
203
163
|
apiUrl?: string;
|
|
164
|
+
defiRouterUrl?: string;
|
|
204
165
|
apiVercelId?: string;
|
|
205
166
|
suiNodeUrl?: string;
|
|
206
167
|
graphQLClient?: GraphQLClient;
|
|
@@ -208,10 +169,11 @@ type ApiConfig = {
|
|
|
208
169
|
declare class SuiTradingClient {
|
|
209
170
|
private readonly apiUser;
|
|
210
171
|
private readonly apiKey;
|
|
172
|
+
private readonly defiRouterUrl;
|
|
211
173
|
private readonly suiClient;
|
|
212
174
|
private readonly kioskClient;
|
|
213
175
|
private readonly allowedApiUsersForUnsharedKiosksMigration;
|
|
214
|
-
constructor({ apiUser, apiKey, apiVercelId, apiUrl, suiNodeUrl, graphQLClient }: ApiConfig);
|
|
176
|
+
constructor({ apiUser, apiKey, apiVercelId, apiUrl, defiRouterUrl, suiNodeUrl, graphQLClient, }: ApiConfig);
|
|
215
177
|
buyListings({ listingIds, walletAddress, tx }: BuyListings): Promise<Transaction>;
|
|
216
178
|
listNfts({ nfts, walletAddress }: ListNfts): Promise<Transaction>;
|
|
217
179
|
unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<Transaction>;
|
|
@@ -224,14 +186,6 @@ declare class SuiTradingClient {
|
|
|
224
186
|
transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<Transaction>;
|
|
225
187
|
cancelNftTransfers({ nftIds, walletAddress }: CancelNftTransfers): Promise<Transaction>;
|
|
226
188
|
claimNfts({ nftIds, walletAddress }: ClaimNfts): Promise<Transaction>;
|
|
227
|
-
createLongLocks(args: CreateLongLocks): Promise<Transaction>;
|
|
228
|
-
createShortLocks(args: CreateShortLocks): Promise<Transaction>;
|
|
229
|
-
cancelLocks(args: CancelLocks): Promise<Transaction>;
|
|
230
|
-
buyLocks(args: BuyLocks): Promise<Transaction>;
|
|
231
|
-
exerciseLongLocks(args: ExerciseLongLocks): Promise<Transaction>;
|
|
232
|
-
exerciseShortLocks(args: ExerciseShortLocks): Promise<Transaction>;
|
|
233
|
-
buyAndExerciseLongLocks(args: BuyAndExerciseLongLocks): Promise<Transaction>;
|
|
234
|
-
buyAndExerciseShortLocks(args: BuyAndExerciseShortLocks): Promise<Transaction>;
|
|
235
189
|
withdrawProfitsFromKiosks(args: WithdrawProfitsFromKiosks): Promise<Transaction>;
|
|
236
190
|
migrateNftsFromUnsharedToSharedKiosks(args: MigrateNftsFromUnsharedToSharedKiosks): Promise<Transaction>;
|
|
237
191
|
createMultiBid(args: CreateMultiBid): Promise<{
|
|
@@ -241,6 +195,12 @@ declare class SuiTradingClient {
|
|
|
241
195
|
cancelMultiBid(args: CancelMultiBid): Promise<Transaction>;
|
|
242
196
|
updateMultiBid(args: UpdateMultiBid): Promise<Transaction>;
|
|
243
197
|
sponsorNftListing(args: SponsorNftListing): Promise<Transaction>;
|
|
198
|
+
swapCoins(args: SwapCoins): Promise<{
|
|
199
|
+
tx: Transaction;
|
|
200
|
+
coinOut: _mysten_sui_dist_cjs_transactions.TransactionResult;
|
|
201
|
+
}>;
|
|
202
|
+
buildSwapRoutes(args: SwapRoutesArgs): Promise<GetRoutesResult<Coin, Coin>>;
|
|
203
|
+
calculateAmountToSwap(args: Pick<SwapCoins, 'coinInType' | 'coinOutType' | 'coinInAmount'>): Promise<bigint>;
|
|
244
204
|
}
|
|
245
205
|
|
|
246
206
|
export { SuiTradingClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import * as _mysten_sui_dist_cjs_transactions from '@mysten/sui/dist/cjs/transactions';
|
|
1
2
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
3
|
import { GraphQLClient } from 'graphql-request';
|
|
3
4
|
import { KioskTransaction } from '@mysten/kiosk';
|
|
5
|
+
import { Protocol, Route, Coin, Commission, GetRoutesResult } from '@flowx-finance/sdk';
|
|
6
|
+
import { StringValue } from 'ms';
|
|
4
7
|
|
|
5
8
|
type AcceptCollectionBid = {
|
|
6
9
|
bidId: string;
|
|
@@ -16,24 +19,6 @@ type AcceptNftBids = {
|
|
|
16
19
|
beforeResolveKioskTransferRequest?: (coin: any, transferRequest: any) => void | Promise<void>;
|
|
17
20
|
};
|
|
18
21
|
|
|
19
|
-
type BuyAndExerciseLongLocks = {
|
|
20
|
-
walletAddress: string;
|
|
21
|
-
locks: Array<{
|
|
22
|
-
id: string;
|
|
23
|
-
bidId?: string;
|
|
24
|
-
}>;
|
|
25
|
-
tx?: Transaction;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type BuyAndExerciseShortLocks = {
|
|
29
|
-
walletAddress: string;
|
|
30
|
-
locks: Array<{
|
|
31
|
-
id: string;
|
|
32
|
-
nftId: string;
|
|
33
|
-
}>;
|
|
34
|
-
tx?: Transaction;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
22
|
type BuyListings = {
|
|
38
23
|
listingIds: string[];
|
|
39
24
|
walletAddress: string;
|
|
@@ -43,17 +28,6 @@ type BuyListings = {
|
|
|
43
28
|
beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
|
|
44
29
|
};
|
|
45
30
|
|
|
46
|
-
type BuyLocks = {
|
|
47
|
-
lockIds: string[];
|
|
48
|
-
transaction?: Transaction;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
type CancelLocks = {
|
|
52
|
-
lockIds: string[];
|
|
53
|
-
walletAddress: string;
|
|
54
|
-
tx?: Transaction;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
31
|
interface CancelMultiBid {
|
|
58
32
|
walletAddress: string;
|
|
59
33
|
multiBidId: string;
|
|
@@ -70,14 +44,6 @@ type ClaimNfts = {
|
|
|
70
44
|
tx?: Transaction;
|
|
71
45
|
};
|
|
72
46
|
|
|
73
|
-
interface CreateLongLocks {
|
|
74
|
-
walletAddress: string;
|
|
75
|
-
nfts: Array<{
|
|
76
|
-
id: string;
|
|
77
|
-
priceInMist: number;
|
|
78
|
-
}>;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
47
|
interface CreateMultiBid {
|
|
82
48
|
walletAddress: string;
|
|
83
49
|
name?: string;
|
|
@@ -85,33 +51,6 @@ interface CreateMultiBid {
|
|
|
85
51
|
tx?: Transaction | string;
|
|
86
52
|
}
|
|
87
53
|
|
|
88
|
-
interface CreateShortLocks {
|
|
89
|
-
nfts: Array<{
|
|
90
|
-
type: string;
|
|
91
|
-
collectionId: string;
|
|
92
|
-
priceInMist: number;
|
|
93
|
-
}>;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
type ExerciseLongLocks = {
|
|
97
|
-
walletAddress: string;
|
|
98
|
-
transaction?: Transaction;
|
|
99
|
-
locks: Array<{
|
|
100
|
-
id: string;
|
|
101
|
-
bidId?: string;
|
|
102
|
-
}>;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
type ExerciseShortLocks = {
|
|
106
|
-
walletAddress: string;
|
|
107
|
-
transaction?: Transaction;
|
|
108
|
-
locks: Array<{
|
|
109
|
-
id: string;
|
|
110
|
-
listingId?: string;
|
|
111
|
-
nftId?: string;
|
|
112
|
-
}>;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
54
|
type SponsorNftListingOptions = {
|
|
116
55
|
shouldSponsor?: boolean;
|
|
117
56
|
numOfPeriods?: number;
|
|
@@ -197,10 +136,32 @@ type WithdrawProfitsFromKiosks = {
|
|
|
197
136
|
walletAddress: string;
|
|
198
137
|
};
|
|
199
138
|
|
|
139
|
+
type SwapCoins = {
|
|
140
|
+
walletAddress: string;
|
|
141
|
+
coinInType: string;
|
|
142
|
+
coinInAmount: string;
|
|
143
|
+
coinOutType: string;
|
|
144
|
+
slippage?: number;
|
|
145
|
+
ttl?: StringValue;
|
|
146
|
+
excludeSources?: Protocol[];
|
|
147
|
+
routes?: Array<Route<Coin, Coin>>;
|
|
148
|
+
commission?: Commission;
|
|
149
|
+
tx?: Transaction;
|
|
150
|
+
};
|
|
151
|
+
type SwapRoutesArgs = {
|
|
152
|
+
walletAddress: string;
|
|
153
|
+
coinInType: string;
|
|
154
|
+
coinOutType: string;
|
|
155
|
+
amountToSwap: bigint;
|
|
156
|
+
excludeSources?: Protocol[];
|
|
157
|
+
commission?: Commission;
|
|
158
|
+
};
|
|
159
|
+
|
|
200
160
|
type ApiConfig = {
|
|
201
161
|
apiUser: string;
|
|
202
162
|
apiKey: string;
|
|
203
163
|
apiUrl?: string;
|
|
164
|
+
defiRouterUrl?: string;
|
|
204
165
|
apiVercelId?: string;
|
|
205
166
|
suiNodeUrl?: string;
|
|
206
167
|
graphQLClient?: GraphQLClient;
|
|
@@ -208,10 +169,11 @@ type ApiConfig = {
|
|
|
208
169
|
declare class SuiTradingClient {
|
|
209
170
|
private readonly apiUser;
|
|
210
171
|
private readonly apiKey;
|
|
172
|
+
private readonly defiRouterUrl;
|
|
211
173
|
private readonly suiClient;
|
|
212
174
|
private readonly kioskClient;
|
|
213
175
|
private readonly allowedApiUsersForUnsharedKiosksMigration;
|
|
214
|
-
constructor({ apiUser, apiKey, apiVercelId, apiUrl, suiNodeUrl, graphQLClient }: ApiConfig);
|
|
176
|
+
constructor({ apiUser, apiKey, apiVercelId, apiUrl, defiRouterUrl, suiNodeUrl, graphQLClient, }: ApiConfig);
|
|
215
177
|
buyListings({ listingIds, walletAddress, tx }: BuyListings): Promise<Transaction>;
|
|
216
178
|
listNfts({ nfts, walletAddress }: ListNfts): Promise<Transaction>;
|
|
217
179
|
unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<Transaction>;
|
|
@@ -224,14 +186,6 @@ declare class SuiTradingClient {
|
|
|
224
186
|
transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<Transaction>;
|
|
225
187
|
cancelNftTransfers({ nftIds, walletAddress }: CancelNftTransfers): Promise<Transaction>;
|
|
226
188
|
claimNfts({ nftIds, walletAddress }: ClaimNfts): Promise<Transaction>;
|
|
227
|
-
createLongLocks(args: CreateLongLocks): Promise<Transaction>;
|
|
228
|
-
createShortLocks(args: CreateShortLocks): Promise<Transaction>;
|
|
229
|
-
cancelLocks(args: CancelLocks): Promise<Transaction>;
|
|
230
|
-
buyLocks(args: BuyLocks): Promise<Transaction>;
|
|
231
|
-
exerciseLongLocks(args: ExerciseLongLocks): Promise<Transaction>;
|
|
232
|
-
exerciseShortLocks(args: ExerciseShortLocks): Promise<Transaction>;
|
|
233
|
-
buyAndExerciseLongLocks(args: BuyAndExerciseLongLocks): Promise<Transaction>;
|
|
234
|
-
buyAndExerciseShortLocks(args: BuyAndExerciseShortLocks): Promise<Transaction>;
|
|
235
189
|
withdrawProfitsFromKiosks(args: WithdrawProfitsFromKiosks): Promise<Transaction>;
|
|
236
190
|
migrateNftsFromUnsharedToSharedKiosks(args: MigrateNftsFromUnsharedToSharedKiosks): Promise<Transaction>;
|
|
237
191
|
createMultiBid(args: CreateMultiBid): Promise<{
|
|
@@ -241,6 +195,12 @@ declare class SuiTradingClient {
|
|
|
241
195
|
cancelMultiBid(args: CancelMultiBid): Promise<Transaction>;
|
|
242
196
|
updateMultiBid(args: UpdateMultiBid): Promise<Transaction>;
|
|
243
197
|
sponsorNftListing(args: SponsorNftListing): Promise<Transaction>;
|
|
198
|
+
swapCoins(args: SwapCoins): Promise<{
|
|
199
|
+
tx: Transaction;
|
|
200
|
+
coinOut: _mysten_sui_dist_cjs_transactions.TransactionResult;
|
|
201
|
+
}>;
|
|
202
|
+
buildSwapRoutes(args: SwapRoutesArgs): Promise<GetRoutesResult<Coin, Coin>>;
|
|
203
|
+
calculateAmountToSwap(args: Pick<SwapCoins, 'coinInType' | 'coinOutType' | 'coinInAmount'>): Promise<bigint>;
|
|
244
204
|
}
|
|
245
205
|
|
|
246
206
|
export { SuiTradingClient };
|