@suilend/sdk 1.1.99 → 2.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 (91) hide show
  1. package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
  2. package/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
  3. package/_generated/_dependencies/source/0x1/index.js +3 -6
  4. package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
  5. package/_generated/_dependencies/source/0x1/option/structs.js +31 -69
  6. package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
  7. package/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
  8. package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
  9. package/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
  10. package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
  11. package/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
  12. package/_generated/_dependencies/source/0x2/index.js +3 -6
  13. package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
  14. package/_generated/_dependencies/source/0x2/object/structs.js +34 -41
  15. package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -7
  16. package/_generated/_dependencies/source/0x2/object-table/structs.js +31 -36
  17. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -5
  18. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +23 -28
  19. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +4 -7
  20. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -11
  21. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +32 -37
  22. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -23
  23. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +29 -34
  24. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -4
  25. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -59
  26. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -55
  27. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +46 -53
  28. package/_generated/_framework/reified.d.ts +2 -2
  29. package/_generated/_framework/reified.js +27 -40
  30. package/_generated/_framework/util.js +26 -40
  31. package/_generated/_framework/vector.d.ts +4 -4
  32. package/_generated/_framework/vector.js +16 -21
  33. package/_generated/suilend/cell/structs.d.ts +4 -4
  34. package/_generated/suilend/cell/structs.js +31 -36
  35. package/_generated/suilend/decimal/structs.d.ts +4 -4
  36. package/_generated/suilend/decimal/structs.js +19 -24
  37. package/_generated/suilend/index.js +8 -12
  38. package/_generated/suilend/lending-market/functions.d.ts +1 -0
  39. package/_generated/suilend/lending-market/functions.js +271 -302
  40. package/_generated/suilend/lending-market/structs.d.ts +146 -146
  41. package/_generated/suilend/lending-market/structs.js +549 -617
  42. package/_generated/suilend/lending-market-registry/functions.js +7 -11
  43. package/_generated/suilend/liquidity-mining/structs.d.ts +50 -50
  44. package/_generated/suilend/liquidity-mining/structs.js +159 -205
  45. package/_generated/suilend/obligation/structs.d.ts +106 -106
  46. package/_generated/suilend/obligation/structs.js +313 -363
  47. package/_generated/suilend/rate-limiter/functions.js +23 -31
  48. package/_generated/suilend/rate-limiter/structs.d.ts +15 -15
  49. package/_generated/suilend/rate-limiter/structs.js +49 -56
  50. package/_generated/suilend/reserve/structs.d.ts +139 -139
  51. package/_generated/suilend/reserve/structs.js +397 -451
  52. package/_generated/suilend/reserve-config/functions.js +149 -190
  53. package/_generated/suilend/reserve-config/structs.d.ts +33 -33
  54. package/_generated/suilend/reserve-config/structs.js +109 -149
  55. package/api/events.js +1 -5
  56. package/api/index.js +1 -17
  57. package/client.d.ts +10 -10
  58. package/client.js +118 -128
  59. package/index.js +7 -23
  60. package/lib/constants.js +3 -9
  61. package/lib/index.js +5 -21
  62. package/lib/initialize.d.ts +3 -3
  63. package/lib/initialize.js +103 -140
  64. package/lib/liquidityMining.d.ts +3 -3
  65. package/lib/liquidityMining.js +57 -72
  66. package/lib/pyth.js +9 -14
  67. package/lib/strategyOwnerCap.js +106 -119
  68. package/lib/transactions.js +2 -7
  69. package/lib/types.js +4 -7
  70. package/mmt.js +2 -5
  71. package/package.json +1 -1
  72. package/parsers/apiReserveAssetDataEvent.js +25 -33
  73. package/parsers/index.js +5 -21
  74. package/parsers/lendingMarket.d.ts +1 -1
  75. package/parsers/lendingMarket.js +12 -19
  76. package/parsers/obligation.js +19 -26
  77. package/parsers/rateLimiter.js +11 -19
  78. package/parsers/reserve.d.ts +1 -1
  79. package/parsers/reserve.js +42 -85
  80. package/strategies.d.ts +11 -11
  81. package/strategies.js +547 -586
  82. package/swap/index.js +2 -18
  83. package/swap/quote.js +57 -65
  84. package/swap/transaction.d.ts +2 -2
  85. package/swap/transaction.js +40 -35
  86. package/utils/events.d.ts +3 -3
  87. package/utils/events.js +18 -35
  88. package/utils/index.js +16 -40
  89. package/utils/obligation.d.ts +4 -4
  90. package/utils/obligation.js +17 -60
  91. package/utils/simulate.js +118 -143
