@suilend/sdk 2.0.4 → 3.0.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.
Files changed (73) hide show
  1. package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -11
  2. package/_generated/_dependencies/source/0x1/ascii/structs.js +6 -63
  3. package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -9
  4. package/_generated/_dependencies/source/0x1/option/structs.js +4 -42
  5. package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -7
  6. package/_generated/_dependencies/source/0x1/type-name/structs.js +3 -32
  7. package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -9
  8. package/_generated/_dependencies/source/0x2/bag/structs.js +3 -31
  9. package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -11
  10. package/_generated/_dependencies/source/0x2/balance/structs.js +7 -82
  11. package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -12
  12. package/_generated/_dependencies/source/0x2/object/structs.js +7 -61
  13. package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -9
  14. package/_generated/_dependencies/source/0x2/object-table/structs.js +4 -44
  15. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -7
  16. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +3 -31
  17. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -13
  18. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +3 -32
  19. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -25
  20. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +3 -32
  21. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -6
  22. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +3 -33
  23. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -59
  24. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +6 -64
  25. package/_generated/_framework/reified.d.ts +2 -4
  26. package/_generated/_framework/vector.d.ts +2 -12
  27. package/_generated/suilend/cell/structs.d.ts +4 -10
  28. package/_generated/suilend/cell/structs.js +4 -42
  29. package/_generated/suilend/decimal/structs.d.ts +4 -6
  30. package/_generated/suilend/decimal/structs.js +3 -32
  31. package/_generated/suilend/lending-market/structs.d.ts +152 -392
  32. package/_generated/suilend/lending-market/structs.js +50 -548
  33. package/_generated/suilend/liquidity-mining/structs.d.ts +50 -158
  34. package/_generated/suilend/liquidity-mining/structs.js +16 -169
  35. package/_generated/suilend/obligation/structs.d.ts +108 -148
  36. package/_generated/suilend/obligation/structs.js +23 -232
  37. package/_generated/suilend/rate-limiter/structs.d.ts +15 -19
  38. package/_generated/suilend/rate-limiter/structs.js +6 -64
  39. package/_generated/suilend/reserve/structs.d.ts +138 -362
  40. package/_generated/suilend/reserve/structs.js +29 -327
  41. package/_generated/suilend/reserve-config/structs.d.ts +33 -37
  42. package/_generated/suilend/reserve-config/structs.js +6 -65
  43. package/client.d.ts +8 -8
  44. package/client.js +55 -88
  45. package/lib/initialize.d.ts +29 -28
  46. package/lib/initialize.js +16 -12
  47. package/lib/liquidityMining.d.ts +3 -3
  48. package/lib/pythAdapter.d.ts +9 -0
  49. package/lib/pythAdapter.js +121 -0
  50. package/lib/strategyOwnerCap.d.ts +12 -7
  51. package/lib/strategyOwnerCap.js +159 -156
  52. package/margin/margin/admin_cap.d.ts +2 -2
  53. package/margin/margin/deps/std/type_name.d.ts +1 -1
  54. package/margin/margin/deps/sui/vec_set.d.ts +3 -5
  55. package/margin/margin/deps/suilend/lending_market.d.ts +2 -2
  56. package/margin/margin/market.d.ts +21 -38
  57. package/margin/margin/position.d.ts +47 -47
  58. package/margin/margin/router.d.ts +5 -5
  59. package/margin/margin/version.d.ts +1 -1
  60. package/package.json +1 -1
  61. package/parsers/lendingMarket.d.ts +6 -6
  62. package/parsers/obligation.d.ts +8 -8
  63. package/parsers/reserve.d.ts +8 -8
  64. package/strategies.d.ts +38 -21
  65. package/strategies.js +239 -79
  66. package/swap/quote.d.ts +1 -9
  67. package/swap/quote.js +1 -52
  68. package/swap/transaction.d.ts +2 -4
  69. package/swap/transaction.js +9 -25
  70. package/utils/events.d.ts +6 -5
  71. package/utils/events.js +11 -8
  72. package/utils/obligation.d.ts +6 -5
  73. package/utils/obligation.js +118 -117
@@ -13,14 +13,14 @@ import { Balance, Supply, } from "../../_dependencies/source/0x2/balance/structs
13
13
  import { ID, UID } from "../../_dependencies/source/0x2/object/structs";
14
14
  import { PriceIdentifier } from "../../_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs";
15
15
  import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../_framework/reified";
16
- import { composeSuiType, compressSuiType, parseTypeName, } from "../../_framework/util";
16
+ import { composeSuiType, compressSuiType, } from "../../_framework/util";
17
17
  import { Cell } from "../cell/structs";
18
18
  import { Decimal } from "../decimal/structs";
