@suilend/sdk 3.0.7 → 4.0.0

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 (71) hide show
  1. package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +4 -4
  2. package/_generated/_dependencies/source/0x1/ascii/structs.js +42 -41
  3. package/_generated/_dependencies/source/0x1/option/structs.js +22 -26
  4. package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +3 -3
  5. package/_generated/_dependencies/source/0x1/type-name/structs.js +21 -25
  6. package/_generated/_dependencies/source/0x2/bag/structs.d.ts +5 -5
  7. package/_generated/_dependencies/source/0x2/bag/structs.js +22 -25
  8. package/_generated/_dependencies/source/0x2/balance/structs.d.ts +4 -4
  9. package/_generated/_dependencies/source/0x2/balance/structs.js +42 -41
  10. package/_generated/_dependencies/source/0x2/object/structs.d.ts +5 -5
  11. package/_generated/_dependencies/source/0x2/object/structs.js +42 -41
  12. package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +5 -5
  13. package/_generated/_dependencies/source/0x2/object-table/structs.js +22 -25
  14. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +3 -3
  15. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +22 -25
  16. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +9 -9
  17. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +24 -25
  18. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +21 -21
  19. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +23 -25
  20. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +2 -2
  21. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -25
  22. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +52 -52
  23. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +45 -41
  24. package/_generated/_framework/vector.js +9 -6
  25. package/_generated/suilend/cell/structs.d.ts +1 -1
  26. package/_generated/suilend/cell/structs.js +21 -25
  27. package/_generated/suilend/decimal/structs.d.ts +2 -2
  28. package/_generated/suilend/decimal/structs.js +21 -25
  29. package/_generated/suilend/lending-market/structs.d.ts +129 -129
  30. package/_generated/suilend/lending-market/structs.js +391 -265
  31. package/_generated/suilend/liquidity-mining/structs.d.ts +44 -44
  32. package/_generated/suilend/liquidity-mining/structs.js +122 -89
  33. package/_generated/suilend/obligation/structs.d.ts +98 -98
  34. package/_generated/suilend/obligation/structs.js +194 -121
  35. package/_generated/suilend/rate-limiter/structs.d.ts +12 -12
  36. package/_generated/suilend/rate-limiter/structs.js +46 -41
  37. package/_generated/suilend/reserve/structs.d.ts +128 -128
  38. package/_generated/suilend/reserve/structs.js +243 -153
  39. package/_generated/suilend/reserve-config/structs.d.ts +30 -30
  40. package/_generated/suilend/reserve-config/structs.js +60 -41
  41. package/api/events.js +5 -14
  42. package/client.js +267 -319
  43. package/lib/initialize.d.ts +2 -2
  44. package/lib/initialize.js +26 -31
  45. package/lib/liquidityMining.js +15 -19
  46. package/lib/pyth.js +6 -15
  47. package/lib/pythAdapter.js +96 -112
  48. package/lib/strategyOwnerCap.js +8 -17
  49. package/margin/margin/admin_cap.d.ts +2 -2
  50. package/margin/margin/deps/std/type_name.d.ts +1 -1
  51. package/margin/margin/deps/suilend/lending_market.d.ts +2 -2
  52. package/margin/margin/market.d.ts +11 -11
  53. package/margin/margin/market.js +22 -22
  54. package/margin/margin/permissions.js +14 -14
  55. package/margin/margin/position.d.ts +47 -47
  56. package/margin/margin/position.js +10 -10
  57. package/margin/margin/router.d.ts +5 -5
  58. package/margin/margin/router.js +16 -16
  59. package/margin/margin/version.d.ts +1 -1
  60. package/margin/utils/index.js +22 -36
  61. package/package.json +1 -1
  62. package/parsers/apiReserveAssetDataEvent.js +4 -1
  63. package/parsers/lendingMarket.js +3 -4
  64. package/parsers/reserve.js +4 -1
  65. package/strategies.js +188 -204
  66. package/swap/quote.d.ts +1 -1
  67. package/swap/quote.js +28 -39
  68. package/swap/transaction.js +17 -26
  69. package/utils/events.js +20 -32
  70. package/utils/obligation.js +111 -135
  71. package/utils/simulate.js +16 -24
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
2
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
3
  import { PKG_V30 } from "../index.js";
@@ -18,10 +9,16 @@ export function isID(type) {
18
9
  return type === `${PKG_V30}::object::ID`;
19
10
  }