@@ -1,19 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.splitGenericParameters = splitGenericParameters;
4
- exports.parseTypeName = parseTypeName;
5
- exports.isTransactionArgument = isTransactionArgument;
6
- exports.obj = obj;
7
- exports.pure = pure;
8
- exports.option = option;
9
- exports.generic = generic;
10
- exports.vector = vector;
11
- exports.typeArgIsPure = typeArgIsPure;
12
- exports.compressSuiAddress = compressSuiAddress;
13
- exports.compressSuiType = compressSuiType;
14
- exports.composeSuiType = composeSuiType;
15
- const bcs_1 = require("@mysten/sui/bcs");
16
- function splitGenericParameters(str, genericSeparators = ["<", ">"]) {
1
+ import { bcs } from "@mysten/sui/bcs";
2
+ export function splitGenericParameters(str, genericSeparators = ["<", ">"]) {
17
3
  const [left, right] = genericSeparators;
18
4
  const tok = [];
19
5
  let word = "";
@@ -36,7 +22,7 @@ function splitGenericParameters(str, genericSeparators = ["<", ">"]) {
36
22
  tok.push(word.trim());
37
23
  return tok;
38
24
  }
39
- function parseTypeName(name) {
25
+ export function parseTypeName(name) {
40
26
  if (typeof name !== "string") {
41
27
  throw new Error(`Illegal type passed as a name of the type: ${name}`);
42
28
  }
@@ -55,7 +41,7 @@ function parseTypeName(name) {
55
41
  const typeArgs = splitGenericParameters(name.slice(l_bound + 1, name.length - r_bound - 1), [left, right]);
56
42
  return { typeName, typeArgs };
57
43
  }
58
- function isTransactionArgument(arg) {
44
+ export function isTransactionArgument(arg) {
59
45
  if (!arg || typeof arg !== "object" || Array.isArray(arg)) {
60
46
  return false;
61
47
  }
@@ -64,10 +50,10 @@ function isTransactionArgument(arg) {
64
50
  "Result" in arg ||
65
51
  "NestedResult" in arg);
66
52
  }
67
- function obj(tx, arg) {
53
+ export function obj(tx, arg) {
68
54
  return isTransactionArgument(arg) ? arg : tx.object(arg);
69
55
  }
70
- function pure(tx, arg, type) {
56
+ export function pure(tx, arg, type) {
71
57
  if (isTransactionArgument(arg)) {
72
58
  return obj(tx, arg);
73
59
  }
@@ -75,30 +61,30 @@ function pure(tx, arg, type) {
75
61
  const { typeName, typeArgs } = parseTypeName(type);
76
62
  switch (typeName) {
77
63
  case "bool":
78
- return bcs_1.bcs.Bool;
64
+ return bcs.Bool;
79
65
  case "u8":
80
- return bcs_1.bcs.U8;
66
+ return bcs.U8;
81
67
  case "u16":
82
- return bcs_1.bcs.U16;
68
+ return bcs.U16;
83
69
  case "u32":
84
- return bcs_1.bcs.U32;
70
+ return bcs.U32;
85
71
  case "u64":
86
- return bcs_1.bcs.U64;
72
+ return bcs.U64;
87
73
  case "u128":
88
- return bcs_1.bcs.U128;
74
+ return bcs.U128;
89
75
  case "u256":
90
- return bcs_1.bcs.U256;
76
+ return bcs.U256;
91
77
  case "address":
92
- return bcs_1.bcs.Address;
78
+ return bcs.Address;
93
79
  case "0x1::string::String":
94
80
  case "0x1::ascii::String":
95
- return bcs_1.bcs.String;
81
+ return bcs.String;
96
82
  case "0x2::object::ID":
97
- return bcs_1.bcs.Address;
83
+ return bcs.Address;
98
84
  case "0x1::option::Option":
99
- return bcs_1.bcs.option(getBcsForType(typeArgs[0]));
85
+ return bcs.option(getBcsForType(typeArgs[0]));
100
86
  case "vector":
101
- return bcs_1.bcs.vector(getBcsForType(typeArgs[0]));
87
+ return bcs.vector(getBcsForType(typeArgs[0]));
102
88
  default:
103
89
  throw new Error(`invalid primitive type ${type}`);
104
90
  }
@@ -175,7 +161,7 @@ function pure(tx, arg, type) {
175
161
  throw new Error("expected an array for vector type");
176
162
  }
177
163
  if (arg.length === 0) {
178
- return tx.pure(bcs_1.bcs.vector(bcs_1.bcs.Bool).serialize([])); // bcs.Bool is arbitrary
164
+ return tx.pure(bcs.vector(bcs.Bool).serialize([])); // bcs.Bool is arbitrary
179
165
  }
180
166
  if (hasUndefinedOrNull(arg)) {
181
167
  throw new Error("the provided array contains undefined or null values");
@@ -194,7 +180,7 @@ function pure(tx, arg, type) {
194
180
  return tx.pure(getBcsForType(type).serialize(arg));
195
181
  }
196
182
  }
197
- function option(tx, type, arg) {
183
+ export function option(tx, type, arg) {
198
184
  if (isTransactionArgument(arg)) {
199
185
  return arg;
200
186
  }
@@ -216,7 +202,7 @@ function option(tx, type, arg) {
216
202
  arguments: [val],
217
203
  });
218
204
  }
219
- function generic(tx, type, arg) {
205
+ export function generic(tx, type, arg) {
220
206
  if (typeArgIsPure(type)) {
221
207
  return pure(tx, arg, type);
222
208
  }
@@ -234,7 +220,7 @@ function generic(tx, type, arg) {
234
220
  }
235
221
  }
236
222
  }
237
- function vector(tx, itemType, items) {
223
+ export function vector(tx, itemType, items) {
238
224
  if (typeof items === "function") {
239
225
  throw new Error("Transaction plugins are not supported");
240
226
  }
@@ -259,7 +245,7 @@ function vector(tx, itemType, items) {
259
245
  });
260
246
  }
261
247
  }
262
- function typeArgIsPure(type) {
248
+ export function typeArgIsPure(type) {
263
249
  const { typeName, typeArgs } = parseTypeName(type);
264
250
  switch (typeName) {
265
251
  case "bool":
@@ -284,7 +270,7 @@ function typeArgIsPure(type) {
284
270
  return false;
285
271
  }
286
272
  }
287
- function compressSuiAddress(addr) {
273
+ export function compressSuiAddress(addr) {
288
274
  // remove leading zeros
289
275
  const stripped = addr.split("0x").join("");
290
276
  for (let i = 0; i < stripped.length; i++) {
@@ -296,7 +282,7 @@ function compressSuiAddress(addr) {
296
282
  }
297
283
  // Recursively removes leading zeros from a type.
298
284
  // e.g. `0x00000002::module::Name<0x00001::a::C>` -> `0x2::module::Name<0x1::a::C>`
299
- function compressSuiType(type) {
285
+ export function compressSuiType(type) {
300
286
  const { typeName, typeArgs } = parseTypeName(type);
301
287
  switch (typeName) {
302
288
  case "bool":
@@ -324,7 +310,7 @@ function compressSuiType(type) {
324
310
  }
325
311
  }
326
312
  }
327
- function composeSuiType(typeName, ...typeArgs) {
313
+ export function composeSuiType(typeName, ...typeArgs) {
328
314
  if (typeArgs.length > 0) {
329
315
  return `${typeName}<${typeArgs.join(", ")}>`;
330
316
  }
@@ -16,14 +16,14 @@ export declare class Vector<T extends TypeArgument> implements VectorClass {
16
16
  static reified<T extends Reified<TypeArgument, any>>(T: T): VectorReified<ToTypeArgument<T>>;
17
17
  static get r(): typeof Vector.reified;
18
18
  static get bcs(): {
19
- <T extends import("@mysten/sui/bcs").BcsType<any>, Name extends string = `vector<${T["name"]}>`>(type: T, options?: import("@mysten/sui/bcs").BcsTypeOptions<import("@mysten/bcs").InferBcsType<T>[], Iterable<import("@mysten/bcs").InferBcsInput<T>> & {
19
+ <T extends import("@mysten/bcs").BcsType<any>, Name extends string = `vector<${T["name"]}>`>(type: T, options?: import("@mysten/bcs").BcsTypeOptions<import("@mysten/bcs").InferBcsType<T>[], Iterable<import("@mysten/bcs").InferBcsInput<T>> & {
20
20
  length: number;
21
- }, Name>): import("@mysten/sui/bcs").BcsType<import("@mysten/bcs").InferBcsType<T>[], Iterable<import("@mysten/bcs").InferBcsInput<T>> & {
21
+ }, Name>): import("@mysten/bcs").BcsType<import("@mysten/bcs").InferBcsType<T>[], Iterable<import("@mysten/bcs").InferBcsInput<T>> & {
22
22
  length: number;
23
23
  }, Name>;
24
- <T, Input, Name extends string = string>(type: import("@mysten/sui/bcs").BcsType<T, Input, Name>, options?: import("@mysten/sui/bcs").BcsTypeOptions<T[], Iterable<Input> & {
24
+ <T, Input, Name extends string = string>(type: import("@mysten/bcs").BcsType<T, Input, Name>, options?: import("@mysten/bcs").BcsTypeOptions<T[], Iterable<Input> & {
25
25
  length: number;
26
- }, `vector<${Name}>`>): import("@mysten/sui/bcs").BcsType<T[], Iterable<Input> & {
26
+ }, `vector<${Name}>`>): import("@mysten/bcs").BcsType<T[], Iterable<Input> & {
27
27
  length: number;
28
28
  }, `vector<${Name}>`>;
29
29
  };
@@ -1,34 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Vector = void 0;
4
- exports.vector = vector;
5
- const bcs_1 = require("@mysten/sui/bcs");
6
- const reified_1 = require("./reified");
7
- const util_1 = require("./util");
8
- class Vector {
1
+ import { bcs } from "@mysten/sui/bcs";
2
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, toBcs, fieldToJSON, } from "./reified";
3
+ import { composeSuiType } from "./util";
4
+ export class Vector {
9
5
  constructor(typeArgs, elements) {
10
6
  this.__VectorClass = true;
11
7
  this.$typeName = "vector";
12
8
  this.$isPhantom = [false];
13
- this.$fullTypeName = (0, util_1.composeSuiType)(this.$typeName, ...typeArgs);
9
+ this.$fullTypeName = composeSuiType(this.$typeName, ...typeArgs);
14
10
  this.$typeArgs = typeArgs;
15
11
  this.elements = elements;
16
12
  }
17
13
  static reified(T) {
18
14
  return {
19
15
  typeName: Vector.$typeName,
20
- fullTypeName: (0, util_1.composeSuiType)(Vector.$typeName, ...[(0, reified_1.extractType)(T)]),
21
- typeArgs: [(0, reified_1.extractType)(T)],
16
+ fullTypeName: composeSuiType(Vector.$typeName, ...[extractType(T)]),
17
+ typeArgs: [extractType(T)],
22
18
  isPhantom: Vector.$isPhantom,
23
19
  reifiedTypeArgs: [T],
24
20
  fromFields: (elements) => Vector.fromFields(T, elements),
25
21
  fromFieldsWithTypes: (item) => Vector.fromFieldsWithTypes(T, item),
26
22
  fromBcs: (data) => Vector.fromBcs(T, data),
27
- bcs: Vector.bcs((0, reified_1.toBcs)(T)),
23
+ bcs: Vector.bcs(toBcs(T)),
28
24
  fromJSONField: (field) => Vector.fromJSONField(T, field),
29
25
  fromJSON: (json) => Vector.fromJSON(T, json),
30
26
  new: (elements) => {
31
- return new Vector([(0, reified_1.extractType)(T)], elements);
27
+ return new Vector([extractType(T)], elements);
32
28
  },
33
29
  kind: "VectorClassReified",
34
30
  };
@@ -37,19 +33,19 @@ class Vector {
37
33
  return Vector.reified;
38
34
  }
39
35
  static get bcs() {
40
- return bcs_1.bcs.vector;
36
+ return bcs.vector;
41
37
  }
42
38
  static fromFields(typeArg, elements) {
43
- return Vector.reified(typeArg).new(elements.map((element) => (0, reified_1.decodeFromFields)(typeArg, element)));
39
+ return Vector.reified(typeArg).new(elements.map((element) => decodeFromFields(typeArg, element)));
44
40
  }
45
41
  static fromFieldsWithTypes(typeArg, item) {
46
- return Vector.reified(typeArg).new(item.map((field) => (0, reified_1.decodeFromFieldsWithTypes)(typeArg, field)));
42
+ return Vector.reified(typeArg).new(item.map((field) => decodeFromFieldsWithTypes(typeArg, field)));
47
43
  }
48
44
  static fromBcs(typeArg, data) {
49
- return Vector.fromFields(typeArg, Vector.bcs((0, reified_1.toBcs)(typeArg)).parse(data));
45
+ return Vector.fromFields(typeArg, Vector.bcs(toBcs(typeArg)).parse(data));
50
46
  }
51
47
  toJSONField() {
52
- return this.elements.map((element) => (0, reified_1.fieldToJSON)(this.$typeArgs[0], element));
48
+ return this.elements.map((element) => fieldToJSON(this.$typeArgs[0], element));
53
49
  }
54
50
  toJSON() {
55
51
  return {
@@ -59,7 +55,7 @@ class Vector {
59
55
  };
60
56
  }
61
57
  static fromJSONField(typeArg, field) {
62
- return Vector.reified(typeArg).new(field.map((field) => (0, reified_1.decodeFromJSONField)(typeArg, field)));
58
+ return Vector.reified(typeArg).new(field.map((field) => decodeFromJSONField(typeArg, field)));
63
59
  }
64
60
  static fromJSON(typeArg, json) {
65
61
  if (json.$typeName !== Vector.$typeName) {
@@ -68,10 +64,9 @@ class Vector {
68
64
  return Vector.fromJSONField(typeArg, json.elements);
69
65
  }
70
66
  }
71
- exports.Vector = Vector;
72
67
  Vector.$typeName = "vector";
73
68
  Vector.$numTypeParams = 1;
74
69
  Vector.$isPhantom = [false];
75
- function vector(T) {
70
+ export function vector(T) {
76
71
  return Vector.r(T);
77
72
  }
@@ -3,7 +3,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeArgument, ToTypeSt
3
3
  import { FieldsWithTypes } from "../../_framework/util";
4
4
  import { PKG_V1 } from "../index";
5
5
  import { BcsType } from "@mysten/sui/bcs";
6
- import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
6
+ import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
7
7
  export declare function isCell(type: string): boolean;
8
8
  export interface CellFields<Element extends TypeArgument> {
9
9
  element: ToField<Option<Element>>;
@@ -24,8 +24,8 @@ export declare class Cell<Element extends TypeArgument> implements StructClass {
24
24
  static get r(): typeof Cell.reified;
25
25
  static phantom<Element extends Reified<TypeArgument, any>>(Element: Element): PhantomReified<ToTypeStr<Cell<ToTypeArgument<Element>>>>;
26
26
  static get p(): typeof Cell.phantom;
27
- static get bcs(): <Element extends BcsType<any>>(Element: Element) => import("@mysten/sui/bcs").BcsStruct<{
28
- element: import("@mysten/sui/bcs").BcsStruct<{
27
+ static get bcs(): <Element extends BcsType<any>>(Element: Element) => import("@mysten/bcs").BcsStruct<{
28
+ element: import("@mysten/bcs").BcsStruct<{
29
29
  vec: BcsType<import("@mysten/bcs").InferBcsType<Element>[], Iterable<import("@mysten/bcs").InferBcsInput<Element>> & {
30
30
  length: number;
31
31
  }, string>;
@@ -46,5 +46,5 @@ export declare class Cell<Element extends TypeArgument> implements StructClass {
46
46
  static fromJSON<Element extends Reified<TypeArgument, any>>(typeArg: Element, json: Record<string, any>): Cell<ToTypeArgument<Element>>;
47
47
  static fromSuiParsedData<Element extends Reified<TypeArgument, any>>(typeArg: Element, content: SuiParsedData): Cell<ToTypeArgument<Element>>;
48
48
  static fromSuiObjectData<Element extends Reified<TypeArgument, any>>(typeArg: Element, data: SuiObjectData): Cell<ToTypeArgument<Element>>;
49
- static fetch<Element extends Reified<TypeArgument, any>>(client: SuiClient, typeArg: Element, id: string): Promise<Cell<ToTypeArgument<Element>>>;
49
+ static fetch<Element extends Reified<TypeArgument, any>>(client: SuiJsonRpcClient, typeArg: Element, id: string): Promise<Cell<ToTypeArgument<Element>>>;
50
50
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,47 +7,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Cell = void 0;
13
- exports.isCell = isCell;
14
- const structs_1 = require("../../_dependencies/source/0x1/option/structs");
15
- const reified_1 = require("../../_framework/reified");
16
- const util_1 = require("../../_framework/util");
17
- const index_1 = require("../index");
18
- const bcs_1 = require("@mysten/sui/bcs");
19
- const utils_1 = require("@mysten/sui/utils");
10
+ import { Option } from "../../_dependencies/source/0x1/option/structs";
11
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, toBcs, } from "../../_framework/reified";
12
+ import { composeSuiType, compressSuiType, parseTypeName, } from "../../_framework/util";
13
+ import { PKG_V1 } from "../index";
14
+ import { bcs } from "@mysten/sui/bcs";
15
+ import { fromBase64 } from "@mysten/sui/utils";
20
16
  /* ============================== Cell =============================== */
21
- function isCell(type) {
22
- type = (0, util_1.compressSuiType)(type);
23
- return type.startsWith(`${index_1.PKG_V1}::cell::Cell` + "<");
17
+ export function isCell(type) {
18
+ type = compressSuiType(type);
19
+ return type.startsWith(`${PKG_V1}::cell::Cell` + "<");
24
20
  }
25
- class Cell {
21
+ export class Cell {
26
22
  constructor(typeArgs, fields) {
27
23
  this.__StructClass = true;
28
24
  this.$typeName = Cell.$typeName;
29
25
  this.$isPhantom = Cell.$isPhantom;
30
- this.$fullTypeName = (0, util_1.composeSuiType)(Cell.$typeName, ...typeArgs);
26
+ this.$fullTypeName = composeSuiType(Cell.$typeName, ...typeArgs);
31
27
  this.$typeArgs = typeArgs;
32
28
  this.element = fields.element;
33
29
  }
34
30
  static reified(Element) {
35
31
  return {
36
32
  typeName: Cell.$typeName,
37
- fullTypeName: (0, util_1.composeSuiType)(Cell.$typeName, ...[(0, reified_1.extractType)(Element)]),
38
- typeArgs: [(0, reified_1.extractType)(Element)],
33
+ fullTypeName: composeSuiType(Cell.$typeName, ...[extractType(Element)]),
34
+ typeArgs: [extractType(Element)],
39
35
  isPhantom: Cell.$isPhantom,
40
36
  reifiedTypeArgs: [Element],
41
37
  fromFields: (fields) => Cell.fromFields(Element, fields),
42
38
  fromFieldsWithTypes: (item) => Cell.fromFieldsWithTypes(Element, item),
43
39
  fromBcs: (data) => Cell.fromBcs(Element, data),
44
- bcs: Cell.bcs((0, reified_1.toBcs)(Element)),
40
+ bcs: Cell.bcs(toBcs(Element)),
45
41
  fromJSONField: (field) => Cell.fromJSONField(Element, field),
46
42
  fromJSON: (json) => Cell.fromJSON(Element, json),
47
43
  fromSuiParsedData: (content) => Cell.fromSuiParsedData(Element, content),
48
44
  fromSuiObjectData: (content) => Cell.fromSuiObjectData(Element, content),
49
45
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Cell.fetch(client, Element, id); }),
50
46
  new: (fields) => {
51
- return new Cell([(0, reified_1.extractType)(Element)], fields);
47
+ return new Cell([extractType(Element)], fields);
52
48
  },
53
49
  kind: "StructClassReified",
54
50
  };
@@ -57,37 +53,37 @@ class Cell {
57
53
  return Cell.reified;
58
54
  }
59
55
  static phantom(Element) {
60
- return (0, reified_1.phantom)(Cell.reified(Element));
56
+ return phantom(Cell.reified(Element));
61
57
  }
62
58
  static get p() {
63
59
  return Cell.phantom;
64
60
  }
65
61
  static get bcs() {
66
- return (Element) => bcs_1.bcs.struct(`Cell<${Element.name}>`, {
67
- element: structs_1.Option.bcs(Element),
62
+ return (Element) => bcs.struct(`Cell<${Element.name}>`, {
63
+ element: Option.bcs(Element),
68
64
  });
69
65
  }
70
66
  static fromFields(typeArg, fields) {
71
67
  return Cell.reified(typeArg).new({
72
- element: (0, reified_1.decodeFromFields)(structs_1.Option.reified(typeArg), fields.element),
68
+ element: decodeFromFields(Option.reified(typeArg), fields.element),
73
69
  });
74
70
  }
75
71
  static fromFieldsWithTypes(typeArg, item) {
76
72
  if (!isCell(item.type)) {
77
73
  throw new Error("not a Cell type");
78
74
  }
79
- (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
75
+ assertFieldsWithTypesArgsMatch(item, [typeArg]);
80
76
  return Cell.reified(typeArg).new({
81
- element: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.Option.reified(typeArg), item.fields.element),
77
+ element: decodeFromFieldsWithTypes(Option.reified(typeArg), item.fields.element),
82
78
  });
83
79
  }
84
80
  static fromBcs(typeArg, data) {
85
81
  const typeArgs = [typeArg];
86
- return Cell.fromFields(typeArg, Cell.bcs((0, reified_1.toBcs)(typeArgs[0])).parse(data));
82
+ return Cell.fromFields(typeArg, Cell.bcs(toBcs(typeArgs[0])).parse(data));
87
83
  }
88
84
  toJSONField() {
89
85
  return {
90
- element: (0, reified_1.fieldToJSON)(`${structs_1.Option.$typeName}<${this.$typeArgs[0]}>`, this.element),
86
+ element: fieldToJSON(`${Option.$typeName}<${this.$typeArgs[0]}>`, this.element),
91
87
  };
92
88
  }
93
89
  toJSON() {
@@ -95,14 +91,14 @@ class Cell {
95
91
  }
96
92
  static fromJSONField(typeArg, field) {
97
93
  return Cell.reified(typeArg).new({
98
- element: (0, reified_1.decodeFromJSONField)(structs_1.Option.reified(typeArg), field.element),
94
+ element: decodeFromJSONField(Option.reified(typeArg), field.element),
99
95
  });
100
96
  }
101
97
  static fromJSON(typeArg, json) {
102
98
  if (json.$typeName !== Cell.$typeName) {
103
99
  throw new Error("not a WithTwoGenerics json object");
104
100
  }
105
- (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(Cell.$typeName, (0, reified_1.extractType)(typeArg)), json.$typeArgs, [typeArg]);
101
+ assertReifiedTypeArgsMatch(composeSuiType(Cell.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
106
102
  return Cell.fromJSONField(typeArg, json);
107
103
  }
108
104
  static fromSuiParsedData(typeArg, content) {
@@ -119,16 +115,16 @@ class Cell {
119
115
  if (data.bcs.dataType !== "moveObject" || !isCell(data.bcs.type)) {
120
116
  throw new Error(`object at is not a Cell object`);
121
117
  }
122
- const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
118
+ const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
123
119
  if (gotTypeArgs.length !== 1) {
124
120
  throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
125
121
  }
126
- const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[0]);
127
- const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg));
128
- if (gotTypeArg !== (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg))) {
122
+ const gotTypeArg = compressSuiType(gotTypeArgs[0]);
123
+ const expectedTypeArg = compressSuiType(extractType(typeArg));
124
+ if (gotTypeArg !== compressSuiType(extractType(typeArg))) {
129
125
  throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
130
126
  }
131
- return Cell.fromBcs(typeArg, (0, utils_1.fromB64)(data.bcs.bcsBytes));
127
+ return Cell.fromBcs(typeArg, fromBase64(data.bcs.bcsBytes));
132
128
  }
133
129
  if (data.content) {
134
130
  return Cell.fromSuiParsedData(typeArg, data.content);
@@ -150,7 +146,6 @@ class Cell {
150
146
  });
151
147
  }
152
148
  }
153
- exports.Cell = Cell;
154
- Cell.$typeName = `${index_1.PKG_V1}::cell::Cell`;
149
+ Cell.$typeName = `${PKG_V1}::cell::Cell`;
155
150
  Cell.$numTypeParams = 1;
156
151
  Cell.$isPhantom = [false];
@@ -1,7 +1,7 @@
1
1
  import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../_framework/reified";
2
2
  import { FieldsWithTypes } from "../../_framework/util";
3
3
  import { PKG_V1 } from "../index";
4
- import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
4
+ import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
5
5
  export declare function isDecimal(type: string): boolean;
6
6
  export interface DecimalFields {
7
7
  value: ToField<"u256">;
@@ -22,8 +22,8 @@ export declare class Decimal implements StructClass {
22
22
  static get r(): import("../../_framework/reified").StructClassReified<Decimal, DecimalFields>;
23
23
  static phantom(): PhantomReified<ToTypeStr<Decimal>>;
24
24
  static get p(): PhantomReified<"0x1f54a9a2d71799553197e9ea24557797c6398d6a65f2d4d3818c9304b75d5e21::decimal::Decimal" | "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::decimal::Decimal">;
25
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
26
- value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u256">;
25
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
26
+ value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u256">;
27
27
  }, string>;
28
28
  static fromFields(fields: Record<string, any>): Decimal;
29
29
  static fromFieldsWithTypes(item: FieldsWithTypes): Decimal;
@@ -40,5 +40,5 @@ export declare class Decimal implements StructClass {
40
40
  static fromJSON(json: Record<string, any>): Decimal;
41
41
  static fromSuiParsedData(content: SuiParsedData): Decimal;
42
42
  static fromSuiObjectData(data: SuiObjectData): Decimal;
43
- static fetch(client: SuiClient, id: string): Promise<Decimal>;
43
+ static fetch(client: SuiJsonRpcClient, id: string): Promise<Decimal>;
44
44
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,32 +7,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Decimal = void 0;
13
- exports.isDecimal = isDecimal;
14
- const reified_1 = require("../../_framework/reified");
15
- const util_1 = require("../../_framework/util");
16
- const index_1 = require("../index");
17
- const bcs_1 = require("@mysten/sui/bcs");
18
- const utils_1 = require("@mysten/sui/utils");
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../_framework/reified";
11
+ import { composeSuiType, compressSuiType, } from "../../_framework/util";
12
+ import { PKG_V1 } from "../index";
13
+ import { bcs } from "@mysten/sui/bcs";
14
+ import { fromBase64 } from "@mysten/sui/utils";
19
15
  /* ============================== Decimal =============================== */
20
- function isDecimal(type) {
21
- type = (0, util_1.compressSuiType)(type);
22
- return type === `${index_1.PKG_V1}::decimal::Decimal`;
16
+ export function isDecimal(type) {
17
+ type = compressSuiType(type);
18
+ return type === `${PKG_V1}::decimal::Decimal`;
23
19
  }
24
- class Decimal {
20
+ export class Decimal {
25
21
  constructor(typeArgs, fields) {
26
22
  this.__StructClass = true;
27
23
  this.$typeName = Decimal.$typeName;
28
24
  this.$isPhantom = Decimal.$isPhantom;
29
- this.$fullTypeName = (0, util_1.composeSuiType)(Decimal.$typeName, ...typeArgs);
25
+ this.$fullTypeName = composeSuiType(Decimal.$typeName, ...typeArgs);
30
26
  this.$typeArgs = typeArgs;
31
27
  this.value = fields.value;
32
28
  }
33
29
  static reified() {
34
30
  return {
35
31
  typeName: Decimal.$typeName,
36
- fullTypeName: (0, util_1.composeSuiType)(Decimal.$typeName, ...[]),
32
+ fullTypeName: composeSuiType(Decimal.$typeName, ...[]),
37
33
  typeArgs: [],
38
34
  isPhantom: Decimal.$isPhantom,
39
35
  reifiedTypeArgs: [],
@@ -56,19 +52,19 @@ class Decimal {
56
52
  return Decimal.reified();
57
53
  }
58
54
  static phantom() {
59
- return (0, reified_1.phantom)(Decimal.reified());
55
+ return phantom(Decimal.reified());
60
56
  }
61
57
  static get p() {
62
58
  return Decimal.phantom();
63
59
  }
64
60
  static get bcs() {
65
- return bcs_1.bcs.struct("Decimal", {
66
- value: bcs_1.bcs.u256(),
61
+ return bcs.struct("Decimal", {
62
+ value: bcs.u256(),
67
63
  });
68
64
  }
69
65
  static fromFields(fields) {
70
66
  return Decimal.reified().new({
71
- value: (0, reified_1.decodeFromFields)("u256", fields.value),
67
+ value: decodeFromFields("u256", fields.value),
72
68
  });
73
69
  }
74
70
  static fromFieldsWithTypes(item) {
@@ -76,7 +72,7 @@ class Decimal {
76
72
  throw new Error("not a Decimal type");
77
73
  }
78
74
  return Decimal.reified().new({
79
- value: (0, reified_1.decodeFromFieldsWithTypes)("u256", item.fields.value),
75
+ value: decodeFromFieldsWithTypes("u256", item.fields.value),
80
76
  });
81
77
  }
82
78
  static fromBcs(data) {
@@ -92,7 +88,7 @@ class Decimal {
92
88
  }
93
89
  static fromJSONField(field) {
94
90
  return Decimal.reified().new({
95
- value: (0, reified_1.decodeFromJSONField)("u256", field.value),
91
+ value: decodeFromJSONField("u256", field.value),
96
92
  });
97
93
  }
98
94
  static fromJSON(json) {
@@ -115,7 +111,7 @@ class Decimal {
115
111
  if (data.bcs.dataType !== "moveObject" || !isDecimal(data.bcs.type)) {
116
112
  throw new Error(`object at is not a Decimal object`);
117
113
  }
118
- return Decimal.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
114
+ return Decimal.fromBcs(fromBase64(data.bcs.bcsBytes));
119
115
  }
120
116
  if (data.content) {
121
117
  return Decimal.fromSuiParsedData(data.content);
@@ -137,7 +133,6 @@ class Decimal {
137
133
  });
138
134
  }
139
135
  }
140
- exports.Decimal = Decimal;
141
- Decimal.$typeName = `${index_1.PKG_V1}::decimal::Decimal`;
136
+ Decimal.$typeName = `${PKG_V1}::decimal::Decimal`;
142
137
  Decimal.$numTypeParams = 0;
143
138
  Decimal.$isPhantom = [];
@@ -1,25 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PKG_V11 = exports.PKG_V10 = exports.PKG_V8 = exports.PKG_V1 = exports.PUBLISHED_AT = exports.PACKAGE_ID = void 0;
4
- exports.setPublishedAt = setPublishedAt;
5
- exports.PACKAGE_ID = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
1
+ export const PACKAGE_ID = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
6
2
  ? "0x1f54a9a2d71799553197e9ea24557797c6398d6a65f2d4d3818c9304b75d5e21"
7
3
  : "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
8
- exports.PUBLISHED_AT = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
4
+ export let PUBLISHED_AT = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
9
5
  ? "0x5bb8cb3894945f523736f4f5059b1621056e8093b165ea56b20805d0ef2461a9"
10
6
  : "0xe37cc7bb50fd9b6dbd3873df66fa2c554e973697f50ef97707311dc78bd08444";
11
- exports.PKG_V1 = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
7
+ export const PKG_V1 = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
12
8
  ? "0x1f54a9a2d71799553197e9ea24557797c6398d6a65f2d4d3818c9304b75d5e21"
13
9
  : "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
14
- exports.PKG_V8 = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
10
+ export const PKG_V8 = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
15
11
  ? "0xe5ed361add4433f4d23e56fc0e3bacab39b93592d5e65d508e33fd19ff696669"
16
12
  : "0x5b54b47971238403d6ade3c8c2cc75814cb55145a5184af916bb5b12aaf184cb";
17
- exports.PKG_V10 = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
13
+ export const PKG_V10 = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
18
14
  ? "0xe5ed361add4433f4d23e56fc0e3bacab39b93592d5e65d508e33fd19ff696669"
19
15
  : "0xe37cc7bb50fd9b6dbd3873df66fa2c554e973697f50ef97707311dc78bd08444";
20
- exports.PKG_V11 = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
16
+ export const PKG_V11 = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
21
17
  ? "0xe5ed361add4433f4d23e56fc0e3bacab39b93592d5e65d508e33fd19ff696669"
22
18
  : "0xd2a67633ccb8de063163e25bcfca242929caf5cf1a26c2929dab519ee0b8f331";
23
- function setPublishedAt(publishedAt) {
24
- exports.PUBLISHED_AT = publishedAt;
19
+ export function setPublishedAt(publishedAt) {
20
+ PUBLISHED_AT = publishedAt;
25
21
  }
@@ -170,6 +170,7 @@ export interface AddReserveArgs {
170
170
  clock: TransactionObjectInput;
171
171
  }
172
172
  export declare function addReserve(tx: Transaction, typeArgs: [string, string], args: AddReserveArgs): import("@mysten/sui/transactions").TransactionResult;
173
+ export declare function addReserveV2(tx: Transaction, typeArgs: [string, string], args: AddReserveArgs): import("@mysten/sui/transactions").TransactionResult;
173
174
  export interface BorrowRequestArgs {
174
175
  lendingMarket: TransactionObjectInput;
175
176
  reserveArrayIndex: bigint | TransactionArgument;