19
19
  import { PKG_V1, PKG_V8 } from "../index";
20
20
  import { PoolRewardManager } from "../liquidity-mining/structs";
21
21
  import { ReserveConfig } from "../reserve-config/structs";
22
22
  import { bcs } from "@mysten/sui/bcs";
23
- import { fromBase64, fromHex, toHex } from "@mysten/sui/utils";
23
+ import { fromHex, toHex } from "@mysten/sui/utils";
24
24
  /* ============================== BalanceKey =============================== */
25
25
  export function isBalanceKey(type) {
26
26
  type = compressSuiType(type);
@@ -48,8 +48,6 @@ export class BalanceKey {
48
48
  bcs: BalanceKey.bcs,
49
49
  fromJSONField: (field) => BalanceKey.fromJSONField(field),
50
50
  fromJSON: (json) => BalanceKey.fromJSON(json),
51
- fromSuiParsedData: (content) => BalanceKey.fromSuiParsedData(content),
52
- fromSuiObjectData: (content) => BalanceKey.fromSuiObjectData(content),
53
51
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return BalanceKey.fetch(client, id); }),
54
52
  new: (fields) => {
55
53
  return new BalanceKey([], fields);
@@ -106,39 +104,13 @@ export class BalanceKey {
106
104
  }
107
105
  return BalanceKey.fromJSONField(json);
108
106
  }
109
- static fromSuiParsedData(content) {
110
- if (content.dataType !== "moveObject") {
111
- throw new Error("not an object");
112
- }
113
- if (!isBalanceKey(content.type)) {
114
- throw new Error(`object at ${content.fields.id} is not a BalanceKey object`);
115
- }
116
- return BalanceKey.fromFieldsWithTypes(content);
117
- }
118
- static fromSuiObjectData(data) {
119
- if (data.bcs) {
120
- if (data.bcs.dataType !== "moveObject" || !isBalanceKey(data.bcs.type)) {
121
- throw new Error(`object at is not a BalanceKey object`);
122
- }
123
- return BalanceKey.fromBcs(fromBase64(data.bcs.bcsBytes));
124
- }
125
- if (data.content) {
126
- return BalanceKey.fromSuiParsedData(data.content);
127
- }
128
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
129
- }
130
107
  static fetch(client, id) {
131
108
  return __awaiter(this, void 0, void 0, function* () {
132
- var _a, _b;
133
- const res = yield client.getObject({ id, options: { showBcs: true } });
134
- if (res.error) {
135
- throw new Error(`error fetching BalanceKey object at id ${id}: ${res.error.code}`);
136
- }
137
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
138
- !isBalanceKey(res.data.bcs.type)) {
109
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
110
+ if (!isBalanceKey(object.type)) {
139
111
  throw new Error(`object at id ${id} is not a BalanceKey object`);
140
112
  }
141
- return BalanceKey.fromSuiObjectData(res.data);
113
+ return BalanceKey.fromBcs(object.content);
142
114
  });
143
115
  }
144
116
  }
