@suilend/sdk 13.0.0-next.g16373c6 → 13.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/suilend/reserve/structs.d.ts +0 -95
- package/_generated/suilend/reserve/structs.js +0 -245
- package/client.d.ts +0 -2
- package/client.js +0 -13
- package/package.json +1 -1
- package/utils/events.d.ts +0 -20
- package/utils/events.js +1 -3
- package/utils/simulate.d.ts +0 -12
- package/utils/simulate.js +0 -14
|
@@ -648,11 +648,6 @@ export type ReserveAssetDataEventJSON = {
|
|
|
648
648
|
$typeName: typeof ReserveAssetDataEvent.$typeName;
|
|
649
649
|
$typeArgs: [];
|
|
650
650
|
} & ReserveAssetDataEventJSONField;
|
|
651
|
-
/**
|
|
652
|
-
* Deprecated: this struct's layout is frozen by Sui's upgrade-compatibility check, since
|
|
653
|
-
* it is already published on mainnet. Use `ReserveAssetDataEventV2` instead, which carries
|
|
654
|
-
* every field here plus `conf`.
|
|
655
|
-
*/
|
|
656
651
|
export declare class ReserveAssetDataEvent implements StructClass {
|
|
657
652
|
__StructClass: true;
|
|
658
653
|
static get $typeName(): `${string}::reserve::ReserveAssetDataEvent`;
|
|
@@ -698,96 +693,6 @@ export declare class ReserveAssetDataEvent implements StructClass {
|
|
|
698
693
|
}>): ReserveAssetDataEvent;
|
|
699
694
|
static fetch(client: ClientWithCoreApi, id: string): Promise<ReserveAssetDataEvent>;
|
|
700
695
|
}
|
|
701
|
-
export declare function isReserveAssetDataEventV2(type: string): boolean;
|
|
702
|
-
export interface ReserveAssetDataEventV2Fields {
|
|
703
|
-
lendingMarketId: ToField<'address'>;
|
|
704
|
-
coinType: ToField<TypeName>;
|
|
705
|
-
reserveId: ToField<'address'>;
|
|
706
|
-
availableAmount: ToField<Decimal>;
|
|
707
|
-
supplyAmount: ToField<Decimal>;
|
|
708
|
-
borrowedAmount: ToField<Decimal>;
|
|
709
|
-
availableAmountUsdEstimate: ToField<Decimal>;
|
|
710
|
-
supplyAmountUsdEstimate: ToField<Decimal>;
|
|
711
|
-
borrowedAmountUsdEstimate: ToField<Decimal>;
|
|
712
|
-
borrowApr: ToField<Decimal>;
|
|
713
|
-
supplyApr: ToField<Decimal>;
|
|
714
|
-
ctokenSupply: ToField<'u64'>;
|
|
715
|
-
cumulativeBorrowRate: ToField<Decimal>;
|
|
716
|
-
price: ToField<Decimal>;
|
|
717
|
-
smoothedPrice: ToField<Decimal>;
|
|
718
|
-
priceLastUpdateTimestampS: ToField<'u64'>;
|
|
719
|
-
conf: ToField<Decimal>;
|
|
720
|
-
}
|
|
721
|
-
export type ReserveAssetDataEventV2Reified = Reified<ReserveAssetDataEventV2, ReserveAssetDataEventV2Fields>;
|
|
722
|
-
export type ReserveAssetDataEventV2JSONField = {
|
|
723
|
-
lendingMarketId: string;
|
|
724
|
-
coinType: string;
|
|
725
|
-
reserveId: string;
|
|
726
|
-
availableAmount: ToJSON<Decimal>;
|
|
727
|
-
supplyAmount: ToJSON<Decimal>;
|
|
728
|
-
borrowedAmount: ToJSON<Decimal>;
|
|
729
|
-
availableAmountUsdEstimate: ToJSON<Decimal>;
|
|
730
|
-
supplyAmountUsdEstimate: ToJSON<Decimal>;
|
|
731
|
-
borrowedAmountUsdEstimate: ToJSON<Decimal>;
|
|
732
|
-
borrowApr: ToJSON<Decimal>;
|
|
733
|
-
supplyApr: ToJSON<Decimal>;
|
|
734
|
-
ctokenSupply: string;
|
|
735
|
-
cumulativeBorrowRate: ToJSON<Decimal>;
|
|
736
|
-
price: ToJSON<Decimal>;
|
|
737
|
-
smoothedPrice: ToJSON<Decimal>;
|
|
738
|
-
priceLastUpdateTimestampS: string;
|
|
739
|
-
conf: ToJSON<Decimal>;
|
|
740
|
-
};
|
|
741
|
-
export type ReserveAssetDataEventV2JSON = {
|
|
742
|
-
$typeName: typeof ReserveAssetDataEventV2.$typeName;
|
|
743
|
-
$typeArgs: [];
|
|
744
|
-
} & ReserveAssetDataEventV2JSONField;
|
|
745
|
-
export declare class ReserveAssetDataEventV2 implements StructClass {
|
|
746
|
-
__StructClass: true;
|
|
747
|
-
static get $typeName(): `${string}::reserve::ReserveAssetDataEventV2`;
|
|
748
|
-
static readonly $numTypeParams = 0;
|
|
749
|
-
static readonly $isPhantom: readonly [];
|
|
750
|
-
readonly $typeName: typeof ReserveAssetDataEventV2.$typeName;
|
|
751
|
-
readonly $fullTypeName: `${string}::reserve::ReserveAssetDataEventV2`;
|
|
752
|
-
readonly $typeArgs: [];
|
|
753
|
-
readonly $isPhantom: typeof ReserveAssetDataEventV2.$isPhantom;
|
|
754
|
-
readonly lendingMarketId: ToField<'address'>;
|
|
755
|
-
readonly coinType: ToField<TypeName>;
|
|
756
|
-
readonly reserveId: ToField<'address'>;
|
|
757
|
-
readonly availableAmount: ToField<Decimal>;
|
|
758
|
-
readonly supplyAmount: ToField<Decimal>;
|
|
759
|
-
readonly borrowedAmount: ToField<Decimal>;
|
|
760
|
-
readonly availableAmountUsdEstimate: ToField<Decimal>;
|
|
761
|
-
readonly supplyAmountUsdEstimate: ToField<Decimal>;
|
|
762
|
-
readonly borrowedAmountUsdEstimate: ToField<Decimal>;
|
|
763
|
-
readonly borrowApr: ToField<Decimal>;
|
|
764
|
-
readonly supplyApr: ToField<Decimal>;
|
|
765
|
-
readonly ctokenSupply: ToField<'u64'>;
|
|
766
|
-
readonly cumulativeBorrowRate: ToField<Decimal>;
|
|
767
|
-
readonly price: ToField<Decimal>;
|
|
768
|
-
readonly smoothedPrice: ToField<Decimal>;
|
|
769
|
-
readonly priceLastUpdateTimestampS: ToField<'u64'>;
|
|
770
|
-
readonly conf: ToField<Decimal>;
|
|
771
|
-
private constructor();
|
|
772
|
-
static reified(): ReserveAssetDataEventV2Reified;
|
|
773
|
-
static get r(): ReserveAssetDataEventV2Reified;
|
|
774
|
-
static phantom(): PhantomReified<ToTypeStr<ReserveAssetDataEventV2>>;
|
|
775
|
-
static get p(): PhantomReified<ToTypeStr<ReserveAssetDataEventV2>>;
|
|
776
|
-
private static instantiateBcs;
|
|
777
|
-
private static cachedBcs;
|
|
778
|
-
static get bcs(): ReturnType<typeof ReserveAssetDataEventV2.instantiateBcs>;
|
|
779
|
-
static fromFields(fields: Record<string, any>): ReserveAssetDataEventV2;
|
|
780
|
-
static fromFieldsWithTypes(item: FieldsWithTypes): ReserveAssetDataEventV2;
|
|
781
|
-
static fromBcs(data: Uint8Array): ReserveAssetDataEventV2;
|
|
782
|
-
toJSONField(): ReserveAssetDataEventV2JSONField;
|
|
783
|
-
toJSON(): ReserveAssetDataEventV2JSON;
|
|
784
|
-
static fromJSONField(field: any): ReserveAssetDataEventV2;
|
|
785
|
-
static fromJSON(json: Record<string, any>): ReserveAssetDataEventV2;
|
|
786
|
-
static fromCoreObject(obj: SuiClientTypes.Object<{
|
|
787
|
-
content: true;
|
|
788
|
-
}>): ReserveAssetDataEventV2;
|
|
789
|
-
static fetch(client: ClientWithCoreApi, id: string): Promise<ReserveAssetDataEventV2>;
|
|
790
|
-
}
|
|
791
696
|
export declare function isClaimStakingRewardsEvent(type: string): boolean;
|
|
792
697
|
export interface ClaimStakingRewardsEventFields {
|
|
793
698
|
lendingMarketId: ToField<'address'>;
|
|
@@ -1754,11 +1754,6 @@ export function isReserveAssetDataEvent(type) {
|
|
|
1754
1754
|
return type
|
|
1755
1755
|
=== `${getTypeOrigin('suilend', 'reserve::ReserveAssetDataEvent')}::reserve::ReserveAssetDataEvent`;
|
|
1756
1756
|
}
|
|
1757
|
-
/**
|
|
1758
|
-
* Deprecated: this struct's layout is frozen by Sui's upgrade-compatibility check, since
|
|
1759
|
-
* it is already published on mainnet. Use `ReserveAssetDataEventV2` instead, which carries
|
|
1760
|
-
* every field here plus `conf`.
|
|
1761
|
-
*/
|
|
1762
1757
|
export class ReserveAssetDataEvent {
|
|
1763
1758
|
__StructClass = true;
|
|
1764
1759
|
static get $typeName() {
|
|
@@ -1986,246 +1981,6 @@ export class ReserveAssetDataEvent {
|
|
|
1986
1981
|
return ReserveAssetDataEvent.fromBcs(object.content);
|
|
1987
1982
|
}
|
|
1988
1983
|
}
|
|
1989
|
-
/* ============================== ReserveAssetDataEventV2 =============================== */
|
|
1990
|
-
export function isReserveAssetDataEventV2(type) {
|
|
1991
|
-
type = compressSuiType(type);
|
|
1992
|
-
return type
|
|
1993
|
-
=== `${getTypeOrigin('suilend', 'reserve::ReserveAssetDataEventV2')}::reserve::ReserveAssetDataEventV2`;
|
|
1994
|
-
}
|
|
1995
|
-
export class ReserveAssetDataEventV2 {
|
|
1996
|
-
__StructClass = true;
|
|
1997
|
-
static get $typeName() {
|
|
1998
|
-
return `${getTypeOrigin('suilend', 'reserve::ReserveAssetDataEventV2')}::reserve::ReserveAssetDataEventV2`;
|
|
1999
|
-
}
|
|
2000
|
-
static $numTypeParams = 0;
|
|
2001
|
-
static $isPhantom = [];
|
|
2002
|
-
$typeName = ReserveAssetDataEventV2.$typeName;
|
|
2003
|
-
$fullTypeName;
|
|
2004
|
-
$typeArgs;
|
|
2005
|
-
$isPhantom = ReserveAssetDataEventV2.$isPhantom;
|
|
2006
|
-
lendingMarketId;
|
|
2007
|
-
coinType;
|
|
2008
|
-
reserveId;
|
|
2009
|
-
availableAmount;
|
|
2010
|
-
supplyAmount;
|
|
2011
|
-
borrowedAmount;
|
|
2012
|
-
availableAmountUsdEstimate;
|
|
2013
|
-
supplyAmountUsdEstimate;
|
|
2014
|
-
borrowedAmountUsdEstimate;
|
|
2015
|
-
borrowApr;
|
|
2016
|
-
supplyApr;
|
|
2017
|
-
ctokenSupply;
|
|
2018
|
-
cumulativeBorrowRate;
|
|
2019
|
-
price;
|
|
2020
|
-
smoothedPrice;
|
|
2021
|
-
priceLastUpdateTimestampS;
|
|
2022
|
-
conf;
|
|
2023
|
-
constructor(typeArgs, fields) {
|
|
2024
|
-
this.$fullTypeName = composeSuiType(ReserveAssetDataEventV2.$typeName, ...typeArgs);
|
|
2025
|
-
this.$typeArgs = typeArgs;
|
|
2026
|
-
this.lendingMarketId = fields.lendingMarketId;
|
|
2027
|
-
this.coinType = fields.coinType;
|
|
2028
|
-
this.reserveId = fields.reserveId;
|
|
2029
|
-
this.availableAmount = fields.availableAmount;
|
|
2030
|
-
this.supplyAmount = fields.supplyAmount;
|
|
2031
|
-
this.borrowedAmount = fields.borrowedAmount;
|
|
2032
|
-
this.availableAmountUsdEstimate = fields.availableAmountUsdEstimate;
|
|
2033
|
-
this.supplyAmountUsdEstimate = fields.supplyAmountUsdEstimate;
|
|
2034
|
-
this.borrowedAmountUsdEstimate = fields.borrowedAmountUsdEstimate;
|
|
2035
|
-
this.borrowApr = fields.borrowApr;
|
|
2036
|
-
this.supplyApr = fields.supplyApr;
|
|
2037
|
-
this.ctokenSupply = fields.ctokenSupply;
|
|
2038
|
-
this.cumulativeBorrowRate = fields.cumulativeBorrowRate;
|
|
2039
|
-
this.price = fields.price;
|
|
2040
|
-
this.smoothedPrice = fields.smoothedPrice;
|
|
2041
|
-
this.priceLastUpdateTimestampS = fields.priceLastUpdateTimestampS;
|
|
2042
|
-
this.conf = fields.conf;
|
|
2043
|
-
}
|
|
2044
|
-
static reified() {
|
|
2045
|
-
const reifiedBcs = ReserveAssetDataEventV2.bcs;
|
|
2046
|
-
return {
|
|
2047
|
-
get typeName() {
|
|
2048
|
-
return ReserveAssetDataEventV2.$typeName;
|
|
2049
|
-
},
|
|
2050
|
-
get fullTypeName() {
|
|
2051
|
-
return composeSuiType(ReserveAssetDataEventV2.$typeName, ...[]);
|
|
2052
|
-
},
|
|
2053
|
-
typeArgs: [],
|
|
2054
|
-
isPhantom: ReserveAssetDataEventV2.$isPhantom,
|
|
2055
|
-
reifiedTypeArgs: [],
|
|
2056
|
-
fromFields: (fields) => ReserveAssetDataEventV2.fromFields(fields),
|
|
2057
|
-
fromFieldsWithTypes: (item) => ReserveAssetDataEventV2.fromFieldsWithTypes(item),
|
|
2058
|
-
fromBcs: (data) => ReserveAssetDataEventV2.fromFields(reifiedBcs.parse(data)),
|
|
2059
|
-
bcs: reifiedBcs,
|
|
2060
|
-
fromJSONField: (field) => ReserveAssetDataEventV2.fromJSONField(field),
|
|
2061
|
-
fromJSON: (json) => ReserveAssetDataEventV2.fromJSON(json),
|
|
2062
|
-
fromCoreObject: (obj) => ReserveAssetDataEventV2.fromCoreObject(obj),
|
|
2063
|
-
fetch: async (client, id) => ReserveAssetDataEventV2.fetch(client, id),
|
|
2064
|
-
new: (fields) => {
|
|
2065
|
-
return new ReserveAssetDataEventV2([], fields);
|
|
2066
|
-
},
|
|
2067
|
-
kind: 'StructClassReified',
|
|
2068
|
-
};
|
|
2069
|
-
}
|
|
2070
|
-
static get r() {
|
|
2071
|
-
return ReserveAssetDataEventV2.reified();
|
|
2072
|
-
}
|
|
2073
|
-
static phantom() {
|
|
2074
|
-
return phantom(ReserveAssetDataEventV2.reified());
|
|
2075
|
-
}
|
|
2076
|
-
static get p() {
|
|
2077
|
-
return ReserveAssetDataEventV2.phantom();
|
|
2078
|
-
}
|
|
2079
|
-
static instantiateBcs() {
|
|
2080
|
-
return bcs.struct('ReserveAssetDataEventV2', {
|
|
2081
|
-
lending_market_id: bcs.bytes(32).transform({
|
|
2082
|
-
input: (val) => fromHex(val),
|
|
2083
|
-
output: (val) => toHex(val),
|
|
2084
|
-
}),
|
|
2085
|
-
coin_type: TypeName.bcs,
|
|
2086
|
-
reserve_id: bcs.bytes(32).transform({
|
|
2087
|
-
input: (val) => fromHex(val),
|
|
2088
|
-
output: (val) => toHex(val),
|
|
2089
|
-
}),
|
|
2090
|
-
available_amount: Decimal.bcs,
|
|
2091
|
-
supply_amount: Decimal.bcs,
|
|
2092
|
-
borrowed_amount: Decimal.bcs,
|
|
2093
|
-
available_amount_usd_estimate: Decimal.bcs,
|
|
2094
|
-
supply_amount_usd_estimate: Decimal.bcs,
|
|
2095
|
-
borrowed_amount_usd_estimate: Decimal.bcs,
|
|
2096
|
-
borrow_apr: Decimal.bcs,
|
|
2097
|
-
supply_apr: Decimal.bcs,
|
|
2098
|
-
ctoken_supply: bcs.u64(),
|
|
2099
|
-
cumulative_borrow_rate: Decimal.bcs,
|
|
2100
|
-
price: Decimal.bcs,
|
|
2101
|
-
smoothed_price: Decimal.bcs,
|
|
2102
|
-
price_last_update_timestamp_s: bcs.u64(),
|
|
2103
|
-
conf: Decimal.bcs,
|
|
2104
|
-
});
|
|
2105
|
-
}
|
|
2106
|
-
static cachedBcs = null;
|
|
2107
|
-
static get bcs() {
|
|
2108
|
-
if (!ReserveAssetDataEventV2.cachedBcs) {
|
|
2109
|
-
ReserveAssetDataEventV2.cachedBcs = ReserveAssetDataEventV2.instantiateBcs();
|
|
2110
|
-
}
|
|
2111
|
-
return ReserveAssetDataEventV2.cachedBcs;
|
|
2112
|
-
}
|
|
2113
|
-
static fromFields(fields) {
|
|
2114
|
-
return ReserveAssetDataEventV2.reified().new({
|
|
2115
|
-
lendingMarketId: decodeFromFields('address', fields.lending_market_id),
|
|
2116
|
-
coinType: decodeFromFields(TypeName.reified(), fields.coin_type),
|
|
2117
|
-
reserveId: decodeFromFields('address', fields.reserve_id),
|
|
2118
|
-
availableAmount: decodeFromFields(Decimal.reified(), fields.available_amount),
|
|
2119
|
-
supplyAmount: decodeFromFields(Decimal.reified(), fields.supply_amount),
|
|
2120
|
-
borrowedAmount: decodeFromFields(Decimal.reified(), fields.borrowed_amount),
|
|
2121
|
-
availableAmountUsdEstimate: decodeFromFields(Decimal.reified(), fields.available_amount_usd_estimate),
|
|
2122
|
-
supplyAmountUsdEstimate: decodeFromFields(Decimal.reified(), fields.supply_amount_usd_estimate),
|
|
2123
|
-
borrowedAmountUsdEstimate: decodeFromFields(Decimal.reified(), fields.borrowed_amount_usd_estimate),
|
|
2124
|
-
borrowApr: decodeFromFields(Decimal.reified(), fields.borrow_apr),
|
|
2125
|
-
supplyApr: decodeFromFields(Decimal.reified(), fields.supply_apr),
|
|
2126
|
-
ctokenSupply: decodeFromFields('u64', fields.ctoken_supply),
|
|
2127
|
-
cumulativeBorrowRate: decodeFromFields(Decimal.reified(), fields.cumulative_borrow_rate),
|
|
2128
|
-
price: decodeFromFields(Decimal.reified(), fields.price),
|
|
2129
|
-
smoothedPrice: decodeFromFields(Decimal.reified(), fields.smoothed_price),
|
|
2130
|
-
priceLastUpdateTimestampS: decodeFromFields('u64', fields.price_last_update_timestamp_s),
|
|
2131
|
-
conf: decodeFromFields(Decimal.reified(), fields.conf),
|
|
2132
|
-
});
|
|
2133
|
-
}
|
|
2134
|
-
static fromFieldsWithTypes(item) {
|
|
2135
|
-
if (!isReserveAssetDataEventV2(item.type)) {
|
|
2136
|
-
throw new Error('not a ReserveAssetDataEventV2 type');
|
|
2137
|
-
}
|
|
2138
|
-
return ReserveAssetDataEventV2.reified().new({
|
|
2139
|
-
lendingMarketId: decodeFromFieldsWithTypes('address', item.fields.lending_market_id),
|
|
2140
|
-
coinType: decodeFromFieldsWithTypes(TypeName.reified(), item.fields.coin_type),
|
|
2141
|
-
reserveId: decodeFromFieldsWithTypes('address', item.fields.reserve_id),
|
|
2142
|
-
availableAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.available_amount),
|
|
2143
|
-
supplyAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.supply_amount),
|
|
2144
|
-
borrowedAmount: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrowed_amount),
|
|
2145
|
-
availableAmountUsdEstimate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.available_amount_usd_estimate),
|
|
2146
|
-
supplyAmountUsdEstimate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.supply_amount_usd_estimate),
|
|
2147
|
-
borrowedAmountUsdEstimate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrowed_amount_usd_estimate),
|
|
2148
|
-
borrowApr: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.borrow_apr),
|
|
2149
|
-
supplyApr: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.supply_apr),
|
|
2150
|
-
ctokenSupply: decodeFromFieldsWithTypes('u64', item.fields.ctoken_supply),
|
|
2151
|
-
cumulativeBorrowRate: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.cumulative_borrow_rate),
|
|
2152
|
-
price: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.price),
|
|
2153
|
-
smoothedPrice: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.smoothed_price),
|
|
2154
|
-
priceLastUpdateTimestampS: decodeFromFieldsWithTypes('u64', item.fields.price_last_update_timestamp_s),
|
|
2155
|
-
conf: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.conf),
|
|
2156
|
-
});
|
|
2157
|
-
}
|
|
2158
|
-
static fromBcs(data) {
|
|
2159
|
-
return ReserveAssetDataEventV2.fromFields(ReserveAssetDataEventV2.bcs.parse(data));
|
|
2160
|
-
}
|
|
2161
|
-
toJSONField() {
|
|
2162
|
-
return {
|
|
2163
|
-
lendingMarketId: this.lendingMarketId,
|
|
2164
|
-
coinType: this.coinType,
|
|
2165
|
-
reserveId: this.reserveId,
|
|
2166
|
-
availableAmount: this.availableAmount.toJSONField(),
|
|
2167
|
-
supplyAmount: this.supplyAmount.toJSONField(),
|
|
2168
|
-
borrowedAmount: this.borrowedAmount.toJSONField(),
|
|
2169
|
-
availableAmountUsdEstimate: this.availableAmountUsdEstimate.toJSONField(),
|
|
2170
|
-
supplyAmountUsdEstimate: this.supplyAmountUsdEstimate.toJSONField(),
|
|
2171
|
-
borrowedAmountUsdEstimate: this.borrowedAmountUsdEstimate.toJSONField(),
|
|
2172
|
-
borrowApr: this.borrowApr.toJSONField(),
|
|
2173
|
-
supplyApr: this.supplyApr.toJSONField(),
|
|
2174
|
-
ctokenSupply: this.ctokenSupply.toString(),
|
|
2175
|
-
cumulativeBorrowRate: this.cumulativeBorrowRate.toJSONField(),
|
|
2176
|
-
price: this.price.toJSONField(),
|
|
2177
|
-
smoothedPrice: this.smoothedPrice.toJSONField(),
|
|
2178
|
-
priceLastUpdateTimestampS: this.priceLastUpdateTimestampS.toString(),
|
|
2179
|
-
conf: this.conf.toJSONField(),
|
|
2180
|
-
};
|
|
2181
|
-
}
|
|
2182
|
-
toJSON() {
|
|
2183
|
-
return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() };
|
|
2184
|
-
}
|
|
2185
|
-
static fromJSONField(field) {
|
|
2186
|
-
return ReserveAssetDataEventV2.reified().new({
|
|
2187
|
-
lendingMarketId: decodeFromJSONField('address', field.lendingMarketId),
|
|
2188
|
-
coinType: decodeFromJSONField(TypeName.reified(), field.coinType),
|
|
2189
|
-
reserveId: decodeFromJSONField('address', field.reserveId),
|
|
2190
|
-
availableAmount: decodeFromJSONField(Decimal.reified(), field.availableAmount),
|
|
2191
|
-
supplyAmount: decodeFromJSONField(Decimal.reified(), field.supplyAmount),
|
|
2192
|
-
borrowedAmount: decodeFromJSONField(Decimal.reified(), field.borrowedAmount),
|
|
2193
|
-
availableAmountUsdEstimate: decodeFromJSONField(Decimal.reified(), field.availableAmountUsdEstimate),
|
|
2194
|
-
supplyAmountUsdEstimate: decodeFromJSONField(Decimal.reified(), field.supplyAmountUsdEstimate),
|
|
2195
|
-
borrowedAmountUsdEstimate: decodeFromJSONField(Decimal.reified(), field.borrowedAmountUsdEstimate),
|
|
2196
|
-
borrowApr: decodeFromJSONField(Decimal.reified(), field.borrowApr),
|
|
2197
|
-
supplyApr: decodeFromJSONField(Decimal.reified(), field.supplyApr),
|
|
2198
|
-
ctokenSupply: decodeFromJSONField('u64', field.ctokenSupply),
|
|
2199
|
-
cumulativeBorrowRate: decodeFromJSONField(Decimal.reified(), field.cumulativeBorrowRate),
|
|
2200
|
-
price: decodeFromJSONField(Decimal.reified(), field.price),
|
|
2201
|
-
smoothedPrice: decodeFromJSONField(Decimal.reified(), field.smoothedPrice),
|
|
2202
|
-
priceLastUpdateTimestampS: decodeFromJSONField('u64', field.priceLastUpdateTimestampS),
|
|
2203
|
-
conf: decodeFromJSONField(Decimal.reified(), field.conf),
|
|
2204
|
-
});
|
|
2205
|
-
}
|
|
2206
|
-
static fromJSON(json) {
|
|
2207
|
-
if (json.$typeName !== ReserveAssetDataEventV2.$typeName) {
|
|
2208
|
-
throw new Error(`not a ReserveAssetDataEventV2 json object: expected '${ReserveAssetDataEventV2.$typeName}' but got '${json.$typeName}'`);
|
|
2209
|
-
}
|
|
2210
|
-
return ReserveAssetDataEventV2.fromJSONField(json);
|
|
2211
|
-
}
|
|
2212
|
-
static fromCoreObject(obj) {
|
|
2213
|
-
if (!isReserveAssetDataEventV2(obj.type)) {
|
|
2214
|
-
throw new Error(`object at ${obj.objectId} is not a ReserveAssetDataEventV2 object`);
|
|
2215
|
-
}
|
|
2216
|
-
return ReserveAssetDataEventV2.fromBcs(obj.content);
|
|
2217
|
-
}
|
|
2218
|
-
static async fetch(client, id) {
|
|
2219
|
-
const { object } = await client.core.getObject({
|
|
2220
|
-
objectId: id,
|
|
2221
|
-
include: { content: true },
|
|
2222
|
-
});
|
|
2223
|
-
if (!isReserveAssetDataEventV2(object.type)) {
|
|
2224
|
-
throw new Error(`object at id ${id} is not a ReserveAssetDataEventV2 object`);
|
|
2225
|
-
}
|
|
2226
|
-
return ReserveAssetDataEventV2.fromBcs(object.content);
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
1984
|
/* ============================== ClaimStakingRewardsEvent =============================== */
|
|
2230
1985
|
export function isClaimStakingRewardsEvent(type) {
|
|
2231
1986
|
type = compressSuiType(type);
|
package/client.d.ts
CHANGED
|
@@ -94,8 +94,6 @@ export declare class SuilendClient {
|
|
|
94
94
|
}>;
|
|
95
95
|
/** A reserve's confidence multiplier `k`, in bps; pass `parsedReserve.config.additionalFields.id`. 0 when unset. */
|
|
96
96
|
static getReserveConfidenceMultiplierBps(suiGrpcClient: SuiGrpcClient, additionalFieldsBagId: string): Promise<BigNumber>;
|
|
97
|
-
/** A reserve's stored Pyth confidence (the `ConfidenceKey` dynamic field on `reserve.id` directly, not inside `config.additionalFields`). Reads as 0 until the reserve's first price update writes it. */
|
|
98
|
-
static getReserveStoredConfidence(suiGrpcClient: SuiGrpcClient, reserveId: string): Promise<BigNumber>;
|
|
99
97
|
static createNewLendingMarket(registryId: string, lendingMarketType: string, transaction: Transaction): {
|
|
100
98
|
NestedResult: [number, number];
|
|
101
99
|
$kind: "NestedResult";
|
package/client.js
CHANGED
|
@@ -4,8 +4,6 @@ import { SuiPythClient } from "@pythnetwork/pyth-sui-js";
|
|
|
4
4
|
import BigNumber from "bignumber.js";
|
|
5
5
|
import { extractCTokenCoinType, getAllCoins, getSpendableCoin, } from "@suilend/sui-core";
|
|
6
6
|
import { phantom } from "./_generated/_framework/reified.js";
|
|
7
|
-
import { Decimal } from "./_generated/suilend/decimal/structs.js";
|
|
8
|
-
import { decimalToBigNumber } from "./utils/simulate.js";
|
|
9
7
|
import { PKG_V10, setPublishedAt } from "./_generated/suilend/index.js";
|
|
10
8
|
import { getPublishedAt } from "./_generated/_envs/index.js";
|
|
11
9
|
import { PACKAGE_ID } from "./_generated/suilend/index.js";
|
|
@@ -428,17 +426,6 @@ export class SuilendClient {
|
|
|
428
426
|
});
|
|
429
427
|
return new BigNumber(bcs.u64().parse(dynamicField.value.bcs));
|
|
430
428
|
}
|
|
431
|
-
/** A reserve's stored Pyth confidence (the `ConfidenceKey` dynamic field on `reserve.id` directly, not inside `config.additionalFields`). Reads as 0 until the reserve's first price update writes it. */
|
|
432
|
-
static async getReserveStoredConfidence(suiGrpcClient, reserveId) {
|
|
433
|
-
const match = await findBagEntryByTypeSuffix(suiGrpcClient, reserveId, "::reserve::ConfidenceKey");
|
|
434
|
-
if (!match)
|
|
435
|
-
return new BigNumber(0);
|
|
436
|
-
const { dynamicField } = await suiGrpcClient.getDynamicField({
|
|
437
|
-
parentId: reserveId,
|
|
438
|
-
name: match.name,
|
|
439
|
-
});
|
|
440
|
-
return decimalToBigNumber(Decimal.fromBcs(dynamicField.value.bcs));
|
|
441
|
-
}
|
|
442
429
|
static createNewLendingMarket(registryId, lendingMarketType, transaction) {
|
|
443
430
|
const [ownerCap, lendingMarket] = createLendingMarket(transaction, lendingMarketType, transaction.object(registryId));
|
|
444
431
|
transaction.moveCall({
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"13.0.0
|
|
1
|
+
{"name":"@suilend/sdk","version":"13.0.0","private":false,"description":"A TypeScript SDK for interacting with the Suilend program","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./client":"./client.js","./mmt":"./mmt.js","./strategies":"./strategies.js","./api/events":"./api/events.js","./api":"./api/index.js","./lib/constants":"./lib/constants.js","./lib":"./lib/index.js","./lib/initialize":"./lib/initialize.js","./lib/liquidityMining":"./lib/liquidityMining.js","./lib/proCompatible":"./lib/proCompatible.js","./lib/pyth":"./lib/pyth.js","./lib/strategyOwnerCap":"./lib/strategyOwnerCap.js","./lib/transactions":"./lib/transactions.js","./lib/types":"./lib/types.js","./margin":"./margin/index.js","./parsers/apiReserveAssetDataEvent":"./parsers/apiReserveAssetDataEvent.js","./parsers":"./parsers/index.js","./parsers/lendingMarket":"./parsers/lendingMarket.js","./parsers/obligation":"./parsers/obligation.js","./parsers/rateLimiter":"./parsers/rateLimiter.js","./parsers/reserve":"./parsers/reserve.js","./swap":"./swap/index.js","./swap/quote":"./swap/quote.js","./swap/transaction":"./swap/transaction.js","./utils/events":"./utils/events.js","./utils/feedId":"./utils/feedId.js","./utils":"./utils/index.js","./utils/obligation":"./utils/obligation.js","./utils/simulate":"./utils/simulate.js","./_generated/_envs":"./_generated/_envs/index.js","./_generated/_envs/mainnet":"./_generated/_envs/mainnet.js","./_generated/_framework/env":"./_generated/_framework/env.js","./_generated/_framework/reified":"./_generated/_framework/reified.js","./_generated/_framework/util":"./_generated/_framework/util.js","./_generated/_framework/vector":"./_generated/_framework/vector.js","./_generated/suilend":"./_generated/suilend/index.js","./margin/margin/admin_cap":"./margin/margin/admin_cap.js","./margin/margin/market":"./margin/margin/market.js","./margin/margin/permissions":"./margin/margin/permissions.js","./margin/margin/position":"./margin/margin/position.js","./margin/margin/router":"./margin/margin/router.js","./margin/margin/version":"./margin/margin/version.js","./margin/utils":"./margin/utils/index.js","./_generated/suilend/cell/structs":"./_generated/suilend/cell/structs.js","./_generated/suilend/decimal/structs":"./_generated/suilend/decimal/structs.js","./_generated/suilend/lending-market/functions":"./_generated/suilend/lending-market/functions.js","./_generated/suilend/lending-market/structs":"./_generated/suilend/lending-market/structs.js","./_generated/suilend/lending-market-registry/functions":"./_generated/suilend/lending-market-registry/functions.js","./_generated/suilend/liquidity-mining/structs":"./_generated/suilend/liquidity-mining/structs.js","./_generated/suilend/obligation/structs":"./_generated/suilend/obligation/structs.js","./_generated/suilend/rate-limiter/functions":"./_generated/suilend/rate-limiter/functions.js","./_generated/suilend/rate-limiter/structs":"./_generated/suilend/rate-limiter/structs.js","./_generated/suilend/reserve/structs":"./_generated/suilend/reserve/structs.js","./_generated/suilend/reserve-config/functions":"./_generated/suilend/reserve-config/functions.js","./_generated/suilend/reserve-config/structs":"./_generated/suilend/reserve-config/structs.js","./_generated/_dependencies/pyth-2/price-identifier/structs":"./_generated/_dependencies/pyth-2/price-identifier/structs.js","./_generated/_dependencies/std/ascii/structs":"./_generated/_dependencies/std/ascii/structs.js","./_generated/_dependencies/std/option/structs":"./_generated/_dependencies/std/option/structs.js","./_generated/_dependencies/std/type-name/structs":"./_generated/_dependencies/std/type-name/structs.js","./_generated/_dependencies/sui/bag/structs":"./_generated/_dependencies/sui/bag/structs.js","./_generated/_dependencies/sui/balance/structs":"./_generated/_dependencies/sui/balance/structs.js","./_generated/_dependencies/sui/object/structs":"./_generated/_dependencies/sui/object/structs.js","./_generated/_dependencies/sui/object-table/structs":"./_generated/_dependencies/sui/object-table/structs.js","./margin/margin/deps/std/type_name":"./margin/margin/deps/std/type_name.js","./margin/margin/deps/sui/vec_set":"./margin/margin/deps/sui/vec_set.js","./margin/margin/deps/suilend/lending_market":"./margin/margin/deps/suilend/lending_market.js"},"types":"./index.d.ts","scripts":{"codegen":"node ./codegen.js","codegen:install":"node ./install-codegen.js","build":"rm -rf ./dist && tsc && node ./fix-esm-imports.js","typecheck":"tsc --noEmit && tsc --noEmit -p tsconfig.test.json","test":"vitest run","lint:ci":"yarn run typecheck","prettier":"prettier --write src/ tests/","release":"yarn run build && node ./release.js && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/fireflyprotocol/lending-mono.git","directory":"ts/sdks/sdk"},"dependencies":{"@bluefin-exchange/bluefin7k-aggregator-sdk":"7.6.3","@cetusprotocol/aggregator-sdk":"1.7.3","@flowx-finance/sdk":"2.1.0","@pythnetwork/hermes-client":"3.1.0","@pythnetwork/pyth-sui-js":"4.0.0","@suilend/springsui-sdk":"4.1.0","bignumber.js":"11.1.5","bn.js":"5.2.5","crypto-js":"4.2.0","lodash":"4.18.1","p-limit":"7.3.3","uuid":"14.0.2"},"devDependencies":{"@mysten/bcs":"2.1.1","@mysten/sui":"2.29.0","@suilend/sui-core":"2.1.0","@tsconfig/recommended":"1.0.13","@types/bn.js":"5.2.0","@types/lodash":"4.17.25","@types/node":"26.5.1","fast-check":"4.10.2","prettier":"3.9.9","ts-node":"10.9.2","typescript":"6.0.3","vite":"8.3.0","vitest":"5.0.1"},"peerDependencies":{"@mysten/bcs":"^2.1.1","@mysten/sui":">=2.22.1 <3","@suilend/sui-core":"^2.0.1"},"type":"module"}
|
package/utils/events.d.ts
CHANGED
|
@@ -69,26 +69,6 @@ export declare class ReserveAssetDataEvent extends TypedParamsSuiEvent<{
|
|
|
69
69
|
price_last_update_timestamp_s: u64;
|
|
70
70
|
}> {
|
|
71
71
|
}
|
|
72
|
-
export declare class ReserveAssetDataEventV2 extends TypedParamsSuiEvent<{
|
|
73
|
-
lending_market_id: address;
|
|
74
|
-
coin_type: TypeName;
|
|
75
|
-
reserve_id: address;
|
|
76
|
-
available_amount: Decimal;
|
|
77
|
-
supply_amount: Decimal;
|
|
78
|
-
borrowed_amount: Decimal;
|
|
79
|
-
available_amount_usd_estimate: Decimal;
|
|
80
|
-
supply_amount_usd_estimate: Decimal;
|
|
81
|
-
borrowed_amount_usd_estimate: Decimal;
|
|
82
|
-
borrow_apr: Decimal;
|
|
83
|
-
supply_apr: Decimal;
|
|
84
|
-
ctoken_supply: u64;
|
|
85
|
-
cumulative_borrow_rate: Decimal;
|
|
86
|
-
price: Decimal;
|
|
87
|
-
smoothed_price: Decimal;
|
|
88
|
-
price_last_update_timestamp_s: u64;
|
|
89
|
-
conf: Decimal;
|
|
90
|
-
}> {
|
|
91
|
-
}
|
|
92
72
|
export declare class MintEvent extends TypedParamsSuiEvent<{
|
|
93
73
|
lending_market_id: address;
|
|
94
74
|
coin_type: TypeName;
|
package/utils/events.js
CHANGED
|
@@ -26,7 +26,7 @@ class TypedParamsSuiEvent {
|
|
|
26
26
|
return this.event.json;
|
|
27
27
|
}
|
|
28
28
|
isType(module, eventType) {
|
|
29
|
-
return this.event.eventType.
|
|
29
|
+
return this.event.eventType.includes(`${module}::${eventType}`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
export class GenericSuilendEvent extends TypedParamsSuiEvent {
|
|
@@ -35,8 +35,6 @@ export class InterestUpdateEvent extends TypedParamsSuiEvent {
|
|
|
35
35
|
}
|
|
36
36
|
export class ReserveAssetDataEvent extends TypedParamsSuiEvent {
|
|
37
37
|
}
|
|
38
|
-
export class ReserveAssetDataEventV2 extends TypedParamsSuiEvent {
|
|
39
|
-
}
|
|
40
38
|
export class MintEvent extends TypedParamsSuiEvent {
|
|
41
39
|
}
|
|
42
40
|
export class RedeemEvent extends TypedParamsSuiEvent {
|
package/utils/simulate.d.ts
CHANGED
|
@@ -149,18 +149,6 @@ export declare const refreshObligation: (unrefreshedObligation: Obligation<strin
|
|
|
149
149
|
export declare const numberToDecimal: (value: number) => Decimal;
|
|
150
150
|
export declare const stringToDecimal: (value: string) => Decimal;
|
|
151
151
|
export declare const decimalToBigNumber: (value: Decimal) => BigNumber;
|
|
152
|
-
/**
|
|
153
|
-
* Mirrors reserve.move's `price_lower_bound`/`price_upper_bound`: the one
|
|
154
|
-
* off-chain place this formula lives. `conf` and `kBps` are the reserve's
|
|
155
|
-
* stored Pyth confidence and its `ReserveConfig` confidence multiplier (in
|
|
156
|
-
* bps, e.g. 30000 for a logical k=3) -- both plain human-scale BigNumbers,
|
|
157
|
-
* not WAD-scaled Decimals. `kBps=0` disables the margin entirely: both
|
|
158
|
-
* bounds collapse to plain `min`/`max(price, smoothedPrice)`.
|
|
159
|
-
*/
|
|
160
|
-
export declare const applyConfidenceMargin: (price: BigNumber, smoothedPrice: BigNumber, conf: BigNumber, kBps: BigNumber) => {
|
|
161
|
-
lowerBound: BigNumber;
|
|
162
|
-
upperBound: BigNumber;
|
|
163
|
-
};
|
|
164
152
|
export declare const getCTokenMarketValue: (reserve: Reserve<string>, depositedCTokenAmount: BigNumber) => BigNumber;
|
|
165
153
|
export declare const getCTokenMarketValueLowerBound: (reserve: Reserve<string>, depositedCTokenAmount: BigNumber) => BigNumber;
|
|
166
154
|
export declare const cTokenRatio: (reserve: Reserve<string>) => BigNumber;
|
package/utils/simulate.js
CHANGED
|
@@ -441,20 +441,6 @@ export const stringToDecimal = (value) => {
|
|
|
441
441
|
export const decimalToBigNumber = (value) => {
|
|
442
442
|
return new BigNumber(value.value.toString()).div(WAD);
|
|
443
443
|
};
|
|
444
|
-
/**
|
|
445
|
-
* Mirrors reserve.move's `price_lower_bound`/`price_upper_bound`: the one
|
|
446
|
-
* off-chain place this formula lives. `conf` and `kBps` are the reserve's
|
|
447
|
-
* stored Pyth confidence and its `ReserveConfig` confidence multiplier (in
|
|
448
|
-
* bps, e.g. 30000 for a logical k=3) -- both plain human-scale BigNumbers,
|
|
449
|
-
* not WAD-scaled Decimals. `kBps=0` disables the margin entirely: both
|
|
450
|
-
* bounds collapse to plain `min`/`max(price, smoothedPrice)`.
|
|
451
|
-
*/
|
|
452
|
-
export const applyConfidenceMargin = (price, smoothedPrice, conf, kBps) => {
|
|
453
|
-
const margin = kBps.dividedBy(10_000).multipliedBy(conf);
|
|
454
|
-
const lowerBound = BigNumber.max(BigNumber.min(price, smoothedPrice).minus(margin), new BigNumber(0));
|
|
455
|
-
const upperBound = BigNumber.max(price, smoothedPrice).plus(margin);
|
|
456
|
-
return { lowerBound, upperBound };
|
|
457
|
-
};
|
|
458
444
|
export const getCTokenMarketValue = (reserve, depositedCTokenAmount) => {
|
|
459
445
|
const liquidityAmount = depositedCTokenAmount.multipliedBy(cTokenRatio(reserve));
|
|
460
446
|
return decimalToBigNumber(reserve.price)
|