@suilend/sdk 1.1.99 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
- package/_generated/_dependencies/source/0x1/index.js +3 -6
- package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
- package/_generated/_dependencies/source/0x1/option/structs.js +31 -69
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
- package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
- package/_generated/_dependencies/source/0x2/index.js +3 -6
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
- package/_generated/_dependencies/source/0x2/object/structs.js +34 -41
- package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/object-table/structs.js +31 -36
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +23 -28
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +4 -7
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -11
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +32 -37
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -23
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +29 -34
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -59
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -55
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +46 -53
- package/_generated/_framework/reified.d.ts +2 -2
- package/_generated/_framework/reified.js +27 -40
- package/_generated/_framework/util.js +26 -40
- package/_generated/_framework/vector.d.ts +4 -4
- package/_generated/_framework/vector.js +16 -21
- package/_generated/suilend/cell/structs.d.ts +4 -4
- package/_generated/suilend/cell/structs.js +31 -36
- package/_generated/suilend/decimal/structs.d.ts +4 -4
- package/_generated/suilend/decimal/structs.js +19 -24
- package/_generated/suilend/index.js +8 -12
- package/_generated/suilend/lending-market/functions.d.ts +1 -0
- package/_generated/suilend/lending-market/functions.js +271 -302
- package/_generated/suilend/lending-market/structs.d.ts +146 -146
- package/_generated/suilend/lending-market/structs.js +549 -617
- package/_generated/suilend/lending-market-registry/functions.js +7 -11
- package/_generated/suilend/liquidity-mining/structs.d.ts +50 -50
- package/_generated/suilend/liquidity-mining/structs.js +159 -205
- package/_generated/suilend/obligation/structs.d.ts +106 -106
- package/_generated/suilend/obligation/structs.js +313 -363
- package/_generated/suilend/rate-limiter/functions.js +23 -31
- package/_generated/suilend/rate-limiter/structs.d.ts +15 -15
- package/_generated/suilend/rate-limiter/structs.js +49 -56
- package/_generated/suilend/reserve/structs.d.ts +139 -139
- package/_generated/suilend/reserve/structs.js +397 -451
- package/_generated/suilend/reserve-config/functions.js +149 -190
- package/_generated/suilend/reserve-config/structs.d.ts +33 -33
- package/_generated/suilend/reserve-config/structs.js +109 -149
- package/api/events.js +1 -5
- package/api/index.js +1 -17
- package/client.d.ts +10 -10
- package/client.js +118 -128
- package/index.js +7 -23
- package/lib/constants.js +3 -9
- package/lib/index.js +5 -21
- package/lib/initialize.d.ts +3 -3
- package/lib/initialize.js +103 -140
- package/lib/liquidityMining.d.ts +3 -3
- package/lib/liquidityMining.js +57 -72
- package/lib/pyth.js +9 -14
- package/lib/strategyOwnerCap.js +106 -119
- package/lib/transactions.js +2 -7
- package/lib/types.js +4 -7
- package/mmt.js +2 -5
- package/package.json +1 -1
- package/parsers/apiReserveAssetDataEvent.js +25 -33
- package/parsers/index.js +5 -21
- package/parsers/lendingMarket.d.ts +1 -1
- package/parsers/lendingMarket.js +12 -19
- package/parsers/obligation.js +19 -26
- package/parsers/rateLimiter.js +11 -19
- package/parsers/reserve.d.ts +1 -1
- package/parsers/reserve.js +42 -85
- package/strategies.d.ts +11 -11
- package/strategies.js +547 -586
- package/swap/index.js +2 -18
- package/swap/quote.js +57 -65
- package/swap/transaction.d.ts +2 -2
- package/swap/transaction.js +40 -35
- package/utils/events.d.ts +3 -3
- package/utils/events.js +18 -35
- package/utils/index.js +16 -40
- package/utils/obligation.d.ts +4 -4
- package/utils/obligation.js +17 -60
- package/utils/simulate.js +118 -143
|
@@ -1,37 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,36 +7,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
8
|
});
|
|
43
9
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const structs_1 = require("../../_dependencies/source/0x1/type-name/structs");
|
|
55
|
-
const structs_2 = require("../../_dependencies/source/0x2/object/structs");
|
|
56
|
-
const reified_1 = require("../../_framework/reified");
|
|
57
|
-
const util_1 = require("../../_framework/util");
|
|
58
|
-
const structs_3 = require("../decimal/structs");
|
|
59
|
-
const index_1 = require("../index");
|
|
60
|
-
const structs_4 = require("../liquidity-mining/structs");
|
|
61
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
62
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
10
|
+
import * as reified from "../../_framework/reified";
|
|
11
|
+
import { TypeName } from "../../_dependencies/source/0x1/type-name/structs";
|
|
12
|
+
import { ID, UID } from "../../_dependencies/source/0x2/object/structs";
|
|
13
|
+
import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, } from "../../_framework/reified";
|
|
14
|
+
import { composeSuiType, compressSuiType, parseTypeName, } from "../../_framework/util";
|
|
15
|
+
import { Decimal } from "../decimal/structs";
|
|
16
|
+
import { PKG_V1, PKG_V11 } from "../index";
|
|
17
|
+
import { UserRewardManager } from "../liquidity-mining/structs";
|
|
18
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
19
|
+
import { fromBase64, fromHex, toHex } from "@mysten/sui/utils";
|
|
63
20
|
/* ============================== Borrow =============================== */
|
|
64
|
-
function isBorrow(type) {
|
|
65
|
-
type =
|
|
66
|
-
return type === `${
|
|
21
|
+
export function isBorrow(type) {
|
|
22
|
+
type = compressSuiType(type);
|
|
23
|
+
return type === `${PKG_V1}::obligation::Borrow`;
|
|
67
24
|
}
|
|
68
|
-
class Borrow {
|
|
25
|
+
export class Borrow {
|
|
69
26
|
constructor(typeArgs, fields) {
|
|
70
27
|
this.__StructClass = true;
|
|
71
28
|
this.$typeName = Borrow.$typeName;
|
|
72
29
|
this.$isPhantom = Borrow.$isPhantom;
|
|
73
|
-
this.$fullTypeName =
|
|
30
|
+
this.$fullTypeName = composeSuiType(Borrow.$typeName, ...typeArgs);
|
|
74
31
|
this.$typeArgs = typeArgs;
|
|
75
32
|
this.coinType = fields.coinType;
|
|
76
33
|
this.reserveArrayIndex = fields.reserveArrayIndex;
|
|
@@ -82,7 +39,7 @@ class Borrow {
|
|
|
82
39
|
static reified() {
|
|
83
40
|
return {
|
|
84
41
|
typeName: Borrow.$typeName,
|
|
85
|
-
fullTypeName:
|
|
42
|
+
fullTypeName: composeSuiType(Borrow.$typeName, ...[]),
|
|
86
43
|
typeArgs: [],
|
|
87
44
|
isPhantom: Borrow.$isPhantom,
|
|
88
45
|
reifiedTypeArgs: [],
|
|
@@ -105,29 +62,29 @@ class Borrow {
|
|
|
105
62
|
return Borrow.reified();
|
|
106
63
|
}
|
|
107
64
|
static phantom() {
|
|
108
|
-
return
|
|
65
|
+
return phantom(Borrow.reified());
|
|
109
66
|
}
|
|
110
67
|
static get p() {
|
|
111
68
|
return Borrow.phantom();
|
|
112
69
|
}
|
|
113
70
|
static get bcs() {
|
|
114
|
-
return
|
|
115
|
-
coin_type:
|
|
116
|
-
reserve_array_index:
|
|
117
|
-
borrowed_amount:
|
|
118
|
-
cumulative_borrow_rate:
|
|
119
|
-
market_value:
|
|
120
|
-
user_reward_manager_index:
|
|
71
|
+
return bcs.struct("Borrow", {
|
|
72
|
+
coin_type: TypeName.bcs,
|
|
73
|
+
reserve_array_index: bcs.u64(),
|
|
74
|
+
borrowed_amount: Decimal.bcs,
|
|
75
|
+
cumulative_borrow_rate: Decimal.bcs,
|
|
76
|
+
market_value: Decimal.bcs,
|
|
77
|
+
user_reward_manager_index: bcs.u64(),
|
|
121
78
|
});
|
|
122
79
|
}
|
|
123
80
|
static fromFields(fields) {
|
|
124
81
|
return Borrow.reified().new({
|
|
125
|
-
coinType:
|
|
126
|
-
reserveArrayIndex:
|
|
127
|
-
borrowedAmount:
|
|
128
|
-
cumulativeBorrowRate:
|
|
129
|
-
marketValue:
|
|
130
|
-
userRewardManagerIndex:
|
|
82
|
+
coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
|
|
83
|
+
reserveArrayIndex: decodeFromFields("u64", fields.reserve_array_index),
|
|
84
|
+
borrowedAmount: decodeFromFields(Decimal.reified(), fields.borrowed_amount),
|
|
85
|
+
cumulativeBorrowRate: decodeFromFields(Decimal.reified(), fields.cumulative_borrow_rate),
|
|
86
|
+
marketValue: decodeFromFields(Decimal.reified(), fields.market_value),
|
|
87
|
+
userRewardManagerIndex: decodeFromFields("u64", fields.user_reward_manager_index),
|
|
131
88
|
});
|
|
132
89
|
}
|
|
133
90
|
static fromFieldsWithTypes(item) {
|
|
@@ -135,12 +92,12 @@ class Borrow {
|
|
|
135
92
|
throw new Error("not a Borrow type");
|
|
136
93
|
}
|
|
137
94
|
return Borrow.reified().new({
|
|
138
|
-
coinType:
|
|
139
|
-
reserveArrayIndex:
|
|
140
|
-
borrowedAmount:
|
|
141
|
-
cumulativeBorrowRate:
|
|
142
|
-
marketValue:
|
|
143
|
-
userRewardManagerIndex:
|
|
95
|
+
coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
|
|
96
|
+
reserveArrayIndex: decodeFromFieldsWithTypes("u64", item.fields.reserve_array_index),
|
|
97
|
+
borrowedAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrowed_amount),
|
|
98
|
+
cumulativeBorrowRate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.cumulative_borrow_rate),
|
|
99
|
+
marketValue: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.market_value),
|
|
100
|
+
userRewardManagerIndex: decodeFromFieldsWithTypes("u64", item.fields.user_reward_manager_index),
|
|
144
101
|
});
|
|
145
102
|
}
|
|
146
103
|
static fromBcs(data) {
|
|
@@ -161,12 +118,12 @@ class Borrow {
|
|
|
161
118
|
}
|
|
162
119
|
static fromJSONField(field) {
|
|
163
120
|
return Borrow.reified().new({
|
|
164
|
-
coinType:
|
|
165
|
-
reserveArrayIndex:
|
|
166
|
-
borrowedAmount:
|
|
167
|
-
cumulativeBorrowRate:
|
|
168
|
-
marketValue:
|
|
169
|
-
userRewardManagerIndex:
|
|
121
|
+
coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
|
|
122
|
+
reserveArrayIndex: decodeFromJSONField("u64", field.reserveArrayIndex),
|
|
123
|
+
borrowedAmount: decodeFromJSONField(Decimal.reified(), field.borrowedAmount),
|
|
124
|
+
cumulativeBorrowRate: decodeFromJSONField(Decimal.reified(), field.cumulativeBorrowRate),
|
|
125
|
+
marketValue: decodeFromJSONField(Decimal.reified(), field.marketValue),
|
|
126
|
+
userRewardManagerIndex: decodeFromJSONField("u64", field.userRewardManagerIndex),
|
|
170
127
|
});
|
|
171
128
|
}
|
|
172
129
|
static fromJSON(json) {
|
|
@@ -189,7 +146,7 @@ class Borrow {
|
|
|
189
146
|
if (data.bcs.dataType !== "moveObject" || !isBorrow(data.bcs.type)) {
|
|
190
147
|
throw new Error(`object at is not a Borrow object`);
|
|
191
148
|
}
|
|
192
|
-
return Borrow.fromBcs((
|
|
149
|
+
return Borrow.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
193
150
|
}
|
|
194
151
|
if (data.content) {
|
|
195
152
|
return Borrow.fromSuiParsedData(data.content);
|
|
@@ -211,21 +168,20 @@ class Borrow {
|
|
|
211
168
|
});
|
|
212
169
|
}
|
|
213
170
|
}
|
|
214
|
-
|
|
215
|
-
Borrow.$typeName = `${index_1.PKG_V1}::obligation::Borrow`;
|
|
171
|
+
Borrow.$typeName = `${PKG_V1}::obligation::Borrow`;
|
|
216
172
|
Borrow.$numTypeParams = 0;
|
|
217
173
|
Borrow.$isPhantom = [];
|
|
218
174
|
/* ============================== BorrowRecord =============================== */
|
|
219
|
-
function isBorrowRecord(type) {
|
|
220
|
-
type =
|
|
221
|
-
return type === `${
|
|
175
|
+
export function isBorrowRecord(type) {
|
|
176
|
+
type = compressSuiType(type);
|
|
177
|
+
return type === `${PKG_V1}::obligation::BorrowRecord`;
|
|
222
178
|
}
|
|
223
|
-
class BorrowRecord {
|
|
179
|
+
export class BorrowRecord {
|
|
224
180
|
constructor(typeArgs, fields) {
|
|
225
181
|
this.__StructClass = true;
|
|
226
182
|
this.$typeName = BorrowRecord.$typeName;
|
|
227
183
|
this.$isPhantom = BorrowRecord.$isPhantom;
|
|
228
|
-
this.$fullTypeName =
|
|
184
|
+
this.$fullTypeName = composeSuiType(BorrowRecord.$typeName, ...typeArgs);
|
|
229
185
|
this.$typeArgs = typeArgs;
|
|
230
186
|
this.coinType = fields.coinType;
|
|
231
187
|
this.reserveArrayIndex = fields.reserveArrayIndex;
|
|
@@ -237,7 +193,7 @@ class BorrowRecord {
|
|
|
237
193
|
static reified() {
|
|
238
194
|
return {
|
|
239
195
|
typeName: BorrowRecord.$typeName,
|
|
240
|
-
fullTypeName:
|
|
196
|
+
fullTypeName: composeSuiType(BorrowRecord.$typeName, ...[]),
|
|
241
197
|
typeArgs: [],
|
|
242
198
|
isPhantom: BorrowRecord.$isPhantom,
|
|
243
199
|
reifiedTypeArgs: [],
|
|
@@ -260,29 +216,29 @@ class BorrowRecord {
|
|
|
260
216
|
return BorrowRecord.reified();
|
|
261
217
|
}
|
|
262
218
|
static phantom() {
|
|
263
|
-
return
|
|
219
|
+
return phantom(BorrowRecord.reified());
|
|
264
220
|
}
|
|
265
221
|
static get p() {
|
|
266
222
|
return BorrowRecord.phantom();
|
|
267
223
|
}
|
|
268
224
|
static get bcs() {
|
|
269
|
-
return
|
|
270
|
-
coin_type:
|
|
271
|
-
reserve_array_index:
|
|
272
|
-
borrowed_amount:
|
|
273
|
-
cumulative_borrow_rate:
|
|
274
|
-
market_value:
|
|
275
|
-
user_reward_manager_index:
|
|
225
|
+
return bcs.struct("BorrowRecord", {
|
|
226
|
+
coin_type: TypeName.bcs,
|
|
227
|
+
reserve_array_index: bcs.u64(),
|
|
228
|
+
borrowed_amount: Decimal.bcs,
|
|
229
|
+
cumulative_borrow_rate: Decimal.bcs,
|
|
230
|
+
market_value: Decimal.bcs,
|
|
231
|
+
user_reward_manager_index: bcs.u64(),
|
|
276
232
|
});
|
|
277
233
|
}
|
|
278
234
|
static fromFields(fields) {
|
|
279
235
|
return BorrowRecord.reified().new({
|
|
280
|
-
coinType:
|
|
281
|
-
reserveArrayIndex:
|
|
282
|
-
borrowedAmount:
|
|
283
|
-
cumulativeBorrowRate:
|
|
284
|
-
marketValue:
|
|
285
|
-
userRewardManagerIndex:
|
|
236
|
+
coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
|
|
237
|
+
reserveArrayIndex: decodeFromFields("u64", fields.reserve_array_index),
|
|
238
|
+
borrowedAmount: decodeFromFields(Decimal.reified(), fields.borrowed_amount),
|
|
239
|
+
cumulativeBorrowRate: decodeFromFields(Decimal.reified(), fields.cumulative_borrow_rate),
|
|
240
|
+
marketValue: decodeFromFields(Decimal.reified(), fields.market_value),
|
|
241
|
+
userRewardManagerIndex: decodeFromFields("u64", fields.user_reward_manager_index),
|
|
286
242
|
});
|
|
287
243
|
}
|
|
288
244
|
static fromFieldsWithTypes(item) {
|
|
@@ -290,12 +246,12 @@ class BorrowRecord {
|
|
|
290
246
|
throw new Error("not a BorrowRecord type");
|
|
291
247
|
}
|
|
292
248
|
return BorrowRecord.reified().new({
|
|
293
|
-
coinType:
|
|
294
|
-
reserveArrayIndex:
|
|
295
|
-
borrowedAmount:
|
|
296
|
-
cumulativeBorrowRate:
|
|
297
|
-
marketValue:
|
|
298
|
-
userRewardManagerIndex:
|
|
249
|
+
coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
|
|
250
|
+
reserveArrayIndex: decodeFromFieldsWithTypes("u64", item.fields.reserve_array_index),
|
|
251
|
+
borrowedAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrowed_amount),
|
|
252
|
+
cumulativeBorrowRate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.cumulative_borrow_rate),
|
|
253
|
+
marketValue: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.market_value),
|
|
254
|
+
userRewardManagerIndex: decodeFromFieldsWithTypes("u64", item.fields.user_reward_manager_index),
|
|
299
255
|
});
|
|
300
256
|
}
|
|
301
257
|
static fromBcs(data) {
|
|
@@ -316,12 +272,12 @@ class BorrowRecord {
|
|
|
316
272
|
}
|
|
317
273
|
static fromJSONField(field) {
|
|
318
274
|
return BorrowRecord.reified().new({
|
|
319
|
-
coinType:
|
|
320
|
-
reserveArrayIndex:
|
|
321
|
-
borrowedAmount:
|
|
322
|
-
cumulativeBorrowRate:
|
|
323
|
-
marketValue:
|
|
324
|
-
userRewardManagerIndex:
|
|
275
|
+
coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
|
|
276
|
+
reserveArrayIndex: decodeFromJSONField("u64", field.reserveArrayIndex),
|
|
277
|
+
borrowedAmount: decodeFromJSONField(Decimal.reified(), field.borrowedAmount),
|
|
278
|
+
cumulativeBorrowRate: decodeFromJSONField(Decimal.reified(), field.cumulativeBorrowRate),
|
|
279
|
+
marketValue: decodeFromJSONField(Decimal.reified(), field.marketValue),
|
|
280
|
+
userRewardManagerIndex: decodeFromJSONField("u64", field.userRewardManagerIndex),
|
|
325
281
|
});
|
|
326
282
|
}
|
|
327
283
|
static fromJSON(json) {
|
|
@@ -345,7 +301,7 @@ class BorrowRecord {
|
|
|
345
301
|
!isBorrowRecord(data.bcs.type)) {
|
|
346
302
|
throw new Error(`object at is not a BorrowRecord object`);
|
|
347
303
|
}
|
|
348
|
-
return BorrowRecord.fromBcs((
|
|
304
|
+
return BorrowRecord.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
349
305
|
}
|
|
350
306
|
if (data.content) {
|
|
351
307
|
return BorrowRecord.fromSuiParsedData(data.content);
|
|
@@ -367,21 +323,20 @@ class BorrowRecord {
|
|
|
367
323
|
});
|
|
368
324
|
}
|
|
369
325
|
}
|
|
370
|
-
|
|
371
|
-
BorrowRecord.$typeName = `${index_1.PKG_V1}::obligation::BorrowRecord`;
|
|
326
|
+
BorrowRecord.$typeName = `${PKG_V1}::obligation::BorrowRecord`;
|
|
372
327
|
BorrowRecord.$numTypeParams = 0;
|
|
373
328
|
BorrowRecord.$isPhantom = [];
|
|
374
329
|
/* ============================== Deposit =============================== */
|
|
375
|
-
function isDeposit(type) {
|
|
376
|
-
type =
|
|
377
|
-
return type === `${
|
|
330
|
+
export function isDeposit(type) {
|
|
331
|
+
type = compressSuiType(type);
|
|
332
|
+
return type === `${PKG_V1}::obligation::Deposit`;
|
|
378
333
|
}
|
|
379
|
-
class Deposit {
|
|
334
|
+
export class Deposit {
|
|
380
335
|
constructor(typeArgs, fields) {
|
|
381
336
|
this.__StructClass = true;
|
|
382
337
|
this.$typeName = Deposit.$typeName;
|
|
383
338
|
this.$isPhantom = Deposit.$isPhantom;
|
|
384
|
-
this.$fullTypeName =
|
|
339
|
+
this.$fullTypeName = composeSuiType(Deposit.$typeName, ...typeArgs);
|
|
385
340
|
this.$typeArgs = typeArgs;
|
|
386
341
|
this.coinType = fields.coinType;
|
|
387
342
|
this.reserveArrayIndex = fields.reserveArrayIndex;
|
|
@@ -393,7 +348,7 @@ class Deposit {
|
|
|
393
348
|
static reified() {
|
|
394
349
|
return {
|
|
395
350
|
typeName: Deposit.$typeName,
|
|
396
|
-
fullTypeName:
|
|
351
|
+
fullTypeName: composeSuiType(Deposit.$typeName, ...[]),
|
|
397
352
|
typeArgs: [],
|
|
398
353
|
isPhantom: Deposit.$isPhantom,
|
|
399
354
|
reifiedTypeArgs: [],
|
|
@@ -416,29 +371,29 @@ class Deposit {
|
|
|
416
371
|
return Deposit.reified();
|
|
417
372
|
}
|
|
418
373
|
static phantom() {
|
|
419
|
-
return
|
|
374
|
+
return phantom(Deposit.reified());
|
|
420
375
|
}
|
|
421
376
|
static get p() {
|
|
422
377
|
return Deposit.phantom();
|
|
423
378
|
}
|
|
424
379
|
static get bcs() {
|
|
425
|
-
return
|
|
426
|
-
coin_type:
|
|
427
|
-
reserve_array_index:
|
|
428
|
-
deposited_ctoken_amount:
|
|
429
|
-
market_value:
|
|
430
|
-
user_reward_manager_index:
|
|
431
|
-
attributed_borrow_value:
|
|
380
|
+
return bcs.struct("Deposit", {
|
|
381
|
+
coin_type: TypeName.bcs,
|
|
382
|
+
reserve_array_index: bcs.u64(),
|
|
383
|
+
deposited_ctoken_amount: bcs.u64(),
|
|
384
|
+
market_value: Decimal.bcs,
|
|
385
|
+
user_reward_manager_index: bcs.u64(),
|
|
386
|
+
attributed_borrow_value: Decimal.bcs,
|
|
432
387
|
});
|
|
433
388
|
}
|
|
434
389
|
static fromFields(fields) {
|
|
435
390
|
return Deposit.reified().new({
|
|
436
|
-
coinType:
|
|
437
|
-
reserveArrayIndex:
|
|
438
|
-
depositedCtokenAmount:
|
|
439
|
-
marketValue:
|
|
440
|
-
userRewardManagerIndex:
|
|
441
|
-
attributedBorrowValue:
|
|
391
|
+
coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
|
|
392
|
+
reserveArrayIndex: decodeFromFields("u64", fields.reserve_array_index),
|
|
393
|
+
depositedCtokenAmount: decodeFromFields("u64", fields.deposited_ctoken_amount),
|
|
394
|
+
marketValue: decodeFromFields(Decimal.reified(), fields.market_value),
|
|
395
|
+
userRewardManagerIndex: decodeFromFields("u64", fields.user_reward_manager_index),
|
|
396
|
+
attributedBorrowValue: decodeFromFields(Decimal.reified(), fields.attributed_borrow_value),
|
|
442
397
|
});
|
|
443
398
|
}
|
|
444
399
|
static fromFieldsWithTypes(item) {
|
|
@@ -446,12 +401,12 @@ class Deposit {
|
|
|
446
401
|
throw new Error("not a Deposit type");
|
|
447
402
|
}
|
|
448
403
|
return Deposit.reified().new({
|
|
449
|
-
coinType:
|
|
450
|
-
reserveArrayIndex:
|
|
451
|
-
depositedCtokenAmount:
|
|
452
|
-
marketValue:
|
|
453
|
-
userRewardManagerIndex:
|
|
454
|
-
attributedBorrowValue:
|
|
404
|
+
coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
|
|
405
|
+
reserveArrayIndex: decodeFromFieldsWithTypes("u64", item.fields.reserve_array_index),
|
|
406
|
+
depositedCtokenAmount: decodeFromFieldsWithTypes("u64", item.fields.deposited_ctoken_amount),
|
|
407
|
+
marketValue: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.market_value),
|
|
408
|
+
userRewardManagerIndex: decodeFromFieldsWithTypes("u64", item.fields.user_reward_manager_index),
|
|
409
|
+
attributedBorrowValue: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.attributed_borrow_value),
|
|
455
410
|
});
|
|
456
411
|
}
|
|
457
412
|
static fromBcs(data) {
|
|
@@ -472,12 +427,12 @@ class Deposit {
|
|
|
472
427
|
}
|
|
473
428
|
static fromJSONField(field) {
|
|
474
429
|
return Deposit.reified().new({
|
|
475
|
-
coinType:
|
|
476
|
-
reserveArrayIndex:
|
|
477
|
-
depositedCtokenAmount:
|
|
478
|
-
marketValue:
|
|
479
|
-
userRewardManagerIndex:
|
|
480
|
-
attributedBorrowValue:
|
|
430
|
+
coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
|
|
431
|
+
reserveArrayIndex: decodeFromJSONField("u64", field.reserveArrayIndex),
|
|
432
|
+
depositedCtokenAmount: decodeFromJSONField("u64", field.depositedCtokenAmount),
|
|
433
|
+
marketValue: decodeFromJSONField(Decimal.reified(), field.marketValue),
|
|
434
|
+
userRewardManagerIndex: decodeFromJSONField("u64", field.userRewardManagerIndex),
|
|
435
|
+
attributedBorrowValue: decodeFromJSONField(Decimal.reified(), field.attributedBorrowValue),
|
|
481
436
|
});
|
|
482
437
|
}
|
|
483
438
|
static fromJSON(json) {
|
|
@@ -500,7 +455,7 @@ class Deposit {
|
|
|
500
455
|
if (data.bcs.dataType !== "moveObject" || !isDeposit(data.bcs.type)) {
|
|
501
456
|
throw new Error(`object at is not a Deposit object`);
|
|
502
457
|
}
|
|
503
|
-
return Deposit.fromBcs((
|
|
458
|
+
return Deposit.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
504
459
|
}
|
|
505
460
|
if (data.content) {
|
|
506
461
|
return Deposit.fromSuiParsedData(data.content);
|
|
@@ -522,21 +477,20 @@ class Deposit {
|
|
|
522
477
|
});
|
|
523
478
|
}
|
|
524
479
|
}
|
|
525
|
-
|
|
526
|
-
Deposit.$typeName = `${index_1.PKG_V1}::obligation::Deposit`;
|
|
480
|
+
Deposit.$typeName = `${PKG_V1}::obligation::Deposit`;
|
|
527
481
|
Deposit.$numTypeParams = 0;
|
|
528
482
|
Deposit.$isPhantom = [];
|
|
529
483
|
/* ============================== DepositRecord =============================== */
|
|
530
|
-
function isDepositRecord(type) {
|
|
531
|
-
type =
|
|
532
|
-
return type === `${
|
|
484
|
+
export function isDepositRecord(type) {
|
|
485
|
+
type = compressSuiType(type);
|
|
486
|
+
return type === `${PKG_V1}::obligation::DepositRecord`;
|
|
533
487
|
}
|
|
534
|
-
class DepositRecord {
|
|
488
|
+
export class DepositRecord {
|
|
535
489
|
constructor(typeArgs, fields) {
|
|
536
490
|
this.__StructClass = true;
|
|
537
491
|
this.$typeName = DepositRecord.$typeName;
|
|
538
492
|
this.$isPhantom = DepositRecord.$isPhantom;
|
|
539
|
-
this.$fullTypeName =
|
|
493
|
+
this.$fullTypeName = composeSuiType(DepositRecord.$typeName, ...typeArgs);
|
|
540
494
|
this.$typeArgs = typeArgs;
|
|
541
495
|
this.coinType = fields.coinType;
|
|
542
496
|
this.reserveArrayIndex = fields.reserveArrayIndex;
|
|
@@ -548,7 +502,7 @@ class DepositRecord {
|
|
|
548
502
|
static reified() {
|
|
549
503
|
return {
|
|
550
504
|
typeName: DepositRecord.$typeName,
|
|
551
|
-
fullTypeName:
|
|
505
|
+
fullTypeName: composeSuiType(DepositRecord.$typeName, ...[]),
|
|
552
506
|
typeArgs: [],
|
|
553
507
|
isPhantom: DepositRecord.$isPhantom,
|
|
554
508
|
reifiedTypeArgs: [],
|
|
@@ -571,29 +525,29 @@ class DepositRecord {
|
|
|
571
525
|
return DepositRecord.reified();
|
|
572
526
|
}
|
|
573
527
|
static phantom() {
|
|
574
|
-
return
|
|
528
|
+
return phantom(DepositRecord.reified());
|
|
575
529
|
}
|
|
576
530
|
static get p() {
|
|
577
531
|
return DepositRecord.phantom();
|
|
578
532
|
}
|
|
579
533
|
static get bcs() {
|
|
580
|
-
return
|
|
581
|
-
coin_type:
|
|
582
|
-
reserve_array_index:
|
|
583
|
-
deposited_ctoken_amount:
|
|
584
|
-
market_value:
|
|
585
|
-
user_reward_manager_index:
|
|
586
|
-
attributed_borrow_value:
|
|
534
|
+
return bcs.struct("DepositRecord", {
|
|
535
|
+
coin_type: TypeName.bcs,
|
|
536
|
+
reserve_array_index: bcs.u64(),
|
|
537
|
+
deposited_ctoken_amount: bcs.u64(),
|
|
538
|
+
market_value: Decimal.bcs,
|
|
539
|
+
user_reward_manager_index: bcs.u64(),
|
|
540
|
+
attributed_borrow_value: Decimal.bcs,
|
|
587
541
|
});
|
|
588
542
|
}
|
|
589
543
|
static fromFields(fields) {
|
|
590
544
|
return DepositRecord.reified().new({
|
|
591
|
-
coinType:
|
|
592
|
-
reserveArrayIndex:
|
|
593
|
-
depositedCtokenAmount:
|
|
594
|
-
marketValue:
|
|
595
|
-
userRewardManagerIndex:
|
|
596
|
-
attributedBorrowValue:
|
|
545
|
+
coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
|
|
546
|
+
reserveArrayIndex: decodeFromFields("u64", fields.reserve_array_index),
|
|
547
|
+
depositedCtokenAmount: decodeFromFields("u64", fields.deposited_ctoken_amount),
|
|
548
|
+
marketValue: decodeFromFields(Decimal.reified(), fields.market_value),
|
|
549
|
+
userRewardManagerIndex: decodeFromFields("u64", fields.user_reward_manager_index),
|
|
550
|
+
attributedBorrowValue: decodeFromFields(Decimal.reified(), fields.attributed_borrow_value),
|
|
597
551
|
});
|
|
598
552
|
}
|
|
599
553
|
static fromFieldsWithTypes(item) {
|
|
@@ -601,12 +555,12 @@ class DepositRecord {
|
|
|
601
555
|
throw new Error("not a DepositRecord type");
|
|
602
556
|
}
|
|
603
557
|
return DepositRecord.reified().new({
|
|
604
|
-
coinType:
|
|
605
|
-
reserveArrayIndex:
|
|
606
|
-
depositedCtokenAmount:
|
|
607
|
-
marketValue:
|
|
608
|
-
userRewardManagerIndex:
|
|
609
|
-
attributedBorrowValue:
|
|
558
|
+
coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
|
|
559
|
+
reserveArrayIndex: decodeFromFieldsWithTypes("u64", item.fields.reserve_array_index),
|
|
560
|
+
depositedCtokenAmount: decodeFromFieldsWithTypes("u64", item.fields.deposited_ctoken_amount),
|
|
561
|
+
marketValue: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.market_value),
|
|
562
|
+
userRewardManagerIndex: decodeFromFieldsWithTypes("u64", item.fields.user_reward_manager_index),
|
|
563
|
+
attributedBorrowValue: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.attributed_borrow_value),
|
|
610
564
|
});
|
|
611
565
|
}
|
|
612
566
|
static fromBcs(data) {
|
|
@@ -627,12 +581,12 @@ class DepositRecord {
|
|
|
627
581
|
}
|
|
628
582
|
static fromJSONField(field) {
|
|
629
583
|
return DepositRecord.reified().new({
|
|
630
|
-
coinType:
|
|
631
|
-
reserveArrayIndex:
|
|
632
|
-
depositedCtokenAmount:
|
|
633
|
-
marketValue:
|
|
634
|
-
userRewardManagerIndex:
|
|
635
|
-
attributedBorrowValue:
|
|
584
|
+
coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
|
|
585
|
+
reserveArrayIndex: decodeFromJSONField("u64", field.reserveArrayIndex),
|
|
586
|
+
depositedCtokenAmount: decodeFromJSONField("u64", field.depositedCtokenAmount),
|
|
587
|
+
marketValue: decodeFromJSONField(Decimal.reified(), field.marketValue),
|
|
588
|
+
userRewardManagerIndex: decodeFromJSONField("u64", field.userRewardManagerIndex),
|
|
589
|
+
attributedBorrowValue: decodeFromJSONField(Decimal.reified(), field.attributedBorrowValue),
|
|
636
590
|
});
|
|
637
591
|
}
|
|
638
592
|
static fromJSON(json) {
|
|
@@ -656,7 +610,7 @@ class DepositRecord {
|
|
|
656
610
|
!isDepositRecord(data.bcs.type)) {
|
|
657
611
|
throw new Error(`object at is not a DepositRecord object`);
|
|
658
612
|
}
|
|
659
|
-
return DepositRecord.fromBcs((
|
|
613
|
+
return DepositRecord.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
660
614
|
}
|
|
661
615
|
if (data.content) {
|
|
662
616
|
return DepositRecord.fromSuiParsedData(data.content);
|
|
@@ -678,28 +632,27 @@ class DepositRecord {
|
|
|
678
632
|
});
|
|
679
633
|
}
|
|
680
634
|
}
|
|
681
|
-
|
|
682
|
-
DepositRecord.$typeName = `${index_1.PKG_V1}::obligation::DepositRecord`;
|
|
635
|
+
DepositRecord.$typeName = `${PKG_V1}::obligation::DepositRecord`;
|
|
683
636
|
DepositRecord.$numTypeParams = 0;
|
|
684
637
|
DepositRecord.$isPhantom = [];
|
|
685
638
|
/* ============================== ExistStaleOracles =============================== */
|
|
686
|
-
function isExistStaleOracles(type) {
|
|
687
|
-
type =
|
|
688
|
-
return type === `${
|
|
639
|
+
export function isExistStaleOracles(type) {
|
|
640
|
+
type = compressSuiType(type);
|
|
641
|
+
return type === `${PKG_V11}::obligation::ExistStaleOracles`;
|
|
689
642
|
}
|
|
690
|
-
class ExistStaleOracles {
|
|
643
|
+
export class ExistStaleOracles {
|
|
691
644
|
constructor(typeArgs, fields) {
|
|
692
645
|
this.__StructClass = true;
|
|
693
646
|
this.$typeName = ExistStaleOracles.$typeName;
|
|
694
647
|
this.$isPhantom = ExistStaleOracles.$isPhantom;
|
|
695
|
-
this.$fullTypeName =
|
|
648
|
+
this.$fullTypeName = composeSuiType(ExistStaleOracles.$typeName, ...typeArgs);
|
|
696
649
|
this.$typeArgs = typeArgs;
|
|
697
650
|
this.dummyField = fields.dummyField;
|
|
698
651
|
}
|
|
699
652
|
static reified() {
|
|
700
653
|
return {
|
|
701
654
|
typeName: ExistStaleOracles.$typeName,
|
|
702
|
-
fullTypeName:
|
|
655
|
+
fullTypeName: composeSuiType(ExistStaleOracles.$typeName, ...[]),
|
|
703
656
|
typeArgs: [],
|
|
704
657
|
isPhantom: ExistStaleOracles.$isPhantom,
|
|
705
658
|
reifiedTypeArgs: [],
|
|
@@ -722,19 +675,19 @@ class ExistStaleOracles {
|
|
|
722
675
|
return ExistStaleOracles.reified();
|
|
723
676
|
}
|
|
724
677
|
static phantom() {
|
|
725
|
-
return
|
|
678
|
+
return phantom(ExistStaleOracles.reified());
|
|
726
679
|
}
|
|
727
680
|
static get p() {
|
|
728
681
|
return ExistStaleOracles.phantom();
|
|
729
682
|
}
|
|
730
683
|
static get bcs() {
|
|
731
|
-
return
|
|
732
|
-
dummy_field:
|
|
684
|
+
return bcs.struct("ExistStaleOracles", {
|
|
685
|
+
dummy_field: bcs.bool(),
|
|
733
686
|
});
|
|
734
687
|
}
|
|
735
688
|
static fromFields(fields) {
|
|
736
689
|
return ExistStaleOracles.reified().new({
|
|
737
|
-
dummyField:
|
|
690
|
+
dummyField: decodeFromFields("bool", fields.dummy_field),
|
|
738
691
|
});
|
|
739
692
|
}
|
|
740
693
|
static fromFieldsWithTypes(item) {
|
|
@@ -742,7 +695,7 @@ class ExistStaleOracles {
|
|
|
742
695
|
throw new Error("not a ExistStaleOracles type");
|
|
743
696
|
}
|
|
744
697
|
return ExistStaleOracles.reified().new({
|
|
745
|
-
dummyField:
|
|
698
|
+
dummyField: decodeFromFieldsWithTypes("bool", item.fields.dummy_field),
|
|
746
699
|
});
|
|
747
700
|
}
|
|
748
701
|
static fromBcs(data) {
|
|
@@ -758,7 +711,7 @@ class ExistStaleOracles {
|
|
|
758
711
|
}
|
|
759
712
|
static fromJSONField(field) {
|
|
760
713
|
return ExistStaleOracles.reified().new({
|
|
761
|
-
dummyField:
|
|
714
|
+
dummyField: decodeFromJSONField("bool", field.dummyField),
|
|
762
715
|
});
|
|
763
716
|
}
|
|
764
717
|
static fromJSON(json) {
|
|
@@ -782,7 +735,7 @@ class ExistStaleOracles {
|
|
|
782
735
|
!isExistStaleOracles(data.bcs.type)) {
|
|
783
736
|
throw new Error(`object at is not a ExistStaleOracles object`);
|
|
784
737
|
}
|
|
785
|
-
return ExistStaleOracles.fromBcs((
|
|
738
|
+
return ExistStaleOracles.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
786
739
|
}
|
|
787
740
|
if (data.content) {
|
|
788
741
|
return ExistStaleOracles.fromSuiParsedData(data.content);
|
|
@@ -804,21 +757,20 @@ class ExistStaleOracles {
|
|
|
804
757
|
});
|
|
805
758
|
}
|
|
806
759
|
}
|
|
807
|
-
|
|
808
|
-
ExistStaleOracles.$typeName = `${index_1.PKG_V11}::obligation::ExistStaleOracles`;
|
|
760
|
+
ExistStaleOracles.$typeName = `${PKG_V11}::obligation::ExistStaleOracles`;
|
|
809
761
|
ExistStaleOracles.$numTypeParams = 0;
|
|
810
762
|
ExistStaleOracles.$isPhantom = [];
|
|
811
763
|
/* ============================== Obligation =============================== */
|
|
812
|
-
function isObligation(type) {
|
|
813
|
-
type =
|
|
814
|
-
return type.startsWith(`${
|
|
764
|
+
export function isObligation(type) {
|
|
765
|
+
type = compressSuiType(type);
|
|
766
|
+
return type.startsWith(`${PKG_V1}::obligation::Obligation` + "<");
|
|
815
767
|
}
|
|
816
|
-
class Obligation {
|
|
768
|
+
export class Obligation {
|
|
817
769
|
constructor(typeArgs, fields) {
|
|
818
770
|
this.__StructClass = true;
|
|
819
771
|
this.$typeName = Obligation.$typeName;
|
|
820
772
|
this.$isPhantom = Obligation.$isPhantom;
|
|
821
|
-
this.$fullTypeName =
|
|
773
|
+
this.$fullTypeName = composeSuiType(Obligation.$typeName, ...typeArgs);
|
|
822
774
|
this.$typeArgs = typeArgs;
|
|
823
775
|
this.id = fields.id;
|
|
824
776
|
this.lendingMarketId = fields.lendingMarketId;
|
|
@@ -840,8 +792,8 @@ class Obligation {
|
|
|
840
792
|
static reified(P) {
|
|
841
793
|
return {
|
|
842
794
|
typeName: Obligation.$typeName,
|
|
843
|
-
fullTypeName:
|
|
844
|
-
typeArgs: [
|
|
795
|
+
fullTypeName: composeSuiType(Obligation.$typeName, ...[extractType(P)]),
|
|
796
|
+
typeArgs: [extractType(P)],
|
|
845
797
|
isPhantom: Obligation.$isPhantom,
|
|
846
798
|
reifiedTypeArgs: [P],
|
|
847
799
|
fromFields: (fields) => Obligation.fromFields(P, fields),
|
|
@@ -854,7 +806,7 @@ class Obligation {
|
|
|
854
806
|
fromSuiObjectData: (content) => Obligation.fromSuiObjectData(P, content),
|
|
855
807
|
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Obligation.fetch(client, P, id); }),
|
|
856
808
|
new: (fields) => {
|
|
857
|
-
return new Obligation([
|
|
809
|
+
return new Obligation([extractType(P)], fields);
|
|
858
810
|
},
|
|
859
811
|
kind: "StructClassReified",
|
|
860
812
|
};
|
|
@@ -863,70 +815,70 @@ class Obligation {
|
|
|
863
815
|
return Obligation.reified;
|
|
864
816
|
}
|
|
865
817
|
static phantom(P) {
|
|
866
|
-
return
|
|
818
|
+
return phantom(Obligation.reified(P));
|
|
867
819
|
}
|
|
868
820
|
static get p() {
|
|
869
821
|
return Obligation.phantom;
|
|
870
822
|
}
|
|
871
823
|
static get bcs() {
|
|
872
|
-
return
|
|
873
|
-
id:
|
|
874
|
-
lending_market_id:
|
|
875
|
-
deposits:
|
|
876
|
-
borrows:
|
|
877
|
-
deposited_value_usd:
|
|
878
|
-
allowed_borrow_value_usd:
|
|
879
|
-
unhealthy_borrow_value_usd:
|
|
880
|
-
super_unhealthy_borrow_value_usd:
|
|
881
|
-
unweighted_borrowed_value_usd:
|
|
882
|
-
weighted_borrowed_value_usd:
|
|
883
|
-
weighted_borrowed_value_upper_bound_usd:
|
|
884
|
-
borrowing_isolated_asset:
|
|
885
|
-
user_reward_managers:
|
|
886
|
-
bad_debt_usd:
|
|
887
|
-
closable:
|
|
824
|
+
return bcs.struct("Obligation", {
|
|
825
|
+
id: UID.bcs,
|
|
826
|
+
lending_market_id: ID.bcs,
|
|
827
|
+
deposits: bcs.vector(Deposit.bcs),
|
|
828
|
+
borrows: bcs.vector(Borrow.bcs),
|
|
829
|
+
deposited_value_usd: Decimal.bcs,
|
|
830
|
+
allowed_borrow_value_usd: Decimal.bcs,
|
|
831
|
+
unhealthy_borrow_value_usd: Decimal.bcs,
|
|
832
|
+
super_unhealthy_borrow_value_usd: Decimal.bcs,
|
|
833
|
+
unweighted_borrowed_value_usd: Decimal.bcs,
|
|
834
|
+
weighted_borrowed_value_usd: Decimal.bcs,
|
|
835
|
+
weighted_borrowed_value_upper_bound_usd: Decimal.bcs,
|
|
836
|
+
borrowing_isolated_asset: bcs.bool(),
|
|
837
|
+
user_reward_managers: bcs.vector(UserRewardManager.bcs),
|
|
838
|
+
bad_debt_usd: Decimal.bcs,
|
|
839
|
+
closable: bcs.bool(),
|
|
888
840
|
});
|
|
889
841
|
}
|
|
890
842
|
static fromFields(typeArg, fields) {
|
|
891
843
|
return Obligation.reified(typeArg).new({
|
|
892
|
-
id:
|
|
893
|
-
lendingMarketId:
|
|
894
|
-
deposits:
|
|
895
|
-
borrows:
|
|
896
|
-
depositedValueUsd:
|
|
897
|
-
allowedBorrowValueUsd:
|
|
898
|
-
unhealthyBorrowValueUsd:
|
|
899
|
-
superUnhealthyBorrowValueUsd:
|
|
900
|
-
unweightedBorrowedValueUsd:
|
|
901
|
-
weightedBorrowedValueUsd:
|
|
902
|
-
weightedBorrowedValueUpperBoundUsd:
|
|
903
|
-
borrowingIsolatedAsset:
|
|
904
|
-
userRewardManagers:
|
|
905
|
-
badDebtUsd:
|
|
906
|
-
closable:
|
|
844
|
+
id: decodeFromFields(UID.reified(), fields.id),
|
|
845
|
+
lendingMarketId: decodeFromFields(ID.reified(), fields.lending_market_id),
|
|
846
|
+
deposits: decodeFromFields(reified.vector(Deposit.reified()), fields.deposits),
|
|
847
|
+
borrows: decodeFromFields(reified.vector(Borrow.reified()), fields.borrows),
|
|
848
|
+
depositedValueUsd: decodeFromFields(Decimal.reified(), fields.deposited_value_usd),
|
|
849
|
+
allowedBorrowValueUsd: decodeFromFields(Decimal.reified(), fields.allowed_borrow_value_usd),
|
|
850
|
+
unhealthyBorrowValueUsd: decodeFromFields(Decimal.reified(), fields.unhealthy_borrow_value_usd),
|
|
851
|
+
superUnhealthyBorrowValueUsd: decodeFromFields(Decimal.reified(), fields.super_unhealthy_borrow_value_usd),
|
|
852
|
+
unweightedBorrowedValueUsd: decodeFromFields(Decimal.reified(), fields.unweighted_borrowed_value_usd),
|
|
853
|
+
weightedBorrowedValueUsd: decodeFromFields(Decimal.reified(), fields.weighted_borrowed_value_usd),
|
|
854
|
+
weightedBorrowedValueUpperBoundUsd: decodeFromFields(Decimal.reified(), fields.weighted_borrowed_value_upper_bound_usd),
|
|
855
|
+
borrowingIsolatedAsset: decodeFromFields("bool", fields.borrowing_isolated_asset),
|
|
856
|
+
userRewardManagers: decodeFromFields(reified.vector(UserRewardManager.reified()), fields.user_reward_managers),
|
|
857
|
+
badDebtUsd: decodeFromFields(Decimal.reified(), fields.bad_debt_usd),
|
|
858
|
+
closable: decodeFromFields("bool", fields.closable),
|
|
907
859
|
});
|
|
908
860
|
}
|
|
909
861
|
static fromFieldsWithTypes(typeArg, item) {
|
|
910
862
|
if (!isObligation(item.type)) {
|
|
911
863
|
throw new Error("not a Obligation type");
|
|
912
864
|
}
|
|
913
|
-
|
|
865
|
+
assertFieldsWithTypesArgsMatch(item, [typeArg]);
|
|
914
866
|
return Obligation.reified(typeArg).new({
|
|
915
|
-
id:
|
|
916
|
-
lendingMarketId:
|
|
917
|
-
deposits:
|
|
918
|
-
borrows:
|
|
919
|
-
depositedValueUsd:
|
|
920
|
-
allowedBorrowValueUsd:
|
|
921
|
-
unhealthyBorrowValueUsd:
|
|
922
|
-
superUnhealthyBorrowValueUsd:
|
|
923
|
-
unweightedBorrowedValueUsd:
|
|
924
|
-
weightedBorrowedValueUsd:
|
|
925
|
-
weightedBorrowedValueUpperBoundUsd:
|
|
926
|
-
borrowingIsolatedAsset:
|
|
927
|
-
userRewardManagers:
|
|
928
|
-
badDebtUsd:
|
|
929
|
-
closable:
|
|
867
|
+
id: decodeFromFieldsWithTypes(UID.reified(), item.fields.id),
|
|
868
|
+
lendingMarketId: decodeFromFieldsWithTypes(ID.reified(), item.fields.lending_market_id),
|
|
869
|
+
deposits: decodeFromFieldsWithTypes(reified.vector(Deposit.reified()), item.fields.deposits),
|
|
870
|
+
borrows: decodeFromFieldsWithTypes(reified.vector(Borrow.reified()), item.fields.borrows),
|
|
871
|
+
depositedValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.deposited_value_usd),
|
|
872
|
+
allowedBorrowValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.allowed_borrow_value_usd),
|
|
873
|
+
unhealthyBorrowValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.unhealthy_borrow_value_usd),
|
|
874
|
+
superUnhealthyBorrowValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.super_unhealthy_borrow_value_usd),
|
|
875
|
+
unweightedBorrowedValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.unweighted_borrowed_value_usd),
|
|
876
|
+
weightedBorrowedValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.weighted_borrowed_value_usd),
|
|
877
|
+
weightedBorrowedValueUpperBoundUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.weighted_borrowed_value_upper_bound_usd),
|
|
878
|
+
borrowingIsolatedAsset: decodeFromFieldsWithTypes("bool", item.fields.borrowing_isolated_asset),
|
|
879
|
+
userRewardManagers: decodeFromFieldsWithTypes(reified.vector(UserRewardManager.reified()), item.fields.user_reward_managers),
|
|
880
|
+
badDebtUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.bad_debt_usd),
|
|
881
|
+
closable: decodeFromFieldsWithTypes("bool", item.fields.closable),
|
|
930
882
|
});
|
|
931
883
|
}
|
|
932
884
|
static fromBcs(typeArg, data) {
|
|
@@ -936,8 +888,8 @@ class Obligation {
|
|
|
936
888
|
return {
|
|
937
889
|
id: this.id,
|
|
938
890
|
lendingMarketId: this.lendingMarketId,
|
|
939
|
-
deposits:
|
|
940
|
-
borrows:
|
|
891
|
+
deposits: fieldToJSON(`vector<${Deposit.$typeName}>`, this.deposits),
|
|
892
|
+
borrows: fieldToJSON(`vector<${Borrow.$typeName}>`, this.borrows),
|
|
941
893
|
depositedValueUsd: this.depositedValueUsd.toJSONField(),
|
|
942
894
|
allowedBorrowValueUsd: this.allowedBorrowValueUsd.toJSONField(),
|
|
943
895
|
unhealthyBorrowValueUsd: this.unhealthyBorrowValueUsd.toJSONField(),
|
|
@@ -946,7 +898,7 @@ class Obligation {
|
|
|
946
898
|
weightedBorrowedValueUsd: this.weightedBorrowedValueUsd.toJSONField(),
|
|
947
899
|
weightedBorrowedValueUpperBoundUsd: this.weightedBorrowedValueUpperBoundUsd.toJSONField(),
|
|
948
900
|
borrowingIsolatedAsset: this.borrowingIsolatedAsset,
|
|
949
|
-
userRewardManagers:
|
|
901
|
+
userRewardManagers: fieldToJSON(`vector<${UserRewardManager.$typeName}>`, this.userRewardManagers),
|
|
950
902
|
badDebtUsd: this.badDebtUsd.toJSONField(),
|
|
951
903
|
closable: this.closable,
|
|
952
904
|
};
|
|
@@ -956,28 +908,28 @@ class Obligation {
|
|
|
956
908
|
}
|
|
957
909
|
static fromJSONField(typeArg, field) {
|
|
958
910
|
return Obligation.reified(typeArg).new({
|
|
959
|
-
id:
|
|
960
|
-
lendingMarketId:
|
|
961
|
-
deposits:
|
|
962
|
-
borrows:
|
|
963
|
-
depositedValueUsd:
|
|
964
|
-
allowedBorrowValueUsd:
|
|
965
|
-
unhealthyBorrowValueUsd:
|
|
966
|
-
superUnhealthyBorrowValueUsd:
|
|
967
|
-
unweightedBorrowedValueUsd:
|
|
968
|
-
weightedBorrowedValueUsd:
|
|
969
|
-
weightedBorrowedValueUpperBoundUsd:
|
|
970
|
-
borrowingIsolatedAsset:
|
|
971
|
-
userRewardManagers:
|
|
972
|
-
badDebtUsd:
|
|
973
|
-
closable:
|
|
911
|
+
id: decodeFromJSONField(UID.reified(), field.id),
|
|
912
|
+
lendingMarketId: decodeFromJSONField(ID.reified(), field.lendingMarketId),
|
|
913
|
+
deposits: decodeFromJSONField(reified.vector(Deposit.reified()), field.deposits),
|
|
914
|
+
borrows: decodeFromJSONField(reified.vector(Borrow.reified()), field.borrows),
|
|
915
|
+
depositedValueUsd: decodeFromJSONField(Decimal.reified(), field.depositedValueUsd),
|
|
916
|
+
allowedBorrowValueUsd: decodeFromJSONField(Decimal.reified(), field.allowedBorrowValueUsd),
|
|
917
|
+
unhealthyBorrowValueUsd: decodeFromJSONField(Decimal.reified(), field.unhealthyBorrowValueUsd),
|
|
918
|
+
superUnhealthyBorrowValueUsd: decodeFromJSONField(Decimal.reified(), field.superUnhealthyBorrowValueUsd),
|
|
919
|
+
unweightedBorrowedValueUsd: decodeFromJSONField(Decimal.reified(), field.unweightedBorrowedValueUsd),
|
|
920
|
+
weightedBorrowedValueUsd: decodeFromJSONField(Decimal.reified(), field.weightedBorrowedValueUsd),
|
|
921
|
+
weightedBorrowedValueUpperBoundUsd: decodeFromJSONField(Decimal.reified(), field.weightedBorrowedValueUpperBoundUsd),
|
|
922
|
+
borrowingIsolatedAsset: decodeFromJSONField("bool", field.borrowingIsolatedAsset),
|
|
923
|
+
userRewardManagers: decodeFromJSONField(reified.vector(UserRewardManager.reified()), field.userRewardManagers),
|
|
924
|
+
badDebtUsd: decodeFromJSONField(Decimal.reified(), field.badDebtUsd),
|
|
925
|
+
closable: decodeFromJSONField("bool", field.closable),
|
|
974
926
|
});
|
|
975
927
|
}
|
|
976
928
|
static fromJSON(typeArg, json) {
|
|
977
929
|
if (json.$typeName !== Obligation.$typeName) {
|
|
978
930
|
throw new Error("not a WithTwoGenerics json object");
|
|
979
931
|
}
|
|
980
|
-
|
|
932
|
+
assertReifiedTypeArgsMatch(composeSuiType(Obligation.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
|
|
981
933
|
return Obligation.fromJSONField(typeArg, json);
|
|
982
934
|
}
|
|
983
935
|
static fromSuiParsedData(typeArg, content) {
|
|
@@ -994,16 +946,16 @@ class Obligation {
|
|
|
994
946
|
if (data.bcs.dataType !== "moveObject" || !isObligation(data.bcs.type)) {
|
|
995
947
|
throw new Error(`object at is not a Obligation object`);
|
|
996
948
|
}
|
|
997
|
-
const gotTypeArgs =
|
|
949
|
+
const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
|
|
998
950
|
if (gotTypeArgs.length !== 1) {
|
|
999
951
|
throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
|
|
1000
952
|
}
|
|
1001
|
-
const gotTypeArg =
|
|
1002
|
-
const expectedTypeArg =
|
|
1003
|
-
if (gotTypeArg !==
|
|
953
|
+
const gotTypeArg = compressSuiType(gotTypeArgs[0]);
|
|
954
|
+
const expectedTypeArg = compressSuiType(extractType(typeArg));
|
|
955
|
+
if (gotTypeArg !== compressSuiType(extractType(typeArg))) {
|
|
1004
956
|
throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
|
|
1005
957
|
}
|
|
1006
|
-
return Obligation.fromBcs(typeArg, (
|
|
958
|
+
return Obligation.fromBcs(typeArg, fromBase64(data.bcs.bcsBytes));
|
|
1007
959
|
}
|
|
1008
960
|
if (data.content) {
|
|
1009
961
|
return Obligation.fromSuiParsedData(typeArg, data.content);
|
|
@@ -1025,21 +977,20 @@ class Obligation {
|
|
|
1025
977
|
});
|
|
1026
978
|
}
|
|
1027
979
|
}
|
|
1028
|
-
|
|
1029
|
-
Obligation.$typeName = `${index_1.PKG_V1}::obligation::Obligation`;
|
|
980
|
+
Obligation.$typeName = `${PKG_V1}::obligation::Obligation`;
|
|
1030
981
|
Obligation.$numTypeParams = 1;
|
|
1031
982
|
Obligation.$isPhantom = [true];
|
|
1032
983
|
/* ============================== ObligationDataEvent =============================== */
|
|
1033
|
-
function isObligationDataEvent(type) {
|
|
1034
|
-
type =
|
|
1035
|
-
return type === `${
|
|
984
|
+
export function isObligationDataEvent(type) {
|
|
985
|
+
type = compressSuiType(type);
|
|
986
|
+
return type === `${PKG_V1}::obligation::ObligationDataEvent`;
|
|
1036
987
|
}
|
|
1037
|
-
class ObligationDataEvent {
|
|
988
|
+
export class ObligationDataEvent {
|
|
1038
989
|
constructor(typeArgs, fields) {
|
|
1039
990
|
this.__StructClass = true;
|
|
1040
991
|
this.$typeName = ObligationDataEvent.$typeName;
|
|
1041
992
|
this.$isPhantom = ObligationDataEvent.$isPhantom;
|
|
1042
|
-
this.$fullTypeName =
|
|
993
|
+
this.$fullTypeName = composeSuiType(ObligationDataEvent.$typeName, ...typeArgs);
|
|
1043
994
|
this.$typeArgs = typeArgs;
|
|
1044
995
|
this.lendingMarketId = fields.lendingMarketId;
|
|
1045
996
|
this.obligationId = fields.obligationId;
|
|
@@ -1060,7 +1011,7 @@ class ObligationDataEvent {
|
|
|
1060
1011
|
static reified() {
|
|
1061
1012
|
return {
|
|
1062
1013
|
typeName: ObligationDataEvent.$typeName,
|
|
1063
|
-
fullTypeName:
|
|
1014
|
+
fullTypeName: composeSuiType(ObligationDataEvent.$typeName, ...[]),
|
|
1064
1015
|
typeArgs: [],
|
|
1065
1016
|
isPhantom: ObligationDataEvent.$isPhantom,
|
|
1066
1017
|
reifiedTypeArgs: [],
|
|
@@ -1083,55 +1034,55 @@ class ObligationDataEvent {
|
|
|
1083
1034
|
return ObligationDataEvent.reified();
|
|
1084
1035
|
}
|
|
1085
1036
|
static phantom() {
|
|
1086
|
-
return
|
|
1037
|
+
return phantom(ObligationDataEvent.reified());
|
|
1087
1038
|
}
|
|
1088
1039
|
static get p() {
|
|
1089
1040
|
return ObligationDataEvent.phantom();
|
|
1090
1041
|
}
|
|
1091
1042
|
static get bcs() {
|
|
1092
|
-
return
|
|
1093
|
-
lending_market_id:
|
|
1043
|
+
return bcs.struct("ObligationDataEvent", {
|
|
1044
|
+
lending_market_id: bcs
|
|
1094
1045
|
.bytes(32)
|
|
1095
1046
|
.transform({
|
|
1096
|
-
input: (val) => (
|
|
1097
|
-
output: (val) => (
|
|
1047
|
+
input: (val) => fromHex(val),
|
|
1048
|
+
output: (val) => toHex(val),
|
|
1098
1049
|
}),
|
|
1099
|
-
obligation_id:
|
|
1050
|
+
obligation_id: bcs
|
|
1100
1051
|
.bytes(32)
|
|
1101
1052
|
.transform({
|
|
1102
|
-
input: (val) => (
|
|
1103
|
-
output: (val) => (
|
|
1053
|
+
input: (val) => fromHex(val),
|
|
1054
|
+
output: (val) => toHex(val),
|
|
1104
1055
|
}),
|
|
1105
|
-
deposits:
|
|
1106
|
-
borrows:
|
|
1107
|
-
deposited_value_usd:
|
|
1108
|
-
allowed_borrow_value_usd:
|
|
1109
|
-
unhealthy_borrow_value_usd:
|
|
1110
|
-
super_unhealthy_borrow_value_usd:
|
|
1111
|
-
unweighted_borrowed_value_usd:
|
|
1112
|
-
weighted_borrowed_value_usd:
|
|
1113
|
-
weighted_borrowed_value_upper_bound_usd:
|
|
1114
|
-
borrowing_isolated_asset:
|
|
1115
|
-
bad_debt_usd:
|
|
1116
|
-
closable:
|
|
1056
|
+
deposits: bcs.vector(DepositRecord.bcs),
|
|
1057
|
+
borrows: bcs.vector(BorrowRecord.bcs),
|
|
1058
|
+
deposited_value_usd: Decimal.bcs,
|
|
1059
|
+
allowed_borrow_value_usd: Decimal.bcs,
|
|
1060
|
+
unhealthy_borrow_value_usd: Decimal.bcs,
|
|
1061
|
+
super_unhealthy_borrow_value_usd: Decimal.bcs,
|
|
1062
|
+
unweighted_borrowed_value_usd: Decimal.bcs,
|
|
1063
|
+
weighted_borrowed_value_usd: Decimal.bcs,
|
|
1064
|
+
weighted_borrowed_value_upper_bound_usd: Decimal.bcs,
|
|
1065
|
+
borrowing_isolated_asset: bcs.bool(),
|
|
1066
|
+
bad_debt_usd: Decimal.bcs,
|
|
1067
|
+
closable: bcs.bool(),
|
|
1117
1068
|
});
|
|
1118
1069
|
}
|
|
1119
1070
|
static fromFields(fields) {
|
|
1120
1071
|
return ObligationDataEvent.reified().new({
|
|
1121
|
-
lendingMarketId:
|
|
1122
|
-
obligationId:
|
|
1123
|
-
deposits:
|
|
1124
|
-
borrows:
|
|
1125
|
-
depositedValueUsd:
|
|
1126
|
-
allowedBorrowValueUsd:
|
|
1127
|
-
unhealthyBorrowValueUsd:
|
|
1128
|
-
superUnhealthyBorrowValueUsd:
|
|
1129
|
-
unweightedBorrowedValueUsd:
|
|
1130
|
-
weightedBorrowedValueUsd:
|
|
1131
|
-
weightedBorrowedValueUpperBoundUsd:
|
|
1132
|
-
borrowingIsolatedAsset:
|
|
1133
|
-
badDebtUsd:
|
|
1134
|
-
closable:
|
|
1072
|
+
lendingMarketId: decodeFromFields("address", fields.lending_market_id),
|
|
1073
|
+
obligationId: decodeFromFields("address", fields.obligation_id),
|
|
1074
|
+
deposits: decodeFromFields(reified.vector(DepositRecord.reified()), fields.deposits),
|
|
1075
|
+
borrows: decodeFromFields(reified.vector(BorrowRecord.reified()), fields.borrows),
|
|
1076
|
+
depositedValueUsd: decodeFromFields(Decimal.reified(), fields.deposited_value_usd),
|
|
1077
|
+
allowedBorrowValueUsd: decodeFromFields(Decimal.reified(), fields.allowed_borrow_value_usd),
|
|
1078
|
+
unhealthyBorrowValueUsd: decodeFromFields(Decimal.reified(), fields.unhealthy_borrow_value_usd),
|
|
1079
|
+
superUnhealthyBorrowValueUsd: decodeFromFields(Decimal.reified(), fields.super_unhealthy_borrow_value_usd),
|
|
1080
|
+
unweightedBorrowedValueUsd: decodeFromFields(Decimal.reified(), fields.unweighted_borrowed_value_usd),
|
|
1081
|
+
weightedBorrowedValueUsd: decodeFromFields(Decimal.reified(), fields.weighted_borrowed_value_usd),
|
|
1082
|
+
weightedBorrowedValueUpperBoundUsd: decodeFromFields(Decimal.reified(), fields.weighted_borrowed_value_upper_bound_usd),
|
|
1083
|
+
borrowingIsolatedAsset: decodeFromFields("bool", fields.borrowing_isolated_asset),
|
|
1084
|
+
badDebtUsd: decodeFromFields(Decimal.reified(), fields.bad_debt_usd),
|
|
1085
|
+
closable: decodeFromFields("bool", fields.closable),
|
|
1135
1086
|
});
|
|
1136
1087
|
}
|
|
1137
1088
|
static fromFieldsWithTypes(item) {
|
|
@@ -1139,20 +1090,20 @@ class ObligationDataEvent {
|
|
|
1139
1090
|
throw new Error("not a ObligationDataEvent type");
|
|
1140
1091
|
}
|
|
1141
1092
|
return ObligationDataEvent.reified().new({
|
|
1142
|
-
lendingMarketId:
|
|
1143
|
-
obligationId:
|
|
1144
|
-
deposits:
|
|
1145
|
-
borrows:
|
|
1146
|
-
depositedValueUsd:
|
|
1147
|
-
allowedBorrowValueUsd:
|
|
1148
|
-
unhealthyBorrowValueUsd:
|
|
1149
|
-
superUnhealthyBorrowValueUsd:
|
|
1150
|
-
unweightedBorrowedValueUsd:
|
|
1151
|
-
weightedBorrowedValueUsd:
|
|
1152
|
-
weightedBorrowedValueUpperBoundUsd:
|
|
1153
|
-
borrowingIsolatedAsset:
|
|
1154
|
-
badDebtUsd:
|
|
1155
|
-
closable:
|
|
1093
|
+
lendingMarketId: decodeFromFieldsWithTypes("address", item.fields.lending_market_id),
|
|
1094
|
+
obligationId: decodeFromFieldsWithTypes("address", item.fields.obligation_id),
|
|
1095
|
+
deposits: decodeFromFieldsWithTypes(reified.vector(DepositRecord.reified()), item.fields.deposits),
|
|
1096
|
+
borrows: decodeFromFieldsWithTypes(reified.vector(BorrowRecord.reified()), item.fields.borrows),
|
|
1097
|
+
depositedValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.deposited_value_usd),
|
|
1098
|
+
allowedBorrowValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.allowed_borrow_value_usd),
|
|
1099
|
+
unhealthyBorrowValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.unhealthy_borrow_value_usd),
|
|
1100
|
+
superUnhealthyBorrowValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.super_unhealthy_borrow_value_usd),
|
|
1101
|
+
unweightedBorrowedValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.unweighted_borrowed_value_usd),
|
|
1102
|
+
weightedBorrowedValueUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.weighted_borrowed_value_usd),
|
|
1103
|
+
weightedBorrowedValueUpperBoundUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.weighted_borrowed_value_upper_bound_usd),
|
|
1104
|
+
borrowingIsolatedAsset: decodeFromFieldsWithTypes("bool", item.fields.borrowing_isolated_asset),
|
|
1105
|
+
badDebtUsd: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.bad_debt_usd),
|
|
1106
|
+
closable: decodeFromFieldsWithTypes("bool", item.fields.closable),
|
|
1156
1107
|
});
|
|
1157
1108
|
}
|
|
1158
1109
|
static fromBcs(data) {
|
|
@@ -1162,8 +1113,8 @@ class ObligationDataEvent {
|
|
|
1162
1113
|
return {
|
|
1163
1114
|
lendingMarketId: this.lendingMarketId,
|
|
1164
1115
|
obligationId: this.obligationId,
|
|
1165
|
-
deposits:
|
|
1166
|
-
borrows:
|
|
1116
|
+
deposits: fieldToJSON(`vector<${DepositRecord.$typeName}>`, this.deposits),
|
|
1117
|
+
borrows: fieldToJSON(`vector<${BorrowRecord.$typeName}>`, this.borrows),
|
|
1167
1118
|
depositedValueUsd: this.depositedValueUsd.toJSONField(),
|
|
1168
1119
|
allowedBorrowValueUsd: this.allowedBorrowValueUsd.toJSONField(),
|
|
1169
1120
|
unhealthyBorrowValueUsd: this.unhealthyBorrowValueUsd.toJSONField(),
|
|
@@ -1181,20 +1132,20 @@ class ObligationDataEvent {
|
|
|
1181
1132
|
}
|
|
1182
1133
|
static fromJSONField(field) {
|
|
1183
1134
|
return ObligationDataEvent.reified().new({
|
|
1184
|
-
lendingMarketId:
|
|
1185
|
-
obligationId:
|
|
1186
|
-
deposits:
|
|
1187
|
-
borrows:
|
|
1188
|
-
depositedValueUsd:
|
|
1189
|
-
allowedBorrowValueUsd:
|
|
1190
|
-
unhealthyBorrowValueUsd:
|
|
1191
|
-
superUnhealthyBorrowValueUsd:
|
|
1192
|
-
unweightedBorrowedValueUsd:
|
|
1193
|
-
weightedBorrowedValueUsd:
|
|
1194
|
-
weightedBorrowedValueUpperBoundUsd:
|
|
1195
|
-
borrowingIsolatedAsset:
|
|
1196
|
-
badDebtUsd:
|
|
1197
|
-
closable:
|
|
1135
|
+
lendingMarketId: decodeFromJSONField("address", field.lendingMarketId),
|
|
1136
|
+
obligationId: decodeFromJSONField("address", field.obligationId),
|
|
1137
|
+
deposits: decodeFromJSONField(reified.vector(DepositRecord.reified()), field.deposits),
|
|
1138
|
+
borrows: decodeFromJSONField(reified.vector(BorrowRecord.reified()), field.borrows),
|
|
1139
|
+
depositedValueUsd: decodeFromJSONField(Decimal.reified(), field.depositedValueUsd),
|
|
1140
|
+
allowedBorrowValueUsd: decodeFromJSONField(Decimal.reified(), field.allowedBorrowValueUsd),
|
|
1141
|
+
unhealthyBorrowValueUsd: decodeFromJSONField(Decimal.reified(), field.unhealthyBorrowValueUsd),
|
|
1142
|
+
superUnhealthyBorrowValueUsd: decodeFromJSONField(Decimal.reified(), field.superUnhealthyBorrowValueUsd),
|
|
1143
|
+
unweightedBorrowedValueUsd: decodeFromJSONField(Decimal.reified(), field.unweightedBorrowedValueUsd),
|
|
1144
|
+
weightedBorrowedValueUsd: decodeFromJSONField(Decimal.reified(), field.weightedBorrowedValueUsd),
|
|
1145
|
+
weightedBorrowedValueUpperBoundUsd: decodeFromJSONField(Decimal.reified(), field.weightedBorrowedValueUpperBoundUsd),
|
|
1146
|
+
borrowingIsolatedAsset: decodeFromJSONField("bool", field.borrowingIsolatedAsset),
|
|
1147
|
+
badDebtUsd: decodeFromJSONField(Decimal.reified(), field.badDebtUsd),
|
|
1148
|
+
closable: decodeFromJSONField("bool", field.closable),
|
|
1198
1149
|
});
|
|
1199
1150
|
}
|
|
1200
1151
|
static fromJSON(json) {
|
|
@@ -1218,7 +1169,7 @@ class ObligationDataEvent {
|
|
|
1218
1169
|
!isObligationDataEvent(data.bcs.type)) {
|
|
1219
1170
|
throw new Error(`object at is not a ObligationDataEvent object`);
|
|
1220
1171
|
}
|
|
1221
|
-
return ObligationDataEvent.fromBcs((
|
|
1172
|
+
return ObligationDataEvent.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
1222
1173
|
}
|
|
1223
1174
|
if (data.content) {
|
|
1224
1175
|
return ObligationDataEvent.fromSuiParsedData(data.content);
|
|
@@ -1240,7 +1191,6 @@ class ObligationDataEvent {
|
|
|
1240
1191
|
});
|
|
1241
1192
|
}
|
|
1242
1193
|
}
|
|
1243
|
-
|
|
1244
|
-
ObligationDataEvent.$typeName = `${index_1.PKG_V1}::obligation::ObligationDataEvent`;
|
|
1194
|
+
ObligationDataEvent.$typeName = `${PKG_V1}::obligation::ObligationDataEvent`;
|
|
1245
1195
|
ObligationDataEvent.$numTypeParams = 0;
|
|
1246
1196
|
ObligationDataEvent.$isPhantom = [];
|