@@ -176,8 +148,6 @@ export class Balances {
176
148
  bcs: Balances.bcs,
177
149
  fromJSONField: (field) => Balances.fromJSONField([P, T], field),
178
150
  fromJSON: (json) => Balances.fromJSON([P, T], json),
179
- fromSuiParsedData: (content) => Balances.fromSuiParsedData([P, T], content),
180
- fromSuiObjectData: (content) => Balances.fromSuiObjectData([P, T], content),
181
151
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Balances.fetch(client, [P, T], id); }),
182
152
  new: (fields) => {
183
153
  return new Balances([extractType(P), extractType(T)], fields);
@@ -256,50 +226,13 @@ export class Balances {
256
226
  assertReifiedTypeArgsMatch(composeSuiType(Balances.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
257
227
  return Balances.fromJSONField(typeArgs, json);
258
228
  }
259
- static fromSuiParsedData(typeArgs, content) {
260
- if (content.dataType !== "moveObject") {
261
- throw new Error("not an object");
262
- }
263
- if (!isBalances(content.type)) {
264
- throw new Error(`object at ${content.fields.id} is not a Balances object`);
265
- }
266
- return Balances.fromFieldsWithTypes(typeArgs, content);
267
- }
268
- static fromSuiObjectData(typeArgs, data) {
269
- if (data.bcs) {
270
- if (data.bcs.dataType !== "moveObject" || !isBalances(data.bcs.type)) {
271
- throw new Error(`object at is not a Balances object`);
272
- }
273
- const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
274
- if (gotTypeArgs.length !== 2) {
275
- throw new Error(`type argument mismatch: expected 2 type arguments but got ${gotTypeArgs.length}`);
276
- }
277
- for (let i = 0; i < 2; i++) {
278
- const gotTypeArg = compressSuiType(gotTypeArgs[i]);
279
- const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
280
- if (gotTypeArg !== expectedTypeArg) {
281
- throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
282
- }
283
- }
284
- return Balances.fromBcs(typeArgs, fromBase64(data.bcs.bcsBytes));
285
- }
286
- if (data.content) {
287
- return Balances.fromSuiParsedData(typeArgs, data.content);
288
- }
289
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
290
- }
291
229
  static fetch(client, typeArgs, id) {
292
230
  return __awaiter(this, void 0, void 0, function* () {
293
- var _a, _b;
294
- const res = yield client.getObject({ id, options: { showBcs: true } });
295
- if (res.error) {
296
- throw new Error(`error fetching Balances object at id ${id}: ${res.error.code}`);
297
- }
298
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
299
- !isBalances(res.data.bcs.type)) {
231
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
232
+ if (!isBalances(object.type)) {
300
233
  throw new Error(`object at id ${id} is not a Balances object`);
301
234
  }
302
- return Balances.fromSuiObjectData(typeArgs, res.data);
235
+ return Balances.fromBcs(typeArgs, object.content);
303
236
  });
304
237
  }
305
238
  }
@@ -333,8 +266,6 @@ export class CToken {
333
266
  bcs: CToken.bcs,
334
267
  fromJSONField: (field) => CToken.fromJSONField([P, T], field),
335
268
  fromJSON: (json) => CToken.fromJSON([P, T], json),
336
- fromSuiParsedData: (content) => CToken.fromSuiParsedData([P, T], content),
337
- fromSuiObjectData: (content) => CToken.fromSuiObjectData([P, T], content),
338
269
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return CToken.fetch(client, [P, T], id); }),
339
270
  new: (fields) => {
340
271
  return new CToken([extractType(P), extractType(T)], fields);
@@ -393,50 +324,13 @@ export class CToken {
393
324
  assertReifiedTypeArgsMatch(composeSuiType(CToken.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
394
325
  return CToken.fromJSONField(typeArgs, json);
395
326
  }
396
- static fromSuiParsedData(typeArgs, content) {
397
- if (content.dataType !== "moveObject") {
398
- throw new Error("not an object");
399
- }
400
- if (!isCToken(content.type)) {
401
- throw new Error(`object at ${content.fields.id} is not a CToken object`);
402
- }
403
- return CToken.fromFieldsWithTypes(typeArgs, content);
404
- }
405
- static fromSuiObjectData(typeArgs, data) {
406
- if (data.bcs) {
407
- if (data.bcs.dataType !== "moveObject" || !isCToken(data.bcs.type)) {
408
- throw new Error(`object at is not a CToken object`);
409
- }
410
- const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
411
- if (gotTypeArgs.length !== 2) {
412
- throw new Error(`type argument mismatch: expected 2 type arguments but got ${gotTypeArgs.length}`);
413
- }
414
- for (let i = 0; i < 2; i++) {
415
- const gotTypeArg = compressSuiType(gotTypeArgs[i]);
416
- const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
417
- if (gotTypeArg !== expectedTypeArg) {
418
- throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
419
- }
420
- }
421
- return CToken.fromBcs(typeArgs, fromBase64(data.bcs.bcsBytes));
422
- }
423
- if (data.content) {
424
- return CToken.fromSuiParsedData(typeArgs, data.content);
425
- }
426
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
427
- }
428
327
  static fetch(client, typeArgs, id) {
429
328
  return __awaiter(this, void 0, void 0, function* () {
430
- var _a, _b;
431
- const res = yield client.getObject({ id, options: { showBcs: true } });
432
- if (res.error) {
433
- throw new Error(`error fetching CToken object at id ${id}: ${res.error.code}`);
434
- }
435
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
436
- !isCToken(res.data.bcs.type)) {
329
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
330
+ if (!isCToken(object.type)) {
437
331
  throw new Error(`object at id ${id} is not a CToken object`);
438
332
  }
439
- return CToken.fromSuiObjectData(typeArgs, res.data);
333
+ return CToken.fromBcs(typeArgs, object.content);
440
334
  });
441
335
  }
442
336
  }
@@ -473,8 +367,6 @@ export class ClaimStakingRewardsEvent {
473
367
  bcs: ClaimStakingRewardsEvent.bcs,
474
368
  fromJSONField: (field) => ClaimStakingRewardsEvent.fromJSONField(field),
475
369
  fromJSON: (json) => ClaimStakingRewardsEvent.fromJSON(json),
476
- fromSuiParsedData: (content) => ClaimStakingRewardsEvent.fromSuiParsedData(content),
477
- fromSuiObjectData: (content) => ClaimStakingRewardsEvent.fromSuiObjectData(content),
478
370
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return ClaimStakingRewardsEvent.fetch(client, id); }),
479
371
  new: (fields) => {
480
372
  return new ClaimStakingRewardsEvent([], fields);
@@ -556,40 +448,13 @@ export class ClaimStakingRewardsEvent {
556
448
  }
557
449
  return ClaimStakingRewardsEvent.fromJSONField(json);
558
450
  }
559
- static fromSuiParsedData(content) {
560
- if (content.dataType !== "moveObject") {
561
- throw new Error("not an object");
562
- }
563
- if (!isClaimStakingRewardsEvent(content.type)) {
564
- throw new Error(`object at ${content.fields.id} is not a ClaimStakingRewardsEvent object`);
565
- }
566
- return ClaimStakingRewardsEvent.fromFieldsWithTypes(content);
567
- }
568
- static fromSuiObjectData(data) {
569
- if (data.bcs) {
570
- if (data.bcs.dataType !== "moveObject" ||
571
- !isClaimStakingRewardsEvent(data.bcs.type)) {
572
- throw new Error(`object at is not a ClaimStakingRewardsEvent object`);
573
- }
574
- return ClaimStakingRewardsEvent.fromBcs(fromBase64(data.bcs.bcsBytes));
575
- }
576
- if (data.content) {
577
- return ClaimStakingRewardsEvent.fromSuiParsedData(data.content);
578
- }
579
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
580
- }
581
451
  static fetch(client, id) {
582
452
  return __awaiter(this, void 0, void 0, function* () {
583
- var _a, _b;
584
- const res = yield client.getObject({ id, options: { showBcs: true } });
585
- if (res.error) {
586
- throw new Error(`error fetching ClaimStakingRewardsEvent object at id ${id}: ${res.error.code}`);
587
- }
588
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
589
- !isClaimStakingRewardsEvent(res.data.bcs.type)) {
453
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
454
+ if (!isClaimStakingRewardsEvent(object.type)) {
590
455
  throw new Error(`object at id ${id} is not a ClaimStakingRewardsEvent object`);
591
456
  }
592
- return ClaimStakingRewardsEvent.fromSuiObjectData(res.data);
457
+ return ClaimStakingRewardsEvent.fromBcs(object.content);
593
458
  });
594
459
  }
595
460
  }
@@ -637,8 +502,6 @@ export class InterestUpdateEvent {
637
502
  bcs: InterestUpdateEvent.bcs,
638
503
  fromJSONField: (field) => InterestUpdateEvent.fromJSONField(field),
639
504
  fromJSON: (json) => InterestUpdateEvent.fromJSON(json),
640
- fromSuiParsedData: (content) => InterestUpdateEvent.fromSuiParsedData(content),
641
- fromSuiObjectData: (content) => InterestUpdateEvent.fromSuiObjectData(content),
642
505
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return InterestUpdateEvent.fetch(client, id); }),
643
506
  new: (fields) => {
644
507
  return new InterestUpdateEvent([], fields);
@@ -770,40 +633,13 @@ export class InterestUpdateEvent {
770
633
  }
771
634
  return InterestUpdateEvent.fromJSONField(json);
772
635
  }
