@suilend/sdk 1.1.26 → 1.1.28
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"1.1.
|
|
1
|
+
{"name":"@suilend/sdk","version":"1.1.28","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","./constants":"./constants.js","./types":"./types.js","./api/events":"./api/events.js","./api":"./api/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","./utils/events":"./utils/events.js","./utils":"./utils/index.js","./utils/obligation":"./utils/obligation.js","./utils/simulate":"./utils/simulate.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","./_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/source/0x1":"./_generated/_dependencies/source/0x1/index.js","./_generated/_dependencies/source/0x2":"./_generated/_dependencies/source/0x2/index.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js","./_generated/_dependencies/source/0x1/ascii/structs":"./_generated/_dependencies/source/0x1/ascii/structs.js","./_generated/_dependencies/source/0x1/option/structs":"./_generated/_dependencies/source/0x1/option/structs.js","./_generated/_dependencies/source/0x1/type-name/structs":"./_generated/_dependencies/source/0x1/type-name/structs.js","./_generated/_dependencies/source/0x2/bag/structs":"./_generated/_dependencies/source/0x2/bag/structs.js","./_generated/_dependencies/source/0x2/balance/structs":"./_generated/_dependencies/source/0x2/balance/structs.js","./_generated/_dependencies/source/0x2/object/structs":"./_generated/_dependencies/source/0x2/object/structs.js","./_generated/_dependencies/source/0x2/object-table/structs":"./_generated/_dependencies/source/0x2/object-table/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix \"./src/**/*.ts\"","prettier":"prettier --write \"./src/**/*\"","lint":"bun eslint && bun prettier && bun tsc --noEmit","release":"bun run build && bun ts-node ./release.ts && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/solendprotocol/suilend-public.git"},"bugs":{"url":"https://github.com/solendprotocol/suilend-public/issues"},"dependencies":{"@mysten/bcs":"1.2.0","@mysten/sui":"1.17.0","@pythnetwork/pyth-sui-js":"^2.1.0","bignumber.js":"^9.1.2","p-limit":"3.1.0","uuid":"^11.0.3"},"devDependencies":{"ts-node":"^10.9.2"}}
|
|
@@ -12,7 +12,7 @@ export declare const parseLendingMarket: (lendingMarket: LendingMarket<string>,
|
|
|
12
12
|
openLtvPct: number;
|
|
13
13
|
closeLtvPct: number;
|
|
14
14
|
maxCloseLtvPct: number;
|
|
15
|
-
borrowWeightBps:
|
|
15
|
+
borrowWeightBps: BigNumber;
|
|
16
16
|
depositLimit: BigNumber;
|
|
17
17
|
borrowLimit: BigNumber;
|
|
18
18
|
liquidationBonusBps: number;
|
package/parsers/obligation.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const parseObligation: (obligation: Obligation<string>, parsedRes
|
|
|
32
32
|
openLtvPct: number;
|
|
33
33
|
closeLtvPct: number;
|
|
34
34
|
maxCloseLtvPct: number;
|
|
35
|
-
borrowWeightBps:
|
|
35
|
+
borrowWeightBps: BigNumber;
|
|
36
36
|
depositLimit: BigNumber;
|
|
37
37
|
borrowLimit: BigNumber;
|
|
38
38
|
liquidationBonusBps: number;
|
|
@@ -149,7 +149,7 @@ export declare const parseObligation: (obligation: Obligation<string>, parsedRes
|
|
|
149
149
|
openLtvPct: number;
|
|
150
150
|
closeLtvPct: number;
|
|
151
151
|
maxCloseLtvPct: number;
|
|
152
|
-
borrowWeightBps:
|
|
152
|
+
borrowWeightBps: BigNumber;
|
|
153
153
|
depositLimit: BigNumber;
|
|
154
154
|
borrowLimit: BigNumber;
|
|
155
155
|
liquidationBonusBps: number;
|
package/parsers/obligation.js
CHANGED
|
@@ -62,10 +62,11 @@ const parseObligation = (obligation, parsedReserveMap) => {
|
|
|
62
62
|
const borrowInterestIndex = reserve.cumulativeBorrowRate.div(cumulativeBorrowRate);
|
|
63
63
|
const borrowedAmount = borrowedAmountInitial.times(borrowInterestIndex);
|
|
64
64
|
const borrowedAmountUsd = borrowedAmount.times(reserve.price);
|
|
65
|
-
const borrowWeight = reserve.config.borrowWeightBps / 10000;
|
|
66
65
|
totalBorrowedAmountUsd = totalBorrowedAmountUsd.plus(borrowedAmountUsd);
|
|
67
|
-
weightedBorrowsUsd = weightedBorrowsUsd.plus(borrowedAmountUsd.times(
|
|
68
|
-
maxPriceWeightedBorrowsUsd = maxPriceWeightedBorrowsUsd.plus(borrowedAmount
|
|
66
|
+
weightedBorrowsUsd = weightedBorrowsUsd.plus(borrowedAmountUsd.times(reserve.config.borrowWeightBps.div(10000)));
|
|
67
|
+
maxPriceWeightedBorrowsUsd = maxPriceWeightedBorrowsUsd.plus(borrowedAmount
|
|
68
|
+
.times(reserve.maxPrice)
|
|
69
|
+
.times(reserve.config.borrowWeightBps.div(10000)));
|
|
69
70
|
const reserveArrayIndex = borrow.reserveArrayIndex;
|
|
70
71
|
const userRewardManagerIndex = Number(borrow.userRewardManagerIndex.toString());
|
|
71
72
|
const userRewardManager = obligation.userRewardManagers[userRewardManagerIndex];
|
package/parsers/reserve.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const parseReserve: (reserve: Reserve<string>, coinMetadataMap: R
|
|
|
12
12
|
openLtvPct: number;
|
|
13
13
|
closeLtvPct: number;
|
|
14
14
|
maxCloseLtvPct: number;
|
|
15
|
-
borrowWeightBps:
|
|
15
|
+
borrowWeightBps: BigNumber;
|
|
16
16
|
depositLimit: BigNumber;
|
|
17
17
|
borrowLimit: BigNumber;
|
|
18
18
|
liquidationBonusBps: number;
|
|
@@ -134,7 +134,7 @@ export declare const parseReserveConfig: (reserve: Reserve<string>) => {
|
|
|
134
134
|
openLtvPct: number;
|
|
135
135
|
closeLtvPct: number;
|
|
136
136
|
maxCloseLtvPct: number;
|
|
137
|
-
borrowWeightBps:
|
|
137
|
+
borrowWeightBps: BigNumber;
|
|
138
138
|
depositLimit: BigNumber;
|
|
139
139
|
borrowLimit: BigNumber;
|
|
140
140
|
liquidationBonusBps: number;
|
package/parsers/reserve.js
CHANGED
|
@@ -73,9 +73,7 @@ const parseReserve = (reserve, coinMetadataMap) => {
|
|
|
73
73
|
// Custom
|
|
74
74
|
const availableAmountUsd = availableAmount.times(price);
|
|
75
75
|
const borrowedAmountUsd = borrowedAmount.times(price);
|
|
76
|
-
const depositedAmount = borrowedAmount
|
|
77
|
-
.plus(availableAmount)
|
|
78
|
-
.minus(unclaimedSpreadFees);
|
|
76
|
+
const depositedAmount = borrowedAmount.plus(availableAmount);
|
|
79
77
|
const depositedAmountUsd = depositedAmount.times(price);
|
|
80
78
|
const cTokenExchangeRate = simulate.cTokenRatio(reserve);
|
|
81
79
|
const borrowAprPercent = simulate.calculateBorrowAprPercent(reserve);
|
|
@@ -148,7 +146,7 @@ const parseReserveConfig = (reserve) => {
|
|
|
148
146
|
const openLtvPct = config.openLtvPct;
|
|
149
147
|
const closeLtvPct = config.closeLtvPct;
|
|
150
148
|
const maxCloseLtvPct = config.maxCloseLtvPct;
|
|
151
|
-
const borrowWeightBps =
|
|
149
|
+
const borrowWeightBps = (0, bignumber_js_1.default)(config.borrowWeightBps.toString());
|
|
152
150
|
const depositLimit = new bignumber_js_1.default(config.depositLimit.toString()).div(10 ** mintDecimals);
|
|
153
151
|
const borrowLimit = new bignumber_js_1.default(config.borrowLimit.toString()).div(10 ** mintDecimals);
|
|
154
152
|
const liquidationBonusBps = Number(config.liquidationBonusBps.toString());
|