20
11
  export class ID {
12
+ __StructClass = true;
13
+ static $typeName = `${PKG_V30}::object::ID`;
14
+ static $numTypeParams = 0;
15
+ static $isPhantom = [];
16
+ $typeName = ID.$typeName;
17
+ $fullTypeName;
18
+ $typeArgs;
19
+ $isPhantom = ID.$isPhantom;
20
+ bytes;
21
21
  constructor(typeArgs, fields) {
22
- this.__StructClass = true;
23
- this.$typeName = ID.$typeName;
24
- this.$isPhantom = ID.$isPhantom;
25
22
  this.$fullTypeName = composeSuiType(ID.$typeName, ...typeArgs);
26
23
  this.$typeArgs = typeArgs;
27
24
  this.bytes = fields.bytes;
@@ -39,7 +36,7 @@ export class ID {
39
36
  bcs: ID.bcs,
40
37
  fromJSONField: (field) => ID.fromJSONField(field),
41
38
  fromJSON: (json) => ID.fromJSON(json),
42
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return ID.fetch(client, id); }),
39
+ fetch: async (client, id) => ID.fetch(client, id),
43
40
  new: (fields) => {
44
41
  return new ID([], fields);
45
42
  },
@@ -87,7 +84,11 @@ export class ID {
87
84
  };
88
85
  }
89
86
  toJSON() {
90
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
87
+ return {
88
+ $typeName: this.$typeName,
89
+ $typeArgs: this.$typeArgs,
90
+ ...this.toJSONField(),
91
+ };
91
92
  }
92
93
  static fromJSONField(field) {
93
94
  return ID.reified().new({
@@ -100,29 +101,30 @@ export class ID {
100
101
  }
101
102
  return ID.fromJSONField(json);
102
103
  }
103
- static fetch(client, id) {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
106
- if (!isID(object.type)) {
107
- throw new Error(`object at id ${id} is not a ID object`);
108
- }
109
- return ID.fromBcs(object.content);
110
- });
104
+ static async fetch(client, id) {
105
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
106
+ if (!isID(object.type)) {
107
+ throw new Error(`object at id ${id} is not a ID object`);
108
+ }
109
+ return ID.fromBcs(object.content);
111
110
  }
112
111
  }
113
- ID.$typeName = `${PKG_V30}::object::ID`;
114
- ID.$numTypeParams = 0;
115
- ID.$isPhantom = [];
116
112
  /* ============================== UID =============================== */
117
113
  export function isUID(type) {
118
114
  type = compressSuiType(type);
119
115
  return type === `${PKG_V30}::object::UID`;
120
116
  }
121
117
  export class UID {
118
+ __StructClass = true;
119
+ static $typeName = `${PKG_V30}::object::UID`;
120
+ static $numTypeParams = 0;
121
+ static $isPhantom = [];
122
+ $typeName = UID.$typeName;
123
+ $fullTypeName;
124
+ $typeArgs;
125
+ $isPhantom = UID.$isPhantom;
126
+ id;
122
127
  constructor(typeArgs, fields) {
123
- this.__StructClass = true;
124
- this.$typeName = UID.$typeName;
125
- this.$isPhantom = UID.$isPhantom;
126
128
  this.$fullTypeName = composeSuiType(UID.$typeName, ...typeArgs);
127
129
  this.$typeArgs = typeArgs;
128
130
  this.id = fields.id;
@@ -140,7 +142,7 @@ export class UID {
140
142
  bcs: UID.bcs,
141
143
  fromJSONField: (field) => UID.fromJSONField(field),
142
144
  fromJSON: (json) => UID.fromJSON(json),
143
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return UID.fetch(client, id); }),
145
+ fetch: async (client, id) => UID.fetch(client, id),
144
146
  new: (fields) => {
145
147
  return new UID([], fields);
146
148
  },
@@ -181,7 +183,11 @@ export class UID {
181
183
  };
182
184
  }
183
185
  toJSON() {
184
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
186
+ return {
187
+ $typeName: this.$typeName,
188
+ $typeArgs: this.$typeArgs,
189
+ ...this.toJSONField(),
190
+ };
185
191
  }