773
- static fromSuiParsedData(content) {
774
- if (content.dataType !== "moveObject") {
775
- throw new Error("not an object");
776
- }
777
- if (!isInterestUpdateEvent(content.type)) {
778
- throw new Error(`object at ${content.fields.id} is not a InterestUpdateEvent object`);
779
- }
780
- return InterestUpdateEvent.fromFieldsWithTypes(content);
781
- }
782
- static fromSuiObjectData(data) {
783
- if (data.bcs) {
784
- if (data.bcs.dataType !== "moveObject" ||
785
- !isInterestUpdateEvent(data.bcs.type)) {
786
- throw new Error(`object at is not a InterestUpdateEvent object`);
787
- }
788
- return InterestUpdateEvent.fromBcs(fromBase64(data.bcs.bcsBytes));
789
- }
790
- if (data.content) {
791
- return InterestUpdateEvent.fromSuiParsedData(data.content);
792
- }
793
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
794
- }
795
636
  static fetch(client, id) {
796
637
  return __awaiter(this, void 0, void 0, function* () {
797
- var _a, _b;
798
- const res = yield client.getObject({ id, options: { showBcs: true } });
799
- if (res.error) {
800
- throw new Error(`error fetching InterestUpdateEvent object at id ${id}: ${res.error.code}`);
801
- }
802
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
803
- !isInterestUpdateEvent(res.data.bcs.type)) {
638
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
639
+ if (!isInterestUpdateEvent(object.type)) {
804
640
  throw new Error(`object at id ${id} is not a InterestUpdateEvent object`);
805
641
  }
806
- return InterestUpdateEvent.fromSuiObjectData(res.data);
642
+ return InterestUpdateEvent.fromBcs(object.content);
807
643
  });
808
644
  }
