@typus/typus-perp-sdk 1.0.20 → 1.0.21-tk1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/src/api/sentio.js +1 -1
  2. package/dist/src/fetch.js +20 -27
  3. package/dist/src/index.d.ts +1 -1
  4. package/dist/src/index.js +16 -12
  5. package/dist/src/typus_perp/admin/structs.d.ts +5 -5
  6. package/dist/src/typus_perp/error/functions.d.ts +2 -2
  7. package/dist/src/typus_perp/error/functions.js +8 -8
  8. package/dist/src/typus_perp/escrow/structs.d.ts +1 -1
  9. package/dist/src/typus_perp/index.js +3 -3
  10. package/dist/src/typus_perp/init.js +0 -3
  11. package/dist/src/typus_perp/lp-pool/functions.d.ts +2 -10
  12. package/dist/src/typus_perp/lp-pool/functions.js +7 -27
  13. package/dist/src/typus_perp/lp-pool/structs.d.ts +26 -26
  14. package/dist/src/typus_perp/position/functions.d.ts +21 -6
  15. package/dist/src/typus_perp/position/functions.js +42 -6
  16. package/dist/src/typus_perp/position/structs.d.ts +6 -6
  17. package/dist/src/typus_perp/symbol/structs.d.ts +1 -1
  18. package/dist/src/typus_perp/tlp/structs.d.ts +2 -2
  19. package/dist/src/typus_perp/trading/functions.d.ts +50 -70
  20. package/dist/src/typus_perp/trading/functions.js +50 -70
  21. package/dist/src/typus_perp/trading/structs.d.ts +52 -30
  22. package/dist/src/typus_perp/trading/structs.js +6 -0
  23. package/dist/src/typus_perp/treasury-caps/structs.d.ts +1 -1
  24. package/dist/src/typus_stake_pool/admin/structs.d.ts +4 -4
  25. package/dist/src/typus_stake_pool/index.js +3 -3
  26. package/dist/src/typus_stake_pool/stake-pool/functions.d.ts +0 -1
  27. package/dist/src/typus_stake_pool/stake-pool/functions.js +0 -1
  28. package/dist/src/typus_stake_pool/stake-pool/structs.d.ts +22 -22
  29. package/dist/src/user/history.js +10 -10
  30. package/dist/src/user/order.js +87 -42
  31. package/dist/src/user/orderWithBidReceipt.js +58 -26
  32. package/dist/src/user/tlp.d.ts +4 -3
  33. package/dist/src/user/tlp.js +93 -60
  34. package/package.json +2 -2
  35. package/dist/src/typus_perp/oracle/functions.d.ts +0 -13
  36. package/dist/src/typus_perp/oracle/functions.js +0 -22
  37. package/dist/src/typus_perp/oracle/structs.d.ts +0 -111
  38. package/dist/src/typus_perp/oracle/structs.js +0 -389
