aftermath-ts-sdk 1.3.23-cleanup → 1.3.23-perps.1
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/general/apiHelpers/transactionsApiHelpers.d.ts +3 -0
- package/dist/general/apiHelpers/transactionsApiHelpers.d.ts.map +1 -1
- package/dist/general/apiHelpers/transactionsApiHelpers.js +12 -0
- package/dist/general/providers/aftermath.d.ts +0 -5
- package/dist/general/providers/aftermath.d.ts.map +1 -1
- package/dist/general/providers/aftermath.js +1 -6
- package/dist/general/providers/aftermathApi.d.ts +0 -5
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/providers/aftermathApi.js +0 -5
- package/dist/general/types/configTypes.d.ts +0 -10
- package/dist/general/types/configTypes.d.ts.map +1 -1
- package/dist/general/types/generalTypes.d.ts +4 -0
- package/dist/general/types/generalTypes.d.ts.map +1 -1
- package/dist/general/types/moveErrorsInterface.d.ts +1 -1
- package/dist/general/types/moveErrorsInterface.d.ts.map +1 -1
- package/dist/general/utils/caller.d.ts +17 -2
- package/dist/general/utils/caller.d.ts.map +1 -1
- package/dist/general/utils/caller.js +35 -2
- package/dist/general/utils/casting.d.ts +4 -5
- package/dist/general/utils/casting.d.ts.map +1 -1
- package/dist/general/utils/casting.js +4 -5
- package/dist/general/utils/helpers.d.ts +1 -0
- package/dist/general/utils/helpers.d.ts.map +1 -1
- package/dist/general/utils/helpers.js +35 -6
- package/dist/general/wallet/wallet.d.ts +1 -1
- package/dist/general/wallet/wallet.d.ts.map +1 -1
- package/dist/packages/coin/coin.d.ts +1 -1
- package/dist/packages/coin/coin.d.ts.map +1 -1
- package/dist/packages/coin/coin.js +3 -1
- package/dist/packages/farms/farms.d.ts +1 -1
- package/dist/packages/farms/farms.d.ts.map +1 -1
- package/dist/packages/farms/farmsStakedPosition.d.ts +1 -1
- package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
- package/dist/packages/farms/farmsStakingPool.d.ts +1 -1
- package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApi.d.ts +9 -17
- package/dist/packages/faucet/api/faucetApi.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApi.js +44 -49
- package/dist/packages/faucet/api/faucetApiCasting.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApiCasting.js +8 -5
- package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts +1 -4
- package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts.map +1 -1
- package/dist/packages/faucet/faucet.d.ts +1 -1
- package/dist/packages/faucet/faucet.d.ts.map +1 -1
- package/dist/packages/faucet/faucet.js +1 -1
- package/dist/packages/faucet/faucetTypes.d.ts +2 -3
- package/dist/packages/faucet/faucetTypes.d.ts.map +1 -1
- package/dist/packages/multisig/multisig.d.ts +1 -1
- package/dist/packages/multisig/multisig.d.ts.map +1 -1
- package/dist/packages/nftAmm/nftAmm.d.ts +1 -1
- package/dist/packages/nftAmm/nftAmm.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts +11 -203
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApi.js +924 -615
- package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts +10 -21
- package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApiCasting.js +243 -221
- package/dist/packages/perpetuals/index.d.ts +1 -0
- package/dist/packages/perpetuals/index.d.ts.map +1 -1
- package/dist/packages/perpetuals/index.js +1 -0
- package/dist/packages/perpetuals/perpetuals.d.ts +83 -14
- package/dist/packages/perpetuals/perpetuals.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetuals.js +158 -59
- package/dist/packages/perpetuals/perpetualsAccount.d.ts +158 -86
- package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsAccount.js +481 -141
- package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts +82 -149
- package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.d.ts +55 -20
- package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.js +110 -55
- package/dist/packages/perpetuals/perpetualsTypes.d.ts +586 -280
- package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsTypes.js +17 -81
- package/dist/packages/perpetuals/perpetualsVault.d.ts +109 -0
- package/dist/packages/perpetuals/perpetualsVault.d.ts.map +1 -0
- package/dist/packages/perpetuals/perpetualsVault.js +290 -0
- package/dist/packages/pools/pool.d.ts +1 -1
- package/dist/packages/pools/pool.d.ts.map +1 -1
- package/dist/packages/pools/pools.d.ts +1 -1
- package/dist/packages/pools/pools.d.ts.map +1 -1
- package/dist/packages/referralVault/referralVault.d.ts +1 -1
- package/dist/packages/referralVault/referralVault.d.ts.map +1 -1
- package/dist/packages/staking/staking.d.ts +1 -1
- package/dist/packages/staking/staking.d.ts.map +1 -1
- package/dist/packages/sui/sui.d.ts +1 -1
- package/dist/packages/sui/sui.d.ts.map +1 -1
- package/dist/packages/suiFrens/stakedSuiFren.d.ts +1 -1
- package/dist/packages/suiFrens/stakedSuiFren.d.ts.map +1 -1
- package/dist/packages/suiFrens/suiFren.d.ts +1 -1
- package/dist/packages/suiFrens/suiFren.d.ts.map +1 -1
- package/dist/packages/suiFrens/suiFrens.d.ts +1 -1
- package/dist/packages/suiFrens/suiFrens.d.ts.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/package.json +1 -1
- package/dist/packages/oracle/api/oracleApi.d.ts +0 -21
- package/dist/packages/oracle/api/oracleApi.d.ts.map +0 -1
- package/dist/packages/oracle/api/oracleApi.js +0 -76
- package/dist/packages/oracle/api/oracleApiCasting.d.ts +0 -6
- package/dist/packages/oracle/api/oracleApiCasting.d.ts.map +0 -1
- package/dist/packages/oracle/api/oracleApiCasting.js +0 -25
- package/dist/packages/oracle/oracle.d.ts +0 -15
- package/dist/packages/oracle/oracle.d.ts.map +0 -1
- package/dist/packages/oracle/oracle.js +0 -46
- package/dist/packages/oracle/oracleCastingTypes.d.ts +0 -11
- package/dist/packages/oracle/oracleCastingTypes.d.ts.map +0 -1
- package/dist/packages/oracle/oracleCastingTypes.js +0 -2
- package/dist/packages/oracle/oracleTypes.d.ts +0 -10
- package/dist/packages/oracle/oracleTypes.d.ts.map +0 -1
- package/dist/packages/oracle/oracleTypes.js +0 -2
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
3
|
exports.PerpetualsApi = void 0;
|
|
24
|
-
const transactions_1 = require("@mysten/sui/transactions");
|
|
25
|
-
const utils_1 = require("../../../general/utils");
|
|
26
|
-
const sui_1 = require("../../sui");
|
|
27
4
|
const eventsApiHelpers_1 = require("../../../general/apiHelpers/eventsApiHelpers");
|
|
28
|
-
const transactionsApiHelpers_1 = require("../../../general/apiHelpers/transactionsApiHelpers");
|
|
29
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
30
5
|
class PerpetualsApi {
|
|
31
6
|
// =========================================================================
|
|
32
7
|
// Constructor
|
|
@@ -34,205 +9,434 @@ class PerpetualsApi {
|
|
|
34
9
|
constructor(Provider) {
|
|
35
10
|
this.Provider = Provider;
|
|
36
11
|
// =========================================================================
|
|
12
|
+
// Objects
|
|
13
|
+
// =========================================================================
|
|
14
|
+
// public fetchMarket = async (inputs: {
|
|
15
|
+
// marketId: PerpetualsMarketId;
|
|
16
|
+
// collateralCoinType: CoinType;
|
|
17
|
+
// }): Promise<PerpetualsMarketData> => {
|
|
18
|
+
// const { collateralCoinType } = inputs;
|
|
19
|
+
// return this.Provider.Objects().fetchCastObject({
|
|
20
|
+
// objectId: inputs.marketId,
|
|
21
|
+
// objectFromSuiObjectResponse: (data) =>
|
|
22
|
+
// Casting.perpetuals.clearingHouseFromOnChain(
|
|
23
|
+
// data,
|
|
24
|
+
// collateralCoinType
|
|
25
|
+
// ),
|
|
26
|
+
// });
|
|
27
|
+
// };
|
|
28
|
+
// =========================================================================
|
|
29
|
+
// Inspections
|
|
30
|
+
// =========================================================================
|
|
31
|
+
// public fetchOrderbookPrice = async (inputs: {
|
|
32
|
+
// collateralCoinType: ObjectId;
|
|
33
|
+
// marketId: PerpetualsMarketId;
|
|
34
|
+
// // marketInitialSharedVersion: ObjectVersion;
|
|
35
|
+
// }): Promise<number> => {
|
|
36
|
+
// const {
|
|
37
|
+
// collateralCoinType,
|
|
38
|
+
// marketId,
|
|
39
|
+
// // marketInitialSharedVersion
|
|
40
|
+
// } = inputs;
|
|
41
|
+
// const tx = new Transaction();
|
|
42
|
+
// this.getBookPriceTx({
|
|
43
|
+
// tx,
|
|
44
|
+
// marketId,
|
|
45
|
+
// collateralCoinType,
|
|
46
|
+
// // marketInitialSharedVersion,
|
|
47
|
+
// });
|
|
48
|
+
// const bytes =
|
|
49
|
+
// await this.Provider.Inspections().fetchFirstBytesFromTxOutput({
|
|
50
|
+
// tx,
|
|
51
|
+
// });
|
|
52
|
+
// return PerpetualsApiCasting.orderbookPriceFromBytes(bytes);
|
|
53
|
+
// };
|
|
54
|
+
// public fetchAllMarketIds = async (inputs: {
|
|
55
|
+
// collateralCoinType: CoinType;
|
|
56
|
+
// }): Promise<PerpetualsMarketId[]> => {
|
|
57
|
+
// const { collateralCoinType } = inputs;
|
|
58
|
+
// const marketIdsData = await this.Provider.indexerCaller.fetchIndexer<
|
|
59
|
+
// {
|
|
60
|
+
// marketId: ObjectId;
|
|
61
|
+
// }[]
|
|
62
|
+
// >(
|
|
63
|
+
// `perpetuals/markets/${Helpers.addLeadingZeroesToType(
|
|
64
|
+
// collateralCoinType
|
|
65
|
+
// )}`
|
|
66
|
+
// );
|
|
67
|
+
// return marketIdsData.map((data) =>
|
|
68
|
+
// Helpers.addLeadingZeroesToType(data.marketId)
|
|
69
|
+
// );
|
|
70
|
+
// };
|
|
71
|
+
// =========================================================================
|
|
37
72
|
// Transaction Commands
|
|
38
73
|
// =========================================================================
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
74
|
+
// public depositCollateralTx = (
|
|
75
|
+
// inputs: {
|
|
76
|
+
// tx: Transaction;
|
|
77
|
+
// collateralCoinType: CoinType;
|
|
78
|
+
// accountCapId: ObjectId | TransactionArgument;
|
|
79
|
+
// } & (
|
|
80
|
+
// | {
|
|
81
|
+
// coinId: ObjectId | TransactionArgument;
|
|
82
|
+
// }
|
|
83
|
+
// | {
|
|
84
|
+
// coinBytes: Uint8Array;
|
|
85
|
+
// }
|
|
86
|
+
// )
|
|
87
|
+
// ) => {
|
|
88
|
+
// const { tx, collateralCoinType, accountCapId } = inputs;
|
|
89
|
+
// return tx.moveCall({
|
|
90
|
+
// target: Helpers.transactions.createTxTarget(
|
|
91
|
+
// this.addresses.packages.perpetuals,
|
|
92
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
93
|
+
// "deposit_collateral"
|
|
94
|
+
// ),
|
|
95
|
+
// typeArguments: [collateralCoinType],
|
|
96
|
+
// arguments: [
|
|
97
|
+
// typeof accountCapId === "string"
|
|
98
|
+
// ? tx.object(accountCapId)
|
|
99
|
+
// : accountCapId,
|
|
100
|
+
// "coinBytes" in inputs
|
|
101
|
+
// ? tx.pure(inputs.coinBytes)
|
|
102
|
+
// : typeof inputs.coinId === "string"
|
|
103
|
+
// ? tx.object(inputs.coinId)
|
|
104
|
+
// : inputs.coinId,
|
|
105
|
+
// ],
|
|
106
|
+
// });
|
|
107
|
+
// };
|
|
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
|
+
// };
|
|
403
|
+
// public withdrawCollateralTx = (inputs: {
|
|
404
|
+
// tx: Transaction;
|
|
405
|
+
// collateralCoinType: CoinType;
|
|
406
|
+
// accountCapId: ObjectId | TransactionArgument;
|
|
407
|
+
// amount: Balance;
|
|
408
|
+
// }): TransactionArgument => {
|
|
409
|
+
// const { tx, collateralCoinType, accountCapId, amount } = inputs;
|
|
410
|
+
// return tx.moveCall({
|
|
411
|
+
// target: Helpers.transactions.createTxTarget(
|
|
412
|
+
// this.addresses.packages.perpetuals,
|
|
413
|
+
// PerpetualsApi.constants.moduleNames.interface,
|
|
414
|
+
// "withdraw_collateral"
|
|
415
|
+
// ),
|
|
416
|
+
// typeArguments: [collateralCoinType],
|
|
417
|
+
// arguments: [
|
|
418
|
+
// typeof accountCapId === "string"
|
|
419
|
+
// ? tx.object(accountCapId)
|
|
420
|
+
// : accountCapId,
|
|
421
|
+
// tx.pure.u64(amount),
|
|
422
|
+
// ],
|
|
423
|
+
// });
|
|
424
|
+
// };
|
|
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
|
+
// };
|
|
236
440
|
// public getHotPotatoFieldsTx = (
|
|
237
441
|
// inputs: {
|
|
238
442
|
// tx: Transaction;
|
|
@@ -277,313 +481,372 @@ class PerpetualsApi {
|
|
|
277
481
|
// ],
|
|
278
482
|
// });
|
|
279
483
|
// };
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
-
};
|
|
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: number;
|
|
584
|
+
// toPrice: number;
|
|
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
|
+
// };
|
|
407
626
|
// =========================================================================
|
|
408
627
|
// Transaction Builders
|
|
409
628
|
// =========================================================================
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
this.
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
629
|
+
// public fetchBuildDepositCollateralTx = async (
|
|
630
|
+
// inputs: ApiPerpetualsDepositCollateralBody
|
|
631
|
+
// ): Promise<Transaction> => {
|
|
632
|
+
// const tx = new Transaction();
|
|
633
|
+
// tx.setSender(inputs.walletAddress);
|
|
634
|
+
// const { walletAddress, collateralCoinType, amount } = inputs;
|
|
635
|
+
// const coinId = await this.Provider.Coin().fetchCoinWithAmountTx({
|
|
636
|
+
// tx,
|
|
637
|
+
// walletAddress,
|
|
638
|
+
// coinType: collateralCoinType,
|
|
639
|
+
// coinAmount: amount,
|
|
640
|
+
// });
|
|
641
|
+
// this.depositCollateralTx({
|
|
642
|
+
// tx,
|
|
643
|
+
// coinId,
|
|
644
|
+
// ...inputs,
|
|
645
|
+
// });
|
|
646
|
+
// return tx;
|
|
647
|
+
// };
|
|
648
|
+
// public buildCancelOrderTx = (
|
|
649
|
+
// inputs: ApiPerpetualsCancelOrderBody
|
|
650
|
+
// ): Transaction => {
|
|
651
|
+
// const {
|
|
652
|
+
// packageId,
|
|
653
|
+
// orderId,
|
|
654
|
+
// marketId,
|
|
655
|
+
// marketInitialSharedVersion,
|
|
656
|
+
// collateralChange,
|
|
657
|
+
// basePriceFeedId,
|
|
658
|
+
// collateralPriceFeedId,
|
|
659
|
+
// ...otherInputs
|
|
660
|
+
// } = inputs;
|
|
661
|
+
// return this.buildCancelOrdersTx({
|
|
662
|
+
// ...otherInputs,
|
|
663
|
+
// orderDatas: [
|
|
664
|
+
// {
|
|
665
|
+
// packageId,
|
|
666
|
+
// orderId,
|
|
667
|
+
// marketId,
|
|
668
|
+
// marketInitialSharedVersion,
|
|
669
|
+
// collateralChange,
|
|
670
|
+
// basePriceFeedId,
|
|
671
|
+
// collateralPriceFeedId,
|
|
672
|
+
// },
|
|
673
|
+
// ],
|
|
674
|
+
// });
|
|
675
|
+
// };
|
|
676
|
+
// public buildCancelOrdersTx = (
|
|
677
|
+
// inputs: ApiPerpetualsCancelOrdersBody
|
|
678
|
+
// ): Transaction => {
|
|
679
|
+
// const { orderDatas, collateralCoinType, accountCapId } = inputs;
|
|
680
|
+
// if (orderDatas.length <= 0)
|
|
681
|
+
// throw new Error("cannot have order datas of length zero");
|
|
682
|
+
// const tx = new Transaction();
|
|
683
|
+
// tx.setSender(inputs.walletAddress);
|
|
684
|
+
// const marketIdToOrderIds = orderDatas.reduce(
|
|
685
|
+
// (acc, order) => {
|
|
686
|
+
// if (order.marketId in acc) {
|
|
687
|
+
// return {
|
|
688
|
+
// ...acc,
|
|
689
|
+
// [order.marketId]: [...acc[order.marketId], order],
|
|
690
|
+
// };
|
|
691
|
+
// }
|
|
692
|
+
// return {
|
|
693
|
+
// ...acc,
|
|
694
|
+
// [order.marketId]: [order],
|
|
695
|
+
// };
|
|
696
|
+
// },
|
|
697
|
+
// {} as Record<
|
|
698
|
+
// PerpetualsMarketId,
|
|
699
|
+
// {
|
|
700
|
+
// packageId: PackageId;
|
|
701
|
+
// orderId: PerpetualsOrderId;
|
|
702
|
+
// marketId: PerpetualsMarketId;
|
|
703
|
+
// marketInitialSharedVersion: ObjectVersion;
|
|
704
|
+
// collateralChange: Balance;
|
|
705
|
+
// basePriceFeedId: ObjectId;
|
|
706
|
+
// collateralPriceFeedId: ObjectId;
|
|
707
|
+
// }[]
|
|
708
|
+
// >
|
|
709
|
+
// );
|
|
710
|
+
// for (const [marketId, orders] of Object.entries(marketIdToOrderIds)) {
|
|
711
|
+
// if (orders.length <= 0) continue;
|
|
712
|
+
// const marketInitialSharedVersion =
|
|
713
|
+
// orders[0].marketInitialSharedVersion;
|
|
714
|
+
// const packageId = orders[0].packageId;
|
|
715
|
+
// this.cancelOrdersTx({
|
|
716
|
+
// tx,
|
|
717
|
+
// collateralCoinType,
|
|
718
|
+
// accountCapId,
|
|
719
|
+
// marketId,
|
|
720
|
+
// marketInitialSharedVersion,
|
|
721
|
+
// packageId,
|
|
722
|
+
// orderIds: orders.map((order) => order.orderId),
|
|
723
|
+
// });
|
|
724
|
+
// const netCollateralChange = Helpers.sumBigInt(
|
|
725
|
+
// orders.map((order) => order.collateralChange)
|
|
726
|
+
// );
|
|
727
|
+
// if (netCollateralChange < BigInt(0)) {
|
|
728
|
+
// this.deallocateCollateralTx({
|
|
729
|
+
// tx,
|
|
730
|
+
// accountCapId,
|
|
731
|
+
// collateralCoinType,
|
|
732
|
+
// marketId,
|
|
733
|
+
// marketInitialSharedVersion,
|
|
734
|
+
// packageId,
|
|
735
|
+
// amount: Helpers.absBigInt(netCollateralChange),
|
|
736
|
+
// basePriceFeedId: orders[0].basePriceFeedId,
|
|
737
|
+
// collateralPriceFeedId: orders[0].collateralPriceFeedId,
|
|
738
|
+
// });
|
|
739
|
+
// } else if (netCollateralChange > BigInt(0)) {
|
|
740
|
+
// this.allocateCollateralTx({
|
|
741
|
+
// tx,
|
|
742
|
+
// accountCapId,
|
|
743
|
+
// collateralCoinType,
|
|
744
|
+
// marketId,
|
|
745
|
+
// marketInitialSharedVersion,
|
|
746
|
+
// packageId,
|
|
747
|
+
// amount: netCollateralChange,
|
|
748
|
+
// });
|
|
749
|
+
// } else {
|
|
750
|
+
// // no collateral change
|
|
751
|
+
// }
|
|
752
|
+
// }
|
|
753
|
+
// return tx;
|
|
754
|
+
// };
|
|
755
|
+
// public buildTransferCollateralTx = (inputs: {
|
|
756
|
+
// walletAddress: SuiAddress;
|
|
757
|
+
// collateralCoinType: CoinType;
|
|
758
|
+
// fromAccountCapId: ObjectId | TransactionArgument;
|
|
759
|
+
// toAccountCapId: ObjectId | TransactionArgument;
|
|
760
|
+
// amount: Balance;
|
|
761
|
+
// }): Transaction => {
|
|
762
|
+
// const {
|
|
763
|
+
// walletAddress,
|
|
764
|
+
// collateralCoinType,
|
|
765
|
+
// fromAccountCapId,
|
|
766
|
+
// toAccountCapId,
|
|
767
|
+
// amount,
|
|
768
|
+
// } = inputs;
|
|
769
|
+
// const tx = new Transaction();
|
|
770
|
+
// tx.setSender(walletAddress);
|
|
771
|
+
// const coinId = this.withdrawCollateralTx({
|
|
772
|
+
// tx,
|
|
773
|
+
// collateralCoinType,
|
|
774
|
+
// amount,
|
|
775
|
+
// accountCapId: fromAccountCapId,
|
|
776
|
+
// });
|
|
777
|
+
// this.depositCollateralTx({
|
|
778
|
+
// tx,
|
|
779
|
+
// collateralCoinType,
|
|
780
|
+
// coinId,
|
|
781
|
+
// accountCapId: toAccountCapId,
|
|
782
|
+
// });
|
|
783
|
+
// return tx;
|
|
784
|
+
// };
|
|
785
|
+
// public buildAllocateCollateralTx = TransactionsApiHelpers.createBuildTxFunc(
|
|
786
|
+
// this.allocateCollateralTx
|
|
787
|
+
// );
|
|
788
|
+
// public buildDeallocateCollateralTx =
|
|
789
|
+
// TransactionsApiHelpers.createBuildTxFunc(this.deallocateCollateralTx);
|
|
790
|
+
// public buildReduceOrdersTx = (
|
|
791
|
+
// inputs: ApiPerpetualsReduceOrdersBody
|
|
792
|
+
// ): Transaction => {
|
|
793
|
+
// const {
|
|
794
|
+
// walletAddress,
|
|
795
|
+
// collateralChange,
|
|
796
|
+
// accountCapId,
|
|
797
|
+
// collateralCoinType,
|
|
798
|
+
// marketId,
|
|
799
|
+
// marketInitialSharedVersion,
|
|
800
|
+
// packageId,
|
|
801
|
+
// basePriceFeedId,
|
|
802
|
+
// collateralPriceFeedId,
|
|
803
|
+
// orderIds,
|
|
804
|
+
// sizesToSubtract,
|
|
805
|
+
// } = inputs;
|
|
806
|
+
// const tx = new Transaction();
|
|
807
|
+
// tx.setSender(walletAddress);
|
|
808
|
+
// this.reduceOrdersTx({
|
|
809
|
+
// tx,
|
|
810
|
+
// packageId,
|
|
811
|
+
// collateralCoinType,
|
|
812
|
+
// accountCapId,
|
|
813
|
+
// marketId,
|
|
814
|
+
// marketInitialSharedVersion,
|
|
815
|
+
// orderIds,
|
|
816
|
+
// sizesToSubtract,
|
|
817
|
+
// });
|
|
818
|
+
// if (collateralChange < BigInt(0)) {
|
|
819
|
+
// this.deallocateCollateralTx({
|
|
820
|
+
// tx,
|
|
821
|
+
// accountCapId,
|
|
822
|
+
// collateralCoinType,
|
|
823
|
+
// marketId,
|
|
824
|
+
// marketInitialSharedVersion,
|
|
825
|
+
// packageId,
|
|
826
|
+
// basePriceFeedId,
|
|
827
|
+
// collateralPriceFeedId,
|
|
828
|
+
// amount: Helpers.absBigInt(collateralChange),
|
|
829
|
+
// });
|
|
830
|
+
// } else if (collateralChange > BigInt(0)) {
|
|
831
|
+
// this.allocateCollateralTx({
|
|
832
|
+
// tx,
|
|
833
|
+
// accountCapId,
|
|
834
|
+
// collateralCoinType,
|
|
835
|
+
// marketId,
|
|
836
|
+
// marketInitialSharedVersion,
|
|
837
|
+
// packageId,
|
|
838
|
+
// amount: collateralChange,
|
|
839
|
+
// });
|
|
840
|
+
// } else {
|
|
841
|
+
// // no collateral change
|
|
842
|
+
// }
|
|
843
|
+
// return tx;
|
|
844
|
+
// };
|
|
582
845
|
// =========================================================================
|
|
583
846
|
// Helpers
|
|
584
847
|
// =========================================================================
|
|
585
848
|
this.getAccountCapType = (inputs) => {
|
|
586
|
-
return `${this.addresses.
|
|
849
|
+
return `${this.addresses.packages.events}::${PerpetualsApi.constants.moduleNames.account}::Account<${inputs.collateralCoinType}>`;
|
|
587
850
|
};
|
|
588
851
|
// =========================================================================
|
|
589
852
|
// Private Helpers
|
|
@@ -971,15 +1234,11 @@ class PerpetualsApi {
|
|
|
971
1234
|
// =========================================================================
|
|
972
1235
|
// Event Types
|
|
973
1236
|
// =========================================================================
|
|
974
|
-
this.eventType = (eventName) => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
if (!perpetuals || !oracle)
|
|
1237
|
+
this.eventType = (eventName) => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.events, PerpetualsApi.constants.moduleNames.events, eventName);
|
|
1238
|
+
const addresses = this.Provider.addresses.perpetuals;
|
|
1239
|
+
if (!addresses)
|
|
978
1240
|
throw new Error("not all required addresses have been set in provider");
|
|
979
|
-
this.addresses =
|
|
980
|
-
perpetuals,
|
|
981
|
-
oracle,
|
|
982
|
-
};
|
|
1241
|
+
this.addresses = addresses;
|
|
983
1242
|
this.eventTypes = {
|
|
984
1243
|
// Collateral
|
|
985
1244
|
withdrewCollateral: this.eventType("WithdrewCollateral"),
|
|
@@ -990,16 +1249,16 @@ class PerpetualsApi {
|
|
|
990
1249
|
// Liquidation
|
|
991
1250
|
liquidated: this.eventType("LiquidatedPosition"),
|
|
992
1251
|
filledTakerOrderLiquidator: this.eventType("FilledTakerOrderLiquidator"),
|
|
1252
|
+
performedLiquidation: this.eventType("PerformedLiquidation"),
|
|
993
1253
|
// Account
|
|
994
1254
|
createdAccount: this.eventType("CreatedAccount"),
|
|
995
1255
|
// Order
|
|
996
1256
|
canceledOrder: this.eventType("CanceledOrder"),
|
|
997
|
-
|
|
1257
|
+
filledMakerOrders: this.eventType("FilledMakerOrders"),
|
|
998
1258
|
filledMakerOrder: this.eventType("FilledMakerOrder"),
|
|
999
1259
|
filledTakerOrder: this.eventType("FilledTakerOrder"),
|
|
1000
1260
|
reducedOrder: this.eventType("ReducedOrder"),
|
|
1001
|
-
|
|
1002
|
-
postedOrderReceipt: this.eventType("OrderbookPostReceipt"),
|
|
1261
|
+
postedOrder: this.eventType("PostedOrder"),
|
|
1003
1262
|
// Twap
|
|
1004
1263
|
updatedPremiumTwap: this.eventType("UpdatedPremiumTwap"),
|
|
1005
1264
|
updatedSpreadTwap: this.eventType("UpdatedSpreadTwap"),
|
|
@@ -1007,90 +1266,140 @@ class PerpetualsApi {
|
|
|
1007
1266
|
updatedFunding: this.eventType("UpdatedFunding"),
|
|
1008
1267
|
// Version
|
|
1009
1268
|
updatedMarketVersion: this.eventType("UpdatedClearingHouseVersion"),
|
|
1269
|
+
// Stop Order
|
|
1270
|
+
createdStopOrderTicket: this.eventType("CreatedStopOrderTicket"),
|
|
1271
|
+
deletedStopOrderTicket: this.eventType("DeletedStopOrderTicket"),
|
|
1272
|
+
editedStopOrderTicketExecutor: this.eventType("EditedStopOrderTicketExecutor"),
|
|
1273
|
+
addedStopOrderTicketCollateral: this.eventType("AddedStopOrderTicketCollateral"),
|
|
1274
|
+
removedStopOrderTicketCollateral: this.eventType("RemovedStopOrderTicketCollateral"),
|
|
1275
|
+
editedStopOrderTicketDetails: this.eventType("EditedStopOrderTicketDetails"),
|
|
1276
|
+
executedStopOrderTicket: this.eventType("ExecutedStopOrderTicket"),
|
|
1010
1277
|
};
|
|
1011
1278
|
this.moveErrors = {
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1279
|
+
// TODO: add support for this back in some way ?
|
|
1280
|
+
// [this.addresses.packages.perpetuals]: {
|
|
1281
|
+
// ["ANY"]: {
|
|
1282
|
+
// // ClearingHouse
|
|
1283
|
+
// /// Cannot deposit/withdraw zero coins to/from the account's collateral.
|
|
1284
|
+
// 0: "Deposit Or Withdraw Amount Zero",
|
|
1285
|
+
// /// Orderbook size or price are invalid values
|
|
1286
|
+
// 1: "Invalid Size Or Price",
|
|
1287
|
+
// /// Index price returned from oracle is 0 or invalid value
|
|
1288
|
+
// 2: "Bad Index Price",
|
|
1289
|
+
// /// Order value in USD is too low
|
|
1290
|
+
// 4: "Order Usd Value Too Low",
|
|
1291
|
+
// /// Passed a vector of invalid order ids to perform force cancellation during liquidation
|
|
1292
|
+
// 5: "Invalid Force Cancel Ids",
|
|
1293
|
+
// /// Liquidate must be the first operation of the session, if performed.
|
|
1294
|
+
// 6: "Liquidate Not First Operation",
|
|
1295
|
+
// /// Passed a vector of invalid order ids to cancel
|
|
1296
|
+
// 7: "Invalid Cancel Order Ids",
|
|
1297
|
+
// /// Ticket has already passed `expire_timestamp` and can only be cancelled
|
|
1298
|
+
// 8: "Stop Order Ticket Expired",
|
|
1299
|
+
// /// Index price is not at correct value to satisfy stop order conditions
|
|
1300
|
+
// 9: "Stop Order Conditions Violated",
|
|
1301
|
+
// /// Index price is not at correct value to satisfy stop order conditions
|
|
1302
|
+
// 10: "Wrong Order Details",
|
|
1303
|
+
// /// Invalid base price feed storage for the clearing house
|
|
1304
|
+
// 11: "Invalid Base Price Feed Storage",
|
|
1305
|
+
// /// Same liquidator and liqee account ids
|
|
1306
|
+
// 12: "Self Liquidation",
|
|
1307
|
+
// /// User trying to access the subaccount is not the one specified by parent
|
|
1308
|
+
// 13: "Invalid Sub Account User",
|
|
1309
|
+
// /// The parent `Account` trying to delete the subaccount is not the correct one.
|
|
1310
|
+
// 14: "Wrong Parent For Sub Account",
|
|
1311
|
+
// /// Raised when trying to delete a subaccount still containing collateral.
|
|
1312
|
+
// 15: "Sub Account Contains Collateral",
|
|
1313
|
+
// /// Raised when trying to call a function with the wrong package's version
|
|
1314
|
+
// 16: "Wrong Version",
|
|
1315
|
+
// /// Raised when trying to have a session composed by only `start_session` and `end_session`
|
|
1316
|
+
// 17: "Empty Session",
|
|
1317
|
+
// /// Market already registered in the registry
|
|
1318
|
+
// 18: "Market Already Registered",
|
|
1319
|
+
// /// Collateral is not registered in the registry
|
|
1320
|
+
// 19: "Collateral Is Not Registered",
|
|
1321
|
+
// /// Market is not registered in the registry
|
|
1322
|
+
// 20: "Market Is Not Registered",
|
|
1323
|
+
// /// Invalid collateral price feed storage for the clearing house
|
|
1324
|
+
// 21: "Invalid Collateral Price Feed Storage",
|
|
1325
|
+
// /// Fees accrued are negative
|
|
1326
|
+
// 22: "Negative Fees Accrued",
|
|
1327
|
+
// /// Reduce-only conditions are not respected for stop order execution
|
|
1328
|
+
// 23: "Not Reduce Only Stop Order",
|
|
1329
|
+
// /// Stop order gas cost provided is not enough
|
|
1330
|
+
// 24: "Not Enough Gas For Stop Order",
|
|
1331
|
+
// /// Stop order collateral to allocate provided is not enough
|
|
1332
|
+
// 25: "Not Enough Collateral To Allocate For Stop Order",
|
|
1333
|
+
// /// Invalid account trying to perform an action on a StopOrderTicket
|
|
1334
|
+
// 26: "Invalid Account For Stop Order",
|
|
1335
|
+
// /// Invalid executor trying to execute the StopOrderTicket
|
|
1336
|
+
// 27: "Invalid Executor For Stop Order",
|
|
1337
|
+
// /// Raised when the market's max open interest is surpassed as a result of the session's actions
|
|
1338
|
+
// 28: "Max Open Interest Surpassed",
|
|
1339
|
+
// /// Raised when a position would get a base amount higher than the allowed percentage of open interest
|
|
1340
|
+
// 29: "Max Open Interest Position Percent Surpassed",
|
|
1341
|
+
// // Market
|
|
1342
|
+
// /// While creating ordered map with invalid parameters, or changing them improperly for an existent map.
|
|
1343
|
+
// 1000: "Invalid Market Parameters",
|
|
1344
|
+
// /// Tried to call `update_funding` before enough time has passed since the last update.
|
|
1345
|
+
// 1001: "Updating Funding Too Early",
|
|
1346
|
+
// /// Margin-ratio update proposal already exists for market
|
|
1347
|
+
// 1002: "Proposal Already Exists",
|
|
1348
|
+
// /// Margin-ratio update proposal cannot be committed too early
|
|
1349
|
+
// 1003: "Premature Proposal",
|
|
1350
|
+
// /// Margin-ratio update proposal delay is outside the valid range
|
|
1351
|
+
// 1004: "Invalid Proposal Delay",
|
|
1352
|
+
// /// Margin-ratio update proposal does not exist for market
|
|
1353
|
+
// 1005: "Proposal Does Not Exist",
|
|
1354
|
+
// /// Exchange has no available fees to withdraw
|
|
1355
|
+
// 1006: "No Fees Accrued",
|
|
1356
|
+
// /// Tried to withdraw more insurance funds than the allowed amount
|
|
1357
|
+
// 1007: "Insufficient Insurance Surplus",
|
|
1358
|
+
// /// Cannot create a market for which a price feed does not exist
|
|
1359
|
+
// 1008: "No Price Feed For Market",
|
|
1360
|
+
// /// Cannot delete a proposal that already matured. It can only be committed.
|
|
1361
|
+
// 1009: "Proposal Already Matured",
|
|
1362
|
+
// // Position
|
|
1363
|
+
// /// Tried placing a new pending order when the position already has the maximum allowed number of pending orders.
|
|
1364
|
+
// 2000: "Max Pending Orders Exceeded",
|
|
1365
|
+
// /// Used for checking both liqee and liqor positions during liquidation
|
|
1366
|
+
// 2001: "Position Below IMR",
|
|
1367
|
+
// ///When leaving liqee's position with a margin ratio above tolerance,
|
|
1368
|
+
// /// meaning that liqor has overbought position
|
|
1369
|
+
// 2002: "Position Above Tolerance",
|
|
1370
|
+
// /// An operation brought an account below initial margin requirements.
|
|
1371
|
+
// 2003: "Initial Margin Requirement Violated",
|
|
1372
|
+
// /// Position is above MMR, so can't be liquidated.
|
|
1373
|
+
// 2004: "Position Above MMR",
|
|
1374
|
+
// /// Cannot realize bad debt via means other than calling 'liquidate'.
|
|
1375
|
+
// 2005: "Position Bad Debt",
|
|
1376
|
+
// /// Cannot withdraw more than the account's free collateral.
|
|
1377
|
+
// 2006: "Insufficient Free Collateral",
|
|
1378
|
+
// /// Cannot have more than 1 position in a market.
|
|
1379
|
+
// 2007: "Position Already Exists",
|
|
1380
|
+
// /// Cannot compute deallocate amount for a target MR < IMR.
|
|
1381
|
+
// 2008: "Deallocate Target MR Too Low",
|
|
1382
|
+
// // Orderbook & OrderedMap
|
|
1383
|
+
// /// While creating ordered map with wrong parameters.
|
|
1384
|
+
// 3000: "Invalid Map Parameters",
|
|
1385
|
+
// /// While searching for a key, but it doesn't exist.
|
|
1386
|
+
// 3001: "Key Not Exist",
|
|
1387
|
+
// /// While inserting already existing key.
|
|
1388
|
+
// 3002: "Key Already Exists",
|
|
1389
|
+
// /// When attempting to destroy a non-empty map
|
|
1390
|
+
// 3003: "Destroy Not Empty",
|
|
1391
|
+
// /// Invalid user tries to modify an order
|
|
1392
|
+
// 3004: "Invalid User For Order",
|
|
1393
|
+
// /// Orderbook flag requirements violated
|
|
1394
|
+
// 3005: "Flag Requirements Violated",
|
|
1395
|
+
// /// Minimum size matched not reached
|
|
1396
|
+
// 3006: "Not Enough Liquidity",
|
|
1397
|
+
// /// When trying to change a map configuration, but the map has length less than 4
|
|
1398
|
+
// 3007: "Map Too Small",
|
|
1399
|
+
// /// When taker matches its own order
|
|
1400
|
+
// 3008: "Self Trading",
|
|
1401
|
+
// },
|
|
1402
|
+
// },
|
|
1094
1403
|
};
|
|
1095
1404
|
}
|
|
1096
1405
|
}
|