809
645
  }
@@ -838,8 +674,6 @@ export class LiquidityRequest {
838
674
  bcs: LiquidityRequest.bcs,
839
675
  fromJSONField: (field) => LiquidityRequest.fromJSONField([P, T], field),
840
676
  fromJSON: (json) => LiquidityRequest.fromJSON([P, T], json),
841
- fromSuiParsedData: (content) => LiquidityRequest.fromSuiParsedData([P, T], content),
842
- fromSuiObjectData: (content) => LiquidityRequest.fromSuiObjectData([P, T], content),
843
677
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return LiquidityRequest.fetch(client, [P, T], id); }),
844
678
  new: (fields) => {
845
679
  return new LiquidityRequest([extractType(P), extractType(T)], fields);
@@ -903,51 +737,13 @@ export class LiquidityRequest {
903
737
  assertReifiedTypeArgsMatch(composeSuiType(LiquidityRequest.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
904
738
  return LiquidityRequest.fromJSONField(typeArgs, json);
905
739
  }
906
- static fromSuiParsedData(typeArgs, content) {
907
- if (content.dataType !== "moveObject") {
908
- throw new Error("not an object");
909
- }
910
- if (!isLiquidityRequest(content.type)) {
911
- throw new Error(`object at ${content.fields.id} is not a LiquidityRequest object`);
912
- }
913
- return LiquidityRequest.fromFieldsWithTypes(typeArgs, content);
914
- }
915
- static fromSuiObjectData(typeArgs, data) {
916
- if (data.bcs) {
917
- if (data.bcs.dataType !== "moveObject" ||
918
- !isLiquidityRequest(data.bcs.type)) {
919
- throw new Error(`object at is not a LiquidityRequest object`);
920
- }
921
- const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
922
- if (gotTypeArgs.length !== 2) {
923
- throw new Error(`type argument mismatch: expected 2 type arguments but got ${gotTypeArgs.length}`);
924
- }
925
- for (let i = 0; i < 2; i++) {
926
- const gotTypeArg = compressSuiType(gotTypeArgs[i]);
927
- const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
928
- if (gotTypeArg !== expectedTypeArg) {
929
- throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
930
- }
931
- }
932
- return LiquidityRequest.fromBcs(typeArgs, fromBase64(data.bcs.bcsBytes));
933
- }
934
- if (data.content) {
935
- return LiquidityRequest.fromSuiParsedData(typeArgs, data.content);
936
- }
937
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
938
- }
939
740
  static fetch(client, typeArgs, id) {
940
741
  return __awaiter(this, void 0, void 0, function* () {
941
- var _a, _b;
942
- const res = yield client.getObject({ id, options: { showBcs: true } });
943
- if (res.error) {
944
- throw new Error(`error fetching LiquidityRequest object at id ${id}: ${res.error.code}`);
945
- }
946
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
947
- !isLiquidityRequest(res.data.bcs.type)) {
742
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
743
+ if (!isLiquidityRequest(object.type)) {
948
744
  throw new Error(`object at id ${id} is not a LiquidityRequest object`);
949
745
  }
950
- return LiquidityRequest.fromSuiObjectData(typeArgs, res.data);
746
+ return LiquidityRequest.fromBcs(typeArgs, object.content);
951
747
  });
952
748
  }
953
749
  }
@@ -999,8 +795,6 @@ export class Reserve {
999
795
  bcs: Reserve.bcs,
1000
796
  fromJSONField: (field) => Reserve.fromJSONField(P, field),
1001
797
  fromJSON: (json) => Reserve.fromJSON(P, json),
1002
- fromSuiParsedData: (content) => Reserve.fromSuiParsedData(P, content),
1003
- fromSuiObjectData: (content) => Reserve.fromSuiObjectData(P, content),
1004
798
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Reserve.fetch(client, P, id); }),
1005
799
  new: (fields) => {
1006
800
  return new Reserve([extractType(P)], fields);
@@ -1149,48 +943,13 @@ export class Reserve {
1149
943
  assertReifiedTypeArgsMatch(composeSuiType(Reserve.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
1150
944
  return Reserve.fromJSONField(typeArg, json);
1151
945
  }
1152
- static fromSuiParsedData(typeArg, content) {
1153
- if (content.dataType !== "moveObject") {
1154
- throw new Error("not an object");
1155
- }
1156
- if (!isReserve(content.type)) {
1157
- throw new Error(`object at ${content.fields.id} is not a Reserve object`);
1158
- }
1159
- return Reserve.fromFieldsWithTypes(typeArg, content);
1160
- }
1161
- static fromSuiObjectData(typeArg, data) {
1162
- if (data.bcs) {
1163
- if (data.bcs.dataType !== "moveObject" || !isReserve(data.bcs.type)) {
1164
- throw new Error(`object at is not a Reserve object`);
1165
- }
1166
- const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
1167
- if (gotTypeArgs.length !== 1) {
1168
- throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
1169
- }
1170
- const gotTypeArg = compressSuiType(gotTypeArgs[0]);
1171
- const expectedTypeArg = compressSuiType(extractType(typeArg));
1172
- if (gotTypeArg !== compressSuiType(extractType(typeArg))) {
1173
- throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
1174
- }
1175
- return Reserve.fromBcs(typeArg, fromBase64(data.bcs.bcsBytes));
1176
- }
1177
- if (data.content) {
1178
- return Reserve.fromSuiParsedData(typeArg, data.content);
1179
- }
1180
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
1181
- }
1182
946
  static fetch(client, typeArg, id) {
1183
947
  return __awaiter(this, void 0, void 0, function* () {
1184
- var _a, _b;
1185
- const res = yield client.getObject({ id, options: { showBcs: true } });
1186
- if (res.error) {
1187
- throw new Error(`error fetching Reserve object at id ${id}: ${res.error.code}`);
1188
- }
1189
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
1190
- !isReserve(res.data.bcs.type)) {
948
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
949
+ if (!isReserve(object.type)) {
1191
950
  throw new Error(`object at id ${id} is not a Reserve object`);
1192
951
  }
1193
- return Reserve.fromSuiObjectData(typeArg, res.data);
952
+ return Reserve.fromBcs(typeArg, object.content);
1194
953
  });
1195
954
  }
1196
955
  }
@@ -1239,8 +998,6 @@ export class ReserveAssetDataEvent {
1239
998
  bcs: ReserveAssetDataEvent.bcs,
1240
999
  fromJSONField: (field) => ReserveAssetDataEvent.fromJSONField(field),
1241
1000
  fromJSON: (json) => ReserveAssetDataEvent.fromJSON(json),
1242
- fromSuiParsedData: (content) => ReserveAssetDataEvent.fromSuiParsedData(content),
1243
- fromSuiObjectData: (content) => ReserveAssetDataEvent.fromSuiObjectData(content),
1244
1001
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return ReserveAssetDataEvent.fetch(client, id); }),
1245
1002
  new: (fields) => {
1246
1003
  return new ReserveAssetDataEvent([], fields);
@@ -1382,40 +1139,13 @@ export class ReserveAssetDataEvent {
1382
1139
  }
1383
1140
  return ReserveAssetDataEvent.fromJSONField(json);
1384
1141
  }
1385
- static fromSuiParsedData(content) {
1386
- if (content.dataType !== "moveObject") {
1387
- throw new Error("not an object");
1388
- }
1389
- if (!isReserveAssetDataEvent(content.type)) {
1390
- throw new Error(`object at ${content.fields.id} is not a ReserveAssetDataEvent object`);
1391
- }
1392
- return ReserveAssetDataEvent.fromFieldsWithTypes(content);
1393
- }
1394
- static fromSuiObjectData(data) {
1395
- if (data.bcs) {
1396
- if (data.bcs.dataType !== "moveObject" ||
1397
- !isReserveAssetDataEvent(data.bcs.type)) {
1398
- throw new Error(`object at is not a ReserveAssetDataEvent object`);
1399
- }
1400
- return ReserveAssetDataEvent.fromBcs(fromBase64(data.bcs.bcsBytes));
1401
- }
1402
- if (data.content) {
1403
- return ReserveAssetDataEvent.fromSuiParsedData(data.content);
1404
- }
1405
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
1406
- }
1407
1142
  static fetch(client, id) {
1408
1143
  return __awaiter(this, void 0, void 0, function* () {
1409
- var _a, _b;
1410
- const res = yield client.getObject({ id, options: { showBcs: true } });
1411
- if (res.error) {
1412
- throw new Error(`error fetching ReserveAssetDataEvent object at id ${id}: ${res.error.code}`);
1413
- }
1414
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
1415
- !isReserveAssetDataEvent(res.data.bcs.type)) {
1144
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
1145
+ if (!isReserveAssetDataEvent(object.type)) {
1416
1146
  throw new Error(`object at id ${id} is not a ReserveAssetDataEvent object`);
1417
1147
  }
1418
- return ReserveAssetDataEvent.fromSuiObjectData(res.data);
1148
+ return ReserveAssetDataEvent.fromBcs(object.content);
1419
1149
  });
1420
1150
  }
1421
1151
  }
@@ -1449,8 +1179,6 @@ export class StakerKey {
1449
1179
  bcs: StakerKey.bcs,
1450
1180
  fromJSONField: (field) => StakerKey.fromJSONField(field),
1451
1181
  fromJSON: (json) => StakerKey.fromJSON(json),
1452
- fromSuiParsedData: (content) => StakerKey.fromSuiParsedData(content),
1453
- fromSuiObjectData: (content) => StakerKey.fromSuiObjectData(content),
1454
1182
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return StakerKey.fetch(client, id); }),
1455
1183
  new: (fields) => {
1456
1184
  return new StakerKey([], fields);
@@ -1507,39 +1235,13 @@ export class StakerKey {
1507
1235
  }
1508
1236
  return StakerKey.fromJSONField(json);
1509
1237
  }
