aftermath-ts-sdk 1.2.52-perps.93 → 1.2.52-perps.95
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.
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { TransactionArgument, Transaction } from "@mysten/sui/transactions";
|
|
2
1
|
import { AftermathApi } from "../../../general/providers/aftermathApi";
|
|
3
|
-
import { CoinType, PerpetualsAddresses,
|
|
4
|
-
import { PerpetualsMarketId, PerpetualsAccountId, PerpetualsOrderId, PerpetualsOrderSide, PerpetualsOrderType } from "../perpetualsTypes";
|
|
2
|
+
import { CoinType, PerpetualsAddresses, AnyObjectType } from "../../../types";
|
|
5
3
|
import { MoveErrors, MoveErrorsInterface } from "../../../general/types/moveErrorsInterface";
|
|
6
4
|
export declare class PerpetualsApi implements MoveErrorsInterface {
|
|
7
5
|
private readonly Provider;
|
|
@@ -36,163 +34,6 @@ export declare class PerpetualsApi implements MoveErrorsInterface {
|
|
|
36
34
|
};
|
|
37
35
|
readonly moveErrors: MoveErrors;
|
|
38
36
|
constructor(Provider: AftermathApi);
|
|
39
|
-
allocateCollateralTx: (inputs: {
|
|
40
|
-
tx: Transaction;
|
|
41
|
-
packageId: PackageId;
|
|
42
|
-
collateralCoinType: CoinType;
|
|
43
|
-
accountCapId: ObjectId | TransactionArgument;
|
|
44
|
-
marketId: PerpetualsMarketId;
|
|
45
|
-
marketInitialSharedVersion: ObjectVersion;
|
|
46
|
-
amount: Balance;
|
|
47
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
48
|
-
deallocateCollateralTx: (inputs: {
|
|
49
|
-
tx: Transaction;
|
|
50
|
-
packageId: PackageId;
|
|
51
|
-
collateralCoinType: CoinType;
|
|
52
|
-
accountCapId: ObjectId;
|
|
53
|
-
basePriceFeedId: ObjectId;
|
|
54
|
-
collateralPriceFeedId: ObjectId;
|
|
55
|
-
marketId: PerpetualsMarketId;
|
|
56
|
-
marketInitialSharedVersion: ObjectVersion;
|
|
57
|
-
amount: Balance;
|
|
58
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
59
|
-
createMarketPositionTx: (inputs: {
|
|
60
|
-
tx: Transaction;
|
|
61
|
-
packageId: PackageId;
|
|
62
|
-
collateralCoinType: CoinType;
|
|
63
|
-
accountCapId: ObjectId | TransactionArgument;
|
|
64
|
-
marketId: PerpetualsMarketId;
|
|
65
|
-
marketInitialSharedVersion: ObjectVersion;
|
|
66
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
67
|
-
shareClearingHouseTx: (inputs: {
|
|
68
|
-
tx: Transaction;
|
|
69
|
-
packageId: PackageId;
|
|
70
|
-
collateralCoinType: CoinType;
|
|
71
|
-
marketId: PerpetualsMarketId | TransactionArgument;
|
|
72
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
73
|
-
startSessionTx: (inputs: {
|
|
74
|
-
tx: Transaction;
|
|
75
|
-
packageId: PackageId;
|
|
76
|
-
collateralCoinType: CoinType;
|
|
77
|
-
accountCapId: ObjectId | TransactionArgument;
|
|
78
|
-
basePriceFeedId: ObjectId;
|
|
79
|
-
collateralPriceFeedId: ObjectId;
|
|
80
|
-
marketId: PerpetualsMarketId;
|
|
81
|
-
marketInitialSharedVersion: ObjectVersion;
|
|
82
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
83
|
-
endSessionTx: (inputs: {
|
|
84
|
-
tx: Transaction;
|
|
85
|
-
packageId: PackageId;
|
|
86
|
-
collateralCoinType: CoinType;
|
|
87
|
-
sessionPotatoId: ObjectId | TransactionArgument;
|
|
88
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
89
|
-
placeMarketOrderTx: (inputs: {
|
|
90
|
-
tx: Transaction;
|
|
91
|
-
packageId: PackageId;
|
|
92
|
-
collateralCoinType: CoinType;
|
|
93
|
-
sessionPotatoId: ObjectId | TransactionArgument;
|
|
94
|
-
side: PerpetualsOrderSide;
|
|
95
|
-
size: bigint;
|
|
96
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
97
|
-
placeLimitOrderTx: (inputs: {
|
|
98
|
-
tx: Transaction;
|
|
99
|
-
packageId: PackageId;
|
|
100
|
-
collateralCoinType: CoinType;
|
|
101
|
-
sessionPotatoId: ObjectId | TransactionArgument;
|
|
102
|
-
side: PerpetualsOrderSide;
|
|
103
|
-
size: bigint;
|
|
104
|
-
price: bigint;
|
|
105
|
-
orderType: PerpetualsOrderType;
|
|
106
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
107
|
-
cancelOrdersTx: (inputs: {
|
|
108
|
-
tx: Transaction;
|
|
109
|
-
packageId: PackageId;
|
|
110
|
-
collateralCoinType: CoinType;
|
|
111
|
-
accountCapId: ObjectId;
|
|
112
|
-
marketId: PerpetualsMarketId;
|
|
113
|
-
marketInitialSharedVersion: ObjectVersion;
|
|
114
|
-
orderIds: PerpetualsOrderId[];
|
|
115
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
116
|
-
reduceOrdersTx: (inputs: {
|
|
117
|
-
tx: Transaction;
|
|
118
|
-
packageId: PackageId;
|
|
119
|
-
collateralCoinType: CoinType;
|
|
120
|
-
accountCapId: ObjectId;
|
|
121
|
-
marketId: PerpetualsMarketId;
|
|
122
|
-
marketInitialSharedVersion: ObjectVersion;
|
|
123
|
-
orderIds: PerpetualsOrderId[];
|
|
124
|
-
sizesToSubtract: bigint[];
|
|
125
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
126
|
-
createAccountTx: (inputs: {
|
|
127
|
-
tx: Transaction;
|
|
128
|
-
collateralCoinType: CoinType;
|
|
129
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
130
|
-
getPositionTx: (inputs: {
|
|
131
|
-
tx: Transaction;
|
|
132
|
-
packageId: PackageId;
|
|
133
|
-
collateralCoinType: CoinType;
|
|
134
|
-
accountId: PerpetualsAccountId;
|
|
135
|
-
marketId: PerpetualsMarketId;
|
|
136
|
-
marketInitialSharedVersion: ObjectVersion;
|
|
137
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
138
|
-
getOrderbookTx: (inputs: {
|
|
139
|
-
tx: Transaction;
|
|
140
|
-
packageId: PackageId;
|
|
141
|
-
collateralCoinType: CoinType;
|
|
142
|
-
marketId: PerpetualsMarketId;
|
|
143
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
144
|
-
getBookPriceTx: (inputs: {
|
|
145
|
-
tx: Transaction;
|
|
146
|
-
packageId: PackageId;
|
|
147
|
-
marketId: PerpetualsMarketId;
|
|
148
|
-
collateralCoinType: CoinType;
|
|
149
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
150
|
-
getBestPriceTx: (inputs: {
|
|
151
|
-
tx: Transaction;
|
|
152
|
-
packageId: PackageId;
|
|
153
|
-
marketId: PerpetualsMarketId;
|
|
154
|
-
marketInitialSharedVersion: ObjectVersion;
|
|
155
|
-
side: PerpetualsOrderSide;
|
|
156
|
-
collateralCoinType: CoinType;
|
|
157
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
158
|
-
inspectOrdersTx: (inputs: {
|
|
159
|
-
tx: Transaction;
|
|
160
|
-
packageId: PackageId;
|
|
161
|
-
orderbookId: ObjectId | TransactionArgument;
|
|
162
|
-
side: PerpetualsOrderSide;
|
|
163
|
-
fromPrice: IFixed;
|
|
164
|
-
toPrice: IFixed;
|
|
165
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
166
|
-
getOrderSizeTx: (inputs: {
|
|
167
|
-
tx: Transaction;
|
|
168
|
-
packageId: PackageId;
|
|
169
|
-
orderbookId: ObjectId | TransactionArgument;
|
|
170
|
-
orderId: PerpetualsOrderId;
|
|
171
|
-
}) => import("@mysten/sui/transactions").TransactionResult;
|
|
172
|
-
buildAllocateCollateralTx: (inputs: {
|
|
173
|
-
walletAddress: string;
|
|
174
|
-
} & Omit<{
|
|
175
|
-
tx: Transaction;
|
|
176
|
-
packageId: PackageId;
|
|
177
|
-
collateralCoinType: CoinType;
|
|
178
|
-
accountCapId: ObjectId | TransactionArgument;
|
|
179
|
-
marketId: PerpetualsMarketId;
|
|
180
|
-
marketInitialSharedVersion: ObjectVersion;
|
|
181
|
-
amount: Balance;
|
|
182
|
-
}, "tx">) => Transaction;
|
|
183
|
-
buildDeallocateCollateralTx: (inputs: {
|
|
184
|
-
walletAddress: string;
|
|
185
|
-
} & Omit<{
|
|
186
|
-
tx: Transaction;
|
|
187
|
-
packageId: PackageId;
|
|
188
|
-
collateralCoinType: CoinType;
|
|
189
|
-
accountCapId: ObjectId;
|
|
190
|
-
basePriceFeedId: ObjectId;
|
|
191
|
-
collateralPriceFeedId: ObjectId;
|
|
192
|
-
marketId: PerpetualsMarketId;
|
|
193
|
-
marketInitialSharedVersion: ObjectVersion;
|
|
194
|
-
amount: Balance;
|
|
195
|
-
}, "tx">) => Transaction;
|
|
196
37
|
getAccountCapType: (inputs: {
|
|
197
38
|
collateralCoinType: CoinType;
|
|
198
39
|
}) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perpetualsApi.d.ts","sourceRoot":"","sources":["../../../../src/packages/perpetuals/api/perpetualsApi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"perpetualsApi.d.ts","sourceRoot":"","sources":["../../../../src/packages/perpetuals/api/perpetualsApi.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EACN,QAAQ,EACR,mBAAmB,EAGnB,aAAa,EAKb,MAAM,gBAAgB,CAAC;AAgBxB,OAAO,EACN,UAAU,EACV,mBAAmB,EACnB,MAAM,4CAA4C,CAAC;AAEpD,qBAAa,aAAc,YAAW,mBAAmB;IAkD5C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IA7CrC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAQ/B;IAEF,SAAgB,SAAS,EAAE,mBAAmB,CAAC;IAE/C,SAAgB,UAAU,EAAE;QAC3B,kBAAkB,EAAE,aAAa,CAAC;QAClC,mBAAmB,EAAE,aAAa,CAAC;QACnC,cAAc,EAAE,aAAa,CAAC;QAC9B,mBAAmB,EAAE,aAAa,CAAC;QACnC,qBAAqB,EAAE,aAAa,CAAC;QACrC,UAAU,EAAE,aAAa,CAAC;QAC1B,cAAc,EAAE,aAAa,CAAC;QAC9B,aAAa,EAAE,aAAa,CAAC;QAC7B,kBAAkB,EAAE,aAAa,CAAC;QAClC,iBAAiB,EAAE,aAAa,CAAC;QACjC,gBAAgB,EAAE,aAAa,CAAC;QAChC,kBAAkB,EAAE,aAAa,CAAC;QAClC,iBAAiB,EAAE,aAAa,CAAC;QACjC,cAAc,EAAE,aAAa,CAAC;QAC9B,oBAAoB,EAAE,aAAa,CAAC;QACpC,sBAAsB,EAAE,aAAa,CAAC;QACtC,sBAAsB,EAAE,aAAa,CAAC;QACtC,6BAA6B,EAAE,aAAa,CAAC;QAC7C,8BAA8B,EAAE,aAAa,CAAC;QAC9C,gCAAgC,EAAE,aAAa,CAAC;QAChD,4BAA4B,EAAE,aAAa,CAAC;QAC5C,uBAAuB,EAAE,aAAa,CAAC;QACvC,0BAA0B,EAAE,aAAa,CAAC;QAC1C,oBAAoB,EAAE,aAAa,CAAC;QACpC,YAAY,EAAE,aAAa,CAAC;KAC5B,CAAC;IACF,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAMV,QAAQ,EAAE,YAAY;IA2jC5C,iBAAiB,WAAY;QACnC,kBAAkB,EAAE,QAAQ,CAAC;KAC7B,KAAG,MAAM,CAER;IAubF,OAAO,CAAC,SAAS,CAKd;CAYH"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PerpetualsApi = void 0;
|
|
4
|
-
const utils_1 = require("../../../general/utils");
|
|
5
|
-
const sui_1 = require("../../sui");
|
|
6
4
|
const eventsApiHelpers_1 = require("../../../general/apiHelpers/eventsApiHelpers");
|
|
7
|
-
const transactionsApiHelpers_1 = require("../../../general/apiHelpers/transactionsApiHelpers");
|
|
8
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
9
5
|
class PerpetualsApi {
|
|
10
6
|
// =========================================================================
|
|
11
7
|
// Constructor
|
|
@@ -109,165 +105,301 @@ class PerpetualsApi {
|
|
|
109
105
|
// ],
|
|
110
106
|
// });
|
|
111
107
|
// };
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
108
|
+
// public allocateCollateralTx = (inputs: {
|
|
109
|
+
// tx: Transaction;
|
|
110
|
+
// packageId: PackageId;
|
|
111
|
+
// collateralCoinType: CoinType;
|
|
112
|
+
// accountCapId: ObjectId | TransactionArgument;
|
|
113
|
+
// marketId: PerpetualsMarketId;
|
|
114
|
+
// marketInitialSharedVersion: ObjectVersion;
|
|
115
|
+
// amount: Balance;
|
|
116
|
+
// }) => {
|
|
117
|
+
// const { tx, collateralCoinType, accountCapId, marketId, amount } =
|
|
118
|
+
// inputs;
|
|
119
|
+
// return tx.moveCall({
|
|
120
|
+
// target: Helpers.transactions.createTxTarget(
|
|
121
|
+
// inputs.packageId,
|
|
122
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
123
|
+
// "allocate_collateral"
|
|
124
|
+
// ),
|
|
125
|
+
// typeArguments: [collateralCoinType],
|
|
126
|
+
// arguments: [
|
|
127
|
+
// tx.sharedObjectRef({
|
|
128
|
+
// objectId: marketId,
|
|
129
|
+
// initialSharedVersion: inputs.marketInitialSharedVersion,
|
|
130
|
+
// mutable: true,
|
|
131
|
+
// }),
|
|
132
|
+
// typeof accountCapId === "string"
|
|
133
|
+
// ? tx.object(accountCapId)
|
|
134
|
+
// : accountCapId,
|
|
135
|
+
// tx.pure.u64(amount),
|
|
136
|
+
// ],
|
|
137
|
+
// });
|
|
138
|
+
// };
|
|
139
|
+
// public deallocateCollateralTx = (inputs: {
|
|
140
|
+
// tx: Transaction;
|
|
141
|
+
// packageId: PackageId;
|
|
142
|
+
// collateralCoinType: CoinType;
|
|
143
|
+
// accountCapId: ObjectId;
|
|
144
|
+
// basePriceFeedId: ObjectId;
|
|
145
|
+
// collateralPriceFeedId: ObjectId;
|
|
146
|
+
// marketId: PerpetualsMarketId;
|
|
147
|
+
// marketInitialSharedVersion: ObjectVersion;
|
|
148
|
+
// amount: Balance;
|
|
149
|
+
// }) => {
|
|
150
|
+
// const { tx, collateralCoinType, accountCapId, marketId, amount } =
|
|
151
|
+
// inputs;
|
|
152
|
+
// return tx.moveCall({
|
|
153
|
+
// target: Helpers.transactions.createTxTarget(
|
|
154
|
+
// inputs.packageId,
|
|
155
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
156
|
+
// "deallocate_collateral"
|
|
157
|
+
// ),
|
|
158
|
+
// typeArguments: [collateralCoinType],
|
|
159
|
+
// arguments: [
|
|
160
|
+
// tx.sharedObjectRef({
|
|
161
|
+
// objectId: marketId,
|
|
162
|
+
// initialSharedVersion: inputs.marketInitialSharedVersion,
|
|
163
|
+
// mutable: true,
|
|
164
|
+
// }),
|
|
165
|
+
// tx.object(accountCapId),
|
|
166
|
+
// tx.object(inputs.basePriceFeedId),
|
|
167
|
+
// tx.object(inputs.collateralPriceFeedId),
|
|
168
|
+
// tx.object(Sui.constants.addresses.suiClockId),
|
|
169
|
+
// tx.pure.u64(amount),
|
|
170
|
+
// ],
|
|
171
|
+
// });
|
|
172
|
+
// };
|
|
173
|
+
// public createMarketPositionTx = (inputs: {
|
|
174
|
+
// tx: Transaction;
|
|
175
|
+
// packageId: PackageId;
|
|
176
|
+
// collateralCoinType: CoinType;
|
|
177
|
+
// accountCapId: ObjectId | TransactionArgument;
|
|
178
|
+
// marketId: PerpetualsMarketId;
|
|
179
|
+
// marketInitialSharedVersion: ObjectVersion;
|
|
180
|
+
// }) => {
|
|
181
|
+
// const { tx, collateralCoinType, accountCapId, marketId } = inputs;
|
|
182
|
+
// return tx.moveCall({
|
|
183
|
+
// target: Helpers.transactions.createTxTarget(
|
|
184
|
+
// inputs.packageId,
|
|
185
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
186
|
+
// "create_market_position"
|
|
187
|
+
// ),
|
|
188
|
+
// typeArguments: [collateralCoinType],
|
|
189
|
+
// arguments: [
|
|
190
|
+
// tx.sharedObjectRef({
|
|
191
|
+
// objectId: marketId,
|
|
192
|
+
// initialSharedVersion: inputs.marketInitialSharedVersion,
|
|
193
|
+
// mutable: true,
|
|
194
|
+
// }),
|
|
195
|
+
// typeof accountCapId === "string"
|
|
196
|
+
// ? tx.object(accountCapId)
|
|
197
|
+
// : accountCapId,
|
|
198
|
+
// ],
|
|
199
|
+
// });
|
|
200
|
+
// };
|
|
201
|
+
// public shareClearingHouseTx = (inputs: {
|
|
202
|
+
// tx: Transaction;
|
|
203
|
+
// packageId: PackageId;
|
|
204
|
+
// collateralCoinType: CoinType;
|
|
205
|
+
// marketId: PerpetualsMarketId | TransactionArgument;
|
|
206
|
+
// }) => {
|
|
207
|
+
// const { tx, collateralCoinType, marketId } = inputs;
|
|
208
|
+
// return tx.moveCall({
|
|
209
|
+
// target: Helpers.transactions.createTxTarget(
|
|
210
|
+
// inputs.packageId,
|
|
211
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
212
|
+
// "share_clearing_house"
|
|
213
|
+
// ),
|
|
214
|
+
// typeArguments: [collateralCoinType],
|
|
215
|
+
// arguments: [
|
|
216
|
+
// typeof marketId === "string" ? tx.object(marketId) : marketId,
|
|
217
|
+
// ],
|
|
218
|
+
// });
|
|
219
|
+
// };
|
|
220
|
+
// public startSessionTx = (inputs: {
|
|
221
|
+
// tx: Transaction;
|
|
222
|
+
// packageId: PackageId;
|
|
223
|
+
// collateralCoinType: CoinType;
|
|
224
|
+
// accountCapId: ObjectId | TransactionArgument;
|
|
225
|
+
// basePriceFeedId: ObjectId;
|
|
226
|
+
// collateralPriceFeedId: ObjectId;
|
|
227
|
+
// marketId: PerpetualsMarketId;
|
|
228
|
+
// marketInitialSharedVersion: ObjectVersion;
|
|
229
|
+
// }) /* SessionHotPotato<T> */ => {
|
|
230
|
+
// const { tx, collateralCoinType, accountCapId, marketId } = inputs;
|
|
231
|
+
// return tx.moveCall({
|
|
232
|
+
// target: Helpers.transactions.createTxTarget(
|
|
233
|
+
// inputs.packageId,
|
|
234
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
235
|
+
// "start_session"
|
|
236
|
+
// ),
|
|
237
|
+
// typeArguments: [collateralCoinType],
|
|
238
|
+
// arguments: [
|
|
239
|
+
// tx.sharedObjectRef({
|
|
240
|
+
// objectId: marketId,
|
|
241
|
+
// initialSharedVersion: inputs.marketInitialSharedVersion,
|
|
242
|
+
// mutable: true,
|
|
243
|
+
// }),
|
|
244
|
+
// typeof accountCapId === "string"
|
|
245
|
+
// ? tx.object(accountCapId)
|
|
246
|
+
// : accountCapId,
|
|
247
|
+
// tx.object(inputs.basePriceFeedId),
|
|
248
|
+
// tx.object(inputs.collateralPriceFeedId),
|
|
249
|
+
// tx.object(Sui.constants.addresses.suiClockId),
|
|
250
|
+
// ],
|
|
251
|
+
// });
|
|
252
|
+
// };
|
|
253
|
+
// public endSessionTx = (inputs: {
|
|
254
|
+
// tx: Transaction;
|
|
255
|
+
// packageId: PackageId;
|
|
256
|
+
// collateralCoinType: CoinType;
|
|
257
|
+
// sessionPotatoId: ObjectId | TransactionArgument;
|
|
258
|
+
// }) /* ClearingHouse<T> */ => {
|
|
259
|
+
// const { tx, collateralCoinType, sessionPotatoId } = inputs;
|
|
260
|
+
// return tx.moveCall({
|
|
261
|
+
// target: Helpers.transactions.createTxTarget(
|
|
262
|
+
// inputs.packageId,
|
|
263
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
264
|
+
// "end_session"
|
|
265
|
+
// ),
|
|
266
|
+
// typeArguments: [collateralCoinType],
|
|
267
|
+
// arguments: [
|
|
268
|
+
// typeof sessionPotatoId === "string"
|
|
269
|
+
// ? tx.object(sessionPotatoId)
|
|
270
|
+
// : sessionPotatoId,
|
|
271
|
+
// ],
|
|
272
|
+
// });
|
|
273
|
+
// };
|
|
274
|
+
// public placeMarketOrderTx = (inputs: {
|
|
275
|
+
// tx: Transaction;
|
|
276
|
+
// packageId: PackageId;
|
|
277
|
+
// collateralCoinType: CoinType;
|
|
278
|
+
// sessionPotatoId: ObjectId | TransactionArgument;
|
|
279
|
+
// side: PerpetualsOrderSide;
|
|
280
|
+
// size: bigint;
|
|
281
|
+
// }) => {
|
|
282
|
+
// const { tx, collateralCoinType, sessionPotatoId, side, size } = inputs;
|
|
283
|
+
// return tx.moveCall({
|
|
284
|
+
// target: Helpers.transactions.createTxTarget(
|
|
285
|
+
// inputs.packageId,
|
|
286
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
287
|
+
// "place_market_order"
|
|
288
|
+
// ),
|
|
289
|
+
// typeArguments: [collateralCoinType],
|
|
290
|
+
// arguments: [
|
|
291
|
+
// typeof sessionPotatoId === "string"
|
|
292
|
+
// ? tx.object(sessionPotatoId)
|
|
293
|
+
// : sessionPotatoId,
|
|
294
|
+
// tx.pure.bool(Boolean(side)),
|
|
295
|
+
// tx.pure.u64(size),
|
|
296
|
+
// ],
|
|
297
|
+
// });
|
|
298
|
+
// };
|
|
299
|
+
// public placeLimitOrderTx = (inputs: {
|
|
300
|
+
// tx: Transaction;
|
|
301
|
+
// packageId: PackageId;
|
|
302
|
+
// collateralCoinType: CoinType;
|
|
303
|
+
// sessionPotatoId: ObjectId | TransactionArgument;
|
|
304
|
+
// side: PerpetualsOrderSide;
|
|
305
|
+
// size: bigint;
|
|
306
|
+
// price: bigint;
|
|
307
|
+
// orderType: PerpetualsOrderType;
|
|
308
|
+
// }) => {
|
|
309
|
+
// const {
|
|
310
|
+
// tx,
|
|
311
|
+
// collateralCoinType,
|
|
312
|
+
// sessionPotatoId,
|
|
313
|
+
// side,
|
|
314
|
+
// size,
|
|
315
|
+
// price,
|
|
316
|
+
// orderType,
|
|
317
|
+
// } = inputs;
|
|
318
|
+
// return tx.moveCall({
|
|
319
|
+
// target: Helpers.transactions.createTxTarget(
|
|
320
|
+
// inputs.packageId,
|
|
321
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
322
|
+
// "place_limit_order"
|
|
323
|
+
// ),
|
|
324
|
+
// typeArguments: [collateralCoinType],
|
|
325
|
+
// arguments: [
|
|
326
|
+
// typeof sessionPotatoId === "string"
|
|
327
|
+
// ? tx.object(sessionPotatoId)
|
|
328
|
+
// : sessionPotatoId,
|
|
329
|
+
// tx.pure.bool(Boolean(side)),
|
|
330
|
+
// tx.pure.u64(size),
|
|
331
|
+
// tx.pure.u64(price),
|
|
332
|
+
// tx.pure.u64(BigInt(orderType)),
|
|
333
|
+
// ],
|
|
334
|
+
// });
|
|
335
|
+
// };
|
|
336
|
+
// public cancelOrdersTx = (inputs: {
|
|
337
|
+
// tx: Transaction;
|
|
338
|
+
// packageId: PackageId;
|
|
339
|
+
// collateralCoinType: CoinType;
|
|
340
|
+
// accountCapId: ObjectId;
|
|
341
|
+
// marketId: PerpetualsMarketId;
|
|
342
|
+
// marketInitialSharedVersion: ObjectVersion;
|
|
343
|
+
// orderIds: PerpetualsOrderId[];
|
|
344
|
+
// }) => {
|
|
345
|
+
// const { tx, collateralCoinType, accountCapId, marketId, orderIds } =
|
|
346
|
+
// inputs;
|
|
347
|
+
// return tx.moveCall({
|
|
348
|
+
// target: Helpers.transactions.createTxTarget(
|
|
349
|
+
// inputs.packageId,
|
|
350
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
351
|
+
// "cancel_orders"
|
|
352
|
+
// ),
|
|
353
|
+
// typeArguments: [collateralCoinType],
|
|
354
|
+
// arguments: [
|
|
355
|
+
// tx.sharedObjectRef({
|
|
356
|
+
// objectId: marketId,
|
|
357
|
+
// initialSharedVersion: inputs.marketInitialSharedVersion,
|
|
358
|
+
// mutable: true,
|
|
359
|
+
// }),
|
|
360
|
+
// tx.object(accountCapId),
|
|
361
|
+
// tx.pure(bcs.vector(bcs.u128()).serialize(orderIds)),
|
|
362
|
+
// ],
|
|
363
|
+
// });
|
|
364
|
+
// };
|
|
365
|
+
// public reduceOrdersTx = (inputs: {
|
|
366
|
+
// tx: Transaction;
|
|
367
|
+
// packageId: PackageId;
|
|
368
|
+
// collateralCoinType: CoinType;
|
|
369
|
+
// accountCapId: ObjectId;
|
|
370
|
+
// marketId: PerpetualsMarketId;
|
|
371
|
+
// marketInitialSharedVersion: ObjectVersion;
|
|
372
|
+
// orderIds: PerpetualsOrderId[];
|
|
373
|
+
// sizesToSubtract: bigint[];
|
|
374
|
+
// }) => {
|
|
375
|
+
// const {
|
|
376
|
+
// tx,
|
|
377
|
+
// packageId,
|
|
378
|
+
// collateralCoinType,
|
|
379
|
+
// accountCapId,
|
|
380
|
+
// marketId,
|
|
381
|
+
// orderIds,
|
|
382
|
+
// sizesToSubtract,
|
|
383
|
+
// } = inputs;
|
|
384
|
+
// return tx.moveCall({
|
|
385
|
+
// target: Helpers.transactions.createTxTarget(
|
|
386
|
+
// packageId,
|
|
387
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
388
|
+
// "reduce_orders"
|
|
389
|
+
// ),
|
|
390
|
+
// typeArguments: [collateralCoinType],
|
|
391
|
+
// arguments: [
|
|
392
|
+
// tx.sharedObjectRef({
|
|
393
|
+
// objectId: marketId,
|
|
394
|
+
// initialSharedVersion: inputs.marketInitialSharedVersion,
|
|
395
|
+
// mutable: true,
|
|
396
|
+
// }),
|
|
397
|
+
// tx.object(accountCapId),
|
|
398
|
+
// tx.pure(bcs.vector(bcs.u128()).serialize(orderIds)),
|
|
399
|
+
// tx.pure(bcs.vector(bcs.u64()).serialize(sizesToSubtract)),
|
|
400
|
+
// ],
|
|
401
|
+
// });
|
|
402
|
+
// };
|
|
271
403
|
// public withdrawCollateralTx = (inputs: {
|
|
272
404
|
// tx: Transaction;
|
|
273
405
|
// collateralCoinType: CoinType;
|
|
@@ -290,14 +422,21 @@ class PerpetualsApi {
|
|
|
290
422
|
// ],
|
|
291
423
|
// });
|
|
292
424
|
// };
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
425
|
+
// public createAccountTx = (inputs: {
|
|
426
|
+
// tx: Transaction;
|
|
427
|
+
// collateralCoinType: CoinType;
|
|
428
|
+
// }) /* Account<T> */ => {
|
|
429
|
+
// const { tx, collateralCoinType } = inputs;
|
|
430
|
+
// return tx.moveCall({
|
|
431
|
+
// target: Helpers.transactions.createTxTarget(
|
|
432
|
+
// this.addresses.packages.perpetuals,
|
|
433
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
434
|
+
// "create_account"
|
|
435
|
+
// ),
|
|
436
|
+
// typeArguments: [collateralCoinType],
|
|
437
|
+
// arguments: [tx.object(this.addresses.objects.registry)],
|
|
438
|
+
// });
|
|
439
|
+
// };
|
|
301
440
|
// public getHotPotatoFieldsTx = (
|
|
302
441
|
// inputs: {
|
|
303
442
|
// tx: Transaction;
|
|
@@ -342,87 +481,148 @@ class PerpetualsApi {
|
|
|
342
481
|
// ],
|
|
343
482
|
// });
|
|
344
483
|
// };
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
484
|
+
// public getPositionTx = (inputs: {
|
|
485
|
+
// tx: Transaction;
|
|
486
|
+
// packageId: PackageId;
|
|
487
|
+
// collateralCoinType: CoinType;
|
|
488
|
+
// accountId: PerpetualsAccountId;
|
|
489
|
+
// marketId: PerpetualsMarketId;
|
|
490
|
+
// marketInitialSharedVersion: ObjectVersion;
|
|
491
|
+
// }) /* Position */ => {
|
|
492
|
+
// const { tx, marketId, collateralCoinType } = inputs;
|
|
493
|
+
// return tx.moveCall({
|
|
494
|
+
// target: Helpers.transactions.createTxTarget(
|
|
495
|
+
// inputs.packageId,
|
|
496
|
+
// PerpetualsApi.constants.moduleNames.clearingHouse,
|
|
497
|
+
// "get_position"
|
|
498
|
+
// ),
|
|
499
|
+
// typeArguments: [collateralCoinType],
|
|
500
|
+
// arguments: [
|
|
501
|
+
// tx.sharedObjectRef({
|
|
502
|
+
// objectId: marketId,
|
|
503
|
+
// initialSharedVersion: inputs.marketInitialSharedVersion,
|
|
504
|
+
// mutable: false,
|
|
505
|
+
// }),
|
|
506
|
+
// tx.pure.u64(inputs.accountId),
|
|
507
|
+
// ],
|
|
508
|
+
// });
|
|
509
|
+
// };
|
|
510
|
+
// public getOrderbookTx = (inputs: {
|
|
511
|
+
// tx: Transaction;
|
|
512
|
+
// packageId: PackageId;
|
|
513
|
+
// collateralCoinType: CoinType;
|
|
514
|
+
// marketId: PerpetualsMarketId;
|
|
515
|
+
// }) /* Orderbook */ => {
|
|
516
|
+
// const { tx, collateralCoinType } = inputs;
|
|
517
|
+
// return tx.moveCall({
|
|
518
|
+
// target: Helpers.transactions.createTxTarget(
|
|
519
|
+
// inputs.packageId,
|
|
520
|
+
// PerpetualsApi.constants.moduleNames.clearingHouse,
|
|
521
|
+
// "get_orderbook"
|
|
522
|
+
// ),
|
|
523
|
+
// typeArguments: [collateralCoinType],
|
|
524
|
+
// arguments: [tx.object(inputs.marketId)],
|
|
525
|
+
// });
|
|
526
|
+
// };
|
|
527
|
+
// public getBookPriceTx = (inputs: {
|
|
528
|
+
// tx: Transaction;
|
|
529
|
+
// packageId: PackageId;
|
|
530
|
+
// marketId: PerpetualsMarketId;
|
|
531
|
+
// // marketInitialSharedVersion: ObjectVersion;
|
|
532
|
+
// collateralCoinType: CoinType;
|
|
533
|
+
// }) /* Option<u256> */ => {
|
|
534
|
+
// const { tx, marketId, collateralCoinType } = inputs;
|
|
535
|
+
// return tx.moveCall({
|
|
536
|
+
// target: Helpers.transactions.createTxTarget(
|
|
537
|
+
// inputs.packageId,
|
|
538
|
+
// PerpetualsApi.constants.moduleNames.clearingHouse,
|
|
539
|
+
// "get_book_price"
|
|
540
|
+
// ),
|
|
541
|
+
// typeArguments: [collateralCoinType],
|
|
542
|
+
// arguments: [
|
|
543
|
+
// tx.object(marketId),
|
|
544
|
+
// // tx.sharedObjectRef({
|
|
545
|
+
// // objectId: marketId,
|
|
546
|
+
// // initialSharedVersion: inputs.marketInitialSharedVersion,
|
|
547
|
+
// // mutable: false,
|
|
548
|
+
// // }),
|
|
549
|
+
// ],
|
|
550
|
+
// });
|
|
551
|
+
// };
|
|
552
|
+
// public getBestPriceTx = (inputs: {
|
|
553
|
+
// tx: Transaction;
|
|
554
|
+
// packageId: PackageId;
|
|
555
|
+
// marketId: PerpetualsMarketId;
|
|
556
|
+
// marketInitialSharedVersion: ObjectVersion;
|
|
557
|
+
// side: PerpetualsOrderSide;
|
|
558
|
+
// collateralCoinType: CoinType;
|
|
559
|
+
// }) /* Option<u256> */ => {
|
|
560
|
+
// const { tx, marketId, collateralCoinType } = inputs;
|
|
561
|
+
// return tx.moveCall({
|
|
562
|
+
// target: Helpers.transactions.createTxTarget(
|
|
563
|
+
// inputs.packageId,
|
|
564
|
+
// PerpetualsApi.constants.moduleNames.clearingHouse,
|
|
565
|
+
// "get_best_price"
|
|
566
|
+
// ),
|
|
567
|
+
// typeArguments: [collateralCoinType],
|
|
568
|
+
// arguments: [
|
|
569
|
+
// tx.sharedObjectRef({
|
|
570
|
+
// objectId: marketId,
|
|
571
|
+
// initialSharedVersion: inputs.marketInitialSharedVersion,
|
|
572
|
+
// mutable: false,
|
|
573
|
+
// }), // ClearingHouse
|
|
574
|
+
// tx.pure.bool(Boolean(inputs.side)), // side
|
|
575
|
+
// ],
|
|
576
|
+
// });
|
|
577
|
+
// };
|
|
578
|
+
// public inspectOrdersTx = (inputs: {
|
|
579
|
+
// tx: Transaction;
|
|
580
|
+
// packageId: PackageId;
|
|
581
|
+
// orderbookId: ObjectId | TransactionArgument;
|
|
582
|
+
// side: PerpetualsOrderSide;
|
|
583
|
+
// fromPrice: IFixed;
|
|
584
|
+
// toPrice: IFixed;
|
|
585
|
+
// }) /* vector<OrderInfo> */ => {
|
|
586
|
+
// const { tx, orderbookId } = inputs;
|
|
587
|
+
// return tx.moveCall({
|
|
588
|
+
// target: Helpers.transactions.createTxTarget(
|
|
589
|
+
// inputs.packageId,
|
|
590
|
+
// PerpetualsApi.constants.moduleNames.orderbook,
|
|
591
|
+
// "inspect_orders"
|
|
592
|
+
// ),
|
|
593
|
+
// typeArguments: [],
|
|
594
|
+
// arguments: [
|
|
595
|
+
// typeof orderbookId === "string"
|
|
596
|
+
// ? tx.object(orderbookId)
|
|
597
|
+
// : orderbookId, // Orderbook
|
|
598
|
+
// tx.pure.bool(Boolean(inputs.side)), // side
|
|
599
|
+
// tx.pure.u64(inputs.fromPrice), // price_from
|
|
600
|
+
// tx.pure.u64(inputs.toPrice), // price_to
|
|
601
|
+
// ],
|
|
602
|
+
// });
|
|
603
|
+
// };
|
|
604
|
+
// public getOrderSizeTx = (inputs: {
|
|
605
|
+
// tx: Transaction;
|
|
606
|
+
// packageId: PackageId;
|
|
607
|
+
// orderbookId: ObjectId | TransactionArgument;
|
|
608
|
+
// orderId: PerpetualsOrderId;
|
|
609
|
+
// }) /* u64 */ => {
|
|
610
|
+
// const { tx, orderbookId } = inputs;
|
|
611
|
+
// return tx.moveCall({
|
|
612
|
+
// target: Helpers.transactions.createTxTarget(
|
|
613
|
+
// inputs.packageId,
|
|
614
|
+
// PerpetualsApi.constants.moduleNames.orderbook,
|
|
615
|
+
// "get_order_size"
|
|
616
|
+
// ),
|
|
617
|
+
// typeArguments: [],
|
|
618
|
+
// arguments: [
|
|
619
|
+
// typeof orderbookId === "string"
|
|
620
|
+
// ? tx.object(orderbookId)
|
|
621
|
+
// : orderbookId, // Orderbook
|
|
622
|
+
// tx.pure.u128(inputs.orderId), // order_id
|
|
623
|
+
// ],
|
|
624
|
+
// });
|
|
625
|
+
// };
|
|
426
626
|
// =========================================================================
|
|
427
627
|
// Transaction Builders
|
|
428
628
|
// =========================================================================
|
|
@@ -582,8 +782,11 @@ class PerpetualsApi {
|
|
|
582
782
|
// });
|
|
583
783
|
// return tx;
|
|
584
784
|
// };
|
|
585
|
-
|
|
586
|
-
this.
|
|
785
|
+
// public buildAllocateCollateralTx = TransactionsApiHelpers.createBuildTxFunc(
|
|
786
|
+
// this.allocateCollateralTx
|
|
787
|
+
// );
|
|
788
|
+
// public buildDeallocateCollateralTx =
|
|
789
|
+
// TransactionsApiHelpers.createBuildTxFunc(this.deallocateCollateralTx);
|
|
587
790
|
// public buildReduceOrdersTx = (
|
|
588
791
|
// inputs: ApiPerpetualsReduceOrdersBody
|
|
589
792
|
// ): Transaction => {
|