186
192
  static fromJSONField(field) {
187
193
  return UID.reified().new({
@@ -194,16 +200,11 @@ export class UID {
194
200
  }
195
201
  return UID.fromJSONField(json);
196
202
  }
197
- static fetch(client, id) {
198
- return __awaiter(this, void 0, void 0, function* () {
199
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
200
- if (!isUID(object.type)) {
201
- throw new Error(`object at id ${id} is not a UID object`);
202
- }
203
- return UID.fromBcs(object.content);
204
- });
203
+ static async fetch(client, id) {
204
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
205
+ if (!isUID(object.type)) {
206
+ throw new Error(`object at id ${id} is not a UID object`);
207
+ }
208
+ return UID.fromBcs(object.content);
205
209
  }
206
210
  }
207
- UID.$typeName = `${PKG_V30}::object::UID`;
208
- UID.$numTypeParams = 0;
209
- UID.$isPhantom = [];
@@ -25,13 +25,13 @@ export declare class ObjectTable<K extends PhantomTypeArgument, V extends Phanto
25
25
  static get r(): typeof ObjectTable.reified;
26
26
  static phantom<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(K: K, V: V): PhantomReified<ToTypeStr<ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>>;
27
27
  static get p(): typeof ObjectTable.phantom;
28
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
29
- id: import("@mysten/sui/bcs").BcsStruct<{
30
- id: import("@mysten/sui/bcs").BcsStruct<{
31
- bytes: import("@mysten/sui/bcs").BcsType<string, string, string>;
28
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
29
+ id: import("@mysten/bcs").BcsStruct<{
30
+ id: import("@mysten/bcs").BcsStruct<{
31
+ bytes: import("@mysten/bcs").BcsType<string, string, string>;
32
32
  }, string>;
33
33
  }, string>;
34
- size: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
34
+ size: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
35
35
  }, string>;
36
36
  static fromFields<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], fields: Record<string, any>): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
37
37
  static fromFieldsWithTypes<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], item: FieldsWithTypes): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../../../_framework/reified.js";
11
2
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
3
  import { PKG_V30 } from "../index.js";
@@ -18,10 +9,17 @@ export function isObjectTable(type) {
18
9
  return type.startsWith(`${PKG_V30}::object_table::ObjectTable` + "<");
19
10
  }
20
11
  export class ObjectTable {
12
+ __StructClass = true;
13
+ static $typeName = `${PKG_V30}::object_table::ObjectTable`;
14
+ static $numTypeParams = 2;
15
+ static $isPhantom = [true, true];
16
+ $typeName = ObjectTable.$typeName;
17
+ $fullTypeName;
18
+ $typeArgs;
19
+ $isPhantom = ObjectTable.$isPhantom;
20
+ id;
21
+ size;
21
22
  constructor(typeArgs, fields) {
22
- this.__StructClass = true;
23
- this.$typeName = ObjectTable.$typeName;
24
- this.$isPhantom = ObjectTable.$isPhantom;
25
23
  this.$fullTypeName = composeSuiType(ObjectTable.$typeName, ...typeArgs);
26
24
  this.$typeArgs = typeArgs;
27
25
  this.id = fields.id;
@@ -40,7 +38,7 @@ export class ObjectTable {
40
38
  bcs: ObjectTable.bcs,
41
39
  fromJSONField: (field) => ObjectTable.fromJSONField([K, V], field),
42
40
  fromJSON: (json) => ObjectTable.fromJSON([K, V], json),
43
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return ObjectTable.fetch(client, [K, V], id); }),
41
+ fetch: async (client, id) => ObjectTable.fetch(client, [K, V], id),
44
42
  new: (fields) => {
45
43
  return new ObjectTable([extractType(K), extractType(V)], fields);
46
44
  },
@@ -88,7 +86,11 @@ export class ObjectTable {
88
86
  };
89
87
  }
90
88
  toJSON() {
91
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
89
+ return {
90
+ $typeName: this.$typeName,
91
+ $typeArgs: this.$typeArgs,
92
+ ...this.toJSONField(),
93
+ };
92
94
  }