1510
- static fromSuiParsedData(content) {
1511
- if (content.dataType !== "moveObject") {
1512
- throw new Error("not an object");
1513
- }
1514
- if (!isStakerKey(content.type)) {
1515
- throw new Error(`object at ${content.fields.id} is not a StakerKey object`);
1516
- }
1517
- return StakerKey.fromFieldsWithTypes(content);
1518
- }
1519
- static fromSuiObjectData(data) {
1520
- if (data.bcs) {
1521
- if (data.bcs.dataType !== "moveObject" || !isStakerKey(data.bcs.type)) {
1522
- throw new Error(`object at is not a StakerKey object`);
1523
- }
1524
- return StakerKey.fromBcs(fromBase64(data.bcs.bcsBytes));
1525
- }
1526
- if (data.content) {
1527
- return StakerKey.fromSuiParsedData(data.content);
1528
- }
1529
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
1530
- }
1531
1238
  static fetch(client, id) {
1532
1239
  return __awaiter(this, void 0, void 0, function* () {
1533
- var _a, _b;
1534
- const res = yield client.getObject({ id, options: { showBcs: true } });
1535
- if (res.error) {
1536
- throw new Error(`error fetching StakerKey object at id ${id}: ${res.error.code}`);
1537
- }
1538
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
1539
- !isStakerKey(res.data.bcs.type)) {
1240
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
1241
+ if (!isStakerKey(object.type)) {
1540
1242
  throw new Error(`object at id ${id} is not a StakerKey object`);
1541
1243
  }
1542
- return StakerKey.fromSuiObjectData(res.data);
1244
+ return StakerKey.fromBcs(object.content);
1543
1245
  });
1544
1246
  }
