@morpho-org/blue-sdk 1.4.1 → 1.4.3
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/lib/market/Market.d.ts
CHANGED
|
@@ -162,22 +162,22 @@ export declare class Market implements InputMarket {
|
|
|
162
162
|
*/
|
|
163
163
|
toBorrowShares(assets: bigint, rounding?: RoundingDirection): bigint;
|
|
164
164
|
/**
|
|
165
|
-
* Returns the volume to supply until the market gets the closest to the given utilization rate.
|
|
165
|
+
* Returns the smallest volume to supply until the market gets the closest to the given utilization rate.
|
|
166
166
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
167
167
|
*/
|
|
168
|
-
getSupplyToUtilization(utilization: bigint):
|
|
168
|
+
getSupplyToUtilization(utilization: bigint): bigint;
|
|
169
169
|
/**
|
|
170
170
|
* Returns the liquidity available to withdraw until the market gets the closest to the given utilization rate.
|
|
171
171
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
172
172
|
*/
|
|
173
|
-
getWithdrawToUtilization(utilization: bigint):
|
|
173
|
+
getWithdrawToUtilization(utilization: bigint): bigint;
|
|
174
174
|
/**
|
|
175
175
|
* Returns the liquidity available to borrow until the market gets the closest to the given utilization rate.
|
|
176
176
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
177
177
|
*/
|
|
178
178
|
getBorrowToUtilization(utilization: bigint): bigint;
|
|
179
179
|
/**
|
|
180
|
-
* Returns the volume to repay until the market gets the closest to the given utilization rate.
|
|
180
|
+
* Returns the smallest volume to repay until the market gets the closest to the given utilization rate.
|
|
181
181
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
182
182
|
*/
|
|
183
183
|
getRepayToUtilization(utilization: bigint): bigint;
|
package/lib/market/Market.js
CHANGED
|
@@ -240,7 +240,7 @@ class Market {
|
|
|
240
240
|
return MarketUtils_1.MarketUtils.toBorrowShares(assets, this, rounding);
|
|
241
241
|
}
|
|
242
242
|
/**
|
|
243
|
-
* Returns the volume to supply until the market gets the closest to the given utilization rate.
|
|
243
|
+
* Returns the smallest volume to supply until the market gets the closest to the given utilization rate.
|
|
244
244
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
245
245
|
*/
|
|
246
246
|
getSupplyToUtilization(utilization) {
|
|
@@ -261,7 +261,7 @@ class Market {
|
|
|
261
261
|
return MarketUtils_1.MarketUtils.getBorrowToUtilization(this, utilization);
|
|
262
262
|
}
|
|
263
263
|
/**
|
|
264
|
-
* Returns the volume to repay until the market gets the closest to the given utilization rate.
|
|
264
|
+
* Returns the smallest volume to repay until the market gets the closest to the given utilization rate.
|
|
265
265
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
266
266
|
*/
|
|
267
267
|
getRepayToUtilization(utilization) {
|
|
@@ -57,14 +57,14 @@ export declare namespace MarketUtils {
|
|
|
57
57
|
feeShares: bigint;
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
|
-
* Returns the volume to supply until the market gets the closest to the given utilization rate.
|
|
60
|
+
* Returns the smallest volume to supply until the market gets the closest to the given utilization rate.
|
|
61
61
|
* @param market The market state.
|
|
62
62
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
63
63
|
*/
|
|
64
|
-
function getSupplyToUtilization(
|
|
64
|
+
function getSupplyToUtilization(market: {
|
|
65
65
|
totalSupplyAssets: BigIntish;
|
|
66
66
|
totalBorrowAssets: BigIntish;
|
|
67
|
-
}, utilization: BigIntish):
|
|
67
|
+
}, utilization: BigIntish): bigint;
|
|
68
68
|
/**
|
|
69
69
|
* Returns the liquidity available to withdraw until the market gets the closest to the given utilization rate.
|
|
70
70
|
* @param market The market state.
|
|
@@ -73,7 +73,7 @@ export declare namespace MarketUtils {
|
|
|
73
73
|
function getWithdrawToUtilization({ totalSupplyAssets, totalBorrowAssets, }: {
|
|
74
74
|
totalSupplyAssets: BigIntish;
|
|
75
75
|
totalBorrowAssets: BigIntish;
|
|
76
|
-
}, utilization: BigIntish):
|
|
76
|
+
}, utilization: BigIntish): bigint;
|
|
77
77
|
/**
|
|
78
78
|
* Returns the liquidity available to borrow until the market gets the closest to the given utilization rate.
|
|
79
79
|
* @param market The market state.
|
|
@@ -84,7 +84,7 @@ export declare namespace MarketUtils {
|
|
|
84
84
|
totalBorrowAssets: BigIntish;
|
|
85
85
|
}, utilization: BigIntish): bigint;
|
|
86
86
|
/**
|
|
87
|
-
* Returns the volume to repay until the market gets the closest to the given utilization rate.
|
|
87
|
+
* Returns the smallest volume to repay until the market gets the closest to the given utilization rate.
|
|
88
88
|
* @param market The market state.
|
|
89
89
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
90
90
|
*/
|
|
@@ -86,19 +86,18 @@ var MarketUtils;
|
|
|
86
86
|
}
|
|
87
87
|
MarketUtils.getAccruedInterest = getAccruedInterest;
|
|
88
88
|
/**
|
|
89
|
-
* Returns the volume to supply until the market gets the closest to the given utilization rate.
|
|
89
|
+
* Returns the smallest volume to supply until the market gets the closest to the given utilization rate.
|
|
90
90
|
* @param market The market state.
|
|
91
91
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
92
92
|
*/
|
|
93
|
-
function getSupplyToUtilization(
|
|
93
|
+
function getSupplyToUtilization(market, utilization) {
|
|
94
94
|
utilization = BigInt(utilization);
|
|
95
|
-
totalBorrowAssets = BigInt(totalBorrowAssets);
|
|
96
95
|
if (utilization === 0n) {
|
|
97
|
-
if (
|
|
98
|
-
return
|
|
99
|
-
return
|
|
96
|
+
if (getUtilization(market) === 0n)
|
|
97
|
+
return 0n;
|
|
98
|
+
return maths_1.MathLib.MAX_UINT_256;
|
|
100
99
|
}
|
|
101
|
-
return maths_1.MathLib.zeroFloorSub(maths_1.MathLib.wDivUp(totalBorrowAssets, utilization), totalSupplyAssets);
|
|
100
|
+
return maths_1.MathLib.zeroFloorSub(maths_1.MathLib.wDivUp(market.totalBorrowAssets, utilization), market.totalSupplyAssets);
|
|
102
101
|
}
|
|
103
102
|
MarketUtils.getSupplyToUtilization = getSupplyToUtilization;
|
|
104
103
|
/**
|
|
@@ -108,6 +107,7 @@ var MarketUtils;
|
|
|
108
107
|
*/
|
|
109
108
|
function getWithdrawToUtilization({ totalSupplyAssets, totalBorrowAssets, }, utilization) {
|
|
110
109
|
utilization = BigInt(utilization);
|
|
110
|
+
totalSupplyAssets = BigInt(totalSupplyAssets);
|
|
111
111
|
totalBorrowAssets = BigInt(totalBorrowAssets);
|
|
112
112
|
if (utilization === 0n) {
|
|
113
113
|
if (totalBorrowAssets === 0n)
|
|
@@ -127,7 +127,7 @@ var MarketUtils;
|
|
|
127
127
|
}
|
|
128
128
|
MarketUtils.getBorrowToUtilization = getBorrowToUtilization;
|
|
129
129
|
/**
|
|
130
|
-
* Returns the volume to repay until the market gets the closest to the given utilization rate.
|
|
130
|
+
* Returns the smallest volume to repay until the market gets the closest to the given utilization rate.
|
|
131
131
|
* @param market The market state.
|
|
132
132
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
133
133
|
*/
|
|
@@ -19,6 +19,8 @@ describe("MarketUtils", () => {
|
|
|
19
19
|
it("should calculate the supply volume to reach utilization", () => {
|
|
20
20
|
expect(MarketUtils_1.MarketUtils.getSupplyToUtilization({ totalSupplyAssets: maths_1.MathLib.WAD, totalBorrowAssets: maths_1.MathLib.WAD }, 900000000000000000n)).toEqual(111111111111111112n);
|
|
21
21
|
expect(MarketUtils_1.MarketUtils.getSupplyToUtilization({ totalSupplyAssets: maths_1.MathLib.WAD, totalBorrowAssets: 0n }, 900000000000000000n)).toEqual(0n);
|
|
22
|
+
expect(MarketUtils_1.MarketUtils.getSupplyToUtilization({ totalSupplyAssets: maths_1.MathLib.WAD, totalBorrowAssets: 0n }, 0n)).toEqual(0n);
|
|
23
|
+
expect(MarketUtils_1.MarketUtils.getSupplyToUtilization({ totalSupplyAssets: maths_1.MathLib.WAD, totalBorrowAssets: 1n }, 0n)).toEqual(maths_1.MathLib.MAX_UINT_256);
|
|
22
24
|
});
|
|
23
25
|
it("should calculate the withdraw volume to reach utilization", () => {
|
|
24
26
|
expect(MarketUtils_1.MarketUtils.getWithdrawToUtilization({ totalSupplyAssets: maths_1.MathLib.WAD, totalBorrowAssets: maths_1.MathLib.WAD }, 900000000000000000n)).toEqual(0n);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/blue-sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"author": "Morpho Association <contact@morpho.org>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"keccak256": "^1.0.6"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@morpho-org/morpho-test": "^1.4.
|
|
20
|
-
"@morpho-org/morpho-ts": "^1.4.
|
|
19
|
+
"@morpho-org/morpho-test": "^1.4.3",
|
|
20
|
+
"@morpho-org/morpho-ts": "^1.4.3",
|
|
21
21
|
"@types/jest": "^29.5.12",
|
|
22
22
|
"@types/node": "^22.0.0",
|
|
23
23
|
"jest": "^29.7.0",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"typescript": "^5.4.5"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@morpho-org/morpho-ts": "^1.4.
|
|
28
|
+
"@morpho-org/morpho-ts": "^1.4.3"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
],
|
|
50
50
|
"preset": "ts-jest"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "451643cc475b899591efce2cf597338c349f4925"
|
|
53
53
|
}
|