93
95
  static fromJSONField(typeArgs, field) {
94
96
  return ObjectTable.reified(typeArgs[0], typeArgs[1]).new({
@@ -103,16 +105,11 @@ export class ObjectTable {
103
105
  assertReifiedTypeArgsMatch(composeSuiType(ObjectTable.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
104
106
  return ObjectTable.fromJSONField(typeArgs, json);
105
107
  }
106
- static fetch(client, typeArgs, id) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
109
- if (!isObjectTable(object.type)) {
110
- throw new Error(`object at id ${id} is not a ObjectTable object`);
111
- }
112
- return ObjectTable.fromBcs(typeArgs, object.content);
113
- });
108
+ static async fetch(client, typeArgs, id) {
109
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
110
+ if (!isObjectTable(object.type)) {
111
+ throw new Error(`object at id ${id} is not a ObjectTable object`);
112
+ }
113
+ return ObjectTable.fromBcs(typeArgs, object.content);
114
114
  }
115
115
  }
116
- ObjectTable.$typeName = `${PKG_V30}::object_table::ObjectTable`;
117
- ObjectTable.$numTypeParams = 2;
118
- ObjectTable.$isPhantom = [true, true];
@@ -24,9 +24,9 @@ export declare class I64 implements StructClass {
24
24
  static get r(): import("../../../../_framework/reified").StructClassReified<I64, I64Fields>;
25
25
  static phantom(): PhantomReified<ToTypeStr<I64>>;
26
26
  static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::i64::I64">;
27
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
28
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
29
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
27
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
28
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
29
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
30
30
  }, string>;
31
31
  static fromFields(fields: Record<string, any>): I64;
32
32
  static fromFieldsWithTypes(item: FieldsWithTypes): I64;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
2
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
3
  import { PKG_V1 } from "../index.js";
@@ -17,10 +8,17 @@ export function isI64(type) {
17
8
  return type === `${PKG_V1}::i64::I64`;
18
9
  }
19
10
  export class I64 {
11
+ __StructClass = true;
12
+ static $typeName = `${PKG_V1}::i64::I64`;
13
+ static $numTypeParams = 0;
14
+ static $isPhantom = [];
15
+ $typeName = I64.$typeName;
16
+ $fullTypeName;
17
+ $typeArgs;
18
+ $isPhantom = I64.$isPhantom;
19
+ negative;
20
+ magnitude;
20
21
  constructor(typeArgs, fields) {
21
- this.__StructClass = true;
22
- this.$typeName = I64.$typeName;
23
- this.$isPhantom = I64.$isPhantom;
24
22
  this.$fullTypeName = composeSuiType(I64.$typeName, ...typeArgs);
25
23
  this.$typeArgs = typeArgs;
26
24
  this.negative = fields.negative;
@@ -39,7 +37,7 @@ export class I64 {
39
37
  bcs: I64.bcs,
40
38
  fromJSONField: (field) => I64.fromJSONField(field),
41
39
  fromJSON: (json) => I64.fromJSON(json),
42
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return I64.fetch(client, id); }),
40
+ fetch: async (client, id) => I64.fetch(client, id),
43
41
  new: (fields) => {
44
42
  return new I64([], fields);
45
43
  },
@@ -86,7 +84,11 @@ export class I64 {
86
84
  };
87
85
  }
88
86
  toJSON() {
89
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
87
+ return {
88
+ $typeName: this.$typeName,
89
+ $typeArgs: this.$typeArgs,
90
+ ...this.toJSONField(),
91
+ };
90
92
  }
91
93
  static fromJSONField(field) {
92
94
  return I64.reified().new({
@@ -100,16 +102,11 @@ export class I64 {
100
102
  }
101
103
  return I64.fromJSONField(json);
102
104
  }
103
- static fetch(client, id) {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
106
- if (!isI64(object.type)) {
107
- throw new Error(`object at id ${id} is not a I64 object`);
108
- }
109
- return I64.fromBcs(object.content);
110
- });
105
+ static async fetch(client, id) {
106
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
107
+ if (!isI64(object.type)) {
108
+ throw new Error(`object at id ${id} is not a I64 object`);
109
+ }
110
+ return I64.fromBcs(object.content);
111
111
  }
112
112
  }
113
- I64.$typeName = `${PKG_V1}::i64::I64`;
114
- I64.$numTypeParams = 0;
115
- I64.$isPhantom = [];
@@ -29,17 +29,17 @@ export declare class Price implements StructClass {
29
29
  static get r(): import("../../../../_framework/reified").StructClassReified<Price, PriceFields>;
30
30
  static phantom(): PhantomReified<ToTypeStr<Price>>;
31
31
  static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price::Price">;
32
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
33
- price: import("@mysten/sui/bcs").BcsStruct<{
34
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
35
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
32
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
33
+ price: import("@mysten/bcs").BcsStruct<{
34
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
35
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
36
36
  }, string>;
37
- conf: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
38
- expo: import("@mysten/sui/bcs").BcsStruct<{
39
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
40
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
37
+ conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
38
+ expo: import("@mysten/bcs").BcsStruct<{
39
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
40
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
41
41
  }, string>;
42
- timestamp: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
42
+ timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
43
43
  }, string>;
44
44
  static fromFields(fields: Record<string, any>): Price;
45
45
  static fromFieldsWithTypes(item: FieldsWithTypes): Price;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
2
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
3
  import { I64 } from "../i64/structs.js";
@@ -18,10 +9,19 @@ export function isPrice(type) {
18
9
  return type === `${PKG_V1}::price::Price`;
19
10
  }
20
11
  export class Price {
12
+ __StructClass = true;
13
+ static $typeName = `${PKG_V1}::price::Price`;
14
+ static $numTypeParams = 0;
15
+ static $isPhantom = [];
16
+ $typeName = Price.$typeName;
17
+ $fullTypeName;
18
+ $typeArgs;
19
+ $isPhantom = Price.$isPhantom;
20
+ price;
21
+ conf;
22
+ expo;
23
+ timestamp;
21
24
  constructor(typeArgs, fields) {
22
- this.__StructClass = true;
23
- this.$typeName = Price.$typeName;
24
- this.$isPhantom = Price.$isPhantom;
25
25
  this.$fullTypeName = composeSuiType(Price.$typeName, ...typeArgs);
26
26
  this.$typeArgs = typeArgs;
27
27
  this.price = fields.price;
@@ -42,7 +42,7 @@ export class Price {
42
42
  bcs: Price.bcs,
43
43
  fromJSONField: (field) => Price.fromJSONField(field),
44
44
  fromJSON: (json) => Price.fromJSON(json),
45
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Price.fetch(client, id); }),
45
+ fetch: async (client, id) => Price.fetch(client, id),
46
46
  new: (fields) => {
47
47
  return new Price([], fields);
48
48
  },
@@ -97,7 +97,11 @@ export class Price {
97
97
  };
98
98
  }
99
99
  toJSON() {
100
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
100
+ return {
101
+ $typeName: this.$typeName,
102
+ $typeArgs: this.$typeArgs,
103
+ ...this.toJSONField(),
104
+ };
101
105
  }
102
106
  static fromJSONField(field) {
103
107
  return Price.reified().new({
@@ -113,16 +117,11 @@ export class Price {
113
117
  }
114
118
  return Price.fromJSONField(json);
115
119
  }
116
- static fetch(client, id) {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
119
- if (!isPrice(object.type)) {
120
- throw new Error(`object at id ${id} is not a Price object`);
121
- }
122
- return Price.fromBcs(object.content);
123
- });
120
+ static async fetch(client, id) {
121
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
122
+ if (!isPrice(object.type)) {
123
+ throw new Error(`object at id ${id} is not a Price object`);
124
+ }
125
+ return Price.fromBcs(object.content);
124
126
  }
125
127
  }
126
- Price.$typeName = `${PKG_V1}::price::Price`;
127
- Price.$numTypeParams = 0;
128
- Price.$isPhantom = [];
@@ -28,35 +28,35 @@ export declare class PriceFeed implements StructClass {
28
28
  static get r(): import("../../../../_framework/reified").StructClassReified<PriceFeed, PriceFeedFields>;
29
29
  static phantom(): PhantomReified<ToTypeStr<PriceFeed>>;
30
30
  static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_feed::PriceFeed">;
31
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
32
- price_identifier: import("@mysten/sui/bcs").BcsStruct<{
33
- bytes: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
31
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
32
+ price_identifier: import("@mysten/bcs").BcsStruct<{
33
+ bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
34
34
  length: number;
35
35
  }, string>;
36
36
  }, string>;
37
- price: import("@mysten/sui/bcs").BcsStruct<{
38
- price: import("@mysten/sui/bcs").BcsStruct<{
39
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
40
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
37
+ price: import("@mysten/bcs").BcsStruct<{
38
+ price: import("@mysten/bcs").BcsStruct<{
39
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
40
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
41
41
  }, string>;
42
- conf: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
43
- expo: import("@mysten/sui/bcs").BcsStruct<{
44
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
45
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
42
+ conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
43
+ expo: import("@mysten/bcs").BcsStruct<{
44
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
45
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
46
46
  }, string>;
47
- timestamp: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
47
+ timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
48
48
  }, string>;
49
- ema_price: import("@mysten/sui/bcs").BcsStruct<{
50
- price: import("@mysten/sui/bcs").BcsStruct<{
51
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
52
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
49
+ ema_price: import("@mysten/bcs").BcsStruct<{
50
+ price: import("@mysten/bcs").BcsStruct<{
51
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
52
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
53
53
  }, string>;
54
- conf: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
55
- expo: import("@mysten/sui/bcs").BcsStruct<{
56
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
57
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
54
+ conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
55
+ expo: import("@mysten/bcs").BcsStruct<{
56
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
57
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
58
58
  }, string>;
59
- timestamp: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
59
+ timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
60
60
  }, string>;
61
61
  }, string>;
62
62
  static fromFields(fields: Record<string, any>): PriceFeed;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
2
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
3
  import { PKG_V1 } from "../index.js";
@@ -19,10 +10,18 @@ export function isPriceFeed(type) {
19
10
  return type === `${PKG_V1}::price_feed::PriceFeed`;
20
11
  }
21
12
  export class PriceFeed {
13
+ __StructClass = true;
14
+ static $typeName = `${PKG_V1}::price_feed::PriceFeed`;
15
+ static $numTypeParams = 0;
16
+ static $isPhantom = [];
17
+ $typeName = PriceFeed.$typeName;
18
+ $fullTypeName;
19
+ $typeArgs;
20
+ $isPhantom = PriceFeed.$isPhantom;
21
+ priceIdentifier;
22
+ price;
23
+ emaPrice;
22
24
  constructor(typeArgs, fields) {
23
- this.__StructClass = true;
24
- this.$typeName = PriceFeed.$typeName;
25
- this.$isPhantom = PriceFeed.$isPhantom;
26
25
  this.$fullTypeName = composeSuiType(PriceFeed.$typeName, ...typeArgs);
27
26
  this.$typeArgs = typeArgs;
28
27
  this.priceIdentifier = fields.priceIdentifier;
@@ -42,7 +41,7 @@ export class PriceFeed {
42
41
  bcs: PriceFeed.bcs,
43
42
  fromJSONField: (field) => PriceFeed.fromJSONField(field),
44
43
  fromJSON: (json) => PriceFeed.fromJSON(json),
45
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return PriceFeed.fetch(client, id); }),
44
+ fetch: async (client, id) => PriceFeed.fetch(client, id),
46
45
  new: (fields) => {
47
46
  return new PriceFeed([], fields);
48
47
  },
@@ -93,7 +92,11 @@ export class PriceFeed {
93
92
  };
94
93
  }
95
94
  toJSON() {
96
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
95
+ return {
96
+ $typeName: this.$typeName,
97
+ $typeArgs: this.$typeArgs,
98
+ ...this.toJSONField(),
99
+ };
97
100
  }
98
101
  static fromJSONField(field) {
99
102
  return PriceFeed.reified().new({
@@ -108,16 +111,11 @@ export class PriceFeed {
108
111
  }
109
112
  return PriceFeed.fromJSONField(json);
110
113
  }
111
- static fetch(client, id) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
114
- if (!isPriceFeed(object.type)) {
115
- throw new Error(`object at id ${id} is not a PriceFeed object`);
116
- }
117
- return PriceFeed.fromBcs(object.content);
118
- });
114
+ static async fetch(client, id) {
115
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
116
+ if (!isPriceFeed(object.type)) {
117
+ throw new Error(`object at id ${id} is not a PriceFeed object`);
118
+ }
119
+ return PriceFeed.fromBcs(object.content);
119
120
  }
120
121
  }
121
- PriceFeed.$typeName = `${PKG_V1}::price_feed::PriceFeed`;
122
- PriceFeed.$numTypeParams = 0;
123
- PriceFeed.$isPhantom = [];
@@ -24,8 +24,8 @@ export declare class PriceIdentifier implements StructClass {
24
24
  static get r(): reified.StructClassReified<PriceIdentifier, PriceIdentifierFields>;
25
25
  static phantom(): PhantomReified<ToTypeStr<PriceIdentifier>>;
26
26
  static get p(): reified.PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_identifier::PriceIdentifier">;
27
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
28
- bytes: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
27
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
28
+ bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
29
29
  length: number;
30
30
  }, string>;
31
31
  }, string>;