1545
1247
  }
@@ -4,7 +4,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
4
4
  import { FieldsWithTypes } from "../../_framework/util";
5
5
  import { Vector } from "../../_framework/vector";
6
6
  import { PKG_V1 } from "../index";
7
- import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
7
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
8
8
  export declare function isReserveConfig(type: string): boolean;
9
9
  export interface ReserveConfigFields {
10
10
  openLtvPct: ToField<"u8">;
@@ -61,36 +61,36 @@ export declare class ReserveConfig implements StructClass {
61
61
  static get r(): reified.StructClassReified<ReserveConfig, ReserveConfigFields>;
62
62
  static phantom(): PhantomReified<ToTypeStr<ReserveConfig>>;
63
63
  static get p(): reified.PhantomReified<"0x1f54a9a2d71799553197e9ea24557797c6398d6a65f2d4d3818c9304b75d5e21::reserve_config::ReserveConfig" | "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::reserve_config::ReserveConfig">;
64
- static get bcs(): import("@mysten/bcs").BcsStruct<{
65
- open_ltv_pct: import("@mysten/bcs").BcsType<number, number, "u8">;
66
- close_ltv_pct: import("@mysten/bcs").BcsType<number, number, "u8">;
67
- max_close_ltv_pct: import("@mysten/bcs").BcsType<number, number, "u8">;
68
- borrow_weight_bps: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
69
- deposit_limit: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
70
- borrow_limit: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
71
- liquidation_bonus_bps: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
72
- max_liquidation_bonus_bps: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
73
- deposit_limit_usd: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
74
- borrow_limit_usd: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
75
- interest_rate_utils: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
64
+ static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
65
+ open_ltv_pct: import("@mysten/sui/bcs").BcsType<number, number, "u8">;
66
+ close_ltv_pct: import("@mysten/sui/bcs").BcsType<number, number, "u8">;
67
+ max_close_ltv_pct: import("@mysten/sui/bcs").BcsType<number, number, "u8">;
68
+ borrow_weight_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
69
+ deposit_limit: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
70
+ borrow_limit: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
71
+ liquidation_bonus_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
72
+ max_liquidation_bonus_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
73
+ deposit_limit_usd: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
74
+ borrow_limit_usd: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
75
+ interest_rate_utils: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
76
76
  length: number;
77
77
  }, string>;
78
- interest_rate_aprs: import("@mysten/bcs").BcsType<string[], Iterable<string | number | bigint> & {
78
+ interest_rate_aprs: import("@mysten/sui/bcs").BcsType<string[], Iterable<string | number | bigint> & {
79
79
  length: number;
80
80
  }, string>;
81
- borrow_fee_bps: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
82
- spread_fee_bps: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
83
- protocol_liquidation_fee_bps: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
84
- isolated: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
85
- open_attributed_borrow_limit_usd: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
86
- close_attributed_borrow_limit_usd: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
87
- additional_fields: import("@mysten/bcs").BcsStruct<{
88
- id: import("@mysten/bcs").BcsStruct<{
89
- id: import("@mysten/bcs").BcsStruct<{
90
- bytes: import("@mysten/bcs").BcsType<string, string, string>;
81
+ borrow_fee_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
82
+ spread_fee_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
83
+ protocol_liquidation_fee_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
84
+ isolated: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
85
+ open_attributed_borrow_limit_usd: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
86
+ close_attributed_borrow_limit_usd: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
87
+ additional_fields: import("@mysten/sui/bcs").BcsStruct<{
88
+ id: import("@mysten/sui/bcs").BcsStruct<{
89
+ id: import("@mysten/sui/bcs").BcsStruct<{
90
+ bytes: import("@mysten/sui/bcs").BcsType<string, string, string>;
91
91
  }, string>;
92
92
  }, string>;
93
- size: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
93
+ size: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
94
94
  }, string>;
95
95
  }, string>;
96
96
  static fromFields(fields: Record<string, any>): ReserveConfig;
@@ -148,9 +148,7 @@ export declare class ReserveConfig implements StructClass {
148
148
  };
149
149
  static fromJSONField(field: any): ReserveConfig;
150
150
  static fromJSON(json: Record<string, any>): ReserveConfig;
151
- static fromSuiParsedData(content: SuiParsedData): ReserveConfig;
152
- static fromSuiObjectData(data: SuiObjectData): ReserveConfig;
153
- static fetch(client: SuiJsonRpcClient, id: string): Promise<ReserveConfig>;
151
+ static fetch(client: SuiGrpcClient, id: string): Promise<ReserveConfig>;
154
152
  }
155
153
  export declare function isReserveConfigBuilder(type: string): boolean;
156
154
  export interface ReserveConfigBuilderFields {
@@ -172,14 +170,14 @@ export declare class ReserveConfigBuilder implements StructClass {
172
170
  static get r(): reified.StructClassReified<ReserveConfigBuilder, ReserveConfigBuilderFields>;
173
171
  static phantom(): PhantomReified<ToTypeStr<ReserveConfigBuilder>>;
174
172
  static get p(): reified.PhantomReified<"0x1f54a9a2d71799553197e9ea24557797c6398d6a65f2d4d3818c9304b75d5e21::reserve_config::ReserveConfigBuilder" | "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::reserve_config::ReserveConfigBuilder">;
175
- static get bcs(): import("@mysten/bcs").BcsStruct<{
176
- fields: import("@mysten/bcs").BcsStruct<{
177
- id: import("@mysten/bcs").BcsStruct<{
178
- id: import("@mysten/bcs").BcsStruct<{
179
- bytes: import("@mysten/bcs").BcsType<string, string, string>;
173
+ static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
174
+ fields: import("@mysten/sui/bcs").BcsStruct<{
175
+ id: import("@mysten/sui/bcs").BcsStruct<{
176
+ id: import("@mysten/sui/bcs").BcsStruct<{
177
+ bytes: import("@mysten/sui/bcs").BcsType<string, string, string>;
180
178
  }, string>;
181
179
  }, string>;
182
- size: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
180
+ size: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
183
181
  }, string>;
184
182
  }, string>;
185
183
  static fromFields(fields: Record<string, any>): ReserveConfigBuilder;
@@ -201,7 +199,5 @@ export declare class ReserveConfigBuilder implements StructClass {
201
199
  };
202
200
  static fromJSONField(field: any): ReserveConfigBuilder;
203
201
  static fromJSON(json: Record<string, any>): ReserveConfigBuilder;
204
- static fromSuiParsedData(content: SuiParsedData): ReserveConfigBuilder;
205
- static fromSuiObjectData(data: SuiObjectData): ReserveConfigBuilder;
206
- static fetch(client: SuiJsonRpcClient, id: string): Promise<ReserveConfigBuilder>;
202
+ static fetch(client: SuiGrpcClient, id: string): Promise<ReserveConfigBuilder>;
207
203
  }