@suilend/sdk 15.0.0 → 16.0.0
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 +5 -1
- package/_generated/_dependencies/std/ascii/structs.d.ts +8 -2
- package/_generated/_dependencies/std/option/structs.d.ts +6 -1
- package/_generated/_dependencies/std/type-name/structs.d.ts +7 -1
- package/_generated/_dependencies/sui/bag/structs.d.ts +8 -1
- package/_generated/_dependencies/sui/balance/structs.d.ts +6 -2
- package/_generated/_dependencies/sui/object/structs.d.ts +8 -2
- package/_generated/_dependencies/sui/object-table/structs.d.ts +8 -1
- package/_generated/_envs/mainnet.js +39 -3
- package/_generated/suilend/cell/structs.d.ts +8 -1
- package/_generated/suilend/decimal/structs.d.ts +3 -1
- package/_generated/suilend/lending-market/functions.d.ts +185 -64
- package/_generated/suilend/lending-market/functions.js +227 -65
- package/_generated/suilend/lending-market/structs.d.ts +764 -25
- package/_generated/suilend/lending-market/structs.js +491 -3
- package/_generated/suilend/liquidity-mining/structs.d.ts +169 -5
- package/_generated/suilend/obligation/structs.d.ts +338 -7
- package/_generated/suilend/rate-limiter/functions.d.ts +6 -0
- package/_generated/suilend/rate-limiter/functions.js +12 -0
- package/_generated/suilend/rate-limiter/structs.d.ts +17 -2
- package/_generated/suilend/reserve/structs.d.ts +664 -17
- package/_generated/suilend/reserve/structs.js +623 -4
- package/_generated/suilend/reserve-config/functions.d.ts +64 -9
- package/_generated/suilend/reserve-config/functions.js +88 -11
- package/_generated/suilend/reserve-config/structs.d.ts +45 -3
- package/package.json +1 -1
|
@@ -834,6 +834,128 @@ export class StakerKey {
|
|
|
834
834
|
return StakerKey.fromBcs(object.content);
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
|
+
/* ============================== StakerValidatorKey =============================== */
|
|
838
|
+
export function isStakerValidatorKey(type) {
|
|
839
|
+
type = compressSuiType(type);
|
|
840
|
+
return type
|
|
841
|
+
=== `${getTypeOrigin('suilend', 'reserve::StakerValidatorKey')}::reserve::StakerValidatorKey`;
|
|
842
|
+
}
|
|
843
|
+
export class StakerValidatorKey {
|
|
844
|
+
__StructClass = true;
|
|
845
|
+
static get $typeName() {
|
|
846
|
+
return `${getTypeOrigin('suilend', 'reserve::StakerValidatorKey')}::reserve::StakerValidatorKey`;
|
|
847
|
+
}
|
|
848
|
+
static $numTypeParams = 0;
|
|
849
|
+
static $isPhantom = [];
|
|
850
|
+
$typeName = StakerValidatorKey.$typeName;
|
|
851
|
+
$fullTypeName;
|
|
852
|
+
$typeArgs;
|
|
853
|
+
$isPhantom = StakerValidatorKey.$isPhantom;
|
|
854
|
+
dummyField;
|
|
855
|
+
constructor(typeArgs, fields) {
|
|
856
|
+
this.$fullTypeName = composeSuiType(StakerValidatorKey.$typeName, ...typeArgs);
|
|
857
|
+
this.$typeArgs = typeArgs;
|
|
858
|
+
this.dummyField = fields.dummyField;
|
|
859
|
+
}
|
|
860
|
+
static reified() {
|
|
861
|
+
const reifiedBcs = StakerValidatorKey.bcs;
|
|
862
|
+
return {
|
|
863
|
+
get typeName() {
|
|
864
|
+
return StakerValidatorKey.$typeName;
|
|
865
|
+
},
|
|
866
|
+
get fullTypeName() {
|
|
867
|
+
return composeSuiType(StakerValidatorKey.$typeName, ...[]);
|
|
868
|
+
},
|
|
869
|
+
typeArgs: [],
|
|
870
|
+
isPhantom: StakerValidatorKey.$isPhantom,
|
|
871
|
+
reifiedTypeArgs: [],
|
|
872
|
+
fromFields: (fields) => StakerValidatorKey.fromFields(fields),
|
|
873
|
+
fromFieldsWithTypes: (item) => StakerValidatorKey.fromFieldsWithTypes(item),
|
|
874
|
+
fromBcs: (data) => StakerValidatorKey.fromFields(reifiedBcs.parse(data)),
|
|
875
|
+
bcs: reifiedBcs,
|
|
876
|
+
fromJSONField: (field) => StakerValidatorKey.fromJSONField(field),
|
|
877
|
+
fromJSON: (json) => StakerValidatorKey.fromJSON(json),
|
|
878
|
+
fromCoreObject: (obj) => StakerValidatorKey.fromCoreObject(obj),
|
|
879
|
+
fetch: async (client, id) => StakerValidatorKey.fetch(client, id),
|
|
880
|
+
new: (fields) => {
|
|
881
|
+
return new StakerValidatorKey([], fields);
|
|
882
|
+
},
|
|
883
|
+
kind: 'StructClassReified',
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
static get r() {
|
|
887
|
+
return StakerValidatorKey.reified();
|
|
888
|
+
}
|
|
889
|
+
static phantom() {
|
|
890
|
+
return phantom(StakerValidatorKey.reified());
|
|
891
|
+
}
|
|
892
|
+
static get p() {
|
|
893
|
+
return StakerValidatorKey.phantom();
|
|
894
|
+
}
|
|
895
|
+
static instantiateBcs() {
|
|
896
|
+
return bcs.struct('StakerValidatorKey', {
|
|
897
|
+
dummy_field: bcs.bool(),
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
static cachedBcs = null;
|
|
901
|
+
static get bcs() {
|
|
902
|
+
if (!StakerValidatorKey.cachedBcs) {
|
|
903
|
+
StakerValidatorKey.cachedBcs = StakerValidatorKey.instantiateBcs();
|
|
904
|
+
}
|
|
905
|
+
return StakerValidatorKey.cachedBcs;
|
|
906
|
+
}
|
|
907
|
+
static fromFields(fields) {
|
|
908
|
+
return StakerValidatorKey.reified().new({
|
|
909
|
+
dummyField: decodeFromFields('bool', fields.dummy_field),
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
static fromFieldsWithTypes(item) {
|
|
913
|
+
if (!isStakerValidatorKey(item.type)) {
|
|
914
|
+
throw new Error('not a StakerValidatorKey type');
|
|
915
|
+
}
|
|
916
|
+
return StakerValidatorKey.reified().new({
|
|
917
|
+
dummyField: decodeFromFieldsWithTypes('bool', item.fields.dummy_field),
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
static fromBcs(data) {
|
|
921
|
+
return StakerValidatorKey.fromFields(StakerValidatorKey.bcs.parse(data));
|
|
922
|
+
}
|
|
923
|
+
toJSONField() {
|
|
924
|
+
return {
|
|
925
|
+
dummyField: this.dummyField,
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
toJSON() {
|
|
929
|
+
return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
|
|
930
|
+
}
|
|
931
|
+
static fromJSONField(field) {
|
|
932
|
+
return StakerValidatorKey.reified().new({
|
|
933
|
+
dummyField: decodeFromJSONField('bool', field.dummyField),
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
static fromJSON(json) {
|
|
937
|
+
if (json.$typeName !== StakerValidatorKey.$typeName) {
|
|
938
|
+
throw new Error(`not a StakerValidatorKey json object: expected '${StakerValidatorKey.$typeName}' but got '${json.$typeName}'`);
|
|
939
|
+
}
|
|
940
|
+
return StakerValidatorKey.fromJSONField(json);
|
|
941
|
+
}
|
|
942
|
+
static fromCoreObject(obj) {
|
|
943
|
+
if (!isStakerValidatorKey(obj.type)) {
|
|
944
|
+
throw new Error(`object at ${obj.objectId} is not a StakerValidatorKey object`);
|
|
945
|
+
}
|
|
946
|
+
return StakerValidatorKey.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 (!isStakerValidatorKey(object.type)) {
|
|
954
|
+
throw new Error(`object at id ${id} is not a StakerValidatorKey object`);
|
|
955
|
+
}
|
|
956
|
+
return StakerValidatorKey.fromBcs(object.content);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
837
959
|
/* ============================== ReservePauseKey =============================== */
|
|
838
960
|
export function isReservePauseKey(type) {
|
|
839
961
|
type = compressSuiType(type);
|
|
@@ -956,6 +1078,128 @@ export class ReservePauseKey {
|
|
|
956
1078
|
return ReservePauseKey.fromBcs(object.content);
|
|
957
1079
|
}
|
|
958
1080
|
}
|
|
1081
|
+
/* ============================== RateLimiterExemptKey =============================== */
|
|
1082
|
+
export function isRateLimiterExemptKey(type) {
|
|
1083
|
+
type = compressSuiType(type);
|
|
1084
|
+
return type
|
|
1085
|
+
=== `${getTypeOrigin('suilend', 'reserve::RateLimiterExemptKey')}::reserve::RateLimiterExemptKey`;
|
|
1086
|
+
}
|
|
1087
|
+
export class RateLimiterExemptKey {
|
|
1088
|
+
__StructClass = true;
|
|
1089
|
+
static get $typeName() {
|
|
1090
|
+
return `${getTypeOrigin('suilend', 'reserve::RateLimiterExemptKey')}::reserve::RateLimiterExemptKey`;
|
|
1091
|
+
}
|
|
1092
|
+
static $numTypeParams = 0;
|
|
1093
|
+
static $isPhantom = [];
|
|
1094
|
+
$typeName = RateLimiterExemptKey.$typeName;
|
|
1095
|
+
$fullTypeName;
|
|
1096
|
+
$typeArgs;
|
|
1097
|
+
$isPhantom = RateLimiterExemptKey.$isPhantom;
|
|
1098
|
+
dummyField;
|
|
1099
|
+
constructor(typeArgs, fields) {
|
|
1100
|
+
this.$fullTypeName = composeSuiType(RateLimiterExemptKey.$typeName, ...typeArgs);
|
|
1101
|
+
this.$typeArgs = typeArgs;
|
|
1102
|
+
this.dummyField = fields.dummyField;
|
|
1103
|
+
}
|
|
1104
|
+
static reified() {
|
|
1105
|
+
const reifiedBcs = RateLimiterExemptKey.bcs;
|
|
1106
|
+
return {
|
|
1107
|
+
get typeName() {
|
|
1108
|
+
return RateLimiterExemptKey.$typeName;
|
|
1109
|
+
},
|
|
1110
|
+
get fullTypeName() {
|
|
1111
|
+
return composeSuiType(RateLimiterExemptKey.$typeName, ...[]);
|
|
1112
|
+
},
|
|
1113
|
+
typeArgs: [],
|
|
1114
|
+
isPhantom: RateLimiterExemptKey.$isPhantom,
|
|
1115
|
+
reifiedTypeArgs: [],
|
|
1116
|
+
fromFields: (fields) => RateLimiterExemptKey.fromFields(fields),
|
|
1117
|
+
fromFieldsWithTypes: (item) => RateLimiterExemptKey.fromFieldsWithTypes(item),
|
|
1118
|
+
fromBcs: (data) => RateLimiterExemptKey.fromFields(reifiedBcs.parse(data)),
|
|
1119
|
+
bcs: reifiedBcs,
|
|
1120
|
+
fromJSONField: (field) => RateLimiterExemptKey.fromJSONField(field),
|
|
1121
|
+
fromJSON: (json) => RateLimiterExemptKey.fromJSON(json),
|
|
1122
|
+
fromCoreObject: (obj) => RateLimiterExemptKey.fromCoreObject(obj),
|
|
1123
|
+
fetch: async (client, id) => RateLimiterExemptKey.fetch(client, id),
|
|
1124
|
+
new: (fields) => {
|
|
1125
|
+
return new RateLimiterExemptKey([], fields);
|
|
1126
|
+
},
|
|
1127
|
+
kind: 'StructClassReified',
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
static get r() {
|
|
1131
|
+
return RateLimiterExemptKey.reified();
|
|
1132
|
+
}
|
|
1133
|
+
static phantom() {
|
|
1134
|
+
return phantom(RateLimiterExemptKey.reified());
|
|
1135
|
+
}
|
|
1136
|
+
static get p() {
|
|
1137
|
+
return RateLimiterExemptKey.phantom();
|
|
1138
|
+
}
|
|
1139
|
+
static instantiateBcs() {
|
|
1140
|
+
return bcs.struct('RateLimiterExemptKey', {
|
|
1141
|
+
dummy_field: bcs.bool(),
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
static cachedBcs = null;
|
|
1145
|
+
static get bcs() {
|
|
1146
|
+
if (!RateLimiterExemptKey.cachedBcs) {
|
|
1147
|
+
RateLimiterExemptKey.cachedBcs = RateLimiterExemptKey.instantiateBcs();
|
|
1148
|
+
}
|
|
1149
|
+
return RateLimiterExemptKey.cachedBcs;
|
|
1150
|
+
}
|
|
1151
|
+
static fromFields(fields) {
|
|
1152
|
+
return RateLimiterExemptKey.reified().new({
|
|
1153
|
+
dummyField: decodeFromFields('bool', fields.dummy_field),
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
static fromFieldsWithTypes(item) {
|
|
1157
|
+
if (!isRateLimiterExemptKey(item.type)) {
|
|
1158
|
+
throw new Error('not a RateLimiterExemptKey type');
|
|
1159
|
+
}
|
|
1160
|
+
return RateLimiterExemptKey.reified().new({
|
|
1161
|
+
dummyField: decodeFromFieldsWithTypes('bool', item.fields.dummy_field),
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
static fromBcs(data) {
|
|
1165
|
+
return RateLimiterExemptKey.fromFields(RateLimiterExemptKey.bcs.parse(data));
|
|
1166
|
+
}
|
|
1167
|
+
toJSONField() {
|
|
1168
|
+
return {
|
|
1169
|
+
dummyField: this.dummyField,
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
toJSON() {
|
|
1173
|
+
return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
|
|
1174
|
+
}
|
|
1175
|
+
static fromJSONField(field) {
|
|
1176
|
+
return RateLimiterExemptKey.reified().new({
|
|
1177
|
+
dummyField: decodeFromJSONField('bool', field.dummyField),
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
static fromJSON(json) {
|
|
1181
|
+
if (json.$typeName !== RateLimiterExemptKey.$typeName) {
|
|
1182
|
+
throw new Error(`not a RateLimiterExemptKey json object: expected '${RateLimiterExemptKey.$typeName}' but got '${json.$typeName}'`);
|
|
1183
|
+
}
|
|
1184
|
+
return RateLimiterExemptKey.fromJSONField(json);
|
|
1185
|
+
}
|
|
1186
|
+
static fromCoreObject(obj) {
|
|
1187
|
+
if (!isRateLimiterExemptKey(obj.type)) {
|
|
1188
|
+
throw new Error(`object at ${obj.objectId} is not a RateLimiterExemptKey object`);
|
|
1189
|
+
}
|
|
1190
|
+
return RateLimiterExemptKey.fromBcs(obj.content);
|
|
1191
|
+
}
|
|
1192
|
+
static async fetch(client, id) {
|
|
1193
|
+
const { object } = await client.core.getObject({
|
|
1194
|
+
objectId: id,
|
|
1195
|
+
include: { content: true },
|
|
1196
|
+
});
|
|
1197
|
+
if (!isRateLimiterExemptKey(object.type)) {
|
|
1198
|
+
throw new Error(`object at id ${id} is not a RateLimiterExemptKey object`);
|
|
1199
|
+
}
|
|
1200
|
+
return RateLimiterExemptKey.fromBcs(object.content);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
959
1203
|
/* ============================== PriceGuardKey =============================== */
|
|
960
1204
|
export function isPriceGuardKey(type) {
|
|
961
1205
|
type = compressSuiType(type);
|
|
@@ -1198,16 +1442,138 @@ export class ConfidenceKey {
|
|
|
1198
1442
|
return ConfidenceKey.fromBcs(object.content);
|
|
1199
1443
|
}
|
|
1200
1444
|
}
|
|
1445
|
+
/* ============================== RawPriceKey =============================== */
|
|
1446
|
+
export function isRawPriceKey(type) {
|
|
1447
|
+
type = compressSuiType(type);
|
|
1448
|
+
return type === `${getTypeOrigin('suilend', 'reserve::RawPriceKey')}::reserve::RawPriceKey`;
|
|
1449
|
+
}
|
|
1450
|
+
export class RawPriceKey {
|
|
1451
|
+
__StructClass = true;
|
|
1452
|
+
static get $typeName() {
|
|
1453
|
+
return `${getTypeOrigin('suilend', 'reserve::RawPriceKey')}::reserve::RawPriceKey`;
|
|
1454
|
+
}
|
|
1455
|
+
static $numTypeParams = 0;
|
|
1456
|
+
static $isPhantom = [];
|
|
1457
|
+
$typeName = RawPriceKey.$typeName;
|
|
1458
|
+
$fullTypeName;
|
|
1459
|
+
$typeArgs;
|
|
1460
|
+
$isPhantom = RawPriceKey.$isPhantom;
|
|
1461
|
+
dummyField;
|
|
1462
|
+
constructor(typeArgs, fields) {
|
|
1463
|
+
this.$fullTypeName = composeSuiType(RawPriceKey.$typeName, ...typeArgs);
|
|
1464
|
+
this.$typeArgs = typeArgs;
|
|
1465
|
+
this.dummyField = fields.dummyField;
|
|
1466
|
+
}
|
|
1467
|
+
static reified() {
|
|
1468
|
+
const reifiedBcs = RawPriceKey.bcs;
|
|
1469
|
+
return {
|
|
1470
|
+
get typeName() {
|
|
1471
|
+
return RawPriceKey.$typeName;
|
|
1472
|
+
},
|
|
1473
|
+
get fullTypeName() {
|
|
1474
|
+
return composeSuiType(RawPriceKey.$typeName, ...[]);
|
|
1475
|
+
},
|
|
1476
|
+
typeArgs: [],
|
|
1477
|
+
isPhantom: RawPriceKey.$isPhantom,
|
|
1478
|
+
reifiedTypeArgs: [],
|
|
1479
|
+
fromFields: (fields) => RawPriceKey.fromFields(fields),
|
|
1480
|
+
fromFieldsWithTypes: (item) => RawPriceKey.fromFieldsWithTypes(item),
|
|
1481
|
+
fromBcs: (data) => RawPriceKey.fromFields(reifiedBcs.parse(data)),
|
|
1482
|
+
bcs: reifiedBcs,
|
|
1483
|
+
fromJSONField: (field) => RawPriceKey.fromJSONField(field),
|
|
1484
|
+
fromJSON: (json) => RawPriceKey.fromJSON(json),
|
|
1485
|
+
fromCoreObject: (obj) => RawPriceKey.fromCoreObject(obj),
|
|
1486
|
+
fetch: async (client, id) => RawPriceKey.fetch(client, id),
|
|
1487
|
+
new: (fields) => {
|
|
1488
|
+
return new RawPriceKey([], fields);
|
|
1489
|
+
},
|
|
1490
|
+
kind: 'StructClassReified',
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
static get r() {
|
|
1494
|
+
return RawPriceKey.reified();
|
|
1495
|
+
}
|
|
1496
|
+
static phantom() {
|
|
1497
|
+
return phantom(RawPriceKey.reified());
|
|
1498
|
+
}
|
|
1499
|
+
static get p() {
|
|
1500
|
+
return RawPriceKey.phantom();
|
|
1501
|
+
}
|
|
1502
|
+
static instantiateBcs() {
|
|
1503
|
+
return bcs.struct('RawPriceKey', {
|
|
1504
|
+
dummy_field: bcs.bool(),
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
static cachedBcs = null;
|
|
1508
|
+
static get bcs() {
|
|
1509
|
+
if (!RawPriceKey.cachedBcs) {
|
|
1510
|
+
RawPriceKey.cachedBcs = RawPriceKey.instantiateBcs();
|
|
1511
|
+
}
|
|
1512
|
+
return RawPriceKey.cachedBcs;
|
|
1513
|
+
}
|
|
1514
|
+
static fromFields(fields) {
|
|
1515
|
+
return RawPriceKey.reified().new({
|
|
1516
|
+
dummyField: decodeFromFields('bool', fields.dummy_field),
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
static fromFieldsWithTypes(item) {
|
|
1520
|
+
if (!isRawPriceKey(item.type)) {
|
|
1521
|
+
throw new Error('not a RawPriceKey type');
|
|
1522
|
+
}
|
|
1523
|
+
return RawPriceKey.reified().new({
|
|
1524
|
+
dummyField: decodeFromFieldsWithTypes('bool', item.fields.dummy_field),
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
static fromBcs(data) {
|
|
1528
|
+
return RawPriceKey.fromFields(RawPriceKey.bcs.parse(data));
|
|
1529
|
+
}
|
|
1530
|
+
toJSONField() {
|
|
1531
|
+
return {
|
|
1532
|
+
dummyField: this.dummyField,
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
toJSON() {
|
|
1536
|
+
return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
|
|
1537
|
+
}
|
|
1538
|
+
static fromJSONField(field) {
|
|
1539
|
+
return RawPriceKey.reified().new({
|
|
1540
|
+
dummyField: decodeFromJSONField('bool', field.dummyField),
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
static fromJSON(json) {
|
|
1544
|
+
if (json.$typeName !== RawPriceKey.$typeName) {
|
|
1545
|
+
throw new Error(`not a RawPriceKey json object: expected '${RawPriceKey.$typeName}' but got '${json.$typeName}'`);
|
|
1546
|
+
}
|
|
1547
|
+
return RawPriceKey.fromJSONField(json);
|
|
1548
|
+
}
|
|
1549
|
+
static fromCoreObject(obj) {
|
|
1550
|
+
if (!isRawPriceKey(obj.type)) {
|
|
1551
|
+
throw new Error(`object at ${obj.objectId} is not a RawPriceKey object`);
|
|
1552
|
+
}
|
|
1553
|
+
return RawPriceKey.fromBcs(obj.content);
|
|
1554
|
+
}
|
|
1555
|
+
static async fetch(client, id) {
|
|
1556
|
+
const { object } = await client.core.getObject({
|
|
1557
|
+
objectId: id,
|
|
1558
|
+
include: { content: true },
|
|
1559
|
+
});
|
|
1560
|
+
if (!isRawPriceKey(object.type)) {
|
|
1561
|
+
throw new Error(`object at id ${id} is not a RawPriceKey object`);
|
|
1562
|
+
}
|
|
1563
|
+
return RawPriceKey.fromBcs(object.content);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1201
1566
|
/* ============================== PriceGuard =============================== */
|
|
1202
1567
|
export function isPriceGuard(type) {
|
|
1203
1568
|
type = compressSuiType(type);
|
|
1204
1569
|
return type === `${getTypeOrigin('suilend', 'reserve::PriceGuard')}::reserve::PriceGuard`;
|
|
1205
1570
|
}
|
|
1206
1571
|
/**
|
|
1207
|
-
* Bounds how far `price` and `smoothed_price`
|
|
1208
|
-
*
|
|
1209
|
-
*
|
|
1210
|
-
* either
|
|
1572
|
+
* Bounds how far `price` and `smoothed_price` move per `min_update_interval_s`. An elapsed
|
|
1573
|
+
* interval opens each anchor on the price stored then, and every refresh until the next
|
|
1574
|
+
* one clamps against it. One PTB stays within one band of the anchor, and two refreshes
|
|
1575
|
+
* either side of a boundary within three bands, the walk
|
|
1576
|
+
* `assert_band_below_liquidation_buffer` bounds.
|
|
1211
1577
|
*/
|
|
1212
1578
|
export class PriceGuard {
|
|
1213
1579
|
__StructClass = true;
|
|
@@ -1353,6 +1719,138 @@ export class PriceGuard {
|
|
|
1353
1719
|
return PriceGuard.fromBcs(object.content);
|
|
1354
1720
|
}
|
|
1355
1721
|
}
|
|
1722
|
+
/* ============================== RawPrice =============================== */
|
|
1723
|
+
export function isRawPrice(type) {
|
|
1724
|
+
type = compressSuiType(type);
|
|
1725
|
+
return type === `${getTypeOrigin('suilend', 'reserve::RawPrice')}::reserve::RawPrice`;
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* While a clamp lags the market, the stored price overvalues falling collateral and
|
|
1729
|
+
* undervalues rising debt, so the borrow and withdraw bounds also range over these.
|
|
1730
|
+
*/
|
|
1731
|
+
export class RawPrice {
|
|
1732
|
+
__StructClass = true;
|
|
1733
|
+
static get $typeName() {
|
|
1734
|
+
return `${getTypeOrigin('suilend', 'reserve::RawPrice')}::reserve::RawPrice`;
|
|
1735
|
+
}
|
|
1736
|
+
static $numTypeParams = 0;
|
|
1737
|
+
static $isPhantom = [];
|
|
1738
|
+
$typeName = RawPrice.$typeName;
|
|
1739
|
+
$fullTypeName;
|
|
1740
|
+
$typeArgs;
|
|
1741
|
+
$isPhantom = RawPrice.$isPhantom;
|
|
1742
|
+
price;
|
|
1743
|
+
smoothedPrice;
|
|
1744
|
+
constructor(typeArgs, fields) {
|
|
1745
|
+
this.$fullTypeName = composeSuiType(RawPrice.$typeName, ...typeArgs);
|
|
1746
|
+
this.$typeArgs = typeArgs;
|
|
1747
|
+
this.price = fields.price;
|
|
1748
|
+
this.smoothedPrice = fields.smoothedPrice;
|
|
1749
|
+
}
|
|
1750
|
+
static reified() {
|
|
1751
|
+
const reifiedBcs = RawPrice.bcs;
|
|
1752
|
+
return {
|
|
1753
|
+
get typeName() {
|
|
1754
|
+
return RawPrice.$typeName;
|
|
1755
|
+
},
|
|
1756
|
+
get fullTypeName() {
|
|
1757
|
+
return composeSuiType(RawPrice.$typeName, ...[]);
|
|
1758
|
+
},
|
|
1759
|
+
typeArgs: [],
|
|
1760
|
+
isPhantom: RawPrice.$isPhantom,
|
|
1761
|
+
reifiedTypeArgs: [],
|
|
1762
|
+
fromFields: (fields) => RawPrice.fromFields(fields),
|
|
1763
|
+
fromFieldsWithTypes: (item) => RawPrice.fromFieldsWithTypes(item),
|
|
1764
|
+
fromBcs: (data) => RawPrice.fromFields(reifiedBcs.parse(data)),
|
|
1765
|
+
bcs: reifiedBcs,
|
|
1766
|
+
fromJSONField: (field) => RawPrice.fromJSONField(field),
|
|
1767
|
+
fromJSON: (json) => RawPrice.fromJSON(json),
|
|
1768
|
+
fromCoreObject: (obj) => RawPrice.fromCoreObject(obj),
|
|
1769
|
+
fetch: async (client, id) => RawPrice.fetch(client, id),
|
|
1770
|
+
new: (fields) => {
|
|
1771
|
+
return new RawPrice([], fields);
|
|
1772
|
+
},
|
|
1773
|
+
kind: 'StructClassReified',
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
static get r() {
|
|
1777
|
+
return RawPrice.reified();
|
|
1778
|
+
}
|
|
1779
|
+
static phantom() {
|
|
1780
|
+
return phantom(RawPrice.reified());
|
|
1781
|
+
}
|
|
1782
|
+
static get p() {
|
|
1783
|
+
return RawPrice.phantom();
|
|
1784
|
+
}
|
|
1785
|
+
static instantiateBcs() {
|
|
1786
|
+
return bcs.struct('RawPrice', {
|
|
1787
|
+
price: Decimal.bcs,
|
|
1788
|
+
smoothed_price: Decimal.bcs,
|
|
1789
|
+
});
|
|
1790
|
+
}
|
|
1791
|
+
static cachedBcs = null;
|
|
1792
|
+
static get bcs() {
|
|
1793
|
+
if (!RawPrice.cachedBcs) {
|
|
1794
|
+
RawPrice.cachedBcs = RawPrice.instantiateBcs();
|
|
1795
|
+
}
|
|
1796
|
+
return RawPrice.cachedBcs;
|
|
1797
|
+
}
|
|
1798
|
+
static fromFields(fields) {
|
|
1799
|
+
return RawPrice.reified().new({
|
|
1800
|
+
price: decodeFromFields(Decimal.reified(), fields.price),
|
|
1801
|
+
smoothedPrice: decodeFromFields(Decimal.reified(), fields.smoothed_price),
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
static fromFieldsWithTypes(item) {
|
|
1805
|
+
if (!isRawPrice(item.type)) {
|
|
1806
|
+
throw new Error('not a RawPrice type');
|
|
1807
|
+
}
|
|
1808
|
+
return RawPrice.reified().new({
|
|
1809
|
+
price: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.price),
|
|
1810
|
+
smoothedPrice: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.smoothed_price),
|
|
1811
|
+
});
|
|
1812
|
+
}
|
|
1813
|
+
static fromBcs(data) {
|
|
1814
|
+
return RawPrice.fromFields(RawPrice.bcs.parse(data));
|
|
1815
|
+
}
|
|
1816
|
+
toJSONField() {
|
|
1817
|
+
return {
|
|
1818
|
+
price: this.price.toJSONField(),
|
|
1819
|
+
smoothedPrice: this.smoothedPrice.toJSONField(),
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
toJSON() {
|
|
1823
|
+
return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
|
|
1824
|
+
}
|
|
1825
|
+
static fromJSONField(field) {
|
|
1826
|
+
return RawPrice.reified().new({
|
|
1827
|
+
price: decodeFromJSONField(Decimal.reified(), field.price),
|
|
1828
|
+
smoothedPrice: decodeFromJSONField(Decimal.reified(), field.smoothedPrice),
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1831
|
+
static fromJSON(json) {
|
|
1832
|
+
if (json.$typeName !== RawPrice.$typeName) {
|
|
1833
|
+
throw new Error(`not a RawPrice json object: expected '${RawPrice.$typeName}' but got '${json.$typeName}'`);
|
|
1834
|
+
}
|
|
1835
|
+
return RawPrice.fromJSONField(json);
|
|
1836
|
+
}
|
|
1837
|
+
static fromCoreObject(obj) {
|
|
1838
|
+
if (!isRawPrice(obj.type)) {
|
|
1839
|
+
throw new Error(`object at ${obj.objectId} is not a RawPrice object`);
|
|
1840
|
+
}
|
|
1841
|
+
return RawPrice.fromBcs(obj.content);
|
|
1842
|
+
}
|
|
1843
|
+
static async fetch(client, id) {
|
|
1844
|
+
const { object } = await client.core.getObject({
|
|
1845
|
+
objectId: id,
|
|
1846
|
+
include: { content: true },
|
|
1847
|
+
});
|
|
1848
|
+
if (!isRawPrice(object.type)) {
|
|
1849
|
+
throw new Error(`object at id ${id} is not a RawPrice object`);
|
|
1850
|
+
}
|
|
1851
|
+
return RawPrice.fromBcs(object.content);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1356
1854
|
/* ============================== Balances =============================== */
|
|
1357
1855
|
export function isBalances(type) {
|
|
1358
1856
|
type = compressSuiType(type);
|
|
@@ -1986,6 +2484,127 @@ export class ReserveAssetDataEvent {
|
|
|
1986
2484
|
return ReserveAssetDataEvent.fromBcs(object.content);
|
|
1987
2485
|
}
|
|
1988
2486
|
}
|
|
2487
|
+
/* ============================== ReserveWitness =============================== */
|
|
2488
|
+
export function isReserveWitness(type) {
|
|
2489
|
+
type = compressSuiType(type);
|
|
2490
|
+
return type === `${getTypeOrigin('suilend', 'reserve::ReserveWitness')}::reserve::ReserveWitness`;
|
|
2491
|
+
}
|
|
2492
|
+
export class ReserveWitness {
|
|
2493
|
+
__StructClass = true;
|
|
2494
|
+
static get $typeName() {
|
|
2495
|
+
return `${getTypeOrigin('suilend', 'reserve::ReserveWitness')}::reserve::ReserveWitness`;
|
|
2496
|
+
}
|
|
2497
|
+
static $numTypeParams = 0;
|
|
2498
|
+
static $isPhantom = [];
|
|
2499
|
+
$typeName = ReserveWitness.$typeName;
|
|
2500
|
+
$fullTypeName;
|
|
2501
|
+
$typeArgs;
|
|
2502
|
+
$isPhantom = ReserveWitness.$isPhantom;
|
|
2503
|
+
dummyField;
|
|
2504
|
+
constructor(typeArgs, fields) {
|
|
2505
|
+
this.$fullTypeName = composeSuiType(ReserveWitness.$typeName, ...typeArgs);
|
|
2506
|
+
this.$typeArgs = typeArgs;
|
|
2507
|
+
this.dummyField = fields.dummyField;
|
|
2508
|
+
}
|
|
2509
|
+
static reified() {
|
|
2510
|
+
const reifiedBcs = ReserveWitness.bcs;
|
|
2511
|
+
return {
|
|
2512
|
+
get typeName() {
|
|
2513
|
+
return ReserveWitness.$typeName;
|
|
2514
|
+
},
|
|
2515
|
+
get fullTypeName() {
|
|
2516
|
+
return composeSuiType(ReserveWitness.$typeName, ...[]);
|
|
2517
|
+
},
|
|
2518
|
+
typeArgs: [],
|
|
2519
|
+
isPhantom: ReserveWitness.$isPhantom,
|
|
2520
|
+
reifiedTypeArgs: [],
|
|
2521
|
+
fromFields: (fields) => ReserveWitness.fromFields(fields),
|
|
2522
|
+
fromFieldsWithTypes: (item) => ReserveWitness.fromFieldsWithTypes(item),
|
|
2523
|
+
fromBcs: (data) => ReserveWitness.fromFields(reifiedBcs.parse(data)),
|
|
2524
|
+
bcs: reifiedBcs,
|
|
2525
|
+
fromJSONField: (field) => ReserveWitness.fromJSONField(field),
|
|
2526
|
+
fromJSON: (json) => ReserveWitness.fromJSON(json),
|
|
2527
|
+
fromCoreObject: (obj) => ReserveWitness.fromCoreObject(obj),
|
|
2528
|
+
fetch: async (client, id) => ReserveWitness.fetch(client, id),
|
|
2529
|
+
new: (fields) => {
|
|
2530
|
+
return new ReserveWitness([], fields);
|
|
2531
|
+
},
|
|
2532
|
+
kind: 'StructClassReified',
|
|
2533
|
+
};
|
|
2534
|
+
}
|
|
2535
|
+
static get r() {
|
|
2536
|
+
return ReserveWitness.reified();
|
|
2537
|
+
}
|
|
2538
|
+
static phantom() {
|
|
2539
|
+
return phantom(ReserveWitness.reified());
|
|
2540
|
+
}
|
|
2541
|
+
static get p() {
|
|
2542
|
+
return ReserveWitness.phantom();
|
|
2543
|
+
}
|
|
2544
|
+
static instantiateBcs() {
|
|
2545
|
+
return bcs.struct('ReserveWitness', {
|
|
2546
|
+
dummy_field: bcs.bool(),
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
static cachedBcs = null;
|
|
2550
|
+
static get bcs() {
|
|
2551
|
+
if (!ReserveWitness.cachedBcs) {
|
|
2552
|
+
ReserveWitness.cachedBcs = ReserveWitness.instantiateBcs();
|
|
2553
|
+
}
|
|
2554
|
+
return ReserveWitness.cachedBcs;
|
|
2555
|
+
}
|
|
2556
|
+
static fromFields(fields) {
|
|
2557
|
+
return ReserveWitness.reified().new({
|
|
2558
|
+
dummyField: decodeFromFields('bool', fields.dummy_field),
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
static fromFieldsWithTypes(item) {
|
|
2562
|
+
if (!isReserveWitness(item.type)) {
|
|
2563
|
+
throw new Error('not a ReserveWitness type');
|
|
2564
|
+
}
|
|
2565
|
+
return ReserveWitness.reified().new({
|
|
2566
|
+
dummyField: decodeFromFieldsWithTypes('bool', item.fields.dummy_field),
|
|
2567
|
+
});
|
|
2568
|
+
}
|
|
2569
|
+
static fromBcs(data) {
|
|
2570
|
+
return ReserveWitness.fromFields(ReserveWitness.bcs.parse(data));
|
|
2571
|
+
}
|
|
2572
|
+
toJSONField() {
|
|
2573
|
+
return {
|
|
2574
|
+
dummyField: this.dummyField,
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2577
|
+
toJSON() {
|
|
2578
|
+
return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
|
|
2579
|
+
}
|
|
2580
|
+
static fromJSONField(field) {
|
|
2581
|
+
return ReserveWitness.reified().new({
|
|
2582
|
+
dummyField: decodeFromJSONField('bool', field.dummyField),
|
|
2583
|
+
});
|
|
2584
|
+
}
|
|
2585
|
+
static fromJSON(json) {
|
|
2586
|
+
if (json.$typeName !== ReserveWitness.$typeName) {
|
|
2587
|
+
throw new Error(`not a ReserveWitness json object: expected '${ReserveWitness.$typeName}' but got '${json.$typeName}'`);
|
|
2588
|
+
}
|
|
2589
|
+
return ReserveWitness.fromJSONField(json);
|
|
2590
|
+
}
|
|
2591
|
+
static fromCoreObject(obj) {
|
|
2592
|
+
if (!isReserveWitness(obj.type)) {
|
|
2593
|
+
throw new Error(`object at ${obj.objectId} is not a ReserveWitness object`);
|
|
2594
|
+
}
|
|
2595
|
+
return ReserveWitness.fromBcs(obj.content);
|
|
2596
|
+
}
|
|
2597
|
+
static async fetch(client, id) {
|
|
2598
|
+
const { object } = await client.core.getObject({
|
|
2599
|
+
objectId: id,
|
|
2600
|
+
include: { content: true },
|
|
2601
|
+
});
|
|
2602
|
+
if (!isReserveWitness(object.type)) {
|
|
2603
|
+
throw new Error(`object at id ${id} is not a ReserveWitness object`);
|
|
2604
|
+
}
|
|
2605
|
+
return ReserveWitness.fromBcs(object.content);
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
1989
2608
|
/* ============================== ClaimStakingRewardsEvent =============================== */
|
|
1990
2609
|
export function isClaimStakingRewardsEvent(type) {
|
|
1991
2610
|
type = compressSuiType(type);
|