@suilend/sdk 12.7.0 → 13.0.0-next.g803bba0

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 (84) hide show
  1. package/_generated/_dependencies/pyth-2/price-identifier/structs.d.ts +46 -0
  2. package/_generated/_dependencies/{source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e → pyth-2}/price-identifier/structs.js +45 -25
  3. package/_generated/_dependencies/std/ascii/structs.d.ts +100 -0
  4. package/_generated/_dependencies/{source/0x1 → std}/ascii/structs.js +153 -103
  5. package/_generated/_dependencies/{source/0x1 → std}/option/structs.d.ts +29 -21
  6. package/_generated/_dependencies/std/option/structs.js +155 -0
  7. package/_generated/_dependencies/std/type-name/structs.d.ts +65 -0
  8. package/_generated/_dependencies/{source/0x1 → std}/type-name/structs.js +49 -22
  9. package/_generated/_dependencies/sui/bag/structs.d.ts +75 -0
  10. package/_generated/_dependencies/sui/bag/structs.js +154 -0
  11. package/_generated/_dependencies/{source/0x2 → sui}/balance/structs.d.ts +80 -60
  12. package/_generated/_dependencies/sui/balance/structs.js +306 -0
  13. package/_generated/_dependencies/sui/object/structs.d.ts +104 -0
  14. package/_generated/_dependencies/{source/0x2 → sui}/object/structs.js +98 -46
  15. package/_generated/_dependencies/{source/0x2 → sui}/object-table/structs.d.ts +37 -30
  16. package/_generated/_dependencies/sui/object-table/structs.js +164 -0
  17. package/_generated/_envs/index.d.ts +3 -0
  18. package/_generated/_envs/index.js +18 -0
  19. package/_generated/_envs/mainnet.d.ts +2 -0
  20. package/_generated/_envs/mainnet.js +490 -0
  21. package/_generated/_framework/env.d.ts +137 -0
  22. package/_generated/_framework/env.js +261 -0
  23. package/_generated/_framework/reified.d.ts +68 -36
  24. package/_generated/_framework/reified.js +110 -98
  25. package/_generated/_framework/util.d.ts +4 -4
  26. package/_generated/_framework/util.js +82 -79
  27. package/_generated/_framework/vector.d.ts +11 -9
  28. package/_generated/_framework/vector.js +10 -10
  29. package/_generated/suilend/cell/structs.d.ts +24 -22
  30. package/_generated/suilend/cell/structs.js +68 -24
  31. package/_generated/suilend/decimal/structs.d.ts +28 -24
  32. package/_generated/suilend/decimal/structs.js +45 -24
  33. package/_generated/suilend/index.d.ts +5 -6
  34. package/_generated/suilend/index.js +10 -19
  35. package/_generated/suilend/lending-market/functions.d.ts +1123 -149
  36. package/_generated/suilend/lending-market/functions.js +1121 -207
  37. package/_generated/suilend/lending-market/structs.d.ts +985 -1290
  38. package/_generated/suilend/lending-market/structs.js +2482 -1282
  39. package/_generated/suilend/lending-market-registry/functions.d.ts +32 -3
  40. package/_generated/suilend/lending-market-registry/functions.js +30 -6
  41. package/_generated/suilend/liquidity-mining/structs.d.ts +200 -333
  42. package/_generated/suilend/liquidity-mining/structs.js +449 -319
  43. package/_generated/suilend/obligation/structs.d.ts +406 -918
  44. package/_generated/suilend/obligation/structs.js +786 -596
  45. package/_generated/suilend/rate-limiter/functions.d.ts +134 -15
  46. package/_generated/suilend/rate-limiter/functions.js +139 -21
  47. package/_generated/suilend/rate-limiter/structs.d.ts +72 -80
  48. package/_generated/suilend/rate-limiter/structs.js +98 -48
  49. package/_generated/suilend/reserve/structs.d.ts +611 -904
  50. package/_generated/suilend/reserve/structs.js +1528 -736
  51. package/_generated/suilend/reserve-config/functions.d.ts +718 -96
  52. package/_generated/suilend/reserve-config/functions.js +751 -157
  53. package/_generated/suilend/reserve-config/structs.d.ts +148 -163
  54. package/_generated/suilend/reserve-config/structs.js +260 -94
  55. package/client.d.ts +2 -2
  56. package/client.js +22 -39
  57. package/lib/initialize.d.ts +76 -76
  58. package/lib/initialize.js +10 -10
  59. package/lib/proCompatible.js +5 -5
  60. package/package.json +1 -1
  61. package/parsers/lendingMarket.d.ts +9 -9
  62. package/parsers/obligation.d.ts +14 -14
  63. package/parsers/obligation.js +4 -4
  64. package/parsers/rateLimiter.d.ts +1 -1
  65. package/parsers/reserve.d.ts +12 -12
  66. package/parsers/reserve.js +2 -2
  67. package/strategies.d.ts +14 -14
  68. package/utils/simulate.d.ts +1 -1
  69. package/utils/simulate.js +5 -5
  70. package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +0 -84
  71. package/_generated/_dependencies/source/0x1/index.d.ts +0 -3
  72. package/_generated/_dependencies/source/0x1/index.js +0 -3
  73. package/_generated/_dependencies/source/0x1/option/structs.js +0 -110
  74. package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +0 -47
  75. package/_generated/_dependencies/source/0x2/bag/structs.d.ts +0 -52
  76. package/_generated/_dependencies/source/0x2/bag/structs.js +0 -113
  77. package/_generated/_dependencies/source/0x2/balance/structs.js +0 -210
  78. package/_generated/_dependencies/source/0x2/index.d.ts +0 -3
  79. package/_generated/_dependencies/source/0x2/index.js +0 -3
  80. package/_generated/_dependencies/source/0x2/object/structs.d.ts +0 -82
  81. package/_generated/_dependencies/source/0x2/object-table/structs.js +0 -115
  82. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.d.ts +0 -4
  83. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +0 -4
  84. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +0 -46