@@ -1,389 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __read = (this && this.__read) || function (o, n) {
50
- var m = typeof Symbol === "function" && o[Symbol.iterator];
51
- if (!m) return o;
52
- var i = m.call(o), r, ar = [], e;
53
- try {
54
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
- }
56
- catch (error) { e = { error: error }; }
57
- finally {
58
- try {
59
- if (r && !r.done && (m = i["return"])) m.call(i);
60
- }
61
- finally { if (e) throw e.error; }
62
- }
63
- return ar;
64
- };
65
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
- if (ar || !(i in from)) {
68
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
- ar[i] = from[i];
70
- }
71
- }
72
- return to.concat(ar || Array.prototype.slice.call(from));
73
- };
74
- Object.defineProperty(exports, "__esModule", { value: true });
75
- exports.PythPriceInfoObject = exports.PythPrice = void 0;
76
- exports.isPythPrice = isPythPrice;
77
- exports.isPythPriceInfoObject = isPythPriceInfoObject;
78
- var structs_1 = require("../../_dependencies/source/0x2/object/structs");
79
- var reified_1 = require("../../_framework/reified");
80
- var util_1 = require("../../_framework/util");
81
- var index_1 = require("../index");
82
- var bcs_1 = require("@mysten/sui/bcs");
83
- var utils_1 = require("@mysten/sui/utils");
84
- /* ============================== PythPrice =============================== */
85
- function isPythPrice(type) {
86
- type = (0, util_1.compressSuiType)(type);
87
- return type === "".concat(index_1.PKG_V1, "::oracle::PythPrice");
88
- }
89
- var PythPrice = /** @class */ (function () {
90
- function PythPrice(typeArgs, fields) {
91
- this.__StructClass = true;
92
- this.$typeName = PythPrice.$typeName;
93
- this.$isPhantom = PythPrice.$isPhantom;
94
- this.$fullTypeName = util_1.composeSuiType.apply(void 0, __spreadArray([PythPrice.$typeName], __read(typeArgs), false));
95
- this.$typeArgs = typeArgs;
96
- this.price = fields.price;
97
- this.conf = fields.conf;
98
- this.timestamp = fields.timestamp;
99
- this.decimal = fields.decimal;
100
- }
101
- PythPrice.reified = function () {
102
- var _this = this;
103
- return {
104
- typeName: PythPrice.$typeName,
105
- fullTypeName: util_1.composeSuiType.apply(void 0, __spreadArray([PythPrice.$typeName], [], false)),
106
- typeArgs: [],
107
- isPhantom: PythPrice.$isPhantom,
108
- reifiedTypeArgs: [],
109
- fromFields: function (fields) { return PythPrice.fromFields(fields); },
110
- fromFieldsWithTypes: function (item) { return PythPrice.fromFieldsWithTypes(item); },
111
- fromBcs: function (data) { return PythPrice.fromBcs(data); },
112
- bcs: PythPrice.bcs,
113
- fromJSONField: function (field) { return PythPrice.fromJSONField(field); },
114
- fromJSON: function (json) { return PythPrice.fromJSON(json); },
115
- fromSuiParsedData: function (content) { return PythPrice.fromSuiParsedData(content); },
116
- fromSuiObjectData: function (content) { return PythPrice.fromSuiObjectData(content); },
117
- fetch: function (client, id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
118
- return [2 /*return*/, PythPrice.fetch(client, id)];
119
- }); }); },
120
- new: function (fields) {
121
- return new PythPrice([], fields);
122
- },
123
- kind: "StructClassReified",
124
- };
125
- };
126
- Object.defineProperty(PythPrice, "r", {
127
- get: function () {
128
- return PythPrice.reified();
129
- },
130
- enumerable: false,
131
- configurable: true
132
- });
133
- PythPrice.phantom = function () {
134
- return (0, reified_1.phantom)(PythPrice.reified());
135
- };
136
- Object.defineProperty(PythPrice, "p", {
137
- get: function () {
138
- return PythPrice.phantom();
139
- },
140
- enumerable: false,
141
- configurable: true
142
- });
143
- Object.defineProperty(PythPrice, "bcs", {
144
- get: function () {
145
- return bcs_1.bcs.struct("PythPrice", {
146
- price: bcs_1.bcs.u64(),
147
- conf: bcs_1.bcs.u64(),
148
- timestamp: bcs_1.bcs.u64(),
149
- decimal: bcs_1.bcs.u64(),
150
- });
151
- },
152
- enumerable: false,
153
- configurable: true
154
- });
155
- PythPrice.fromFields = function (fields) {
156
- return PythPrice.reified().new({
157
- price: (0, reified_1.decodeFromFields)("u64", fields.price),
158
- conf: (0, reified_1.decodeFromFields)("u64", fields.conf),
159
- timestamp: (0, reified_1.decodeFromFields)("u64", fields.timestamp),
160
- decimal: (0, reified_1.decodeFromFields)("u64", fields.decimal),
161
- });
162
- };
163
- PythPrice.fromFieldsWithTypes = function (item) {
164
- if (!isPythPrice(item.type)) {
165
- throw new Error("not a PythPrice type");
166
- }
167
- return PythPrice.reified().new({
168
- price: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.price),
169
- conf: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.conf),
170
- timestamp: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.timestamp),
171
- decimal: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.decimal),
172
- });
173
- };
174
- PythPrice.fromBcs = function (data) {
175
- return PythPrice.fromFields(PythPrice.bcs.parse(data));
176
- };
177
- PythPrice.prototype.toJSONField = function () {
178
- return {
179
- price: this.price.toString(),
180
- conf: this.conf.toString(),
181
- timestamp: this.timestamp.toString(),
182
- decimal: this.decimal.toString(),
183
- };
184
- };
185
- PythPrice.prototype.toJSON = function () {
186
- return __assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
187
- };
188
- PythPrice.fromJSONField = function (field) {
189
- return PythPrice.reified().new({
190
- price: (0, reified_1.decodeFromJSONField)("u64", field.price),
191
- conf: (0, reified_1.decodeFromJSONField)("u64", field.conf),
192
- timestamp: (0, reified_1.decodeFromJSONField)("u64", field.timestamp),
193
- decimal: (0, reified_1.decodeFromJSONField)("u64", field.decimal),
194
- });
195
- };
196
- PythPrice.fromJSON = function (json) {
197
- if (json.$typeName !== PythPrice.$typeName) {
198
- throw new Error("not a WithTwoGenerics json object");
199
- }
200
- return PythPrice.fromJSONField(json);
201
- };
202
- PythPrice.fromSuiParsedData = function (content) {
203
- if (content.dataType !== "moveObject") {
204
- throw new Error("not an object");
205
- }
206
- if (!isPythPrice(content.type)) {
207
- throw new Error("object at ".concat(content.fields.id, " is not a PythPrice object"));
208
- }
209
- return PythPrice.fromFieldsWithTypes(content);
210
- };
211
- PythPrice.fromSuiObjectData = function (data) {
212
- if (data.bcs) {
213
- if (data.bcs.dataType !== "moveObject" || !isPythPrice(data.bcs.type)) {
214
- throw new Error("object at is not a PythPrice object");
215
- }
216
- return PythPrice.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
217
- }
218
- if (data.content) {
219
- return PythPrice.fromSuiParsedData(data.content);
220
- }
221
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
222
- };
223
- PythPrice.fetch = function (client, id) {
224
- return __awaiter(this, void 0, void 0, function () {
225
- var res;
226
- var _a, _b;
227
- return __generator(this, function (_c) {
228
- switch (_c.label) {
229
- case 0: return [4 /*yield*/, client.getObject({ id: id, options: { showBcs: true } })];
230
- case 1:
231
- res = _c.sent();
232
- if (res.error) {
233
- throw new Error("error fetching PythPrice object at id ".concat(id, ": ").concat(res.error.code));
234
- }
235
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isPythPrice(res.data.bcs.type)) {
236
- throw new Error("object at id ".concat(id, " is not a PythPrice object"));
237
- }
238
- return [2 /*return*/, PythPrice.fromSuiObjectData(res.data)];
239
- }
240
- });
241
- });
242
- };
243
- PythPrice.$typeName = "".concat(index_1.PKG_V1, "::oracle::PythPrice");
244
- PythPrice.$numTypeParams = 0;
245
- PythPrice.$isPhantom = [];
246
- return PythPrice;
247
- }());
248
- exports.PythPrice = PythPrice;
249
- /* ============================== PythPriceInfoObject =============================== */
250
- function isPythPriceInfoObject(type) {
251
- type = (0, util_1.compressSuiType)(type);
252
- return type === "".concat(index_1.PKG_V1, "::oracle::PythPriceInfoObject");
253
- }
254
- var PythPriceInfoObject = /** @class */ (function () {
255
- function PythPriceInfoObject(typeArgs, fields) {
256
- this.__StructClass = true;
257
- this.$typeName = PythPriceInfoObject.$typeName;
258
- this.$isPhantom = PythPriceInfoObject.$isPhantom;
259
- this.$fullTypeName = util_1.composeSuiType.apply(void 0, __spreadArray([PythPriceInfoObject.$typeName], __read(typeArgs), false));
260
- this.$typeArgs = typeArgs;
261
- this.id = fields.id;
262
- }
263
- PythPriceInfoObject.reified = function () {
264
- var _this = this;
265
- return {
266
- typeName: PythPriceInfoObject.$typeName,
267
- fullTypeName: util_1.composeSuiType.apply(void 0, __spreadArray([PythPriceInfoObject.$typeName], [], false)),
268
- typeArgs: [],
269
- isPhantom: PythPriceInfoObject.$isPhantom,
270
- reifiedTypeArgs: [],
271
- fromFields: function (fields) { return PythPriceInfoObject.fromFields(fields); },
272
- fromFieldsWithTypes: function (item) { return PythPriceInfoObject.fromFieldsWithTypes(item); },
273
- fromBcs: function (data) { return PythPriceInfoObject.fromBcs(data); },
274
- bcs: PythPriceInfoObject.bcs,
275
- fromJSONField: function (field) { return PythPriceInfoObject.fromJSONField(field); },
276
- fromJSON: function (json) { return PythPriceInfoObject.fromJSON(json); },
277
- fromSuiParsedData: function (content) { return PythPriceInfoObject.fromSuiParsedData(content); },
278
- fromSuiObjectData: function (content) { return PythPriceInfoObject.fromSuiObjectData(content); },
279
- fetch: function (client, id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
280
- return [2 /*return*/, PythPriceInfoObject.fetch(client, id)];
281
- }); }); },
282
- new: function (fields) {
283
- return new PythPriceInfoObject([], fields);
284
- },
285
- kind: "StructClassReified",
286
- };
287
- };
288
- Object.defineProperty(PythPriceInfoObject, "r", {
289
- get: function () {
290
- return PythPriceInfoObject.reified();
291
- },
292
- enumerable: false,
293
- configurable: true
294
- });
295
- PythPriceInfoObject.phantom = function () {
296
- return (0, reified_1.phantom)(PythPriceInfoObject.reified());
297
- };
298
- Object.defineProperty(PythPriceInfoObject, "p", {
299
- get: function () {
300
- return PythPriceInfoObject.phantom();
301
- },
302
- enumerable: false,
303
- configurable: true
304
- });
305
- Object.defineProperty(PythPriceInfoObject, "bcs", {
306
- get: function () {
307
- return bcs_1.bcs.struct("PythPriceInfoObject", {
308
- id: structs_1.ID.bcs,
309
- });
310
- },
311
- enumerable: false,
312
- configurable: true
313
- });
314
- PythPriceInfoObject.fromFields = function (fields) {
315
- return PythPriceInfoObject.reified().new({ id: (0, reified_1.decodeFromFields)(structs_1.ID.reified(), fields.id) });
316
- };
317
- PythPriceInfoObject.fromFieldsWithTypes = function (item) {
318
- if (!isPythPriceInfoObject(item.type)) {
319
- throw new Error("not a PythPriceInfoObject type");
320
- }
321
- return PythPriceInfoObject.reified().new({ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.ID.reified(), item.fields.id) });
322
- };
323
- PythPriceInfoObject.fromBcs = function (data) {
324
- return PythPriceInfoObject.fromFields(PythPriceInfoObject.bcs.parse(data));
325
- };
326
- PythPriceInfoObject.prototype.toJSONField = function () {
327
- return {
328
- id: this.id,
329
- };
330
- };
331
- PythPriceInfoObject.prototype.toJSON = function () {
332
- return __assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
333
- };
334
- PythPriceInfoObject.fromJSONField = function (field) {
335
- return PythPriceInfoObject.reified().new({ id: (0, reified_1.decodeFromJSONField)(structs_1.ID.reified(), field.id) });
336
- };
337
- PythPriceInfoObject.fromJSON = function (json) {
338
- if (json.$typeName !== PythPriceInfoObject.$typeName) {
339
- throw new Error("not a WithTwoGenerics json object");
340
- }
341
- return PythPriceInfoObject.fromJSONField(json);
342
- };
343
- PythPriceInfoObject.fromSuiParsedData = function (content) {
344
- if (content.dataType !== "moveObject") {
345
- throw new Error("not an object");
346
- }
347
- if (!isPythPriceInfoObject(content.type)) {
348
- throw new Error("object at ".concat(content.fields.id, " is not a PythPriceInfoObject object"));
349
- }
350
- return PythPriceInfoObject.fromFieldsWithTypes(content);
351
- };
352
- PythPriceInfoObject.fromSuiObjectData = function (data) {
353
- if (data.bcs) {
354
- if (data.bcs.dataType !== "moveObject" || !isPythPriceInfoObject(data.bcs.type)) {
355
- throw new Error("object at is not a PythPriceInfoObject object");
356
- }
357
- return PythPriceInfoObject.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
358
- }
359
- if (data.content) {
360
- return PythPriceInfoObject.fromSuiParsedData(data.content);
361
- }
362
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
363
- };
364
- PythPriceInfoObject.fetch = function (client, id) {
365
- return __awaiter(this, void 0, void 0, function () {
366
- var res;
367
- var _a, _b;
368
- return __generator(this, function (_c) {
369
- switch (_c.label) {
370
- case 0: return [4 /*yield*/, client.getObject({ id: id, options: { showBcs: true } })];
371
- case 1:
372
- res = _c.sent();
373
- if (res.error) {
374
- throw new Error("error fetching PythPriceInfoObject object at id ".concat(id, ": ").concat(res.error.code));
375
- }
376
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isPythPriceInfoObject(res.data.bcs.type)) {
377
- throw new Error("object at id ".concat(id, " is not a PythPriceInfoObject object"));
378
- }
379
- return [2 /*return*/, PythPriceInfoObject.fromSuiObjectData(res.data)];
380
- }
381
- });
382
- });
383
- };
384
- PythPriceInfoObject.$typeName = "".concat(index_1.PKG_V1, "::oracle::PythPriceInfoObject");
385
- PythPriceInfoObject.$numTypeParams = 0;
386
- PythPriceInfoObject.$isPhantom = [];
387
- return PythPriceInfoObject;
388
- }());
389
- exports.PythPriceInfoObject = PythPriceInfoObject;