@suilend/sdk 12.7.0 → 13.0.0-next.g122801a
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/pyth-2/price-identifier/structs.d.ts +46 -0
- package/_generated/_dependencies/{source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e → pyth-2}/price-identifier/structs.js +45 -25
- package/_generated/_dependencies/std/ascii/structs.d.ts +100 -0
- package/_generated/_dependencies/{source/0x1 → std}/ascii/structs.js +153 -103
- package/_generated/_dependencies/{source/0x1 → std}/option/structs.d.ts +29 -21
- package/_generated/_dependencies/std/option/structs.js +155 -0
- package/_generated/_dependencies/std/type-name/structs.d.ts +65 -0
- package/_generated/_dependencies/{source/0x1 → std}/type-name/structs.js +49 -22
- package/_generated/_dependencies/sui/bag/structs.d.ts +75 -0
- package/_generated/_dependencies/sui/bag/structs.js +154 -0
- package/_generated/_dependencies/{source/0x2 → sui}/balance/structs.d.ts +80 -60
- package/_generated/_dependencies/sui/balance/structs.js +306 -0
- package/_generated/_dependencies/sui/object/structs.d.ts +104 -0
- package/_generated/_dependencies/{source/0x2 → sui}/object/structs.js +98 -46
- package/_generated/_dependencies/{source/0x2 → sui}/object-table/structs.d.ts +37 -30
- package/_generated/_dependencies/sui/object-table/structs.js +164 -0
- package/_generated/_envs/index.d.ts +3 -0
- package/_generated/_envs/index.js +18 -0
- package/_generated/_envs/mainnet.d.ts +2 -0
- package/_generated/_envs/mainnet.js +490 -0
- package/_generated/_framework/env.d.ts +137 -0
- package/_generated/_framework/env.js +261 -0
- package/_generated/_framework/reified.d.ts +68 -36
- package/_generated/_framework/reified.js +110 -98
- package/_generated/_framework/util.d.ts +4 -4
- package/_generated/_framework/util.js +82 -79
- package/_generated/_framework/vector.d.ts +11 -9
- package/_generated/_framework/vector.js +10 -10
- package/_generated/suilend/cell/structs.d.ts +24 -22
- package/_generated/suilend/cell/structs.js +68 -24
- package/_generated/suilend/decimal/structs.d.ts +28 -24
- package/_generated/suilend/decimal/structs.js +45 -24
- package/_generated/suilend/index.d.ts +5 -6
- package/_generated/suilend/index.js +10 -19
- package/_generated/suilend/lending-market/functions.d.ts +1123 -149
- package/_generated/suilend/lending-market/functions.js +1121 -207
- package/_generated/suilend/lending-market/structs.d.ts +985 -1290
- package/_generated/suilend/lending-market/structs.js +2482 -1282
- package/_generated/suilend/lending-market-registry/functions.d.ts +32 -3
- package/_generated/suilend/lending-market-registry/functions.js +30 -6
- package/_generated/suilend/liquidity-mining/structs.d.ts +200 -333
- package/_generated/suilend/liquidity-mining/structs.js +449 -319
- package/_generated/suilend/obligation/structs.d.ts +406 -918
- package/_generated/suilend/obligation/structs.js +786 -596
- package/_generated/suilend/rate-limiter/functions.d.ts +134 -15
- package/_generated/suilend/rate-limiter/functions.js +139 -21
- package/_generated/suilend/rate-limiter/structs.d.ts +72 -80
- package/_generated/suilend/rate-limiter/structs.js +98 -48
- package/_generated/suilend/reserve/structs.d.ts +611 -904
- package/_generated/suilend/reserve/structs.js +1528 -736
- package/_generated/suilend/reserve-config/functions.d.ts +718 -96
- package/_generated/suilend/reserve-config/functions.js +751 -157
- package/_generated/suilend/reserve-config/structs.d.ts +148 -163
- package/_generated/suilend/reserve-config/structs.js +260 -94
- package/client.d.ts +2 -2
- package/client.js +22 -39
- package/lib/initialize.d.ts +617 -83
- package/lib/initialize.js +151 -48
- package/lib/proCompatible.js +5 -5
- package/package.json +1 -1
- package/parsers/lendingMarket.d.ts +9 -9
- package/parsers/obligation.d.ts +14 -14
- package/parsers/obligation.js +4 -4
- package/parsers/rateLimiter.d.ts +1 -1
- package/parsers/reserve.d.ts +12 -12
- package/parsers/reserve.js +2 -2
- package/strategies.d.ts +14 -14
- package/utils/obligation.d.ts +3 -0
- package/utils/obligation.js +10 -0
- package/utils/simulate.d.ts +1 -1
- package/utils/simulate.js +5 -5
- package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +0 -84
- package/_generated/_dependencies/source/0x1/index.d.ts +0 -3
- package/_generated/_dependencies/source/0x1/index.js +0 -3
- package/_generated/_dependencies/source/0x1/option/structs.js +0 -110
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +0 -47
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +0 -52
- package/_generated/_dependencies/source/0x2/bag/structs.js +0 -113
- package/_generated/_dependencies/source/0x2/balance/structs.js +0 -210
- package/_generated/_dependencies/source/0x2/index.d.ts +0 -3
- package/_generated/_dependencies/source/0x2/index.js +0 -3
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +0 -82
- package/_generated/_dependencies/source/0x2/object-table/structs.js +0 -115
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.d.ts +0 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +0 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +0 -46
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
2
|
+
import { getTypeOrigin } from '../../_envs/index.js';
|
|
3
|
+
import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from '../../_framework/reified.js';
|
|
4
|
+
import { composeSuiType, compressSuiType } from '../../_framework/util.js';
|
|
5
|
+
import { Decimal } from '../decimal/structs.js';
|
|
6
6
|
/* ============================== RateLimiter =============================== */
|
|
7
7
|
export function isRateLimiter(type) {
|
|
8
8
|
type = compressSuiType(type);
|
|
9
|
-
return type
|
|
9
|
+
return type
|
|
10
|
+
=== `${getTypeOrigin('suilend', 'rate_limiter::RateLimiter')}::rate_limiter::RateLimiter`;
|
|
10
11
|
}
|
|
12
|
+
/** A structure to manage rate limiting for outflows within a specified time window. */
|
|
11
13
|
export class RateLimiter {
|
|
12
14
|
__StructClass = true;
|
|
13
|
-
static $typeName
|
|
15
|
+
static get $typeName() {
|
|
16
|
+
return `${getTypeOrigin('suilend', 'rate_limiter::RateLimiter')}::rate_limiter::RateLimiter`;
|
|
17
|
+
}
|
|
14
18
|
static $numTypeParams = 0;
|
|
15
19
|
static $isPhantom = [];
|
|
16
20
|
$typeName = RateLimiter.$typeName;
|
|
17
21
|
$fullTypeName;
|
|
18
22
|
$typeArgs;
|
|
19
23
|
$isPhantom = RateLimiter.$isPhantom;
|
|
24
|
+
/** Configuration parameters for the rate limiter. */
|
|
20
25
|
config;
|
|
26
|
+
/** The sum of all outflows from the previous window. */
|
|
21
27
|
prevQty;
|
|
28
|
+
/** The timestamp (in seconds) when the current window started. */
|
|
22
29
|
windowStart;
|
|
30
|
+
/** The sum of all outflows in the current window. */
|
|
23
31
|
curQty;
|
|
24
32
|
constructor(typeArgs, fields) {
|
|
25
33
|
this.$fullTypeName = composeSuiType(RateLimiter.$typeName, ...typeArgs);
|
|
@@ -30,23 +38,29 @@ export class RateLimiter {
|
|
|
30
38
|
this.curQty = fields.curQty;
|
|
31
39
|
}
|
|
32
40
|
static reified() {
|
|
41
|
+
const reifiedBcs = RateLimiter.bcs;
|
|
33
42
|
return {
|
|
34
|
-
typeName
|
|
35
|
-
|
|
43
|
+
get typeName() {
|
|
44
|
+
return RateLimiter.$typeName;
|
|
45
|
+
},
|
|
46
|
+
get fullTypeName() {
|
|
47
|
+
return composeSuiType(RateLimiter.$typeName, ...[]);
|
|
48
|
+
},
|
|
36
49
|
typeArgs: [],
|
|
37
50
|
isPhantom: RateLimiter.$isPhantom,
|
|
38
51
|
reifiedTypeArgs: [],
|
|
39
52
|
fromFields: (fields) => RateLimiter.fromFields(fields),
|
|
40
53
|
fromFieldsWithTypes: (item) => RateLimiter.fromFieldsWithTypes(item),
|
|
41
|
-
fromBcs: (data) => RateLimiter.
|
|
42
|
-
bcs:
|
|
54
|
+
fromBcs: (data) => RateLimiter.fromFields(reifiedBcs.parse(data)),
|
|
55
|
+
bcs: reifiedBcs,
|
|
43
56
|
fromJSONField: (field) => RateLimiter.fromJSONField(field),
|
|
44
57
|
fromJSON: (json) => RateLimiter.fromJSON(json),
|
|
58
|
+
fromCoreObject: (obj) => RateLimiter.fromCoreObject(obj),
|
|
45
59
|
fetch: async (client, id) => RateLimiter.fetch(client, id),
|
|
46
60
|
new: (fields) => {
|
|
47
61
|
return new RateLimiter([], fields);
|
|
48
62
|
},
|
|
49
|
-
kind:
|
|
63
|
+
kind: 'StructClassReified',
|
|
50
64
|
};
|
|
51
65
|
}
|
|
52
66
|
static get r() {
|
|
@@ -58,30 +72,37 @@ export class RateLimiter {
|
|
|
58
72
|
static get p() {
|
|
59
73
|
return RateLimiter.phantom();
|
|
60
74
|
}
|
|
61
|
-
static
|
|
62
|
-
return bcs.struct(
|
|
75
|
+
static instantiateBcs() {
|
|
76
|
+
return bcs.struct('RateLimiter', {
|
|
63
77
|
config: RateLimiterConfig.bcs,
|
|
64
78
|
prev_qty: Decimal.bcs,
|
|
65
79
|
window_start: bcs.u64(),
|
|
66
80
|
cur_qty: Decimal.bcs,
|
|
67
81
|
});
|
|
68
82
|
}
|
|
83
|
+
static cachedBcs = null;
|
|
84
|
+
static get bcs() {
|
|
85
|
+
if (!RateLimiter.cachedBcs) {
|
|
86
|
+
RateLimiter.cachedBcs = RateLimiter.instantiateBcs();
|
|
87
|
+
}
|
|
88
|
+
return RateLimiter.cachedBcs;
|
|
89
|
+
}
|
|
69
90
|
static fromFields(fields) {
|
|
70
91
|
return RateLimiter.reified().new({
|
|
71
92
|
config: decodeFromFields(RateLimiterConfig.reified(), fields.config),
|
|
72
93
|
prevQty: decodeFromFields(Decimal.reified(), fields.prev_qty),
|
|
73
|
-
windowStart: decodeFromFields(
|
|
94
|
+
windowStart: decodeFromFields('u64', fields.window_start),
|
|
74
95
|
curQty: decodeFromFields(Decimal.reified(), fields.cur_qty),
|
|
75
96
|
});
|
|
76
97
|
}
|
|
77
98
|
static fromFieldsWithTypes(item) {
|
|
78
99
|
if (!isRateLimiter(item.type)) {
|
|
79
|
-
throw new Error(
|
|
100
|
+
throw new Error('not a RateLimiter type');
|
|
80
101
|
}
|
|
81
102
|
return RateLimiter.reified().new({
|
|
82
103
|
config: decodeFromFieldsWithTypes(RateLimiterConfig.reified(), item.fields.config),
|
|
83
104
|
prevQty: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.prev_qty),
|
|
84
|
-
windowStart: decodeFromFieldsWithTypes(
|
|
105
|
+
windowStart: decodeFromFieldsWithTypes('u64', item.fields.window_start),
|
|
85
106
|
curQty: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.cur_qty),
|
|
86
107
|
});
|
|
87
108
|
}
|
|
@@ -97,28 +118,33 @@ export class RateLimiter {
|
|
|
97
118
|
};
|
|
98
119
|
}
|
|
99
120
|
toJSON() {
|
|
100
|
-
return {
|
|
101
|
-
$typeName: this.$typeName,
|
|
102
|
-
$typeArgs: this.$typeArgs,
|
|
103
|
-
...this.toJSONField(),
|
|
104
|
-
};
|
|
121
|
+
return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
|
|
105
122
|
}
|
|
106
123
|
static fromJSONField(field) {
|
|
107
124
|
return RateLimiter.reified().new({
|
|
108
125
|
config: decodeFromJSONField(RateLimiterConfig.reified(), field.config),
|
|
109
126
|
prevQty: decodeFromJSONField(Decimal.reified(), field.prevQty),
|
|
110
|
-
windowStart: decodeFromJSONField(
|
|
127
|
+
windowStart: decodeFromJSONField('u64', field.windowStart),
|
|
111
128
|
curQty: decodeFromJSONField(Decimal.reified(), field.curQty),
|
|
112
129
|
});
|
|
113
130
|
}
|
|
114
131
|
static fromJSON(json) {
|
|
115
132
|
if (json.$typeName !== RateLimiter.$typeName) {
|
|
116
|
-
throw new Error(
|
|
133
|
+
throw new Error(`not a RateLimiter json object: expected '${RateLimiter.$typeName}' but got '${json.$typeName}'`);
|
|
117
134
|
}
|
|
118
135
|
return RateLimiter.fromJSONField(json);
|
|
119
136
|
}
|
|
137
|
+
static fromCoreObject(obj) {
|
|
138
|
+
if (!isRateLimiter(obj.type)) {
|
|
139
|
+
throw new Error(`object at ${obj.objectId} is not a RateLimiter object`);
|
|
140
|
+
}
|
|
141
|
+
return RateLimiter.fromBcs(obj.content);
|
|
142
|
+
}
|
|
120
143
|
static async fetch(client, id) {
|
|
121
|
-
const { object } = await client.getObject({
|
|
144
|
+
const { object } = await client.core.getObject({
|
|
145
|
+
objectId: id,
|
|
146
|
+
include: { content: true },
|
|
147
|
+
});
|
|
122
148
|
if (!isRateLimiter(object.type)) {
|
|
123
149
|
throw new Error(`object at id ${id} is not a RateLimiter object`);
|
|
124
150
|
}
|
|
@@ -128,18 +154,24 @@ export class RateLimiter {
|
|
|
128
154
|
/* ============================== RateLimiterConfig =============================== */
|
|
129
155
|
export function isRateLimiterConfig(type) {
|
|
130
156
|
type = compressSuiType(type);
|
|
131
|
-
return type
|
|
157
|
+
return type
|
|
158
|
+
=== `${getTypeOrigin('suilend', 'rate_limiter::RateLimiterConfig')}::rate_limiter::RateLimiterConfig`;
|
|
132
159
|
}
|
|
160
|
+
/** Configuration for the rate limiter, defining the window duration and maximum outflow. */
|
|
133
161
|
export class RateLimiterConfig {
|
|
134
162
|
__StructClass = true;
|
|
135
|
-
static $typeName
|
|
163
|
+
static get $typeName() {
|
|
164
|
+
return `${getTypeOrigin('suilend', 'rate_limiter::RateLimiterConfig')}::rate_limiter::RateLimiterConfig`;
|
|
165
|
+
}
|
|
136
166
|
static $numTypeParams = 0;
|
|
137
167
|
static $isPhantom = [];
|
|
138
168
|
$typeName = RateLimiterConfig.$typeName;
|
|
139
169
|
$fullTypeName;
|
|
140
170
|
$typeArgs;
|
|
141
171
|
$isPhantom = RateLimiterConfig.$isPhantom;
|
|
172
|
+
/** The duration of the rate limiter window in seconds. */
|
|
142
173
|
windowDuration;
|
|
174
|
+
/** The maximum allowed outflow in a single window. */
|
|
143
175
|
maxOutflow;
|
|
144
176
|
constructor(typeArgs, fields) {
|
|
145
177
|
this.$fullTypeName = composeSuiType(RateLimiterConfig.$typeName, ...typeArgs);
|
|
@@ -148,23 +180,29 @@ export class RateLimiterConfig {
|
|
|
148
180
|
this.maxOutflow = fields.maxOutflow;
|
|
149
181
|
}
|
|
150
182
|
static reified() {
|
|
183
|
+
const reifiedBcs = RateLimiterConfig.bcs;
|
|
151
184
|
return {
|
|
152
|
-
typeName
|
|
153
|
-
|
|
185
|
+
get typeName() {
|
|
186
|
+
return RateLimiterConfig.$typeName;
|
|
187
|
+
},
|
|
188
|
+
get fullTypeName() {
|
|
189
|
+
return composeSuiType(RateLimiterConfig.$typeName, ...[]);
|
|
190
|
+
},
|
|
154
191
|
typeArgs: [],
|
|
155
192
|
isPhantom: RateLimiterConfig.$isPhantom,
|
|
156
193
|
reifiedTypeArgs: [],
|
|
157
194
|
fromFields: (fields) => RateLimiterConfig.fromFields(fields),
|
|
158
195
|
fromFieldsWithTypes: (item) => RateLimiterConfig.fromFieldsWithTypes(item),
|
|
159
|
-
fromBcs: (data) => RateLimiterConfig.
|
|
160
|
-
bcs:
|
|
196
|
+
fromBcs: (data) => RateLimiterConfig.fromFields(reifiedBcs.parse(data)),
|
|
197
|
+
bcs: reifiedBcs,
|
|
161
198
|
fromJSONField: (field) => RateLimiterConfig.fromJSONField(field),
|
|
162
199
|
fromJSON: (json) => RateLimiterConfig.fromJSON(json),
|
|
200
|
+
fromCoreObject: (obj) => RateLimiterConfig.fromCoreObject(obj),
|
|
163
201
|
fetch: async (client, id) => RateLimiterConfig.fetch(client, id),
|
|
164
202
|
new: (fields) => {
|
|
165
203
|
return new RateLimiterConfig([], fields);
|
|
166
204
|
},
|
|
167
|
-
kind:
|
|
205
|
+
kind: 'StructClassReified',
|
|
168
206
|
};
|
|
169
207
|
}
|
|
170
208
|
static get r() {
|
|
@@ -176,25 +214,32 @@ export class RateLimiterConfig {
|
|
|
176
214
|
static get p() {
|
|
177
215
|
return RateLimiterConfig.phantom();
|
|
178
216
|
}
|
|
179
|
-
static
|
|
180
|
-
return bcs.struct(
|
|
217
|
+
static instantiateBcs() {
|
|
218
|
+
return bcs.struct('RateLimiterConfig', {
|
|
181
219
|
window_duration: bcs.u64(),
|
|
182
220
|
max_outflow: bcs.u64(),
|
|
183
221
|
});
|
|
184
222
|
}
|
|
223
|
+
static cachedBcs = null;
|
|
224
|
+
static get bcs() {
|
|
225
|
+
if (!RateLimiterConfig.cachedBcs) {
|
|
226
|
+
RateLimiterConfig.cachedBcs = RateLimiterConfig.instantiateBcs();
|
|
227
|
+
}
|
|
228
|
+
return RateLimiterConfig.cachedBcs;
|
|
229
|
+
}
|
|
185
230
|
static fromFields(fields) {
|
|
186
231
|
return RateLimiterConfig.reified().new({
|
|
187
|
-
windowDuration: decodeFromFields(
|
|
188
|
-
maxOutflow: decodeFromFields(
|
|
232
|
+
windowDuration: decodeFromFields('u64', fields.window_duration),
|
|
233
|
+
maxOutflow: decodeFromFields('u64', fields.max_outflow),
|
|
189
234
|
});
|
|
190
235
|
}
|
|
191
236
|
static fromFieldsWithTypes(item) {
|
|
192
237
|
if (!isRateLimiterConfig(item.type)) {
|
|
193
|
-
throw new Error(
|
|
238
|
+
throw new Error('not a RateLimiterConfig type');
|
|
194
239
|
}
|
|
195
240
|
return RateLimiterConfig.reified().new({
|
|
196
|
-
windowDuration: decodeFromFieldsWithTypes(
|
|
197
|
-
maxOutflow: decodeFromFieldsWithTypes(
|
|
241
|
+
windowDuration: decodeFromFieldsWithTypes('u64', item.fields.window_duration),
|
|
242
|
+
maxOutflow: decodeFromFieldsWithTypes('u64', item.fields.max_outflow),
|
|
198
243
|
});
|
|
199
244
|
}
|
|
200
245
|
static fromBcs(data) {
|
|
@@ -207,26 +252,31 @@ export class RateLimiterConfig {
|
|
|
207
252
|
};
|
|
208
253
|
}
|
|
209
254
|
toJSON() {
|
|
210
|
-
return {
|
|
211
|
-
$typeName: this.$typeName,
|
|
212
|
-
$typeArgs: this.$typeArgs,
|
|
213
|
-
...this.toJSONField(),
|
|
214
|
-
};
|
|
255
|
+
return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
|
|
215
256
|
}
|
|
216
257
|
static fromJSONField(field) {
|
|
217
258
|
return RateLimiterConfig.reified().new({
|
|
218
|
-
windowDuration: decodeFromJSONField(
|
|
219
|
-
maxOutflow: decodeFromJSONField(
|
|
259
|
+
windowDuration: decodeFromJSONField('u64', field.windowDuration),
|
|
260
|
+
maxOutflow: decodeFromJSONField('u64', field.maxOutflow),
|
|
220
261
|
});
|
|
221
262
|
}
|
|
222
263
|
static fromJSON(json) {
|
|
223
264
|
if (json.$typeName !== RateLimiterConfig.$typeName) {
|
|
224
|
-
throw new Error(
|
|
265
|
+
throw new Error(`not a RateLimiterConfig json object: expected '${RateLimiterConfig.$typeName}' but got '${json.$typeName}'`);
|
|
225
266
|
}
|
|
226
267
|
return RateLimiterConfig.fromJSONField(json);
|
|
227
268
|
}
|
|
269
|
+
static fromCoreObject(obj) {
|
|
270
|
+
if (!isRateLimiterConfig(obj.type)) {
|
|
271
|
+
throw new Error(`object at ${obj.objectId} is not a RateLimiterConfig object`);
|
|
272
|
+
}
|
|
273
|
+
return RateLimiterConfig.fromBcs(obj.content);
|
|
274
|
+
}
|
|
228
275
|
static async fetch(client, id) {
|
|
229
|
-
const { object } = await client.getObject({
|
|
276
|
+
const { object } = await client.core.getObject({
|
|
277
|
+
objectId: id,
|
|
278
|
+
include: { content: true },
|
|
279
|
+
});
|
|
230
280
|
if (!isRateLimiterConfig(object.type)) {
|
|
231
281
|
throw new Error(`object at id ${id} is not a RateLimiterConfig object`);
|
|
232
282
|
}
|