@@ -1,25 +1,607 @@
1
- import * as reified from "../../_framework/reified.js";
2
- import { TypeName } from "../../_dependencies/source/0x1/type-name/structs.js";
3
- import { Balance, Supply, } from "../../_dependencies/source/0x2/balance/structs.js";
4
- import { ID, UID } from "../../_dependencies/source/0x2/object/structs.js";
5
- import { PriceIdentifier } from "../../_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js";
6
- import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../_framework/reified.js";
7
- import { composeSuiType, compressSuiType, } from "../../_framework/util.js";
8
- import { Cell } from "../cell/structs.js";
9
- import { Decimal } from "../decimal/structs.js";
10
- import { PKG_V1, PKG_V8 } from "../index.js";
11
- import { PoolRewardManager } from "../liquidity-mining/structs.js";
12
- import { ReserveConfig } from "../reserve-config/structs.js";
13
- import { bcs } from "@mysten/sui/bcs";
14
- import { fromHex, toHex } from "@mysten/sui/utils";
1
+ /** The reserve module holds the coins of a certain type for a given lending market. */
2
+ import { bcs } from '@mysten/sui/bcs';
3
+ import { fromHex, toHex } from '@mysten/sui/utils';
4
+ import { PriceIdentifier } from '../../_dependencies/pyth-2/price-identifier/structs.js';
5
+ import { TypeName } from '../../_dependencies/std/type-name/structs.js';
6
+ import { Balance, Supply } from '../../_dependencies/sui/balance/structs.js';
7
+ import { ID, UID } from '../../_dependencies/sui/object/structs.js';
8
+ import { getTypeOrigin } from '../../_envs/index.js';
9
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from '../../_framework/reified.js';
10
+ import { composeSuiType, compressSuiType, parseTypeName, } from '../../_framework/util.js';
11
+ import { Cell } from '../cell/structs.js';
12
+ import { Decimal } from '../decimal/structs.js';
13
+ import { PoolRewardManager } from '../liquidity-mining/structs.js';
14
+ import { ReserveConfig } from '../reserve-config/structs.js';
15
+ /* ============================== Reserve =============================== */
16
+ export function isReserve(type) {
17
+ type = compressSuiType(type);
18
+ return type.startsWith(`${getTypeOrigin('suilend', 'reserve::Reserve')}::reserve::Reserve` + '<');
19
+ }
20
+ export class Reserve {
21
+ __StructClass = true;
22
+ static get $typeName() {
23
+ return `${getTypeOrigin('suilend', 'reserve::Reserve')}::reserve::Reserve`;
24
+ }
25
+ static $numTypeParams = 1;
26
+ static $isPhantom = [true];
27
+ $typeName = Reserve.$typeName;
28
+ $fullTypeName;
29
+ $typeArgs;
30
+ $isPhantom = Reserve.$isPhantom;
31
+ id;
32
+ lendingMarketId;
33
+ arrayIndex;
34
+ coinType;
35
+ config;
36
+ mintDecimals;
37
+ priceIdentifier;
38
+ price;
39
+ smoothedPrice;
40
+ priceLastUpdateTimestampS;
41
+ availableAmount;
42
+ ctokenSupply;
43
+ borrowedAmount;
44
+ cumulativeBorrowRate;
45
+ interestLastUpdateTimestampS;
46
+ unclaimedSpreadFees;
47
+ /** unused */
48
+ attributedBorrowValue;
49
+ depositsPoolRewardManager;
50
+ borrowsPoolRewardManager;
51
+ constructor(typeArgs, fields) {
52
+ this.$fullTypeName = composeSuiType(Reserve.$typeName, ...typeArgs);
53
+ this.$typeArgs = typeArgs;
54
+ this.id = fields.id;
55
+ this.lendingMarketId = fields.lendingMarketId;
56
+ this.arrayIndex = fields.arrayIndex;
57
+ this.coinType = fields.coinType;
58
+ this.config = fields.config;
59
+ this.mintDecimals = fields.mintDecimals;
60
+ this.priceIdentifier = fields.priceIdentifier;
61
+ this.price = fields.price;
62
+ this.smoothedPrice = fields.smoothedPrice;
63
+ this.priceLastUpdateTimestampS = fields.priceLastUpdateTimestampS;
64
+ this.availableAmount = fields.availableAmount;
65
+ this.ctokenSupply = fields.ctokenSupply;
66
+ this.borrowedAmount = fields.borrowedAmount;
67
+ this.cumulativeBorrowRate = fields.cumulativeBorrowRate;
68
+ this.interestLastUpdateTimestampS = fields.interestLastUpdateTimestampS;
69
+ this.unclaimedSpreadFees = fields.unclaimedSpreadFees;
70
+ this.attributedBorrowValue = fields.attributedBorrowValue;
71
+ this.depositsPoolRewardManager = fields.depositsPoolRewardManager;
72
+ this.borrowsPoolRewardManager = fields.borrowsPoolRewardManager;
73
+ }
74
+ static reified(P) {
75
+ const reifiedBcs = Reserve.bcs;
76
+ return {
77
+ get typeName() {
78
+ return Reserve.$typeName;
79
+ },
80
+ get fullTypeName() {
81
+ return composeSuiType(Reserve.$typeName, ...[extractType(P)]);
82
+ },
83
+ get typeArgs() {
84
+ return [extractType(P)];
85
+ },
86
+ isPhantom: Reserve.$isPhantom,
87
+ reifiedTypeArgs: [P],
88
+ fromFields: (fields) => Reserve.fromFields(P, fields),
89
+ fromFieldsWithTypes: (item) => Reserve.fromFieldsWithTypes(P, item),
90
+ fromBcs: (data) => Reserve.fromFields(P, reifiedBcs.parse(data)),
91
+ bcs: reifiedBcs,
92
+ fromJSONField: (field) => Reserve.fromJSONField(P, field),
93
+ fromJSON: (json) => Reserve.fromJSON(P, json),
94
+ fromCoreObject: (obj) => Reserve.fromCoreObject(P, obj),
95
+ fetch: async (client, id) => Reserve.fetch(client, P, id),
96
+ new: (fields) => {
97
+ return new Reserve([extractType(P)], fields);
98
+ },
99
+ kind: 'StructClassReified',
100
+ };
101
+ }
102
+ static get r() {
103
+ return Reserve.reified;
104
+ }
105
+ static phantom(P) {
106
+ return phantom(Reserve.reified(P));
107
+ }
108
+ static get p() {
109
+ return Reserve.phantom;
110
+ }
111
+ static instantiateBcs() {
112
+ return bcs.struct('Reserve', {
113
+ id: UID.bcs,
114
+ lending_market_id: ID.bcs,
115
+ array_index: bcs.u64(),
116
+ coin_type: TypeName.bcs,
117
+ config: Cell.bcs(ReserveConfig.bcs),
118
+ mint_decimals: bcs.u8(),
119
+ price_identifier: PriceIdentifier.bcs,
120
+ price: Decimal.bcs,
121
+ smoothed_price: Decimal.bcs,
122
+ price_last_update_timestamp_s: bcs.u64(),
123
+ available_amount: bcs.u64(),
124
+ ctoken_supply: bcs.u64(),
125
+ borrowed_amount: Decimal.bcs,
126
+ cumulative_borrow_rate: Decimal.bcs,
127
+ interest_last_update_timestamp_s: bcs.u64(),
128
+ unclaimed_spread_fees: Decimal.bcs,
129
+ attributed_borrow_value: Decimal.bcs,
130
+ deposits_pool_reward_manager: PoolRewardManager.bcs,
131
+ borrows_pool_reward_manager: PoolRewardManager.bcs,
132
+ });
133
+ }
134
+ static cachedBcs = null;
135
+ static get bcs() {
136
+ if (!Reserve.cachedBcs) {
137
+ Reserve.cachedBcs = Reserve.instantiateBcs();
138
+ }
139
+ return Reserve.cachedBcs;
140
+ }
141
+ static fromFields(typeArg, fields) {
142
+ return Reserve.reified(typeArg).new({
143
+ id: decodeFromFields(UID.reified(), fields.id),
144
+ lendingMarketId: decodeFromFields(ID.reified(), fields.lending_market_id),
145
+ arrayIndex: decodeFromFields('u64', fields.array_index),
146
+ coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
147
+ config: decodeFromFields(Cell.reified(ReserveConfig.reified()), fields.config),
148
+ mintDecimals: decodeFromFields('u8', fields.mint_decimals),
149
+ priceIdentifier: decodeFromFields(PriceIdentifier.reified(), fields.price_identifier),
150
+ price: decodeFromFields(Decimal.reified(), fields.price),
151
+ smoothedPrice: decodeFromFields(Decimal.reified(), fields.smoothed_price),
152
+ priceLastUpdateTimestampS: decodeFromFields('u64', fields.price_last_update_timestamp_s),
153
+ availableAmount: decodeFromFields('u64', fields.available_amount),
154
+ ctokenSupply: decodeFromFields('u64', fields.ctoken_supply),
155
+ borrowedAmount: decodeFromFields(Decimal.reified(), fields.borrowed_amount),
156
+ cumulativeBorrowRate: decodeFromFields(Decimal.reified(), fields.cumulative_borrow_rate),
157
+ interestLastUpdateTimestampS: decodeFromFields('u64', fields.interest_last_update_timestamp_s),
158
+ unclaimedSpreadFees: decodeFromFields(Decimal.reified(), fields.unclaimed_spread_fees),
159
+ attributedBorrowValue: decodeFromFields(Decimal.reified(), fields.attributed_borrow_value),
160
+ depositsPoolRewardManager: decodeFromFields(PoolRewardManager.reified(), fields.deposits_pool_reward_manager),
161
+ borrowsPoolRewardManager: decodeFromFields(PoolRewardManager.reified(), fields.borrows_pool_reward_manager),
162
+ });
163
+ }
164
+ static fromFieldsWithTypes(typeArg, item) {
165
+ if (!isReserve(item.type)) {
166
+ throw new Error('not a Reserve type');
167
+ }
168
+ assertFieldsWithTypesArgsMatch(item, [typeArg]);
169
+ return Reserve.reified(typeArg).new({
170
+ id: decodeFromFieldsWithTypes(UID.reified(), item.fields.id),
171
+ lendingMarketId: decodeFromFieldsWithTypes(ID.reified(), item.fields.lending_market_id),
172
+ arrayIndex: decodeFromFieldsWithTypes('u64', item.fields.array_index),
173
+ coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
174
+ config: decodeFromFieldsWithTypes(Cell.reified(ReserveConfig.reified()), item.fields.config),
175
+ mintDecimals: decodeFromFieldsWithTypes('u8', item.fields.mint_decimals),
176
+ priceIdentifier: decodeFromFieldsWithTypes(PriceIdentifier.reified(), item.fields.price_identifier),
177
+ price: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.price),
178
+ smoothedPrice: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.smoothed_price),
179
+ priceLastUpdateTimestampS: decodeFromFieldsWithTypes('u64', item.fields.price_last_update_timestamp_s),
180
+ availableAmount: decodeFromFieldsWithTypes('u64', item.fields.available_amount),
181
+ ctokenSupply: decodeFromFieldsWithTypes('u64', item.fields.ctoken_supply),
182
+ borrowedAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrowed_amount),
183
+ cumulativeBorrowRate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.cumulative_borrow_rate),
184
+ interestLastUpdateTimestampS: decodeFromFieldsWithTypes('u64', item.fields.interest_last_update_timestamp_s),
185
+ unclaimedSpreadFees: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.unclaimed_spread_fees),
186
+ attributedBorrowValue: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.attributed_borrow_value),
187
+ depositsPoolRewardManager: decodeFromFieldsWithTypes(PoolRewardManager.reified(), item.fields.deposits_pool_reward_manager),
188
+ borrowsPoolRewardManager: decodeFromFieldsWithTypes(PoolRewardManager.reified(), item.fields.borrows_pool_reward_manager),
189
+ });
190
+ }
191
+ static fromBcs(typeArg, data) {
192
+ return Reserve.fromFields(typeArg, Reserve.bcs.parse(data));
193
+ }
194
+ toJSONField() {
195
+ return {
196
+ id: this.id,
197
+ lendingMarketId: this.lendingMarketId,
198
+ arrayIndex: this.arrayIndex.toString(),
199
+ coinType: this.coinType,
200
+ config: this.config.toJSONField(),
201
+ mintDecimals: this.mintDecimals,
202
+ priceIdentifier: this.priceIdentifier.toJSONField(),
203
+ price: this.price.toJSONField(),
204
+ smoothedPrice: this.smoothedPrice.toJSONField(),
205
+ priceLastUpdateTimestampS: this.priceLastUpdateTimestampS.toString(),
206
+ availableAmount: this.availableAmount.toString(),
207
+ ctokenSupply: this.ctokenSupply.toString(),
208
+ borrowedAmount: this.borrowedAmount.toJSONField(),
209
+ cumulativeBorrowRate: this.cumulativeBorrowRate.toJSONField(),
210
+ interestLastUpdateTimestampS: this.interestLastUpdateTimestampS.toString(),
211
+ unclaimedSpreadFees: this.unclaimedSpreadFees.toJSONField(),
212
+ attributedBorrowValue: this.attributedBorrowValue.toJSONField(),
213
+ depositsPoolRewardManager: this.depositsPoolRewardManager.toJSONField(),
214
+ borrowsPoolRewardManager: this.borrowsPoolRewardManager.toJSONField(),
215
+ };
216
+ }
217
+ toJSON() {
218
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
219
+ }
220
+ static fromJSONField(typeArg, field) {
221
+ return Reserve.reified(typeArg).new({
222
+ id: decodeFromJSONField(UID.reified(), field.id),
223
+ lendingMarketId: decodeFromJSONField(ID.reified(), field.lendingMarketId),
224
+ arrayIndex: decodeFromJSONField('u64', field.arrayIndex),
225
+ coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
226
+ config: decodeFromJSONField(Cell.reified(ReserveConfig.reified()), field.config),
227
+ mintDecimals: decodeFromJSONField('u8', field.mintDecimals),
228
+ priceIdentifier: decodeFromJSONField(PriceIdentifier.reified(), field.priceIdentifier),
229
+ price: decodeFromJSONField(Decimal.reified(), field.price),
230
+ smoothedPrice: decodeFromJSONField(Decimal.reified(), field.smoothedPrice),
231
+ priceLastUpdateTimestampS: decodeFromJSONField('u64', field.priceLastUpdateTimestampS),
232
+ availableAmount: decodeFromJSONField('u64', field.availableAmount),
233
+ ctokenSupply: decodeFromJSONField('u64', field.ctokenSupply),
234
+ borrowedAmount: decodeFromJSONField(Decimal.reified(), field.borrowedAmount),
235
+ cumulativeBorrowRate: decodeFromJSONField(Decimal.reified(), field.cumulativeBorrowRate),
236
+ interestLastUpdateTimestampS: decodeFromJSONField('u64', field.interestLastUpdateTimestampS),
237
+ unclaimedSpreadFees: decodeFromJSONField(Decimal.reified(), field.unclaimedSpreadFees),
238
+ attributedBorrowValue: decodeFromJSONField(Decimal.reified(), field.attributedBorrowValue),
239
+ depositsPoolRewardManager: decodeFromJSONField(PoolRewardManager.reified(), field.depositsPoolRewardManager),
240
+ borrowsPoolRewardManager: decodeFromJSONField(PoolRewardManager.reified(), field.borrowsPoolRewardManager),
241
+ });
242
+ }
243
+ static fromJSON(typeArg, json) {
244
+ if (json.$typeName !== Reserve.$typeName) {
245
+ throw new Error(`not a Reserve json object: expected '${Reserve.$typeName}' but got '${json.$typeName}'`);
246
+ }
247
+ assertReifiedTypeArgsMatch(composeSuiType(Reserve.$typeName, ...[extractType(typeArg)]), json.$typeArgs, [typeArg]);
248
+ return Reserve.fromJSONField(typeArg, json);
249
+ }
250
+ static fromCoreObject(typeArg, obj) {
251
+ if (!isReserve(obj.type)) {
252
+ throw new Error(`object at ${obj.objectId} is not a Reserve object`);
253
+ }
254
+ const gotTypeArgs = parseTypeName(obj.type).typeArgs;
255
+ if (gotTypeArgs.length !== 1) {
256
+ throw new Error(`type argument mismatch: expected 1 type arguments but got '${gotTypeArgs.length}'`);
257
+ }
258
+ for (let i = 0; i < 1; i++) {
259
+ const gotTypeArg = compressSuiType(gotTypeArgs[i]);
260
+ const expectedTypeArg = compressSuiType(extractType([typeArg][i]));
261
+ if (gotTypeArg !== expectedTypeArg) {
262
+ throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
263
+ }
264
+ }
265
+ return Reserve.fromBcs(typeArg, obj.content);
266
+ }
267
+ static async fetch(client, typeArg, id) {
268
+ const { object } = await client.core.getObject({
269
+ objectId: id,
270
+ include: { content: true },
271
+ });
272
+ if (!isReserve(object.type)) {
273
+ throw new Error(`object at id ${id} is not a Reserve object`);
274
+ }
275
+ const gotTypeArgs = parseTypeName(object.type).typeArgs;
276
+ if (gotTypeArgs.length !== 1) {
277
+ throw new Error(`type argument mismatch: expected 1 type arguments but got '${gotTypeArgs.length}'`);
278
+ }
279
+ for (let i = 0; i < 1; i++) {
280
+ const gotTypeArg = compressSuiType(gotTypeArgs[i]);
281
+ const expectedTypeArg = compressSuiType(extractType([typeArg][i]));
282
+ if (gotTypeArg !== expectedTypeArg) {
283
+ throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
284
+ }
285
+ }
286
+ return Reserve.fromBcs(typeArg, object.content);
287
+ }
288
+ }
289
+ /* ============================== CToken =============================== */
290
+ export function isCToken(type) {
291
+ type = compressSuiType(type);
292
+ return type.startsWith(`${getTypeOrigin('suilend', 'reserve::CToken')}::reserve::CToken` + '<');
293
+ }
294
+ /**
295
+ * Interest bearing token on the underlying Coin<T>. The ctoken can be redeemed for
296
+ * the underlying token + any interest earned.
297
+ */
298
+ export class CToken {
299
+ __StructClass = true;
300
+ static get $typeName() {
301
+ return `${getTypeOrigin('suilend', 'reserve::CToken')}::reserve::CToken`;
302
+ }
303
+ static $numTypeParams = 2;
304
+ static $isPhantom = [true, true];
305
+ $typeName = CToken.$typeName;
306
+ $fullTypeName;
307
+ $typeArgs;
308
+ $isPhantom = CToken.$isPhantom;
309
+ dummyField;
310
+ constructor(typeArgs, fields) {
311
+ this.$fullTypeName = composeSuiType(CToken.$typeName, ...typeArgs);
312
+ this.$typeArgs = typeArgs;
313
+ this.dummyField = fields.dummyField;
314
+ }
315
+ static reified(P, T) {
316
+ const reifiedBcs = CToken.bcs;
317
+ return {
318
+ get typeName() {
319
+ return CToken.$typeName;
320
+ },
321
+ get fullTypeName() {
322
+ return composeSuiType(CToken.$typeName, ...[extractType(P), extractType(T)]);
323
+ },
324
+ get typeArgs() {
325
+ return [extractType(P), extractType(T)];
326
+ },
327
+ isPhantom: CToken.$isPhantom,
328
+ reifiedTypeArgs: [P, T],
329
+ fromFields: (fields) => CToken.fromFields([P, T], fields),
330
+ fromFieldsWithTypes: (item) => CToken.fromFieldsWithTypes([P, T], item),
331
+ fromBcs: (data) => CToken.fromFields([P, T], reifiedBcs.parse(data)),
332
+ bcs: reifiedBcs,
333
+ fromJSONField: (field) => CToken.fromJSONField([P, T], field),
334
+ fromJSON: (json) => CToken.fromJSON([P, T], json),
335
+ fromCoreObject: (obj) => CToken.fromCoreObject([P, T], obj),
336
+ fetch: async (client, id) => CToken.fetch(client, [P, T], id),
337
+ new: (fields) => {
338
+ return new CToken([extractType(P), extractType(T)], fields);
339
+ },
340
+ kind: 'StructClassReified',
341
+ };
342
+ }
343
+ static get r() {
344
+ return CToken.reified;
345
+ }
346
+ static phantom(P, T) {
347
+ return phantom(CToken.reified(P, T));
348
+ }
349
+ static get p() {
350
+ return CToken.phantom;
351
+ }
352
+ static instantiateBcs() {
353
+ return bcs.struct('CToken', {
354
+ dummy_field: bcs.bool(),
355
+ });
356
+ }
357
+ static cachedBcs = null;
358
+ static get bcs() {
359
+ if (!CToken.cachedBcs) {
360
+ CToken.cachedBcs = CToken.instantiateBcs();
361
+ }
362
+ return CToken.cachedBcs;
363
+ }
364
+ static fromFields(typeArgs, fields) {
365
+ return CToken.reified(typeArgs[0], typeArgs[1]).new({
366
+ dummyField: decodeFromFields('bool', fields.dummy_field),
367
+ });
368
+ }
369
+ static fromFieldsWithTypes(typeArgs, item) {
370
+ if (!isCToken(item.type)) {
371
+ throw new Error('not a CToken type');
372
+ }
373
+ assertFieldsWithTypesArgsMatch(item, typeArgs);
374
+ return CToken.reified(typeArgs[0], typeArgs[1]).new({
375
+ dummyField: decodeFromFieldsWithTypes('bool', item.fields.dummy_field),
376
+ });
377
+ }
378
+ static fromBcs(typeArgs, data) {
379
+ return CToken.fromFields(typeArgs, CToken.bcs.parse(data));
380
+ }
381
+ toJSONField() {
382
+ return {
383
+ dummyField: this.dummyField,
384
+ };
385
+ }
386
+ toJSON() {
387
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
388
+ }
389
+ static fromJSONField(typeArgs, field) {
390
+ return CToken.reified(typeArgs[0], typeArgs[1]).new({
391
+ dummyField: decodeFromJSONField('bool', field.dummyField),
392
+ });
393
+ }
394
+ static fromJSON(typeArgs, json) {
395
+ if (json.$typeName !== CToken.$typeName) {
396
+ throw new Error(`not a CToken json object: expected '${CToken.$typeName}' but got '${json.$typeName}'`);
397
+ }
398
+ assertReifiedTypeArgsMatch(composeSuiType(CToken.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
399
+ return CToken.fromJSONField(typeArgs, json);
400
+ }
401
+ static fromCoreObject(typeArgs, obj) {
402
+ if (!isCToken(obj.type)) {
403
+ throw new Error(`object at ${obj.objectId} is not a CToken object`);
404
+ }
405
+ const gotTypeArgs = parseTypeName(obj.type).typeArgs;
406
+ if (gotTypeArgs.length !== 2) {
407
+ throw new Error(`type argument mismatch: expected 2 type arguments but got '${gotTypeArgs.length}'`);
408
+ }
409
+ for (let i = 0; i < 2; i++) {
410
+ const gotTypeArg = compressSuiType(gotTypeArgs[i]);
411
+ const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
412
+ if (gotTypeArg !== expectedTypeArg) {
413
+ throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
414
+ }
415
+ }
416
+ return CToken.fromBcs(typeArgs, obj.content);
417
+ }
418
+ static async fetch(client, typeArgs, id) {
419
+ const { object } = await client.core.getObject({
420
+ objectId: id,
421
+ include: { content: true },
422
+ });
423
+ if (!isCToken(object.type)) {
424
+ throw new Error(`object at id ${id} is not a CToken object`);
425
+ }
426
+ const gotTypeArgs = parseTypeName(object.type).typeArgs;
427
+ if (gotTypeArgs.length !== 2) {
428
+ throw new Error(`type argument mismatch: expected 2 type arguments but got '${gotTypeArgs.length}'`);
429
+ }
430
+ for (let i = 0; i < 2; i++) {
431
+ const gotTypeArg = compressSuiType(gotTypeArgs[i]);
432
+ const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
433
+ if (gotTypeArg !== expectedTypeArg) {
434
+ throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
435
+ }
436
+ }
437
+ return CToken.fromBcs(typeArgs, object.content);
438
+ }
439
+ }
440
+ /* ============================== LiquidityRequest =============================== */
441
+ export function isLiquidityRequest(type) {
442
+ type = compressSuiType(type);
443
+ return type.startsWith(`${getTypeOrigin('suilend', 'reserve::LiquidityRequest')}::reserve::LiquidityRequest` + '<');
444
+ }
445
+ /** A request to withdraw liquidity from the reserve. This is a hot potato object. */
446
+ export class LiquidityRequest {
447
+ __StructClass = true;
448
+ static get $typeName() {
449
+ return `${getTypeOrigin('suilend', 'reserve::LiquidityRequest')}::reserve::LiquidityRequest`;
450
+ }
451
+ static $numTypeParams = 2;
452
+ static $isPhantom = [true, true];
453
+ $typeName = LiquidityRequest.$typeName;
454
+ $fullTypeName;
455
+ $typeArgs;
456
+ $isPhantom = LiquidityRequest.$isPhantom;
457
+ amount;
458
+ fee;
459
+ constructor(typeArgs, fields) {
460
+ this.$fullTypeName = composeSuiType(LiquidityRequest.$typeName, ...typeArgs);
461
+ this.$typeArgs = typeArgs;
462
+ this.amount = fields.amount;
463
+ this.fee = fields.fee;
464
+ }
465
+ static reified(P, T) {
466
+ const reifiedBcs = LiquidityRequest.bcs;
467
+ return {
468
+ get typeName() {
469
+ return LiquidityRequest.$typeName;
470
+ },
471
+ get fullTypeName() {
472
+ return composeSuiType(LiquidityRequest.$typeName, ...[extractType(P), extractType(T)]);
473
+ },
474
+ get typeArgs() {
475
+ return [extractType(P), extractType(T)];
476
+ },
477
+ isPhantom: LiquidityRequest.$isPhantom,
478
+ reifiedTypeArgs: [P, T],
479
+ fromFields: (fields) => LiquidityRequest.fromFields([P, T], fields),
480
+ fromFieldsWithTypes: (item) => LiquidityRequest.fromFieldsWithTypes([P, T], item),
481
+ fromBcs: (data) => LiquidityRequest.fromFields([P, T], reifiedBcs.parse(data)),
482
+ bcs: reifiedBcs,
483
+ fromJSONField: (field) => LiquidityRequest.fromJSONField([P, T], field),
484
+ fromJSON: (json) => LiquidityRequest.fromJSON([P, T], json),
485
+ fromCoreObject: (obj) => LiquidityRequest.fromCoreObject([P, T], obj),
486
+ fetch: async (client, id) => LiquidityRequest.fetch(client, [P, T], id),
487
+ new: (fields) => {
488
+ return new LiquidityRequest([extractType(P), extractType(T)], fields);
489
+ },
490
+ kind: 'StructClassReified',
491
+ };
492
+ }
493
+ static get r() {
494
+ return LiquidityRequest.reified;
495
+ }
496
+ static phantom(P, T) {
497
+ return phantom(LiquidityRequest.reified(P, T));
498
+ }
499
+ static get p() {
500
+ return LiquidityRequest.phantom;
501
+ }
502
+ static instantiateBcs() {
503
+ return bcs.struct('LiquidityRequest', {
504
+ amount: bcs.u64(),
505
+ fee: bcs.u64(),
506
+ });
507
+ }
508
+ static cachedBcs = null;
509
+ static get bcs() {
510
+ if (!LiquidityRequest.cachedBcs) {
511
+ LiquidityRequest.cachedBcs = LiquidityRequest.instantiateBcs();
512
+ }
513
+ return LiquidityRequest.cachedBcs;
514
+ }
515
+ static fromFields(typeArgs, fields) {
516
+ return LiquidityRequest.reified(typeArgs[0], typeArgs[1]).new({
517
+ amount: decodeFromFields('u64', fields.amount),
518
+ fee: decodeFromFields('u64', fields.fee),
519
+ });
520
+ }
521
+ static fromFieldsWithTypes(typeArgs, item) {
522
+ if (!isLiquidityRequest(item.type)) {
523
+ throw new Error('not a LiquidityRequest type');
524
+ }
525
+ assertFieldsWithTypesArgsMatch(item, typeArgs);
526
+ return LiquidityRequest.reified(typeArgs[0], typeArgs[1]).new({
527
+ amount: decodeFromFieldsWithTypes('u64', item.fields.amount),
528
+ fee: decodeFromFieldsWithTypes('u64', item.fields.fee),
529
+ });
530
+ }
531
+ static fromBcs(typeArgs, data) {
532
+ return LiquidityRequest.fromFields(typeArgs, LiquidityRequest.bcs.parse(data));
533
+ }
534
+ toJSONField() {
535
+ return {
536
+ amount: this.amount.toString(),
537
+ fee: this.fee.toString(),
538
+ };
539
+ }
540
+ toJSON() {
541
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
542
+ }
543
+ static fromJSONField(typeArgs, field) {
544
+ return LiquidityRequest.reified(typeArgs[0], typeArgs[1]).new({
545
+ amount: decodeFromJSONField('u64', field.amount),
546
+ fee: decodeFromJSONField('u64', field.fee),
547
+ });
548
+ }
549
+ static fromJSON(typeArgs, json) {
550
+ if (json.$typeName !== LiquidityRequest.$typeName) {
551
+ throw new Error(`not a LiquidityRequest json object: expected '${LiquidityRequest.$typeName}' but got '${json.$typeName}'`);
552
+ }
553
+ assertReifiedTypeArgsMatch(composeSuiType(LiquidityRequest.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
554
+ return LiquidityRequest.fromJSONField(typeArgs, json);
555
+ }
556
+ static fromCoreObject(typeArgs, obj) {
557
+ if (!isLiquidityRequest(obj.type)) {
558
+ throw new Error(`object at ${obj.objectId} is not a LiquidityRequest object`);
559
+ }
560
+ const gotTypeArgs = parseTypeName(obj.type).typeArgs;
561
+ if (gotTypeArgs.length !== 2) {
562
+ throw new Error(`type argument mismatch: expected 2 type arguments but got '${gotTypeArgs.length}'`);
563
+ }
564
+ for (let i = 0; i < 2; i++) {
565
+ const gotTypeArg = compressSuiType(gotTypeArgs[i]);
566
+ const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
567
+ if (gotTypeArg !== expectedTypeArg) {
568
+ throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
569
+ }
570
+ }
571
+ return LiquidityRequest.fromBcs(typeArgs, obj.content);
572
+ }
573
+ static async fetch(client, typeArgs, id) {
574
+ const { object } = await client.core.getObject({
575
+ objectId: id,
576
+ include: { content: true },
577
+ });
578
+ if (!isLiquidityRequest(object.type)) {
579
+ throw new Error(`object at id ${id} is not a LiquidityRequest object`);
580
+ }
581
+ const gotTypeArgs = parseTypeName(object.type).typeArgs;
582
+ if (gotTypeArgs.length !== 2) {
583
+ throw new Error(`type argument mismatch: expected 2 type arguments but got '${gotTypeArgs.length}'`);
584
+ }
585
+ for (let i = 0; i < 2; i++) {
586
+ const gotTypeArg = compressSuiType(gotTypeArgs[i]);
587
+ const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
588
+ if (gotTypeArg !== expectedTypeArg) {
589
+ throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
590
+ }
591
+ }
592
+ return LiquidityRequest.fromBcs(typeArgs, object.content);
593
+ }
594
+ }
15
595
  /* ============================== BalanceKey =============================== */
16
596
  export function isBalanceKey(type) {
17
597
  type = compressSuiType(type);
18
- return type === `${PKG_V1}::reserve::BalanceKey`;
598
+ return type === `${getTypeOrigin('suilend', 'reserve::BalanceKey')}::reserve::BalanceKey`;
19
599
  }
20
600
  export class BalanceKey {
21
601
  __StructClass = true;
22
- static $typeName = `${PKG_V1}::reserve::BalanceKey`;
602
+ static get $typeName() {
603
+ return `${getTypeOrigin('suilend', 'reserve::BalanceKey')}::reserve::BalanceKey`;
604
+ }
23
605
  static $numTypeParams = 0;
24
606
  static $isPhantom = [];
25
607
  $typeName = BalanceKey.$typeName;
@@ -33,23 +615,29 @@ export class BalanceKey {
33
615
  this.dummyField = fields.dummyField;
34
616
  }
35
617
  static reified() {
618
+ const reifiedBcs = BalanceKey.bcs;
36
619
  return {
37
- typeName: BalanceKey.$typeName,
38
- fullTypeName: composeSuiType(BalanceKey.$typeName, ...[]),
620
+ get typeName() {
621
+ return BalanceKey.$typeName;
622
+ },
623
+ get fullTypeName() {
624
+ return composeSuiType(BalanceKey.$typeName, ...[]);
625
+ },
39
626
  typeArgs: [],
40
627
  isPhantom: BalanceKey.$isPhantom,
41
628
  reifiedTypeArgs: [],
42
629
  fromFields: (fields) => BalanceKey.fromFields(fields),
43
630
  fromFieldsWithTypes: (item) => BalanceKey.fromFieldsWithTypes(item),
44
- fromBcs: (data) => BalanceKey.fromBcs(data),
45
- bcs: BalanceKey.bcs,
631
+ fromBcs: (data) => BalanceKey.fromFields(reifiedBcs.parse(data)),
632
+ bcs: reifiedBcs,
46
633
  fromJSONField: (field) => BalanceKey.fromJSONField(field),
47
634
  fromJSON: (json) => BalanceKey.fromJSON(json),
635
+ fromCoreObject: (obj) => BalanceKey.fromCoreObject(obj),
48
636
  fetch: async (client, id) => BalanceKey.fetch(client, id),
49
637
  new: (fields) => {
50
638
  return new BalanceKey([], fields);
51
639
  },
52
- kind: "StructClassReified",
640
+ kind: 'StructClassReified',
53
641
  };
54
642
  }
55
643
  static get r() {
@@ -61,22 +649,29 @@ export class BalanceKey {
61
649
  static get p() {
62
650
  return BalanceKey.phantom();
63
651
  }
64
- static get bcs() {
65
- return bcs.struct("BalanceKey", {
652
+ static instantiateBcs() {
653
+ return bcs.struct('BalanceKey', {
66
654
  dummy_field: bcs.bool(),
67
655
  });
68
656
  }
657
+ static cachedBcs = null;
658
+ static get bcs() {
659
+ if (!BalanceKey.cachedBcs) {
660
+ BalanceKey.cachedBcs = BalanceKey.instantiateBcs();
661
+ }
662
+ return BalanceKey.cachedBcs;
663
+ }
69
664
  static fromFields(fields) {
70
665
  return BalanceKey.reified().new({
71
- dummyField: decodeFromFields("bool", fields.dummy_field),
666
+ dummyField: decodeFromFields('bool', fields.dummy_field),
72
667
  });
73
668
  }
74
669
  static fromFieldsWithTypes(item) {
75
670
  if (!isBalanceKey(item.type)) {
76
- throw new Error("not a BalanceKey type");
671
+ throw new Error('not a BalanceKey type');
77
672
  }
78
673
  return BalanceKey.reified().new({
79
- dummyField: decodeFromFieldsWithTypes("bool", item.fields.dummy_field),
674
+ dummyField: decodeFromFieldsWithTypes('bool', item.fields.dummy_field),
80
675
  });
81
676
  }
82
677
  static fromBcs(data) {
@@ -88,232 +683,363 @@ export class BalanceKey {
88
683
  };
89
684
  }
90
685
  toJSON() {
91
- return {
92
- $typeName: this.$typeName,
93
- $typeArgs: this.$typeArgs,
94
- ...this.toJSONField(),
95
- };
686
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
96
687
  }
97
688
  static fromJSONField(field) {
98
689
  return BalanceKey.reified().new({
99
- dummyField: decodeFromJSONField("bool", field.dummyField),
690
+ dummyField: decodeFromJSONField('bool', field.dummyField),
100
691
  });
101
692
  }
102
693
  static fromJSON(json) {
103
694
  if (json.$typeName !== BalanceKey.$typeName) {
104
- throw new Error("not a WithTwoGenerics json object");
695
+ throw new Error(`not a BalanceKey json object: expected '${BalanceKey.$typeName}' but got '${json.$typeName}'`);
105
696
  }
106
697
  return BalanceKey.fromJSONField(json);
107
698
  }
699
+ static fromCoreObject(obj) {
700
+ if (!isBalanceKey(obj.type)) {
701
+ throw new Error(`object at ${obj.objectId} is not a BalanceKey object`);
702
+ }
703
+ return BalanceKey.fromBcs(obj.content);
704
+ }
108
705
  static async fetch(client, id) {
109
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
706
+ const { object } = await client.core.getObject({
707
+ objectId: id,
708
+ include: { content: true },
709
+ });
110
710
  if (!isBalanceKey(object.type)) {
111
711
  throw new Error(`object at id ${id} is not a BalanceKey object`);
112
712
  }
113
713
  return BalanceKey.fromBcs(object.content);
114
714
  }
115
715
  }
116
- /* ============================== Balances =============================== */
117
- export function isBalances(type) {
716
+ /* ============================== StakerKey =============================== */
717
+ export function isStakerKey(type) {
118
718
  type = compressSuiType(type);
119
- return type.startsWith(`${PKG_V1}::reserve::Balances` + "<");
719
+ return type === `${getTypeOrigin('suilend', 'reserve::StakerKey')}::reserve::StakerKey`;
120
720
  }
121
- export class Balances {
721
+ export class StakerKey {
122
722
  __StructClass = true;
123
- static $typeName = `${PKG_V1}::reserve::Balances`;
124
- static $numTypeParams = 2;
125
- static $isPhantom = [true, true];
126
- $typeName = Balances.$typeName;
723
+ static get $typeName() {
724
+ return `${getTypeOrigin('suilend', 'reserve::StakerKey')}::reserve::StakerKey`;
725
+ }
726
+ static $numTypeParams = 0;
727
+ static $isPhantom = [];
728
+ $typeName = StakerKey.$typeName;
127
729
  $fullTypeName;
128
730
  $typeArgs;
129
- $isPhantom = Balances.$isPhantom;
130
- availableAmount;
131
- ctokenSupply;
132
- fees;
133
- ctokenFees;
134
- depositedCtokens;
731
+ $isPhantom = StakerKey.$isPhantom;
732
+ dummyField;
135
733
  constructor(typeArgs, fields) {
136
- this.$fullTypeName = composeSuiType(Balances.$typeName, ...typeArgs);
734
+ this.$fullTypeName = composeSuiType(StakerKey.$typeName, ...typeArgs);
137
735
  this.$typeArgs = typeArgs;
138
- this.availableAmount = fields.availableAmount;
139
- this.ctokenSupply = fields.ctokenSupply;
140
- this.fees = fields.fees;
141
- this.ctokenFees = fields.ctokenFees;
142
- this.depositedCtokens = fields.depositedCtokens;
736
+ this.dummyField = fields.dummyField;
143
737
  }
144
- static reified(P, T) {
738
+ static reified() {
739
+ const reifiedBcs = StakerKey.bcs;
145
740
  return {
146
- typeName: Balances.$typeName,
147
- fullTypeName: composeSuiType(Balances.$typeName, ...[extractType(P), extractType(T)]),
148
- typeArgs: [extractType(P), extractType(T)],
149
- isPhantom: Balances.$isPhantom,
150
- reifiedTypeArgs: [P, T],
151
- fromFields: (fields) => Balances.fromFields([P, T], fields),
152
- fromFieldsWithTypes: (item) => Balances.fromFieldsWithTypes([P, T], item),
153
- fromBcs: (data) => Balances.fromBcs([P, T], data),
154
- bcs: Balances.bcs,
155
- fromJSONField: (field) => Balances.fromJSONField([P, T], field),
156
- fromJSON: (json) => Balances.fromJSON([P, T], json),
157
- fetch: async (client, id) => Balances.fetch(client, [P, T], id),
741
+ get typeName() {
742
+ return StakerKey.$typeName;
743
+ },
744
+ get fullTypeName() {
745
+ return composeSuiType(StakerKey.$typeName, ...[]);
746
+ },
747
+ typeArgs: [],
748
+ isPhantom: StakerKey.$isPhantom,
749
+ reifiedTypeArgs: [],
750
+ fromFields: (fields) => StakerKey.fromFields(fields),
751
+ fromFieldsWithTypes: (item) => StakerKey.fromFieldsWithTypes(item),
752
+ fromBcs: (data) => StakerKey.fromFields(reifiedBcs.parse(data)),
753
+ bcs: reifiedBcs,
754
+ fromJSONField: (field) => StakerKey.fromJSONField(field),
755
+ fromJSON: (json) => StakerKey.fromJSON(json),
756
+ fromCoreObject: (obj) => StakerKey.fromCoreObject(obj),
757
+ fetch: async (client, id) => StakerKey.fetch(client, id),
158
758
  new: (fields) => {
159
- return new Balances([extractType(P), extractType(T)], fields);
759
+ return new StakerKey([], fields);
160
760
  },
161
- kind: "StructClassReified",
761
+ kind: 'StructClassReified',
162
762
  };
163
763
  }
164
764
  static get r() {
165
- return Balances.reified;
765
+ return StakerKey.reified();
766
+ }
767
+ static phantom() {
768
+ return phantom(StakerKey.reified());
769
+ }
770
+ static get p() {
771
+ return StakerKey.phantom();
772
+ }
773
+ static instantiateBcs() {
774
+ return bcs.struct('StakerKey', {
775
+ dummy_field: bcs.bool(),
776
+ });
777
+ }
778
+ static cachedBcs = null;
779
+ static get bcs() {
780
+ if (!StakerKey.cachedBcs) {
781
+ StakerKey.cachedBcs = StakerKey.instantiateBcs();
782
+ }
783
+ return StakerKey.cachedBcs;
784
+ }
785
+ static fromFields(fields) {
786
+ return StakerKey.reified().new({
787
+ dummyField: decodeFromFields('bool', fields.dummy_field),
788
+ });
789
+ }
790
+ static fromFieldsWithTypes(item) {
791
+ if (!isStakerKey(item.type)) {
792
+ throw new Error('not a StakerKey type');
793
+ }
794
+ return StakerKey.reified().new({
795
+ dummyField: decodeFromFieldsWithTypes('bool', item.fields.dummy_field),
796
+ });
797
+ }
798
+ static fromBcs(data) {
799
+ return StakerKey.fromFields(StakerKey.bcs.parse(data));
800
+ }
801
+ toJSONField() {
802
+ return {
803
+ dummyField: this.dummyField,
804
+ };
805
+ }
806
+ toJSON() {
807
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
808
+ }
809
+ static fromJSONField(field) {
810
+ return StakerKey.reified().new({
811
+ dummyField: decodeFromJSONField('bool', field.dummyField),
812
+ });
813
+ }
814
+ static fromJSON(json) {
815
+ if (json.$typeName !== StakerKey.$typeName) {
816
+ throw new Error(`not a StakerKey json object: expected '${StakerKey.$typeName}' but got '${json.$typeName}'`);
817
+ }
818
+ return StakerKey.fromJSONField(json);
819
+ }
820
+ static fromCoreObject(obj) {
821
+ if (!isStakerKey(obj.type)) {
822
+ throw new Error(`object at ${obj.objectId} is not a StakerKey object`);
823
+ }
824
+ return StakerKey.fromBcs(obj.content);
825
+ }
826
+ static async fetch(client, id) {
827
+ const { object } = await client.core.getObject({
828
+ objectId: id,
829
+ include: { content: true },
830
+ });
831
+ if (!isStakerKey(object.type)) {
832
+ throw new Error(`object at id ${id} is not a StakerKey object`);
833
+ }
834
+ return StakerKey.fromBcs(object.content);
835
+ }
836
+ }
837
+ /* ============================== ReservePauseKey =============================== */
838
+ export function isReservePauseKey(type) {
839
+ type = compressSuiType(type);
840
+ return type
841
+ === `${getTypeOrigin('suilend', 'reserve::ReservePauseKey')}::reserve::ReservePauseKey`;
842
+ }
843
+ export class ReservePauseKey {
844
+ __StructClass = true;
845
+ static get $typeName() {
846
+ return `${getTypeOrigin('suilend', 'reserve::ReservePauseKey')}::reserve::ReservePauseKey`;
847
+ }
848
+ static $numTypeParams = 0;
849
+ static $isPhantom = [];
850
+ $typeName = ReservePauseKey.$typeName;
851
+ $fullTypeName;
852
+ $typeArgs;
853
+ $isPhantom = ReservePauseKey.$isPhantom;
854
+ dummyField;
855
+ constructor(typeArgs, fields) {
856
+ this.$fullTypeName = composeSuiType(ReservePauseKey.$typeName, ...typeArgs);
857
+ this.$typeArgs = typeArgs;
858
+ this.dummyField = fields.dummyField;
859
+ }
860
+ static reified() {
861
+ const reifiedBcs = ReservePauseKey.bcs;
862
+ return {
863
+ get typeName() {
864
+ return ReservePauseKey.$typeName;
865
+ },
866
+ get fullTypeName() {
867
+ return composeSuiType(ReservePauseKey.$typeName, ...[]);
868
+ },
869
+ typeArgs: [],
870
+ isPhantom: ReservePauseKey.$isPhantom,
871
+ reifiedTypeArgs: [],
872
+ fromFields: (fields) => ReservePauseKey.fromFields(fields),
873
+ fromFieldsWithTypes: (item) => ReservePauseKey.fromFieldsWithTypes(item),
874
+ fromBcs: (data) => ReservePauseKey.fromFields(reifiedBcs.parse(data)),
875
+ bcs: reifiedBcs,
876
+ fromJSONField: (field) => ReservePauseKey.fromJSONField(field),
877
+ fromJSON: (json) => ReservePauseKey.fromJSON(json),
878
+ fromCoreObject: (obj) => ReservePauseKey.fromCoreObject(obj),
879
+ fetch: async (client, id) => ReservePauseKey.fetch(client, id),
880
+ new: (fields) => {
881
+ return new ReservePauseKey([], fields);
882
+ },
883
+ kind: 'StructClassReified',
884
+ };
885
+ }
886
+ static get r() {
887
+ return ReservePauseKey.reified();
166
888
  }
167
- static phantom(P, T) {
168
- return phantom(Balances.reified(P, T));
889
+ static phantom() {
890
+ return phantom(ReservePauseKey.reified());
169
891
  }
170
892
  static get p() {
171
- return Balances.phantom;
893
+ return ReservePauseKey.phantom();
172
894
  }
173
- static get bcs() {
174
- return bcs.struct("Balances", {
175
- available_amount: Balance.bcs,
176
- ctoken_supply: Supply.bcs,
177
- fees: Balance.bcs,
178
- ctoken_fees: Balance.bcs,
179
- deposited_ctokens: Balance.bcs,
895
+ static instantiateBcs() {
896
+ return bcs.struct('ReservePauseKey', {
897
+ dummy_field: bcs.bool(),
180
898
  });
181
899
  }
182
- static fromFields(typeArgs, fields) {
183
- return Balances.reified(typeArgs[0], typeArgs[1]).new({
184
- availableAmount: decodeFromFields(Balance.reified(typeArgs[1]), fields.available_amount),
185
- ctokenSupply: decodeFromFields(Supply.reified(reified.phantom(CToken.reified(typeArgs[0], typeArgs[1]))), fields.ctoken_supply),
186
- fees: decodeFromFields(Balance.reified(typeArgs[1]), fields.fees),
187
- ctokenFees: decodeFromFields(Balance.reified(reified.phantom(CToken.reified(typeArgs[0], typeArgs[1]))), fields.ctoken_fees),
188
- depositedCtokens: decodeFromFields(Balance.reified(reified.phantom(CToken.reified(typeArgs[0], typeArgs[1]))), fields.deposited_ctokens),
900
+ static cachedBcs = null;
901
+ static get bcs() {
902
+ if (!ReservePauseKey.cachedBcs) {
903
+ ReservePauseKey.cachedBcs = ReservePauseKey.instantiateBcs();
904
+ }
905
+ return ReservePauseKey.cachedBcs;
906
+ }
907
+ static fromFields(fields) {
908
+ return ReservePauseKey.reified().new({
909
+ dummyField: decodeFromFields('bool', fields.dummy_field),
189
910
  });
190
911
  }
191
- static fromFieldsWithTypes(typeArgs, item) {
192
- if (!isBalances(item.type)) {
193
- throw new Error("not a Balances type");
912
+ static fromFieldsWithTypes(item) {
913
+ if (!isReservePauseKey(item.type)) {
914
+ throw new Error('not a ReservePauseKey type');
194
915
  }
195
- assertFieldsWithTypesArgsMatch(item, typeArgs);
196
- return Balances.reified(typeArgs[0], typeArgs[1]).new({
197
- availableAmount: decodeFromFieldsWithTypes(Balance.reified(typeArgs[1]), item.fields.available_amount),
198
- ctokenSupply: decodeFromFieldsWithTypes(Supply.reified(reified.phantom(CToken.reified(typeArgs[0], typeArgs[1]))), item.fields.ctoken_supply),
199
- fees: decodeFromFieldsWithTypes(Balance.reified(typeArgs[1]), item.fields.fees),
200
- ctokenFees: decodeFromFieldsWithTypes(Balance.reified(reified.phantom(CToken.reified(typeArgs[0], typeArgs[1]))), item.fields.ctoken_fees),
201
- depositedCtokens: decodeFromFieldsWithTypes(Balance.reified(reified.phantom(CToken.reified(typeArgs[0], typeArgs[1]))), item.fields.deposited_ctokens),
916
+ return ReservePauseKey.reified().new({
917
+ dummyField: decodeFromFieldsWithTypes('bool', item.fields.dummy_field),
202
918
  });
203
919
  }
204
- static fromBcs(typeArgs, data) {
205
- return Balances.fromFields(typeArgs, Balances.bcs.parse(data));
920
+ static fromBcs(data) {
921
+ return ReservePauseKey.fromFields(ReservePauseKey.bcs.parse(data));
206
922
  }
207
923
  toJSONField() {
208
924
  return {
209
- availableAmount: this.availableAmount.toJSONField(),
210
- ctokenSupply: this.ctokenSupply.toJSONField(),
211
- fees: this.fees.toJSONField(),
212
- ctokenFees: this.ctokenFees.toJSONField(),
213
- depositedCtokens: this.depositedCtokens.toJSONField(),
925
+ dummyField: this.dummyField,
214
926
  };
215
927
  }
216
928
  toJSON() {
217
- return {
218
- $typeName: this.$typeName,
219
- $typeArgs: this.$typeArgs,
220
- ...this.toJSONField(),
221
- };
929
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
222
930
  }
223
- static fromJSONField(typeArgs, field) {
224
- return Balances.reified(typeArgs[0], typeArgs[1]).new({
225
- availableAmount: decodeFromJSONField(Balance.reified(typeArgs[1]), field.availableAmount),
226
- ctokenSupply: decodeFromJSONField(Supply.reified(reified.phantom(CToken.reified(typeArgs[0], typeArgs[1]))), field.ctokenSupply),
227
- fees: decodeFromJSONField(Balance.reified(typeArgs[1]), field.fees),
228
- ctokenFees: decodeFromJSONField(Balance.reified(reified.phantom(CToken.reified(typeArgs[0], typeArgs[1]))), field.ctokenFees),
229
- depositedCtokens: decodeFromJSONField(Balance.reified(reified.phantom(CToken.reified(typeArgs[0], typeArgs[1]))), field.depositedCtokens),
931
+ static fromJSONField(field) {
932
+ return ReservePauseKey.reified().new({
933
+ dummyField: decodeFromJSONField('bool', field.dummyField),
230
934
  });
231
935
  }
232
- static fromJSON(typeArgs, json) {
233
- if (json.$typeName !== Balances.$typeName) {
234
- throw new Error("not a WithTwoGenerics json object");
936
+ static fromJSON(json) {
937
+ if (json.$typeName !== ReservePauseKey.$typeName) {
938
+ throw new Error(`not a ReservePauseKey json object: expected '${ReservePauseKey.$typeName}' but got '${json.$typeName}'`);
235
939
  }
236
- assertReifiedTypeArgsMatch(composeSuiType(Balances.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
237
- return Balances.fromJSONField(typeArgs, json);
940
+ return ReservePauseKey.fromJSONField(json);
238
941
  }
239
- static async fetch(client, typeArgs, id) {
240
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
241
- if (!isBalances(object.type)) {
242
- throw new Error(`object at id ${id} is not a Balances object`);
942
+ static fromCoreObject(obj) {
943
+ if (!isReservePauseKey(obj.type)) {
944
+ throw new Error(`object at ${obj.objectId} is not a ReservePauseKey object`);
243
945
  }
244
- return Balances.fromBcs(typeArgs, object.content);
946
+ return ReservePauseKey.fromBcs(obj.content);
947
+ }
948
+ static async fetch(client, id) {
949
+ const { object } = await client.core.getObject({
950
+ objectId: id,
951
+ include: { content: true },
952
+ });
953
+ if (!isReservePauseKey(object.type)) {
954
+ throw new Error(`object at id ${id} is not a ReservePauseKey object`);
955
+ }
956
+ return ReservePauseKey.fromBcs(object.content);
245
957
  }
246
958
  }
247
- /* ============================== CToken =============================== */
248
- export function isCToken(type) {
959
+ /* ============================== PriceGuardKey =============================== */
960
+ export function isPriceGuardKey(type) {
249
961
  type = compressSuiType(type);
250
- return type.startsWith(`${PKG_V1}::reserve::CToken` + "<");
962
+ return type === `${getTypeOrigin('suilend', 'reserve::PriceGuardKey')}::reserve::PriceGuardKey`;
251
963
  }
252
- export class CToken {
964
+ export class PriceGuardKey {
253
965
  __StructClass = true;
254
- static $typeName = `${PKG_V1}::reserve::CToken`;
255
- static $numTypeParams = 2;
256
- static $isPhantom = [true, true];
257
- $typeName = CToken.$typeName;
966
+ static get $typeName() {
967
+ return `${getTypeOrigin('suilend', 'reserve::PriceGuardKey')}::reserve::PriceGuardKey`;
968
+ }
969
+ static $numTypeParams = 0;
970
+ static $isPhantom = [];
971
+ $typeName = PriceGuardKey.$typeName;
258
972
  $fullTypeName;
259
973
  $typeArgs;
260
- $isPhantom = CToken.$isPhantom;
974
+ $isPhantom = PriceGuardKey.$isPhantom;
261
975
  dummyField;
262
976
  constructor(typeArgs, fields) {
263
- this.$fullTypeName = composeSuiType(CToken.$typeName, ...typeArgs);
977
+ this.$fullTypeName = composeSuiType(PriceGuardKey.$typeName, ...typeArgs);
264
978
  this.$typeArgs = typeArgs;
265
979
  this.dummyField = fields.dummyField;
266
980
  }
267
- static reified(P, T) {
981
+ static reified() {
982
+ const reifiedBcs = PriceGuardKey.bcs;
268
983
  return {
269
- typeName: CToken.$typeName,
270
- fullTypeName: composeSuiType(CToken.$typeName, ...[extractType(P), extractType(T)]),
271
- typeArgs: [extractType(P), extractType(T)],
272
- isPhantom: CToken.$isPhantom,
273
- reifiedTypeArgs: [P, T],
274
- fromFields: (fields) => CToken.fromFields([P, T], fields),
275
- fromFieldsWithTypes: (item) => CToken.fromFieldsWithTypes([P, T], item),
276
- fromBcs: (data) => CToken.fromBcs([P, T], data),
277
- bcs: CToken.bcs,
278
- fromJSONField: (field) => CToken.fromJSONField([P, T], field),
279
- fromJSON: (json) => CToken.fromJSON([P, T], json),
280
- fetch: async (client, id) => CToken.fetch(client, [P, T], id),
984
+ get typeName() {
985
+ return PriceGuardKey.$typeName;
986
+ },
987
+ get fullTypeName() {
988
+ return composeSuiType(PriceGuardKey.$typeName, ...[]);
989
+ },
990
+ typeArgs: [],
991
+ isPhantom: PriceGuardKey.$isPhantom,
992
+ reifiedTypeArgs: [],
993
+ fromFields: (fields) => PriceGuardKey.fromFields(fields),
994
+ fromFieldsWithTypes: (item) => PriceGuardKey.fromFieldsWithTypes(item),
995
+ fromBcs: (data) => PriceGuardKey.fromFields(reifiedBcs.parse(data)),
996
+ bcs: reifiedBcs,
997
+ fromJSONField: (field) => PriceGuardKey.fromJSONField(field),
998
+ fromJSON: (json) => PriceGuardKey.fromJSON(json),
999
+ fromCoreObject: (obj) => PriceGuardKey.fromCoreObject(obj),
1000
+ fetch: async (client, id) => PriceGuardKey.fetch(client, id),
281
1001
  new: (fields) => {
282
- return new CToken([extractType(P), extractType(T)], fields);
1002
+ return new PriceGuardKey([], fields);
283
1003
  },
284
- kind: "StructClassReified",
1004
+ kind: 'StructClassReified',
285
1005
  };
286
1006
  }
287
1007
  static get r() {
288
- return CToken.reified;
1008
+ return PriceGuardKey.reified();
289
1009
  }
290
- static phantom(P, T) {
291
- return phantom(CToken.reified(P, T));
1010
+ static phantom() {
1011
+ return phantom(PriceGuardKey.reified());
292
1012
  }
293
1013
  static get p() {
294
- return CToken.phantom;
1014
+ return PriceGuardKey.phantom();
295
1015
  }
296
- static get bcs() {
297
- return bcs.struct("CToken", {
1016
+ static instantiateBcs() {
1017
+ return bcs.struct('PriceGuardKey', {
298
1018
  dummy_field: bcs.bool(),
299
1019
  });
300
1020
  }
301
- static fromFields(typeArgs, fields) {
302
- return CToken.reified(typeArgs[0], typeArgs[1]).new({
303
- dummyField: decodeFromFields("bool", fields.dummy_field),
1021
+ static cachedBcs = null;
1022
+ static get bcs() {
1023
+ if (!PriceGuardKey.cachedBcs) {
1024
+ PriceGuardKey.cachedBcs = PriceGuardKey.instantiateBcs();
1025
+ }
1026
+ return PriceGuardKey.cachedBcs;
1027
+ }
1028
+ static fromFields(fields) {
1029
+ return PriceGuardKey.reified().new({
1030
+ dummyField: decodeFromFields('bool', fields.dummy_field),
304
1031
  });
305
1032
  }
306
- static fromFieldsWithTypes(typeArgs, item) {
307
- if (!isCToken(item.type)) {
308
- throw new Error("not a CToken type");
1033
+ static fromFieldsWithTypes(item) {
1034
+ if (!isPriceGuardKey(item.type)) {
1035
+ throw new Error('not a PriceGuardKey type');
309
1036
  }
310
- assertFieldsWithTypesArgsMatch(item, typeArgs);
311
- return CToken.reified(typeArgs[0], typeArgs[1]).new({
312
- dummyField: decodeFromFieldsWithTypes("bool", item.fields.dummy_field),
1037
+ return PriceGuardKey.reified().new({
1038
+ dummyField: decodeFromFieldsWithTypes('bool', item.fields.dummy_field),
313
1039
  });
314
1040
  }
315
- static fromBcs(typeArgs, data) {
316
- return CToken.fromFields(typeArgs, CToken.bcs.parse(data));
1041
+ static fromBcs(data) {
1042
+ return PriceGuardKey.fromFields(PriceGuardKey.bcs.parse(data));
317
1043
  }
318
1044
  toJSONField() {
319
1045
  return {
@@ -321,714 +1047,718 @@ export class CToken {
321
1047
  };
322
1048
  }
323
1049
  toJSON() {
324
- return {
325
- $typeName: this.$typeName,
326
- $typeArgs: this.$typeArgs,
327
- ...this.toJSONField(),
328
- };
1050
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
329
1051
  }
330
- static fromJSONField(typeArgs, field) {
331
- return CToken.reified(typeArgs[0], typeArgs[1]).new({
332
- dummyField: decodeFromJSONField("bool", field.dummyField),
1052
+ static fromJSONField(field) {
1053
+ return PriceGuardKey.reified().new({
1054
+ dummyField: decodeFromJSONField('bool', field.dummyField),
333
1055
  });
334
1056
  }
335
- static fromJSON(typeArgs, json) {
336
- if (json.$typeName !== CToken.$typeName) {
337
- throw new Error("not a WithTwoGenerics json object");
1057
+ static fromJSON(json) {
1058
+ if (json.$typeName !== PriceGuardKey.$typeName) {
1059
+ throw new Error(`not a PriceGuardKey json object: expected '${PriceGuardKey.$typeName}' but got '${json.$typeName}'`);
338
1060
  }
339
- assertReifiedTypeArgsMatch(composeSuiType(CToken.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
340
- return CToken.fromJSONField(typeArgs, json);
1061
+ return PriceGuardKey.fromJSONField(json);
341
1062
  }
342
- static async fetch(client, typeArgs, id) {
343
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
344
- if (!isCToken(object.type)) {
345
- throw new Error(`object at id ${id} is not a CToken object`);
1063
+ static fromCoreObject(obj) {
1064
+ if (!isPriceGuardKey(obj.type)) {
1065
+ throw new Error(`object at ${obj.objectId} is not a PriceGuardKey object`);
346
1066
  }
347
- return CToken.fromBcs(typeArgs, object.content);
1067
+ return PriceGuardKey.fromBcs(obj.content);
1068
+ }
1069
+ static async fetch(client, id) {
1070
+ const { object } = await client.core.getObject({
1071
+ objectId: id,
1072
+ include: { content: true },
1073
+ });
1074
+ if (!isPriceGuardKey(object.type)) {
1075
+ throw new Error(`object at id ${id} is not a PriceGuardKey object`);
1076
+ }
1077
+ return PriceGuardKey.fromBcs(object.content);
348
1078
  }
349
1079
  }
350
- /* ============================== ClaimStakingRewardsEvent =============================== */
351
- export function isClaimStakingRewardsEvent(type) {
1080
+ /* ============================== ConfidenceKey =============================== */
1081
+ export function isConfidenceKey(type) {
352
1082
  type = compressSuiType(type);
353
- return type === `${PKG_V8}::reserve::ClaimStakingRewardsEvent`;
1083
+ return type === `${getTypeOrigin('suilend', 'reserve::ConfidenceKey')}::reserve::ConfidenceKey`;
354
1084
  }
355
- export class ClaimStakingRewardsEvent {
1085
+ export class ConfidenceKey {
356
1086
  __StructClass = true;
357
- static $typeName = `${PKG_V8}::reserve::ClaimStakingRewardsEvent`;
1087
+ static get $typeName() {
1088
+ return `${getTypeOrigin('suilend', 'reserve::ConfidenceKey')}::reserve::ConfidenceKey`;
1089
+ }
358
1090
  static $numTypeParams = 0;
359
1091
  static $isPhantom = [];
360
- $typeName = ClaimStakingRewardsEvent.$typeName;
1092
+ $typeName = ConfidenceKey.$typeName;
361
1093
  $fullTypeName;
362
1094
  $typeArgs;
363
- $isPhantom = ClaimStakingRewardsEvent.$isPhantom;
364
- lendingMarketId;
365
- coinType;
366
- reserveId;
367
- amount;
1095
+ $isPhantom = ConfidenceKey.$isPhantom;
1096
+ dummyField;
368
1097
  constructor(typeArgs, fields) {
369
- this.$fullTypeName = composeSuiType(ClaimStakingRewardsEvent.$typeName, ...typeArgs);
1098
+ this.$fullTypeName = composeSuiType(ConfidenceKey.$typeName, ...typeArgs);
370
1099
  this.$typeArgs = typeArgs;
371
- this.lendingMarketId = fields.lendingMarketId;
372
- this.coinType = fields.coinType;
373
- this.reserveId = fields.reserveId;
374
- this.amount = fields.amount;
1100
+ this.dummyField = fields.dummyField;
375
1101
  }
376
1102
  static reified() {
1103
+ const reifiedBcs = ConfidenceKey.bcs;
377
1104
  return {
378
- typeName: ClaimStakingRewardsEvent.$typeName,
379
- fullTypeName: composeSuiType(ClaimStakingRewardsEvent.$typeName, ...[]),
1105
+ get typeName() {
1106
+ return ConfidenceKey.$typeName;
1107
+ },
1108
+ get fullTypeName() {
1109
+ return composeSuiType(ConfidenceKey.$typeName, ...[]);
1110
+ },
380
1111
  typeArgs: [],
381
- isPhantom: ClaimStakingRewardsEvent.$isPhantom,
1112
+ isPhantom: ConfidenceKey.$isPhantom,
382
1113
  reifiedTypeArgs: [],
383
- fromFields: (fields) => ClaimStakingRewardsEvent.fromFields(fields),
384
- fromFieldsWithTypes: (item) => ClaimStakingRewardsEvent.fromFieldsWithTypes(item),
385
- fromBcs: (data) => ClaimStakingRewardsEvent.fromBcs(data),
386
- bcs: ClaimStakingRewardsEvent.bcs,
387
- fromJSONField: (field) => ClaimStakingRewardsEvent.fromJSONField(field),
388
- fromJSON: (json) => ClaimStakingRewardsEvent.fromJSON(json),
389
- fetch: async (client, id) => ClaimStakingRewardsEvent.fetch(client, id),
1114
+ fromFields: (fields) => ConfidenceKey.fromFields(fields),
1115
+ fromFieldsWithTypes: (item) => ConfidenceKey.fromFieldsWithTypes(item),
1116
+ fromBcs: (data) => ConfidenceKey.fromFields(reifiedBcs.parse(data)),
1117
+ bcs: reifiedBcs,
1118
+ fromJSONField: (field) => ConfidenceKey.fromJSONField(field),
1119
+ fromJSON: (json) => ConfidenceKey.fromJSON(json),
1120
+ fromCoreObject: (obj) => ConfidenceKey.fromCoreObject(obj),
1121
+ fetch: async (client, id) => ConfidenceKey.fetch(client, id),
390
1122
  new: (fields) => {
391
- return new ClaimStakingRewardsEvent([], fields);
1123
+ return new ConfidenceKey([], fields);
392
1124
  },
393
- kind: "StructClassReified",
1125
+ kind: 'StructClassReified',
394
1126
  };
395
1127
  }
396
1128
  static get r() {
397
- return ClaimStakingRewardsEvent.reified();
1129
+ return ConfidenceKey.reified();
398
1130
  }
399
1131
  static phantom() {
400
- return phantom(ClaimStakingRewardsEvent.reified());
1132
+ return phantom(ConfidenceKey.reified());
401
1133
  }
402
1134
  static get p() {
403
- return ClaimStakingRewardsEvent.phantom();
1135
+ return ConfidenceKey.phantom();
404
1136
  }
405
- static get bcs() {
406
- return bcs.struct("ClaimStakingRewardsEvent", {
407
- lending_market_id: bcs
408
- .bytes(32)
409
- .transform({
410
- input: (val) => fromHex(val),
411
- output: (val) => toHex(val),
412
- }),
413
- coin_type: TypeName.bcs,
414
- reserve_id: bcs
415
- .bytes(32)
416
- .transform({
417
- input: (val) => fromHex(val),
418
- output: (val) => toHex(val),
419
- }),
420
- amount: bcs.u64(),
1137
+ static instantiateBcs() {
1138
+ return bcs.struct('ConfidenceKey', {
1139
+ dummy_field: bcs.bool(),
421
1140
  });
422
1141
  }
1142
+ static cachedBcs = null;
1143
+ static get bcs() {
1144
+ if (!ConfidenceKey.cachedBcs) {
1145
+ ConfidenceKey.cachedBcs = ConfidenceKey.instantiateBcs();
1146
+ }
1147
+ return ConfidenceKey.cachedBcs;
1148
+ }
423
1149
  static fromFields(fields) {
424
- return ClaimStakingRewardsEvent.reified().new({
425
- lendingMarketId: decodeFromFields("address", fields.lending_market_id),
426
- coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
427
- reserveId: decodeFromFields("address", fields.reserve_id),
428
- amount: decodeFromFields("u64", fields.amount),
1150
+ return ConfidenceKey.reified().new({
1151
+ dummyField: decodeFromFields('bool', fields.dummy_field),
429
1152
  });
430
1153
  }
431
1154
  static fromFieldsWithTypes(item) {
432
- if (!isClaimStakingRewardsEvent(item.type)) {
433
- throw new Error("not a ClaimStakingRewardsEvent type");
1155
+ if (!isConfidenceKey(item.type)) {
1156
+ throw new Error('not a ConfidenceKey type');
434
1157
  }
435
- return ClaimStakingRewardsEvent.reified().new({
436
- lendingMarketId: decodeFromFieldsWithTypes("address", item.fields.lending_market_id),
437
- coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
438
- reserveId: decodeFromFieldsWithTypes("address", item.fields.reserve_id),
439
- amount: decodeFromFieldsWithTypes("u64", item.fields.amount),
1158
+ return ConfidenceKey.reified().new({
1159
+ dummyField: decodeFromFieldsWithTypes('bool', item.fields.dummy_field),
440
1160
  });
441
1161
  }
442
1162
  static fromBcs(data) {
443
- return ClaimStakingRewardsEvent.fromFields(ClaimStakingRewardsEvent.bcs.parse(data));
1163
+ return ConfidenceKey.fromFields(ConfidenceKey.bcs.parse(data));
444
1164
  }
445
1165
  toJSONField() {
446
1166
  return {
447
- lendingMarketId: this.lendingMarketId,
448
- coinType: this.coinType.toJSONField(),
449
- reserveId: this.reserveId,
450
- amount: this.amount.toString(),
1167
+ dummyField: this.dummyField,
451
1168
  };
452
1169
  }
453
1170
  toJSON() {
454
- return {
455
- $typeName: this.$typeName,
456
- $typeArgs: this.$typeArgs,
457
- ...this.toJSONField(),
458
- };
1171
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
459
1172
  }
460
1173
  static fromJSONField(field) {
461
- return ClaimStakingRewardsEvent.reified().new({
462
- lendingMarketId: decodeFromJSONField("address", field.lendingMarketId),
463
- coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
464
- reserveId: decodeFromJSONField("address", field.reserveId),
465
- amount: decodeFromJSONField("u64", field.amount),
1174
+ return ConfidenceKey.reified().new({
1175
+ dummyField: decodeFromJSONField('bool', field.dummyField),
466
1176
  });
467
1177
  }
468
1178
  static fromJSON(json) {
469
- if (json.$typeName !== ClaimStakingRewardsEvent.$typeName) {
470
- throw new Error("not a WithTwoGenerics json object");
1179
+ if (json.$typeName !== ConfidenceKey.$typeName) {
1180
+ throw new Error(`not a ConfidenceKey json object: expected '${ConfidenceKey.$typeName}' but got '${json.$typeName}'`);
471
1181
  }
472
- return ClaimStakingRewardsEvent.fromJSONField(json);
1182
+ return ConfidenceKey.fromJSONField(json);
1183
+ }
1184
+ static fromCoreObject(obj) {
1185
+ if (!isConfidenceKey(obj.type)) {
1186
+ throw new Error(`object at ${obj.objectId} is not a ConfidenceKey object`);
1187
+ }
1188
+ return ConfidenceKey.fromBcs(obj.content);
473
1189
  }
474
1190
  static async fetch(client, id) {
475
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
476
- if (!isClaimStakingRewardsEvent(object.type)) {
477
- throw new Error(`object at id ${id} is not a ClaimStakingRewardsEvent object`);
1191
+ const { object } = await client.core.getObject({
1192
+ objectId: id,
1193
+ include: { content: true },
1194
+ });
1195
+ if (!isConfidenceKey(object.type)) {
1196
+ throw new Error(`object at id ${id} is not a ConfidenceKey object`);
478
1197
  }
479
- return ClaimStakingRewardsEvent.fromBcs(object.content);
1198
+ return ConfidenceKey.fromBcs(object.content);
480
1199
  }
481
1200
  }
482
- /* ============================== InterestUpdateEvent =============================== */
483
- export function isInterestUpdateEvent(type) {
1201
+ /* ============================== PriceGuard =============================== */
1202
+ export function isPriceGuard(type) {
484
1203
  type = compressSuiType(type);
485
- return type === `${PKG_V1}::reserve::InterestUpdateEvent`;
1204
+ return type === `${getTypeOrigin('suilend', 'reserve::PriceGuard')}::reserve::PriceGuard`;
486
1205
  }
487
- export class InterestUpdateEvent {
1206
+ /**
1207
+ * Bounds how far `price` and `smoothed_price` may move per
1208
+ * `min_update_interval_s`. Each anchor moves at most one band per interval and is
1209
+ * advanced to the clamped value, so repeating a refresh inside one PTB cannot walk
1210
+ * either price further than a single band.
1211
+ */
1212
+ export class PriceGuard {
488
1213
  __StructClass = true;
489
- static $typeName = `${PKG_V1}::reserve::InterestUpdateEvent`;
1214
+ static get $typeName() {
1215
+ return `${getTypeOrigin('suilend', 'reserve::PriceGuard')}::reserve::PriceGuard`;
1216
+ }
490
1217
  static $numTypeParams = 0;
491
1218
  static $isPhantom = [];
492
- $typeName = InterestUpdateEvent.$typeName;
1219
+ $typeName = PriceGuard.$typeName;
493
1220
  $fullTypeName;
494
1221
  $typeArgs;
495
- $isPhantom = InterestUpdateEvent.$isPhantom;
496
- lendingMarketId;
497
- coinType;
498
- reserveId;
499
- cumulativeBorrowRate;
500
- availableAmount;
501
- borrowedAmount;
502
- unclaimedSpreadFees;
503
- ctokenSupply;
504
- borrowInterestPaid;
505
- spreadFee;
506
- supplyInterestEarned;
507
- borrowInterestPaidUsdEstimate;
508
- protocolFeeUsdEstimate;
509
- supplyInterestEarnedUsdEstimate;
1222
+ $isPhantom = PriceGuard.$isPhantom;
1223
+ maxPriceChangeBps;
1224
+ minUpdateIntervalS;
1225
+ priceAnchor;
1226
+ smoothedPriceAnchor;
1227
+ anchorTimestampS;
510
1228
  constructor(typeArgs, fields) {
511
- this.$fullTypeName = composeSuiType(InterestUpdateEvent.$typeName, ...typeArgs);
1229
+ this.$fullTypeName = composeSuiType(PriceGuard.$typeName, ...typeArgs);
512
1230
  this.$typeArgs = typeArgs;
513
- this.lendingMarketId = fields.lendingMarketId;
514
- this.coinType = fields.coinType;
515
- this.reserveId = fields.reserveId;
516
- this.cumulativeBorrowRate = fields.cumulativeBorrowRate;
517
- this.availableAmount = fields.availableAmount;
518
- this.borrowedAmount = fields.borrowedAmount;
519
- this.unclaimedSpreadFees = fields.unclaimedSpreadFees;
520
- this.ctokenSupply = fields.ctokenSupply;
521
- this.borrowInterestPaid = fields.borrowInterestPaid;
522
- this.spreadFee = fields.spreadFee;
523
- this.supplyInterestEarned = fields.supplyInterestEarned;
524
- this.borrowInterestPaidUsdEstimate = fields.borrowInterestPaidUsdEstimate;
525
- this.protocolFeeUsdEstimate = fields.protocolFeeUsdEstimate;
526
- this.supplyInterestEarnedUsdEstimate =
527
- fields.supplyInterestEarnedUsdEstimate;
1231
+ this.maxPriceChangeBps = fields.maxPriceChangeBps;
1232
+ this.minUpdateIntervalS = fields.minUpdateIntervalS;
1233
+ this.priceAnchor = fields.priceAnchor;
1234
+ this.smoothedPriceAnchor = fields.smoothedPriceAnchor;
1235
+ this.anchorTimestampS = fields.anchorTimestampS;
528
1236
  }
529
1237
  static reified() {
1238
+ const reifiedBcs = PriceGuard.bcs;
530
1239
  return {
531
- typeName: InterestUpdateEvent.$typeName,
532
- fullTypeName: composeSuiType(InterestUpdateEvent.$typeName, ...[]),
1240
+ get typeName() {
1241
+ return PriceGuard.$typeName;
1242
+ },
1243
+ get fullTypeName() {
1244
+ return composeSuiType(PriceGuard.$typeName, ...[]);
1245
+ },
533
1246
  typeArgs: [],
534
- isPhantom: InterestUpdateEvent.$isPhantom,
1247
+ isPhantom: PriceGuard.$isPhantom,
535
1248
  reifiedTypeArgs: [],
536
- fromFields: (fields) => InterestUpdateEvent.fromFields(fields),
537
- fromFieldsWithTypes: (item) => InterestUpdateEvent.fromFieldsWithTypes(item),
538
- fromBcs: (data) => InterestUpdateEvent.fromBcs(data),
539
- bcs: InterestUpdateEvent.bcs,
540
- fromJSONField: (field) => InterestUpdateEvent.fromJSONField(field),
541
- fromJSON: (json) => InterestUpdateEvent.fromJSON(json),
542
- fetch: async (client, id) => InterestUpdateEvent.fetch(client, id),
1249
+ fromFields: (fields) => PriceGuard.fromFields(fields),
1250
+ fromFieldsWithTypes: (item) => PriceGuard.fromFieldsWithTypes(item),
1251
+ fromBcs: (data) => PriceGuard.fromFields(reifiedBcs.parse(data)),
1252
+ bcs: reifiedBcs,
1253
+ fromJSONField: (field) => PriceGuard.fromJSONField(field),
1254
+ fromJSON: (json) => PriceGuard.fromJSON(json),
1255
+ fromCoreObject: (obj) => PriceGuard.fromCoreObject(obj),
1256
+ fetch: async (client, id) => PriceGuard.fetch(client, id),
543
1257
  new: (fields) => {
544
- return new InterestUpdateEvent([], fields);
545
- },
546
- kind: "StructClassReified",
547
- };
548
- }
549
- static get r() {
550
- return InterestUpdateEvent.reified();
551
- }
552
- static phantom() {
553
- return phantom(InterestUpdateEvent.reified());
554
- }
555
- static get p() {
556
- return InterestUpdateEvent.phantom();
557
- }
558
- static get bcs() {
559
- return bcs.struct("InterestUpdateEvent", {
560
- lending_market_id: bcs
561
- .bytes(32)
562
- .transform({
563
- input: (val) => fromHex(val),
564
- output: (val) => toHex(val),
565
- }),
566
- coin_type: TypeName.bcs,
567
- reserve_id: bcs
568
- .bytes(32)
569
- .transform({
570
- input: (val) => fromHex(val),
571
- output: (val) => toHex(val),
572
- }),
573
- cumulative_borrow_rate: Decimal.bcs,
574
- available_amount: bcs.u64(),
575
- borrowed_amount: Decimal.bcs,
576
- unclaimed_spread_fees: Decimal.bcs,
577
- ctoken_supply: bcs.u64(),
578
- borrow_interest_paid: Decimal.bcs,
579
- spread_fee: Decimal.bcs,
580
- supply_interest_earned: Decimal.bcs,
581
- borrow_interest_paid_usd_estimate: Decimal.bcs,
582
- protocol_fee_usd_estimate: Decimal.bcs,
583
- supply_interest_earned_usd_estimate: Decimal.bcs,
1258
+ return new PriceGuard([], fields);
1259
+ },
1260
+ kind: 'StructClassReified',
1261
+ };
1262
+ }
1263
+ static get r() {
1264
+ return PriceGuard.reified();
1265
+ }
1266
+ static phantom() {
1267
+ return phantom(PriceGuard.reified());
1268
+ }
1269
+ static get p() {
1270
+ return PriceGuard.phantom();
1271
+ }
1272
+ static instantiateBcs() {
1273
+ return bcs.struct('PriceGuard', {
1274
+ max_price_change_bps: bcs.u64(),
1275
+ min_update_interval_s: bcs.u64(),
1276
+ price_anchor: Decimal.bcs,
1277
+ smoothed_price_anchor: Decimal.bcs,
1278
+ anchor_timestamp_s: bcs.u64(),
584
1279
  });
585
1280
  }
1281
+ static cachedBcs = null;
1282
+ static get bcs() {
1283
+ if (!PriceGuard.cachedBcs) {
1284
+ PriceGuard.cachedBcs = PriceGuard.instantiateBcs();
1285
+ }
1286
+ return PriceGuard.cachedBcs;
1287
+ }
586
1288
  static fromFields(fields) {
587
- return InterestUpdateEvent.reified().new({
588
- lendingMarketId: decodeFromFields("address", fields.lending_market_id),
589
- coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
590
- reserveId: decodeFromFields("address", fields.reserve_id),
591
- cumulativeBorrowRate: decodeFromFields(Decimal.reified(), fields.cumulative_borrow_rate),
592
- availableAmount: decodeFromFields("u64", fields.available_amount),
593
- borrowedAmount: decodeFromFields(Decimal.reified(), fields.borrowed_amount),
594
- unclaimedSpreadFees: decodeFromFields(Decimal.reified(), fields.unclaimed_spread_fees),
595
- ctokenSupply: decodeFromFields("u64", fields.ctoken_supply),
596
- borrowInterestPaid: decodeFromFields(Decimal.reified(), fields.borrow_interest_paid),
597
- spreadFee: decodeFromFields(Decimal.reified(), fields.spread_fee),
598
- supplyInterestEarned: decodeFromFields(Decimal.reified(), fields.supply_interest_earned),
599
- borrowInterestPaidUsdEstimate: decodeFromFields(Decimal.reified(), fields.borrow_interest_paid_usd_estimate),
600
- protocolFeeUsdEstimate: decodeFromFields(Decimal.reified(), fields.protocol_fee_usd_estimate),
601
- supplyInterestEarnedUsdEstimate: decodeFromFields(Decimal.reified(), fields.supply_interest_earned_usd_estimate),
1289
+ return PriceGuard.reified().new({
1290
+ maxPriceChangeBps: decodeFromFields('u64', fields.max_price_change_bps),
1291
+ minUpdateIntervalS: decodeFromFields('u64', fields.min_update_interval_s),
1292
+ priceAnchor: decodeFromFields(Decimal.reified(), fields.price_anchor),
1293
+ smoothedPriceAnchor: decodeFromFields(Decimal.reified(), fields.smoothed_price_anchor),
1294
+ anchorTimestampS: decodeFromFields('u64', fields.anchor_timestamp_s),
602
1295
  });
603
1296
  }
604
1297
  static fromFieldsWithTypes(item) {
605
- if (!isInterestUpdateEvent(item.type)) {
606
- throw new Error("not a InterestUpdateEvent type");
1298
+ if (!isPriceGuard(item.type)) {
1299
+ throw new Error('not a PriceGuard type');
607
1300
  }
608
- return InterestUpdateEvent.reified().new({
609
- lendingMarketId: decodeFromFieldsWithTypes("address", item.fields.lending_market_id),
610
- coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
611
- reserveId: decodeFromFieldsWithTypes("address", item.fields.reserve_id),
612
- cumulativeBorrowRate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.cumulative_borrow_rate),
613
- availableAmount: decodeFromFieldsWithTypes("u64", item.fields.available_amount),
614
- borrowedAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrowed_amount),
615
- unclaimedSpreadFees: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.unclaimed_spread_fees),
616
- ctokenSupply: decodeFromFieldsWithTypes("u64", item.fields.ctoken_supply),
617
- borrowInterestPaid: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrow_interest_paid),
618
- spreadFee: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.spread_fee),
619
- supplyInterestEarned: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.supply_interest_earned),
620
- borrowInterestPaidUsdEstimate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrow_interest_paid_usd_estimate),
621
- protocolFeeUsdEstimate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.protocol_fee_usd_estimate),
622
- supplyInterestEarnedUsdEstimate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.supply_interest_earned_usd_estimate),
1301
+ return PriceGuard.reified().new({
1302
+ maxPriceChangeBps: decodeFromFieldsWithTypes('u64', item.fields.max_price_change_bps),
1303
+ minUpdateIntervalS: decodeFromFieldsWithTypes('u64', item.fields.min_update_interval_s),
1304
+ priceAnchor: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.price_anchor),
1305
+ smoothedPriceAnchor: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.smoothed_price_anchor),
1306
+ anchorTimestampS: decodeFromFieldsWithTypes('u64', item.fields.anchor_timestamp_s),
623
1307
  });
624
1308
  }
625
1309
  static fromBcs(data) {
626
- return InterestUpdateEvent.fromFields(InterestUpdateEvent.bcs.parse(data));
1310
+ return PriceGuard.fromFields(PriceGuard.bcs.parse(data));
627
1311
  }
628
1312
  toJSONField() {
629
1313
  return {
630
- lendingMarketId: this.lendingMarketId,
631
- coinType: this.coinType.toJSONField(),
632
- reserveId: this.reserveId,
633
- cumulativeBorrowRate: this.cumulativeBorrowRate.toJSONField(),
634
- availableAmount: this.availableAmount.toString(),
635
- borrowedAmount: this.borrowedAmount.toJSONField(),
636
- unclaimedSpreadFees: this.unclaimedSpreadFees.toJSONField(),
637
- ctokenSupply: this.ctokenSupply.toString(),
638
- borrowInterestPaid: this.borrowInterestPaid.toJSONField(),
639
- spreadFee: this.spreadFee.toJSONField(),
640
- supplyInterestEarned: this.supplyInterestEarned.toJSONField(),
641
- borrowInterestPaidUsdEstimate: this.borrowInterestPaidUsdEstimate.toJSONField(),
642
- protocolFeeUsdEstimate: this.protocolFeeUsdEstimate.toJSONField(),
643
- supplyInterestEarnedUsdEstimate: this.supplyInterestEarnedUsdEstimate.toJSONField(),
1314
+ maxPriceChangeBps: this.maxPriceChangeBps.toString(),
1315
+ minUpdateIntervalS: this.minUpdateIntervalS.toString(),
1316
+ priceAnchor: this.priceAnchor.toJSONField(),
1317
+ smoothedPriceAnchor: this.smoothedPriceAnchor.toJSONField(),
1318
+ anchorTimestampS: this.anchorTimestampS.toString(),
644
1319
  };
645
1320
  }
646
1321
  toJSON() {
647
- return {
648
- $typeName: this.$typeName,
649
- $typeArgs: this.$typeArgs,
650
- ...this.toJSONField(),
651
- };
1322
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
652
1323
  }
653
1324
  static fromJSONField(field) {
654
- return InterestUpdateEvent.reified().new({
655
- lendingMarketId: decodeFromJSONField("address", field.lendingMarketId),
656
- coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
657
- reserveId: decodeFromJSONField("address", field.reserveId),
658
- cumulativeBorrowRate: decodeFromJSONField(Decimal.reified(), field.cumulativeBorrowRate),
659
- availableAmount: decodeFromJSONField("u64", field.availableAmount),
660
- borrowedAmount: decodeFromJSONField(Decimal.reified(), field.borrowedAmount),
661
- unclaimedSpreadFees: decodeFromJSONField(Decimal.reified(), field.unclaimedSpreadFees),
662
- ctokenSupply: decodeFromJSONField("u64", field.ctokenSupply),
663
- borrowInterestPaid: decodeFromJSONField(Decimal.reified(), field.borrowInterestPaid),
664
- spreadFee: decodeFromJSONField(Decimal.reified(), field.spreadFee),
665
- supplyInterestEarned: decodeFromJSONField(Decimal.reified(), field.supplyInterestEarned),
666
- borrowInterestPaidUsdEstimate: decodeFromJSONField(Decimal.reified(), field.borrowInterestPaidUsdEstimate),
667
- protocolFeeUsdEstimate: decodeFromJSONField(Decimal.reified(), field.protocolFeeUsdEstimate),
668
- supplyInterestEarnedUsdEstimate: decodeFromJSONField(Decimal.reified(), field.supplyInterestEarnedUsdEstimate),
1325
+ return PriceGuard.reified().new({
1326
+ maxPriceChangeBps: decodeFromJSONField('u64', field.maxPriceChangeBps),
1327
+ minUpdateIntervalS: decodeFromJSONField('u64', field.minUpdateIntervalS),
1328
+ priceAnchor: decodeFromJSONField(Decimal.reified(), field.priceAnchor),
1329
+ smoothedPriceAnchor: decodeFromJSONField(Decimal.reified(), field.smoothedPriceAnchor),
1330
+ anchorTimestampS: decodeFromJSONField('u64', field.anchorTimestampS),
669
1331
  });
670
1332
  }
671
1333
  static fromJSON(json) {
672
- if (json.$typeName !== InterestUpdateEvent.$typeName) {
673
- throw new Error("not a WithTwoGenerics json object");
1334
+ if (json.$typeName !== PriceGuard.$typeName) {
1335
+ throw new Error(`not a PriceGuard json object: expected '${PriceGuard.$typeName}' but got '${json.$typeName}'`);
674
1336
  }
675
- return InterestUpdateEvent.fromJSONField(json);
1337
+ return PriceGuard.fromJSONField(json);
1338
+ }
1339
+ static fromCoreObject(obj) {
1340
+ if (!isPriceGuard(obj.type)) {
1341
+ throw new Error(`object at ${obj.objectId} is not a PriceGuard object`);
1342
+ }
1343
+ return PriceGuard.fromBcs(obj.content);
676
1344
  }
677
1345
  static async fetch(client, id) {
678
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
679
- if (!isInterestUpdateEvent(object.type)) {
680
- throw new Error(`object at id ${id} is not a InterestUpdateEvent object`);
1346
+ const { object } = await client.core.getObject({
1347
+ objectId: id,
1348
+ include: { content: true },
1349
+ });
1350
+ if (!isPriceGuard(object.type)) {
1351
+ throw new Error(`object at id ${id} is not a PriceGuard object`);
681
1352
  }
682
- return InterestUpdateEvent.fromBcs(object.content);
1353
+ return PriceGuard.fromBcs(object.content);
683
1354
  }
684
1355
  }
685
- /* ============================== LiquidityRequest =============================== */
686
- export function isLiquidityRequest(type) {
1356
+ /* ============================== Balances =============================== */
1357
+ export function isBalances(type) {
687
1358
  type = compressSuiType(type);
688
- return type.startsWith(`${PKG_V8}::reserve::LiquidityRequest` + "<");
1359
+ return type.startsWith(`${getTypeOrigin('suilend', 'reserve::Balances')}::reserve::Balances` + '<');
689
1360
  }
690
- export class LiquidityRequest {
1361
+ /** Balances are stored in a dynamic field to avoid typing the Reserve with CoinType */
1362
+ export class Balances {
691
1363
  __StructClass = true;
692
- static $typeName = `${PKG_V8}::reserve::LiquidityRequest`;
1364
+ static get $typeName() {
1365
+ return `${getTypeOrigin('suilend', 'reserve::Balances')}::reserve::Balances`;
1366
+ }
693
1367
  static $numTypeParams = 2;
694
1368
  static $isPhantom = [true, true];
695
- $typeName = LiquidityRequest.$typeName;
1369
+ $typeName = Balances.$typeName;
696
1370
  $fullTypeName;
697
1371
  $typeArgs;
698
- $isPhantom = LiquidityRequest.$isPhantom;
699
- amount;
700
- fee;
1372
+ $isPhantom = Balances.$isPhantom;
1373
+ availableAmount;
1374
+ ctokenSupply;
1375
+ fees;
1376
+ ctokenFees;
1377
+ depositedCtokens;
701
1378
  constructor(typeArgs, fields) {
702
- this.$fullTypeName = composeSuiType(LiquidityRequest.$typeName, ...typeArgs);
1379
+ this.$fullTypeName = composeSuiType(Balances.$typeName, ...typeArgs);
703
1380
  this.$typeArgs = typeArgs;
704
- this.amount = fields.amount;
705
- this.fee = fields.fee;
1381
+ this.availableAmount = fields.availableAmount;
1382
+ this.ctokenSupply = fields.ctokenSupply;
1383
+ this.fees = fields.fees;
1384
+ this.ctokenFees = fields.ctokenFees;
1385
+ this.depositedCtokens = fields.depositedCtokens;
706
1386
  }
707
1387
  static reified(P, T) {
1388
+ const reifiedBcs = Balances.bcs;
708
1389
  return {
709
- typeName: LiquidityRequest.$typeName,
710
- fullTypeName: composeSuiType(LiquidityRequest.$typeName, ...[extractType(P), extractType(T)]),
711
- typeArgs: [extractType(P), extractType(T)],
712
- isPhantom: LiquidityRequest.$isPhantom,
1390
+ get typeName() {
1391
+ return Balances.$typeName;
1392
+ },
1393
+ get fullTypeName() {
1394
+ return composeSuiType(Balances.$typeName, ...[extractType(P), extractType(T)]);
1395
+ },
1396
+ get typeArgs() {
1397
+ return [extractType(P), extractType(T)];
1398
+ },
1399
+ isPhantom: Balances.$isPhantom,
713
1400
  reifiedTypeArgs: [P, T],
714
- fromFields: (fields) => LiquidityRequest.fromFields([P, T], fields),
715
- fromFieldsWithTypes: (item) => LiquidityRequest.fromFieldsWithTypes([P, T], item),
716
- fromBcs: (data) => LiquidityRequest.fromBcs([P, T], data),
717
- bcs: LiquidityRequest.bcs,
718
- fromJSONField: (field) => LiquidityRequest.fromJSONField([P, T], field),
719
- fromJSON: (json) => LiquidityRequest.fromJSON([P, T], json),
720
- fetch: async (client, id) => LiquidityRequest.fetch(client, [P, T], id),
1401
+ fromFields: (fields) => Balances.fromFields([P, T], fields),
1402
+ fromFieldsWithTypes: (item) => Balances.fromFieldsWithTypes([P, T], item),
1403
+ fromBcs: (data) => Balances.fromFields([P, T], reifiedBcs.parse(data)),
1404
+ bcs: reifiedBcs,
1405
+ fromJSONField: (field) => Balances.fromJSONField([P, T], field),
1406
+ fromJSON: (json) => Balances.fromJSON([P, T], json),
1407
+ fromCoreObject: (obj) => Balances.fromCoreObject([P, T], obj),
1408
+ fetch: async (client, id) => Balances.fetch(client, [P, T], id),
721
1409
  new: (fields) => {
722
- return new LiquidityRequest([extractType(P), extractType(T)], fields);
1410
+ return new Balances([extractType(P), extractType(T)], fields);
723
1411
  },
724
- kind: "StructClassReified",
1412
+ kind: 'StructClassReified',
725
1413
  };
726
1414
  }
727
1415
  static get r() {
728
- return LiquidityRequest.reified;
1416
+ return Balances.reified;
729
1417
  }
730
1418
  static phantom(P, T) {
731
- return phantom(LiquidityRequest.reified(P, T));
1419
+ return phantom(Balances.reified(P, T));
732
1420
  }
733
1421
  static get p() {
734
- return LiquidityRequest.phantom;
1422
+ return Balances.phantom;
735
1423
  }
736
- static get bcs() {
737
- return bcs.struct("LiquidityRequest", {
738
- amount: bcs.u64(),
739
- fee: bcs.u64(),
1424
+ static instantiateBcs() {
1425
+ return bcs.struct('Balances', {
1426
+ available_amount: Balance.bcs,
1427
+ ctoken_supply: Supply.bcs,
1428
+ fees: Balance.bcs,
1429
+ ctoken_fees: Balance.bcs,
1430
+ deposited_ctokens: Balance.bcs,
740
1431
  });
741
1432
  }
1433
+ static cachedBcs = null;
1434
+ static get bcs() {
1435
+ if (!Balances.cachedBcs) {
1436
+ Balances.cachedBcs = Balances.instantiateBcs();
1437
+ }
1438
+ return Balances.cachedBcs;
1439
+ }
742
1440
  static fromFields(typeArgs, fields) {
743
- return LiquidityRequest.reified(typeArgs[0], typeArgs[1]).new({
744
- amount: decodeFromFields("u64", fields.amount),
745
- fee: decodeFromFields("u64", fields.fee),
1441
+ return Balances.reified(typeArgs[0], typeArgs[1]).new({
1442
+ availableAmount: decodeFromFields(Balance.reified(typeArgs[1]), fields.available_amount),
1443
+ ctokenSupply: decodeFromFields(Supply.reified(phantom(CToken.reified(typeArgs[0], typeArgs[1]))), fields.ctoken_supply),
1444
+ fees: decodeFromFields(Balance.reified(typeArgs[1]), fields.fees),
1445
+ ctokenFees: decodeFromFields(Balance.reified(phantom(CToken.reified(typeArgs[0], typeArgs[1]))), fields.ctoken_fees),
1446
+ depositedCtokens: decodeFromFields(Balance.reified(phantom(CToken.reified(typeArgs[0], typeArgs[1]))), fields.deposited_ctokens),
746
1447
  });
747
1448
  }
748
1449
  static fromFieldsWithTypes(typeArgs, item) {
749
- if (!isLiquidityRequest(item.type)) {
750
- throw new Error("not a LiquidityRequest type");
1450
+ if (!isBalances(item.type)) {
1451
+ throw new Error('not a Balances type');
751
1452
  }
752
1453
  assertFieldsWithTypesArgsMatch(item, typeArgs);
753
- return LiquidityRequest.reified(typeArgs[0], typeArgs[1]).new({
754
- amount: decodeFromFieldsWithTypes("u64", item.fields.amount),
755
- fee: decodeFromFieldsWithTypes("u64", item.fields.fee),
1454
+ return Balances.reified(typeArgs[0], typeArgs[1]).new({
1455
+ availableAmount: decodeFromFieldsWithTypes(Balance.reified(typeArgs[1]), item.fields.available_amount),
1456
+ ctokenSupply: decodeFromFieldsWithTypes(Supply.reified(phantom(CToken.reified(typeArgs[0], typeArgs[1]))), item.fields.ctoken_supply),
1457
+ fees: decodeFromFieldsWithTypes(Balance.reified(typeArgs[1]), item.fields.fees),
1458
+ ctokenFees: decodeFromFieldsWithTypes(Balance.reified(phantom(CToken.reified(typeArgs[0], typeArgs[1]))), item.fields.ctoken_fees),
1459
+ depositedCtokens: decodeFromFieldsWithTypes(Balance.reified(phantom(CToken.reified(typeArgs[0], typeArgs[1]))), item.fields.deposited_ctokens),
756
1460
  });
757
1461
  }
758
1462
  static fromBcs(typeArgs, data) {
759
- return LiquidityRequest.fromFields(typeArgs, LiquidityRequest.bcs.parse(data));
1463
+ return Balances.fromFields(typeArgs, Balances.bcs.parse(data));
760
1464
  }
761
1465
  toJSONField() {
762
1466
  return {
763
- amount: this.amount.toString(),
764
- fee: this.fee.toString(),
1467
+ availableAmount: this.availableAmount.toJSONField(),
1468
+ ctokenSupply: this.ctokenSupply.toJSONField(),
1469
+ fees: this.fees.toJSONField(),
1470
+ ctokenFees: this.ctokenFees.toJSONField(),
1471
+ depositedCtokens: this.depositedCtokens.toJSONField(),
765
1472
  };
766
1473
  }
767
1474
  toJSON() {
768
- return {
769
- $typeName: this.$typeName,
770
- $typeArgs: this.$typeArgs,
771
- ...this.toJSONField(),
772
- };
1475
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
773
1476
  }
774
1477
  static fromJSONField(typeArgs, field) {
775
- return LiquidityRequest.reified(typeArgs[0], typeArgs[1]).new({
776
- amount: decodeFromJSONField("u64", field.amount),
777
- fee: decodeFromJSONField("u64", field.fee),
1478
+ return Balances.reified(typeArgs[0], typeArgs[1]).new({
1479
+ availableAmount: decodeFromJSONField(Balance.reified(typeArgs[1]), field.availableAmount),
1480
+ ctokenSupply: decodeFromJSONField(Supply.reified(phantom(CToken.reified(typeArgs[0], typeArgs[1]))), field.ctokenSupply),
1481
+ fees: decodeFromJSONField(Balance.reified(typeArgs[1]), field.fees),
1482
+ ctokenFees: decodeFromJSONField(Balance.reified(phantom(CToken.reified(typeArgs[0], typeArgs[1]))), field.ctokenFees),
1483
+ depositedCtokens: decodeFromJSONField(Balance.reified(phantom(CToken.reified(typeArgs[0], typeArgs[1]))), field.depositedCtokens),
778
1484
  });
779
1485
  }
780
1486
  static fromJSON(typeArgs, json) {
781
- if (json.$typeName !== LiquidityRequest.$typeName) {
782
- throw new Error("not a WithTwoGenerics json object");
1487
+ if (json.$typeName !== Balances.$typeName) {
1488
+ throw new Error(`not a Balances json object: expected '${Balances.$typeName}' but got '${json.$typeName}'`);
783
1489
  }
784
- assertReifiedTypeArgsMatch(composeSuiType(LiquidityRequest.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
785
- return LiquidityRequest.fromJSONField(typeArgs, json);
1490
+ assertReifiedTypeArgsMatch(composeSuiType(Balances.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
1491
+ return Balances.fromJSONField(typeArgs, json);
1492
+ }
1493
+ static fromCoreObject(typeArgs, obj) {
1494
+ if (!isBalances(obj.type)) {
1495
+ throw new Error(`object at ${obj.objectId} is not a Balances object`);
1496
+ }
1497
+ const gotTypeArgs = parseTypeName(obj.type).typeArgs;
1498
+ if (gotTypeArgs.length !== 2) {
1499
+ throw new Error(`type argument mismatch: expected 2 type arguments but got '${gotTypeArgs.length}'`);
1500
+ }
1501
+ for (let i = 0; i < 2; i++) {
1502
+ const gotTypeArg = compressSuiType(gotTypeArgs[i]);
1503
+ const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
1504
+ if (gotTypeArg !== expectedTypeArg) {
1505
+ throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
1506
+ }
1507
+ }
1508
+ return Balances.fromBcs(typeArgs, obj.content);
786
1509
  }
787
1510
  static async fetch(client, typeArgs, id) {
788
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
789
- if (!isLiquidityRequest(object.type)) {
790
- throw new Error(`object at id ${id} is not a LiquidityRequest object`);
1511
+ const { object } = await client.core.getObject({
1512
+ objectId: id,
1513
+ include: { content: true },
1514
+ });
1515
+ if (!isBalances(object.type)) {
1516
+ throw new Error(`object at id ${id} is not a Balances object`);
791
1517
  }
792
- return LiquidityRequest.fromBcs(typeArgs, object.content);
1518
+ const gotTypeArgs = parseTypeName(object.type).typeArgs;
1519
+ if (gotTypeArgs.length !== 2) {
1520
+ throw new Error(`type argument mismatch: expected 2 type arguments but got '${gotTypeArgs.length}'`);
1521
+ }
1522
+ for (let i = 0; i < 2; i++) {
1523
+ const gotTypeArg = compressSuiType(gotTypeArgs[i]);
1524
+ const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
1525
+ if (gotTypeArg !== expectedTypeArg) {
1526
+ throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
1527
+ }
1528
+ }
1529
+ return Balances.fromBcs(typeArgs, object.content);
793
1530
  }
794
1531
  }
795
- /* ============================== Reserve =============================== */
796
- export function isReserve(type) {
1532
+ /* ============================== InterestUpdateEvent =============================== */
1533
+ export function isInterestUpdateEvent(type) {
797
1534
  type = compressSuiType(type);
798
- return type.startsWith(`${PKG_V1}::reserve::Reserve` + "<");
1535
+ return type
1536
+ === `${getTypeOrigin('suilend', 'reserve::InterestUpdateEvent')}::reserve::InterestUpdateEvent`;
799
1537
  }
800
- export class Reserve {
1538
+ export class InterestUpdateEvent {
801
1539
  __StructClass = true;
802
- static $typeName = `${PKG_V1}::reserve::Reserve`;
803
- static $numTypeParams = 1;
804
- static $isPhantom = [true];
805
- $typeName = Reserve.$typeName;
1540
+ static get $typeName() {
1541
+ return `${getTypeOrigin('suilend', 'reserve::InterestUpdateEvent')}::reserve::InterestUpdateEvent`;
1542
+ }
1543
+ static $numTypeParams = 0;
1544
+ static $isPhantom = [];
1545
+ $typeName = InterestUpdateEvent.$typeName;
806
1546
  $fullTypeName;
807
1547
  $typeArgs;
808
- $isPhantom = Reserve.$isPhantom;
809
- id;
1548
+ $isPhantom = InterestUpdateEvent.$isPhantom;
810
1549
  lendingMarketId;
811
- arrayIndex;
812
1550
  coinType;
813
- config;
814
- mintDecimals;
815
- priceIdentifier;
816
- price;
817
- smoothedPrice;
818
- priceLastUpdateTimestampS;
1551
+ reserveId;
1552
+ cumulativeBorrowRate;
819
1553
  availableAmount;
820
- ctokenSupply;
821
1554
  borrowedAmount;
822
- cumulativeBorrowRate;
823
- interestLastUpdateTimestampS;
824
1555
  unclaimedSpreadFees;
825
- attributedBorrowValue;
826
- depositsPoolRewardManager;
827
- borrowsPoolRewardManager;
1556
+ ctokenSupply;
1557
+ borrowInterestPaid;
1558
+ spreadFee;
1559
+ supplyInterestEarned;
1560
+ borrowInterestPaidUsdEstimate;
1561
+ protocolFeeUsdEstimate;
1562
+ supplyInterestEarnedUsdEstimate;
828
1563
  constructor(typeArgs, fields) {
829
- this.$fullTypeName = composeSuiType(Reserve.$typeName, ...typeArgs);
1564
+ this.$fullTypeName = composeSuiType(InterestUpdateEvent.$typeName, ...typeArgs);
830
1565
  this.$typeArgs = typeArgs;
831
- this.id = fields.id;
832
1566
  this.lendingMarketId = fields.lendingMarketId;
833
- this.arrayIndex = fields.arrayIndex;
834
1567
  this.coinType = fields.coinType;
835
- this.config = fields.config;
836
- this.mintDecimals = fields.mintDecimals;
837
- this.priceIdentifier = fields.priceIdentifier;
838
- this.price = fields.price;
839
- this.smoothedPrice = fields.smoothedPrice;
840
- this.priceLastUpdateTimestampS = fields.priceLastUpdateTimestampS;
1568
+ this.reserveId = fields.reserveId;
1569
+ this.cumulativeBorrowRate = fields.cumulativeBorrowRate;
841
1570
  this.availableAmount = fields.availableAmount;
842
- this.ctokenSupply = fields.ctokenSupply;
843
1571
  this.borrowedAmount = fields.borrowedAmount;
844
- this.cumulativeBorrowRate = fields.cumulativeBorrowRate;
845
- this.interestLastUpdateTimestampS = fields.interestLastUpdateTimestampS;
846
1572
  this.unclaimedSpreadFees = fields.unclaimedSpreadFees;
847
- this.attributedBorrowValue = fields.attributedBorrowValue;
848
- this.depositsPoolRewardManager = fields.depositsPoolRewardManager;
849
- this.borrowsPoolRewardManager = fields.borrowsPoolRewardManager;
1573
+ this.ctokenSupply = fields.ctokenSupply;
1574
+ this.borrowInterestPaid = fields.borrowInterestPaid;
1575
+ this.spreadFee = fields.spreadFee;
1576
+ this.supplyInterestEarned = fields.supplyInterestEarned;
1577
+ this.borrowInterestPaidUsdEstimate = fields.borrowInterestPaidUsdEstimate;
1578
+ this.protocolFeeUsdEstimate = fields.protocolFeeUsdEstimate;
1579
+ this.supplyInterestEarnedUsdEstimate = fields.supplyInterestEarnedUsdEstimate;
850
1580
  }
851
- static reified(P) {
1581
+ static reified() {
1582
+ const reifiedBcs = InterestUpdateEvent.bcs;
852
1583
  return {
853
- typeName: Reserve.$typeName,
854
- fullTypeName: composeSuiType(Reserve.$typeName, ...[extractType(P)]),
855
- typeArgs: [extractType(P)],
856
- isPhantom: Reserve.$isPhantom,
857
- reifiedTypeArgs: [P],
858
- fromFields: (fields) => Reserve.fromFields(P, fields),
859
- fromFieldsWithTypes: (item) => Reserve.fromFieldsWithTypes(P, item),
860
- fromBcs: (data) => Reserve.fromBcs(P, data),
861
- bcs: Reserve.bcs,
862
- fromJSONField: (field) => Reserve.fromJSONField(P, field),
863
- fromJSON: (json) => Reserve.fromJSON(P, json),
864
- fetch: async (client, id) => Reserve.fetch(client, P, id),
1584
+ get typeName() {
1585
+ return InterestUpdateEvent.$typeName;
1586
+ },
1587
+ get fullTypeName() {
1588
+ return composeSuiType(InterestUpdateEvent.$typeName, ...[]);
1589
+ },
1590
+ typeArgs: [],
1591
+ isPhantom: InterestUpdateEvent.$isPhantom,
1592
+ reifiedTypeArgs: [],
1593
+ fromFields: (fields) => InterestUpdateEvent.fromFields(fields),
1594
+ fromFieldsWithTypes: (item) => InterestUpdateEvent.fromFieldsWithTypes(item),
1595
+ fromBcs: (data) => InterestUpdateEvent.fromFields(reifiedBcs.parse(data)),
1596
+ bcs: reifiedBcs,
1597
+ fromJSONField: (field) => InterestUpdateEvent.fromJSONField(field),
1598
+ fromJSON: (json) => InterestUpdateEvent.fromJSON(json),
1599
+ fromCoreObject: (obj) => InterestUpdateEvent.fromCoreObject(obj),
1600
+ fetch: async (client, id) => InterestUpdateEvent.fetch(client, id),
865
1601
  new: (fields) => {
866
- return new Reserve([extractType(P)], fields);
1602
+ return new InterestUpdateEvent([], fields);
867
1603
  },
868
- kind: "StructClassReified",
1604
+ kind: 'StructClassReified',
869
1605
  };
870
1606
  }
871
1607
  static get r() {
872
- return Reserve.reified;
1608
+ return InterestUpdateEvent.reified();
873
1609
  }
874
- static phantom(P) {
875
- return phantom(Reserve.reified(P));
1610
+ static phantom() {
1611
+ return phantom(InterestUpdateEvent.reified());
876
1612
  }
877
1613
  static get p() {
878
- return Reserve.phantom;
1614
+ return InterestUpdateEvent.phantom();
879
1615
  }
880
- static get bcs() {
881
- return bcs.struct("Reserve", {
882
- id: UID.bcs,
883
- lending_market_id: ID.bcs,
884
- array_index: bcs.u64(),
1616
+ static instantiateBcs() {
1617
+ return bcs.struct('InterestUpdateEvent', {
1618
+ lending_market_id: bcs.bytes(32).transform({
1619
+ input: (val) => fromHex(val),
1620
+ output: (val) => toHex(val),
1621
+ }),
885
1622
  coin_type: TypeName.bcs,
886
- config: Cell.bcs(ReserveConfig.bcs),
887
- mint_decimals: bcs.u8(),
888
- price_identifier: PriceIdentifier.bcs,
889
- price: Decimal.bcs,
890
- smoothed_price: Decimal.bcs,
891
- price_last_update_timestamp_s: bcs.u64(),
1623
+ reserve_id: bcs.bytes(32).transform({
1624
+ input: (val) => fromHex(val),
1625
+ output: (val) => toHex(val),
1626
+ }),
1627
+ cumulative_borrow_rate: Decimal.bcs,
892
1628
  available_amount: bcs.u64(),
893
- ctoken_supply: bcs.u64(),
894
1629
  borrowed_amount: Decimal.bcs,
895
- cumulative_borrow_rate: Decimal.bcs,
896
- interest_last_update_timestamp_s: bcs.u64(),
897
1630
  unclaimed_spread_fees: Decimal.bcs,
898
- attributed_borrow_value: Decimal.bcs,
899
- deposits_pool_reward_manager: PoolRewardManager.bcs,
900
- borrows_pool_reward_manager: PoolRewardManager.bcs,
1631
+ ctoken_supply: bcs.u64(),
1632
+ borrow_interest_paid: Decimal.bcs,
1633
+ spread_fee: Decimal.bcs,
1634
+ supply_interest_earned: Decimal.bcs,
1635
+ borrow_interest_paid_usd_estimate: Decimal.bcs,
1636
+ protocol_fee_usd_estimate: Decimal.bcs,
1637
+ supply_interest_earned_usd_estimate: Decimal.bcs,
901
1638
  });
902
1639
  }
903
- static fromFields(typeArg, fields) {
904
- return Reserve.reified(typeArg).new({
905
- id: decodeFromFields(UID.reified(), fields.id),
906
- lendingMarketId: decodeFromFields(ID.reified(), fields.lending_market_id),
907
- arrayIndex: decodeFromFields("u64", fields.array_index),
1640
+ static cachedBcs = null;
1641
+ static get bcs() {
1642
+ if (!InterestUpdateEvent.cachedBcs) {
1643
+ InterestUpdateEvent.cachedBcs = InterestUpdateEvent.instantiateBcs();
1644
+ }
1645
+ return InterestUpdateEvent.cachedBcs;
1646
+ }
1647
+ static fromFields(fields) {
1648
+ return InterestUpdateEvent.reified().new({
1649
+ lendingMarketId: decodeFromFields('address', fields.lending_market_id),
908
1650
  coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
909
- config: decodeFromFields(Cell.reified(ReserveConfig.reified()), fields.config),
910
- mintDecimals: decodeFromFields("u8", fields.mint_decimals),
911
- priceIdentifier: decodeFromFields(PriceIdentifier.reified(), fields.price_identifier),
912
- price: decodeFromFields(Decimal.reified(), fields.price),
913
- smoothedPrice: decodeFromFields(Decimal.reified(), fields.smoothed_price),
914
- priceLastUpdateTimestampS: decodeFromFields("u64", fields.price_last_update_timestamp_s),
915
- availableAmount: decodeFromFields("u64", fields.available_amount),
916
- ctokenSupply: decodeFromFields("u64", fields.ctoken_supply),
917
- borrowedAmount: decodeFromFields(Decimal.reified(), fields.borrowed_amount),
1651
+ reserveId: decodeFromFields('address', fields.reserve_id),
918
1652
  cumulativeBorrowRate: decodeFromFields(Decimal.reified(), fields.cumulative_borrow_rate),
919
- interestLastUpdateTimestampS: decodeFromFields("u64", fields.interest_last_update_timestamp_s),
1653
+ availableAmount: decodeFromFields('u64', fields.available_amount),
1654
+ borrowedAmount: decodeFromFields(Decimal.reified(), fields.borrowed_amount),
920
1655
  unclaimedSpreadFees: decodeFromFields(Decimal.reified(), fields.unclaimed_spread_fees),
921
- attributedBorrowValue: decodeFromFields(Decimal.reified(), fields.attributed_borrow_value),
922
- depositsPoolRewardManager: decodeFromFields(PoolRewardManager.reified(), fields.deposits_pool_reward_manager),
923
- borrowsPoolRewardManager: decodeFromFields(PoolRewardManager.reified(), fields.borrows_pool_reward_manager),
1656
+ ctokenSupply: decodeFromFields('u64', fields.ctoken_supply),
1657
+ borrowInterestPaid: decodeFromFields(Decimal.reified(), fields.borrow_interest_paid),
1658
+ spreadFee: decodeFromFields(Decimal.reified(), fields.spread_fee),
1659
+ supplyInterestEarned: decodeFromFields(Decimal.reified(), fields.supply_interest_earned),
1660
+ borrowInterestPaidUsdEstimate: decodeFromFields(Decimal.reified(), fields.borrow_interest_paid_usd_estimate),
1661
+ protocolFeeUsdEstimate: decodeFromFields(Decimal.reified(), fields.protocol_fee_usd_estimate),
1662
+ supplyInterestEarnedUsdEstimate: decodeFromFields(Decimal.reified(), fields.supply_interest_earned_usd_estimate),
924
1663
  });
925
1664
  }
926
- static fromFieldsWithTypes(typeArg, item) {
927
- if (!isReserve(item.type)) {
928
- throw new Error("not a Reserve type");
1665
+ static fromFieldsWithTypes(item) {
1666
+ if (!isInterestUpdateEvent(item.type)) {
1667
+ throw new Error('not a InterestUpdateEvent type');
929
1668
  }
930
- assertFieldsWithTypesArgsMatch(item, [typeArg]);
931
- return Reserve.reified(typeArg).new({
932
- id: decodeFromFieldsWithTypes(UID.reified(), item.fields.id),
933
- lendingMarketId: decodeFromFieldsWithTypes(ID.reified(), item.fields.lending_market_id),
934
- arrayIndex: decodeFromFieldsWithTypes("u64", item.fields.array_index),
1669
+ return InterestUpdateEvent.reified().new({
1670
+ lendingMarketId: decodeFromFieldsWithTypes('address', item.fields.lending_market_id),
935
1671
  coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
936
- config: decodeFromFieldsWithTypes(Cell.reified(ReserveConfig.reified()), item.fields.config),
937
- mintDecimals: decodeFromFieldsWithTypes("u8", item.fields.mint_decimals),
938
- priceIdentifier: decodeFromFieldsWithTypes(PriceIdentifier.reified(), item.fields.price_identifier),
939
- price: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.price),
940
- smoothedPrice: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.smoothed_price),
941
- priceLastUpdateTimestampS: decodeFromFieldsWithTypes("u64", item.fields.price_last_update_timestamp_s),
942
- availableAmount: decodeFromFieldsWithTypes("u64", item.fields.available_amount),
943
- ctokenSupply: decodeFromFieldsWithTypes("u64", item.fields.ctoken_supply),
944
- borrowedAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrowed_amount),
1672
+ reserveId: decodeFromFieldsWithTypes('address', item.fields.reserve_id),
945
1673
  cumulativeBorrowRate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.cumulative_borrow_rate),
946
- interestLastUpdateTimestampS: decodeFromFieldsWithTypes("u64", item.fields.interest_last_update_timestamp_s),
1674
+ availableAmount: decodeFromFieldsWithTypes('u64', item.fields.available_amount),
1675
+ borrowedAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrowed_amount),
947
1676
  unclaimedSpreadFees: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.unclaimed_spread_fees),
948
- attributedBorrowValue: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.attributed_borrow_value),
949
- depositsPoolRewardManager: decodeFromFieldsWithTypes(PoolRewardManager.reified(), item.fields.deposits_pool_reward_manager),
950
- borrowsPoolRewardManager: decodeFromFieldsWithTypes(PoolRewardManager.reified(), item.fields.borrows_pool_reward_manager),
1677
+ ctokenSupply: decodeFromFieldsWithTypes('u64', item.fields.ctoken_supply),
1678
+ borrowInterestPaid: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrow_interest_paid),
1679
+ spreadFee: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.spread_fee),
1680
+ supplyInterestEarned: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.supply_interest_earned),
1681
+ borrowInterestPaidUsdEstimate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrow_interest_paid_usd_estimate),
1682
+ protocolFeeUsdEstimate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.protocol_fee_usd_estimate),
1683
+ supplyInterestEarnedUsdEstimate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.supply_interest_earned_usd_estimate),
951
1684
  });
952
1685
  }
953
- static fromBcs(typeArg, data) {
954
- return Reserve.fromFields(typeArg, Reserve.bcs.parse(data));
1686
+ static fromBcs(data) {
1687
+ return InterestUpdateEvent.fromFields(InterestUpdateEvent.bcs.parse(data));
955
1688
  }
956
1689
  toJSONField() {
957
1690
  return {
958
- id: this.id,
959
1691
  lendingMarketId: this.lendingMarketId,
960
- arrayIndex: this.arrayIndex.toString(),
961
- coinType: this.coinType.toJSONField(),
962
- config: this.config.toJSONField(),
963
- mintDecimals: this.mintDecimals,
964
- priceIdentifier: this.priceIdentifier.toJSONField(),
965
- price: this.price.toJSONField(),
966
- smoothedPrice: this.smoothedPrice.toJSONField(),
967
- priceLastUpdateTimestampS: this.priceLastUpdateTimestampS.toString(),
1692
+ coinType: this.coinType,
1693
+ reserveId: this.reserveId,
1694
+ cumulativeBorrowRate: this.cumulativeBorrowRate.toJSONField(),
968
1695
  availableAmount: this.availableAmount.toString(),
969
- ctokenSupply: this.ctokenSupply.toString(),
970
1696
  borrowedAmount: this.borrowedAmount.toJSONField(),
971
- cumulativeBorrowRate: this.cumulativeBorrowRate.toJSONField(),
972
- interestLastUpdateTimestampS: this.interestLastUpdateTimestampS.toString(),
973
1697
  unclaimedSpreadFees: this.unclaimedSpreadFees.toJSONField(),
974
- attributedBorrowValue: this.attributedBorrowValue.toJSONField(),
975
- depositsPoolRewardManager: this.depositsPoolRewardManager.toJSONField(),
976
- borrowsPoolRewardManager: this.borrowsPoolRewardManager.toJSONField(),
1698
+ ctokenSupply: this.ctokenSupply.toString(),
1699
+ borrowInterestPaid: this.borrowInterestPaid.toJSONField(),
1700
+ spreadFee: this.spreadFee.toJSONField(),
1701
+ supplyInterestEarned: this.supplyInterestEarned.toJSONField(),
1702
+ borrowInterestPaidUsdEstimate: this.borrowInterestPaidUsdEstimate.toJSONField(),
1703
+ protocolFeeUsdEstimate: this.protocolFeeUsdEstimate.toJSONField(),
1704
+ supplyInterestEarnedUsdEstimate: this.supplyInterestEarnedUsdEstimate.toJSONField(),
977
1705
  };
978
1706
  }
979
1707
  toJSON() {
980
- return {
981
- $typeName: this.$typeName,
982
- $typeArgs: this.$typeArgs,
983
- ...this.toJSONField(),
984
- };
1708
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
985
1709
  }
986
- static fromJSONField(typeArg, field) {
987
- return Reserve.reified(typeArg).new({
988
- id: decodeFromJSONField(UID.reified(), field.id),
989
- lendingMarketId: decodeFromJSONField(ID.reified(), field.lendingMarketId),
990
- arrayIndex: decodeFromJSONField("u64", field.arrayIndex),
1710
+ static fromJSONField(field) {
1711
+ return InterestUpdateEvent.reified().new({
1712
+ lendingMarketId: decodeFromJSONField('address', field.lendingMarketId),
991
1713
  coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
992
- config: decodeFromJSONField(Cell.reified(ReserveConfig.reified()), field.config),
993
- mintDecimals: decodeFromJSONField("u8", field.mintDecimals),
994
- priceIdentifier: decodeFromJSONField(PriceIdentifier.reified(), field.priceIdentifier),
995
- price: decodeFromJSONField(Decimal.reified(), field.price),
996
- smoothedPrice: decodeFromJSONField(Decimal.reified(), field.smoothedPrice),
997
- priceLastUpdateTimestampS: decodeFromJSONField("u64", field.priceLastUpdateTimestampS),
998
- availableAmount: decodeFromJSONField("u64", field.availableAmount),
999
- ctokenSupply: decodeFromJSONField("u64", field.ctokenSupply),
1000
- borrowedAmount: decodeFromJSONField(Decimal.reified(), field.borrowedAmount),
1714
+ reserveId: decodeFromJSONField('address', field.reserveId),
1001
1715
  cumulativeBorrowRate: decodeFromJSONField(Decimal.reified(), field.cumulativeBorrowRate),
1002
- interestLastUpdateTimestampS: decodeFromJSONField("u64", field.interestLastUpdateTimestampS),
1716
+ availableAmount: decodeFromJSONField('u64', field.availableAmount),
1717
+ borrowedAmount: decodeFromJSONField(Decimal.reified(), field.borrowedAmount),
1003
1718
  unclaimedSpreadFees: decodeFromJSONField(Decimal.reified(), field.unclaimedSpreadFees),
1004
- attributedBorrowValue: decodeFromJSONField(Decimal.reified(), field.attributedBorrowValue),
1005
- depositsPoolRewardManager: decodeFromJSONField(PoolRewardManager.reified(), field.depositsPoolRewardManager),
1006
- borrowsPoolRewardManager: decodeFromJSONField(PoolRewardManager.reified(), field.borrowsPoolRewardManager),
1719
+ ctokenSupply: decodeFromJSONField('u64', field.ctokenSupply),
1720
+ borrowInterestPaid: decodeFromJSONField(Decimal.reified(), field.borrowInterestPaid),
1721
+ spreadFee: decodeFromJSONField(Decimal.reified(), field.spreadFee),
1722
+ supplyInterestEarned: decodeFromJSONField(Decimal.reified(), field.supplyInterestEarned),
1723
+ borrowInterestPaidUsdEstimate: decodeFromJSONField(Decimal.reified(), field.borrowInterestPaidUsdEstimate),
1724
+ protocolFeeUsdEstimate: decodeFromJSONField(Decimal.reified(), field.protocolFeeUsdEstimate),
1725
+ supplyInterestEarnedUsdEstimate: decodeFromJSONField(Decimal.reified(), field.supplyInterestEarnedUsdEstimate),
1007
1726
  });
1008
1727
  }
1009
- static fromJSON(typeArg, json) {
1010
- if (json.$typeName !== Reserve.$typeName) {
1011
- throw new Error("not a WithTwoGenerics json object");
1728
+ static fromJSON(json) {
1729
+ if (json.$typeName !== InterestUpdateEvent.$typeName) {
1730
+ throw new Error(`not a InterestUpdateEvent json object: expected '${InterestUpdateEvent.$typeName}' but got '${json.$typeName}'`);
1012
1731
  }
1013
- assertReifiedTypeArgsMatch(composeSuiType(Reserve.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
1014
- return Reserve.fromJSONField(typeArg, json);
1732
+ return InterestUpdateEvent.fromJSONField(json);
1015
1733
  }
1016
- static async fetch(client, typeArg, id) {
1017
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
1018
- if (!isReserve(object.type)) {
1019
- throw new Error(`object at id ${id} is not a Reserve object`);
1734
+ static fromCoreObject(obj) {
1735
+ if (!isInterestUpdateEvent(obj.type)) {
1736
+ throw new Error(`object at ${obj.objectId} is not a InterestUpdateEvent object`);
1020
1737
  }
1021
- return Reserve.fromBcs(typeArg, object.content);
1738
+ return InterestUpdateEvent.fromBcs(obj.content);
1739
+ }
1740
+ static async fetch(client, id) {
1741
+ const { object } = await client.core.getObject({
1742
+ objectId: id,
1743
+ include: { content: true },
1744
+ });
1745
+ if (!isInterestUpdateEvent(object.type)) {
1746
+ throw new Error(`object at id ${id} is not a InterestUpdateEvent object`);
1747
+ }
1748
+ return InterestUpdateEvent.fromBcs(object.content);
1022
1749
  }
1023
1750
  }
1024
1751
  /* ============================== ReserveAssetDataEvent =============================== */
1025
1752
  export function isReserveAssetDataEvent(type) {
1026
1753
  type = compressSuiType(type);
1027
- return type === `${PKG_V1}::reserve::ReserveAssetDataEvent`;
1754
+ return type
1755
+ === `${getTypeOrigin('suilend', 'reserve::ReserveAssetDataEvent')}::reserve::ReserveAssetDataEvent`;
1028
1756
  }
1029
1757
  export class ReserveAssetDataEvent {
1030
1758
  __StructClass = true;
1031
- static $typeName = `${PKG_V1}::reserve::ReserveAssetDataEvent`;
1759
+ static get $typeName() {
1760
+ return `${getTypeOrigin('suilend', 'reserve::ReserveAssetDataEvent')}::reserve::ReserveAssetDataEvent`;
1761
+ }
1032
1762
  static $numTypeParams = 0;
1033
1763
  static $isPhantom = [];
1034
1764
  $typeName = ReserveAssetDataEvent.$typeName;
@@ -1072,23 +1802,29 @@ export class ReserveAssetDataEvent {
1072
1802
  this.priceLastUpdateTimestampS = fields.priceLastUpdateTimestampS;
1073
1803
  }
1074
1804
  static reified() {
1805
+ const reifiedBcs = ReserveAssetDataEvent.bcs;
1075
1806
  return {
1076
- typeName: ReserveAssetDataEvent.$typeName,
1077
- fullTypeName: composeSuiType(ReserveAssetDataEvent.$typeName, ...[]),
1807
+ get typeName() {
1808
+ return ReserveAssetDataEvent.$typeName;
1809
+ },
1810
+ get fullTypeName() {
1811
+ return composeSuiType(ReserveAssetDataEvent.$typeName, ...[]);
1812
+ },
1078
1813
  typeArgs: [],
1079
1814
  isPhantom: ReserveAssetDataEvent.$isPhantom,
1080
1815
  reifiedTypeArgs: [],
1081
1816
  fromFields: (fields) => ReserveAssetDataEvent.fromFields(fields),
1082
1817
  fromFieldsWithTypes: (item) => ReserveAssetDataEvent.fromFieldsWithTypes(item),
1083
- fromBcs: (data) => ReserveAssetDataEvent.fromBcs(data),
1084
- bcs: ReserveAssetDataEvent.bcs,
1818
+ fromBcs: (data) => ReserveAssetDataEvent.fromFields(reifiedBcs.parse(data)),
1819
+ bcs: reifiedBcs,
1085
1820
  fromJSONField: (field) => ReserveAssetDataEvent.fromJSONField(field),
1086
1821
  fromJSON: (json) => ReserveAssetDataEvent.fromJSON(json),
1822
+ fromCoreObject: (obj) => ReserveAssetDataEvent.fromCoreObject(obj),
1087
1823
  fetch: async (client, id) => ReserveAssetDataEvent.fetch(client, id),
1088
1824
  new: (fields) => {
1089
1825
  return new ReserveAssetDataEvent([], fields);
1090
1826
  },
1091
- kind: "StructClassReified",
1827
+ kind: 'StructClassReified',
1092
1828
  };
1093
1829
  }
1094
1830
  static get r() {
@@ -1100,18 +1836,14 @@ export class ReserveAssetDataEvent {
1100
1836
  static get p() {
1101
1837
  return ReserveAssetDataEvent.phantom();
1102
1838
  }
1103
- static get bcs() {
1104
- return bcs.struct("ReserveAssetDataEvent", {
1105
- lending_market_id: bcs
1106
- .bytes(32)
1107
- .transform({
1839
+ static instantiateBcs() {
1840
+ return bcs.struct('ReserveAssetDataEvent', {
1841
+ lending_market_id: bcs.bytes(32).transform({
1108
1842
  input: (val) => fromHex(val),
1109
1843
  output: (val) => toHex(val),
1110
1844
  }),
1111
1845
  coin_type: TypeName.bcs,
1112
- reserve_id: bcs
1113
- .bytes(32)
1114
- .transform({
1846
+ reserve_id: bcs.bytes(32).transform({
1115
1847
  input: (val) => fromHex(val),
1116
1848
  output: (val) => toHex(val),
1117
1849
  }),
@@ -1130,11 +1862,18 @@ export class ReserveAssetDataEvent {
1130
1862
  price_last_update_timestamp_s: bcs.u64(),
1131
1863
  });
1132
1864
  }
1865
+ static cachedBcs = null;
1866
+ static get bcs() {
1867
+ if (!ReserveAssetDataEvent.cachedBcs) {
1868
+ ReserveAssetDataEvent.cachedBcs = ReserveAssetDataEvent.instantiateBcs();
1869
+ }
1870
+ return ReserveAssetDataEvent.cachedBcs;
1871
+ }
1133
1872
  static fromFields(fields) {
1134
1873
  return ReserveAssetDataEvent.reified().new({
1135
- lendingMarketId: decodeFromFields("address", fields.lending_market_id),
1874
+ lendingMarketId: decodeFromFields('address', fields.lending_market_id),
1136
1875
  coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
1137
- reserveId: decodeFromFields("address", fields.reserve_id),
1876
+ reserveId: decodeFromFields('address', fields.reserve_id),
1138
1877
  availableAmount: decodeFromFields(Decimal.reified(), fields.available_amount),
1139
1878
  supplyAmount: decodeFromFields(Decimal.reified(), fields.supply_amount),
1140
1879
  borrowedAmount: decodeFromFields(Decimal.reified(), fields.borrowed_amount),
@@ -1143,21 +1882,21 @@ export class ReserveAssetDataEvent {
1143
1882
  borrowedAmountUsdEstimate: decodeFromFields(Decimal.reified(), fields.borrowed_amount_usd_estimate),
1144
1883
  borrowApr: decodeFromFields(Decimal.reified(), fields.borrow_apr),
1145
1884
  supplyApr: decodeFromFields(Decimal.reified(), fields.supply_apr),
1146
- ctokenSupply: decodeFromFields("u64", fields.ctoken_supply),
1885
+ ctokenSupply: decodeFromFields('u64', fields.ctoken_supply),
1147
1886
  cumulativeBorrowRate: decodeFromFields(Decimal.reified(), fields.cumulative_borrow_rate),
1148
1887
  price: decodeFromFields(Decimal.reified(), fields.price),
1149
1888
  smoothedPrice: decodeFromFields(Decimal.reified(), fields.smoothed_price),
1150
- priceLastUpdateTimestampS: decodeFromFields("u64", fields.price_last_update_timestamp_s),
1889
+ priceLastUpdateTimestampS: decodeFromFields('u64', fields.price_last_update_timestamp_s),
1151
1890
  });
1152
1891
  }
1153
1892
  static fromFieldsWithTypes(item) {
1154
1893
  if (!isReserveAssetDataEvent(item.type)) {
1155
- throw new Error("not a ReserveAssetDataEvent type");
1894
+ throw new Error('not a ReserveAssetDataEvent type');
1156
1895
  }
1157
1896
  return ReserveAssetDataEvent.reified().new({
1158
- lendingMarketId: decodeFromFieldsWithTypes("address", item.fields.lending_market_id),
1897
+ lendingMarketId: decodeFromFieldsWithTypes('address', item.fields.lending_market_id),
1159
1898
  coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
1160
- reserveId: decodeFromFieldsWithTypes("address", item.fields.reserve_id),
1899
+ reserveId: decodeFromFieldsWithTypes('address', item.fields.reserve_id),
1161
1900
  availableAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.available_amount),
1162
1901
  supplyAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.supply_amount),
1163
1902
  borrowedAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrowed_amount),
@@ -1166,11 +1905,11 @@ export class ReserveAssetDataEvent {
1166
1905
  borrowedAmountUsdEstimate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrowed_amount_usd_estimate),
1167
1906
  borrowApr: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrow_apr),
1168
1907
  supplyApr: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.supply_apr),
1169
- ctokenSupply: decodeFromFieldsWithTypes("u64", item.fields.ctoken_supply),
1908
+ ctokenSupply: decodeFromFieldsWithTypes('u64', item.fields.ctoken_supply),
1170
1909
  cumulativeBorrowRate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.cumulative_borrow_rate),
1171
1910
  price: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.price),
1172
1911
  smoothedPrice: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.smoothed_price),
1173
- priceLastUpdateTimestampS: decodeFromFieldsWithTypes("u64", item.fields.price_last_update_timestamp_s),
1912
+ priceLastUpdateTimestampS: decodeFromFieldsWithTypes('u64', item.fields.price_last_update_timestamp_s),
1174
1913
  });
1175
1914
  }
1176
1915
  static fromBcs(data) {
@@ -1179,7 +1918,7 @@ export class ReserveAssetDataEvent {
1179
1918
  toJSONField() {
1180
1919
  return {
1181
1920
  lendingMarketId: this.lendingMarketId,
1182
- coinType: this.coinType.toJSONField(),
1921
+ coinType: this.coinType,
1183
1922
  reserveId: this.reserveId,
1184
1923
  availableAmount: this.availableAmount.toJSONField(),
1185
1924
  supplyAmount: this.supplyAmount.toJSONField(),
@@ -1197,17 +1936,13 @@ export class ReserveAssetDataEvent {
1197
1936
  };
1198
1937
  }
1199
1938
  toJSON() {
1200
- return {
1201
- $typeName: this.$typeName,
1202
- $typeArgs: this.$typeArgs,
1203
- ...this.toJSONField(),
1204
- };
1939
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
1205
1940
  }
1206
1941
  static fromJSONField(field) {
1207
1942
  return ReserveAssetDataEvent.reified().new({
1208
- lendingMarketId: decodeFromJSONField("address", field.lendingMarketId),
1943
+ lendingMarketId: decodeFromJSONField('address', field.lendingMarketId),
1209
1944
  coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
1210
- reserveId: decodeFromJSONField("address", field.reserveId),
1945
+ reserveId: decodeFromJSONField('address', field.reserveId),
1211
1946
  availableAmount: decodeFromJSONField(Decimal.reified(), field.availableAmount),
1212
1947
  supplyAmount: decodeFromJSONField(Decimal.reified(), field.supplyAmount),
1213
1948
  borrowedAmount: decodeFromJSONField(Decimal.reified(), field.borrowedAmount),
@@ -1216,125 +1951,182 @@ export class ReserveAssetDataEvent {
1216
1951
  borrowedAmountUsdEstimate: decodeFromJSONField(Decimal.reified(), field.borrowedAmountUsdEstimate),
1217
1952
  borrowApr: decodeFromJSONField(Decimal.reified(), field.borrowApr),
1218
1953
  supplyApr: decodeFromJSONField(Decimal.reified(), field.supplyApr),
1219
- ctokenSupply: decodeFromJSONField("u64", field.ctokenSupply),
1954
+ ctokenSupply: decodeFromJSONField('u64', field.ctokenSupply),
1220
1955
  cumulativeBorrowRate: decodeFromJSONField(Decimal.reified(), field.cumulativeBorrowRate),
1221
1956
  price: decodeFromJSONField(Decimal.reified(), field.price),
1222
1957
  smoothedPrice: decodeFromJSONField(Decimal.reified(), field.smoothedPrice),
1223
- priceLastUpdateTimestampS: decodeFromJSONField("u64", field.priceLastUpdateTimestampS),
1958
+ priceLastUpdateTimestampS: decodeFromJSONField('u64', field.priceLastUpdateTimestampS),
1224
1959
  });
1225
1960
  }
1226
1961
  static fromJSON(json) {
1227
1962
  if (json.$typeName !== ReserveAssetDataEvent.$typeName) {
1228
- throw new Error("not a WithTwoGenerics json object");
1963
+ throw new Error(`not a ReserveAssetDataEvent json object: expected '${ReserveAssetDataEvent.$typeName}' but got '${json.$typeName}'`);
1229
1964
  }
1230
1965
  return ReserveAssetDataEvent.fromJSONField(json);
1231
1966
  }
1967
+ static fromCoreObject(obj) {
1968
+ if (!isReserveAssetDataEvent(obj.type)) {
1969
+ throw new Error(`object at ${obj.objectId} is not a ReserveAssetDataEvent object`);
1970
+ }
1971
+ return ReserveAssetDataEvent.fromBcs(obj.content);
1972
+ }
1232
1973
  static async fetch(client, id) {
1233
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
1974
+ const { object } = await client.core.getObject({
1975
+ objectId: id,
1976
+ include: { content: true },
1977
+ });
1234
1978
  if (!isReserveAssetDataEvent(object.type)) {
1235
1979
  throw new Error(`object at id ${id} is not a ReserveAssetDataEvent object`);
1236
1980
  }
1237
1981
  return ReserveAssetDataEvent.fromBcs(object.content);
1238
1982
  }
1239
1983
  }
1240
- /* ============================== StakerKey =============================== */
1241
- export function isStakerKey(type) {
1984
+ /* ============================== ClaimStakingRewardsEvent =============================== */
1985
+ export function isClaimStakingRewardsEvent(type) {
1242
1986
  type = compressSuiType(type);
1243
- return type === `${PKG_V8}::reserve::StakerKey`;
1987
+ return type
1988
+ === `${getTypeOrigin('suilend', 'reserve::ClaimStakingRewardsEvent')}::reserve::ClaimStakingRewardsEvent`;
1244
1989
  }
1245
- export class StakerKey {
1990
+ export class ClaimStakingRewardsEvent {
1246
1991
  __StructClass = true;
1247
- static $typeName = `${PKG_V8}::reserve::StakerKey`;
1992
+ static get $typeName() {
1993
+ return `${getTypeOrigin('suilend', 'reserve::ClaimStakingRewardsEvent')}::reserve::ClaimStakingRewardsEvent`;
1994
+ }
1248
1995
  static $numTypeParams = 0;
1249
1996
  static $isPhantom = [];
1250
- $typeName = StakerKey.$typeName;
1997
+ $typeName = ClaimStakingRewardsEvent.$typeName;
1251
1998
  $fullTypeName;
1252
1999
  $typeArgs;
1253
- $isPhantom = StakerKey.$isPhantom;
1254
- dummyField;
2000
+ $isPhantom = ClaimStakingRewardsEvent.$isPhantom;
2001
+ lendingMarketId;
2002
+ coinType;
2003
+ reserveId;
2004
+ amount;
1255
2005
  constructor(typeArgs, fields) {
1256
- this.$fullTypeName = composeSuiType(StakerKey.$typeName, ...typeArgs);
2006
+ this.$fullTypeName = composeSuiType(ClaimStakingRewardsEvent.$typeName, ...typeArgs);
1257
2007
  this.$typeArgs = typeArgs;
1258
- this.dummyField = fields.dummyField;
2008
+ this.lendingMarketId = fields.lendingMarketId;
2009
+ this.coinType = fields.coinType;
2010
+ this.reserveId = fields.reserveId;
2011
+ this.amount = fields.amount;
1259
2012
  }
1260
2013
  static reified() {
2014
+ const reifiedBcs = ClaimStakingRewardsEvent.bcs;
1261
2015
  return {
1262
- typeName: StakerKey.$typeName,
1263
- fullTypeName: composeSuiType(StakerKey.$typeName, ...[]),
2016
+ get typeName() {
2017
+ return ClaimStakingRewardsEvent.$typeName;
2018
+ },
2019
+ get fullTypeName() {
2020
+ return composeSuiType(ClaimStakingRewardsEvent.$typeName, ...[]);
2021
+ },
1264
2022
  typeArgs: [],
1265
- isPhantom: StakerKey.$isPhantom,
2023
+ isPhantom: ClaimStakingRewardsEvent.$isPhantom,
1266
2024
  reifiedTypeArgs: [],
1267
- fromFields: (fields) => StakerKey.fromFields(fields),
1268
- fromFieldsWithTypes: (item) => StakerKey.fromFieldsWithTypes(item),
1269
- fromBcs: (data) => StakerKey.fromBcs(data),
1270
- bcs: StakerKey.bcs,
1271
- fromJSONField: (field) => StakerKey.fromJSONField(field),
1272
- fromJSON: (json) => StakerKey.fromJSON(json),
1273
- fetch: async (client, id) => StakerKey.fetch(client, id),
2025
+ fromFields: (fields) => ClaimStakingRewardsEvent.fromFields(fields),
2026
+ fromFieldsWithTypes: (item) => ClaimStakingRewardsEvent.fromFieldsWithTypes(item),
2027
+ fromBcs: (data) => ClaimStakingRewardsEvent.fromFields(reifiedBcs.parse(data)),
2028
+ bcs: reifiedBcs,
2029
+ fromJSONField: (field) => ClaimStakingRewardsEvent.fromJSONField(field),
2030
+ fromJSON: (json) => ClaimStakingRewardsEvent.fromJSON(json),
2031
+ fromCoreObject: (obj) => ClaimStakingRewardsEvent.fromCoreObject(obj),
2032
+ fetch: async (client, id) => ClaimStakingRewardsEvent.fetch(client, id),
1274
2033
  new: (fields) => {
1275
- return new StakerKey([], fields);
2034
+ return new ClaimStakingRewardsEvent([], fields);
1276
2035
  },
1277
- kind: "StructClassReified",
2036
+ kind: 'StructClassReified',
1278
2037
  };
1279
2038
  }
1280
2039
  static get r() {
1281
- return StakerKey.reified();
2040
+ return ClaimStakingRewardsEvent.reified();
1282
2041
  }
1283
2042
  static phantom() {
1284
- return phantom(StakerKey.reified());
2043
+ return phantom(ClaimStakingRewardsEvent.reified());
1285
2044
  }
1286
2045
  static get p() {
1287
- return StakerKey.phantom();
2046
+ return ClaimStakingRewardsEvent.phantom();
1288
2047
  }
1289
- static get bcs() {
1290
- return bcs.struct("StakerKey", {
1291
- dummy_field: bcs.bool(),
2048
+ static instantiateBcs() {
2049
+ return bcs.struct('ClaimStakingRewardsEvent', {
2050
+ lending_market_id: bcs.bytes(32).transform({
2051
+ input: (val) => fromHex(val),
2052
+ output: (val) => toHex(val),
2053
+ }),
2054
+ coin_type: TypeName.bcs,
2055
+ reserve_id: bcs.bytes(32).transform({
2056
+ input: (val) => fromHex(val),
2057
+ output: (val) => toHex(val),
2058
+ }),
2059
+ amount: bcs.u64(),
1292
2060
  });
1293
2061
  }
2062
+ static cachedBcs = null;
2063
+ static get bcs() {
2064
+ if (!ClaimStakingRewardsEvent.cachedBcs) {
2065
+ ClaimStakingRewardsEvent.cachedBcs = ClaimStakingRewardsEvent.instantiateBcs();
2066
+ }
2067
+ return ClaimStakingRewardsEvent.cachedBcs;
2068
+ }
1294
2069
  static fromFields(fields) {
1295
- return StakerKey.reified().new({
1296
- dummyField: decodeFromFields("bool", fields.dummy_field),
2070
+ return ClaimStakingRewardsEvent.reified().new({
2071
+ lendingMarketId: decodeFromFields('address', fields.lending_market_id),
2072
+ coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
2073
+ reserveId: decodeFromFields('address', fields.reserve_id),
2074
+ amount: decodeFromFields('u64', fields.amount),
1297
2075
  });
1298
2076
  }
1299
2077
  static fromFieldsWithTypes(item) {
1300
- if (!isStakerKey(item.type)) {
1301
- throw new Error("not a StakerKey type");
2078
+ if (!isClaimStakingRewardsEvent(item.type)) {
2079
+ throw new Error('not a ClaimStakingRewardsEvent type');
1302
2080
  }
1303
- return StakerKey.reified().new({
1304
- dummyField: decodeFromFieldsWithTypes("bool", item.fields.dummy_field),
2081
+ return ClaimStakingRewardsEvent.reified().new({
2082
+ lendingMarketId: decodeFromFieldsWithTypes('address', item.fields.lending_market_id),
2083
+ coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
2084
+ reserveId: decodeFromFieldsWithTypes('address', item.fields.reserve_id),
2085
+ amount: decodeFromFieldsWithTypes('u64', item.fields.amount),
1305
2086
  });
1306
2087
  }
1307
2088
  static fromBcs(data) {
1308
- return StakerKey.fromFields(StakerKey.bcs.parse(data));
2089
+ return ClaimStakingRewardsEvent.fromFields(ClaimStakingRewardsEvent.bcs.parse(data));
1309
2090
  }
1310
2091
  toJSONField() {
1311
2092
  return {
1312
- dummyField: this.dummyField,
2093
+ lendingMarketId: this.lendingMarketId,
2094
+ coinType: this.coinType,
2095
+ reserveId: this.reserveId,
2096
+ amount: this.amount.toString(),
1313
2097
  };
1314
2098
  }
1315
2099
  toJSON() {
1316
- return {
1317
- $typeName: this.$typeName,
1318
- $typeArgs: this.$typeArgs,
1319
- ...this.toJSONField(),
1320
- };
2100
+ return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
1321
2101
  }
1322
2102
  static fromJSONField(field) {
1323
- return StakerKey.reified().new({
1324
- dummyField: decodeFromJSONField("bool", field.dummyField),
2103
+ return ClaimStakingRewardsEvent.reified().new({
2104
+ lendingMarketId: decodeFromJSONField('address', field.lendingMarketId),
2105
+ coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
2106
+ reserveId: decodeFromJSONField('address', field.reserveId),
2107
+ amount: decodeFromJSONField('u64', field.amount),
1325
2108
  });
1326
2109
  }
1327
2110
  static fromJSON(json) {
1328
- if (json.$typeName !== StakerKey.$typeName) {
1329
- throw new Error("not a WithTwoGenerics json object");
2111
+ if (json.$typeName !== ClaimStakingRewardsEvent.$typeName) {
2112
+ throw new Error(`not a ClaimStakingRewardsEvent json object: expected '${ClaimStakingRewardsEvent.$typeName}' but got '${json.$typeName}'`);
1330
2113
  }
1331
- return StakerKey.fromJSONField(json);
2114
+ return ClaimStakingRewardsEvent.fromJSONField(json);
2115
+ }
2116
+ static fromCoreObject(obj) {
2117
+ if (!isClaimStakingRewardsEvent(obj.type)) {
2118
+ throw new Error(`object at ${obj.objectId} is not a ClaimStakingRewardsEvent object`);
2119
+ }
2120
+ return ClaimStakingRewardsEvent.fromBcs(obj.content);
1332
2121
  }
1333
2122
  static async fetch(client, id) {
1334
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
1335
- if (!isStakerKey(object.type)) {
1336
- throw new Error(`object at id ${id} is not a StakerKey object`);
2123
+ const { object } = await client.core.getObject({
2124
+ objectId: id,
2125
+ include: { content: true },
2126
+ });
2127
+ if (!isClaimStakingRewardsEvent(object.type)) {
2128
+ throw new Error(`object at id ${id} is not a ClaimStakingRewardsEvent object`);
1337
2129
  }
1338
- return StakerKey.fromBcs(object.content);
2130
+ return ClaimStakingRewardsEvent.fromBcs(object.content);
1339
2131
  }
1340
2132
  }