@morpho-org/blue-sdk 3.0.0-next.9 → 3.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/lib/addresses.d.ts +15 -0
- package/lib/addresses.js +14 -0
- package/lib/errors.d.ts +9 -0
- package/lib/errors.js +20 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/market/Market.d.ts +1 -1
- package/lib/market/MarketUtils.d.ts +2 -2
- package/lib/market/MarketUtils.js +1 -5
- package/lib/position/Position.d.ts +20 -13
- package/lib/position/Position.js +52 -38
- package/lib/position/PreLiquidationPosition.d.ts +60 -0
- package/lib/position/PreLiquidationPosition.js +102 -0
- package/lib/position/index.d.ts +1 -0
- package/lib/position/index.js +1 -0
- package/lib/preLiquidation.d.ts +15 -0
- package/lib/preLiquidation.js +85 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/lib/addresses.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export interface ChainAddresses {
|
|
|
35
35
|
publicAllocator?: Address;
|
|
36
36
|
metaMorphoFactory?: Address;
|
|
37
37
|
chainlinkOracleFactory?: Address;
|
|
38
|
+
preLiquidationFactory?: Address;
|
|
38
39
|
wNative?: Address;
|
|
39
40
|
morphoToken?: Address;
|
|
40
41
|
/**
|
|
@@ -78,6 +79,7 @@ export declare const addressesRegistry: {
|
|
|
78
79
|
readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
|
|
79
80
|
readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
|
|
80
81
|
readonly chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766";
|
|
82
|
+
readonly preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476";
|
|
81
83
|
readonly wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
|
82
84
|
readonly morphoToken: "0x9994E35Db50125E0DF82e4c2dde62496CE330999";
|
|
83
85
|
readonly dai: "0x6B175474E89094C44Da98b954EedeAC495271d0F";
|
|
@@ -128,6 +130,7 @@ export declare const addressesRegistry: {
|
|
|
128
130
|
readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
|
|
129
131
|
readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
|
|
130
132
|
readonly chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d";
|
|
133
|
+
readonly preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef";
|
|
131
134
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
132
135
|
readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
133
136
|
readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
|
|
@@ -148,6 +151,7 @@ export declare const addressesRegistry: {
|
|
|
148
151
|
readonly publicAllocator: "0xfac15aff53ADd2ff80C2962127C434E8615Df0d3";
|
|
149
152
|
readonly metaMorphoFactory: "0xa9c87daB340631C34BB738625C70499e29ddDC98";
|
|
150
153
|
readonly chainlinkOracleFactory: "0x1ff7895Eb842794c5d07C4c547b6730e61295215";
|
|
154
|
+
readonly preLiquidationFactory: "0xeDadDe37D76c72b98725614d0b41C20Fe612d304";
|
|
151
155
|
readonly wNative: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270";
|
|
152
156
|
};
|
|
153
157
|
readonly 42161: {
|
|
@@ -162,6 +166,7 @@ export declare const addressesRegistry: {
|
|
|
162
166
|
readonly publicAllocator: "0x769583Af5e9D03589F159EbEC31Cc2c23E8C355E";
|
|
163
167
|
readonly metaMorphoFactory: "0x878988f5f561081deEa117717052164ea1Ef0c82";
|
|
164
168
|
readonly chainlinkOracleFactory: "0x98Ce5D183DC0c176f54D37162F87e7eD7f2E41b5";
|
|
169
|
+
readonly preLiquidationFactory: "0x635c31B5DF1F7EFbCbC07E302335Ef4230758e3d";
|
|
165
170
|
readonly wNative: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
|
166
171
|
readonly usdc: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
167
172
|
};
|
|
@@ -177,6 +182,7 @@ export declare const addressesRegistry: {
|
|
|
177
182
|
readonly publicAllocator: "0x0d68a97324E602E02799CD83B42D337207B40658";
|
|
178
183
|
readonly metaMorphoFactory: "0x3Bb6A6A0Bc85b367EFE0A5bAc81c5E52C892839a";
|
|
179
184
|
readonly chainlinkOracleFactory: "0x1ec408D4131686f727F3Fd6245CF85Bc5c9DAD70";
|
|
185
|
+
readonly preLiquidationFactory: "0x3d05C01EE8e97361b9E19D172128255eaE5F98B9";
|
|
180
186
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
181
187
|
readonly usdc: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85";
|
|
182
188
|
};
|
|
@@ -190,6 +196,7 @@ export declare const addressesRegistry: {
|
|
|
190
196
|
readonly publicAllocator: "0xef9889B4e443DEd35FA0Bd060f2104Cca94e6A43";
|
|
191
197
|
readonly metaMorphoFactory: "0x4DBB3a642a2146d5413750Cca3647086D9ba5F12";
|
|
192
198
|
readonly chainlinkOracleFactory: "0xd706690BA1Fe26b70c4AD89e60ff62cEB3A2eD02";
|
|
199
|
+
readonly preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695";
|
|
193
200
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
194
201
|
};
|
|
195
202
|
readonly 252: {
|
|
@@ -202,6 +209,7 @@ export declare const addressesRegistry: {
|
|
|
202
209
|
readonly publicAllocator: "0x37a888192165fC39884f87c64E2476BfD2C09675";
|
|
203
210
|
readonly metaMorphoFactory: "0x27D4Af0AC9E7FDfA6D0853236f249CC27AE79488";
|
|
204
211
|
readonly chainlinkOracleFactory: "0x39d8622C607A691D7705E8842fbB12E3c38dCD41";
|
|
212
|
+
readonly preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695";
|
|
205
213
|
readonly wNative: "0xfc00000000000000000000000000000000000006";
|
|
206
214
|
};
|
|
207
215
|
readonly 534352: {
|
|
@@ -214,6 +222,7 @@ export declare const addressesRegistry: {
|
|
|
214
222
|
readonly publicAllocator: "0x8a7f671E45E51dE245649Cf916cA0256FB8a9927";
|
|
215
223
|
readonly metaMorphoFactory: "0x56b65742ade55015e6480959808229Ad6dbc9295";
|
|
216
224
|
readonly chainlinkOracleFactory: "0xb5961902E60b188b1c665B7b72Ef616656A9e24E";
|
|
225
|
+
readonly preLiquidationFactory: "0xeD960178e4aDA0296786Fa79D84e8FDF7bd44B25";
|
|
217
226
|
readonly wNative: "0x5300000000000000000000000000000000000004";
|
|
218
227
|
readonly usdc: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4";
|
|
219
228
|
};
|
|
@@ -227,6 +236,7 @@ export declare const addressesRegistry: {
|
|
|
227
236
|
readonly publicAllocator: "0x85416891752a6B81106c1C2999AE1AF5d8Cd3357";
|
|
228
237
|
readonly metaMorphoFactory: "0xd3f39505d0c48AFED3549D625982FdC38Ea9904b";
|
|
229
238
|
readonly chainlinkOracleFactory: "0x3FFFE273ee348b9E1ef89533025C7f165B17B439";
|
|
239
|
+
readonly preLiquidationFactory: "0x30607fEa77168d2c0401B6f60F0B40E32F9339E3";
|
|
230
240
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
231
241
|
readonly usdc: "0xF1815bd50389c46847f0Bda824eC8da914045D14";
|
|
232
242
|
};
|
|
@@ -240,6 +250,7 @@ export declare const addressesRegistry: {
|
|
|
240
250
|
readonly publicAllocator: "0xB0c9a107fA17c779B3378210A7a593e88938C7C9";
|
|
241
251
|
readonly metaMorphoFactory: "0xe9EdE3929F43a7062a007C3e8652e4ACa610Bdc0";
|
|
242
252
|
readonly chainlinkOracleFactory: "0x43269546e1D586a1f7200a0AC07e26f9631f7539";
|
|
253
|
+
readonly preLiquidationFactory: "0xb04e4D3D59Ee47Ca9BA192707AF13A7D02969911";
|
|
243
254
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
244
255
|
readonly usdc: "0x078D782b760474a361dDA0AF3839290b0EF57AD6";
|
|
245
256
|
};
|
|
@@ -253,6 +264,7 @@ export declare const addressesRegistry: {
|
|
|
253
264
|
readonly publicAllocator: "0x6Cef2EDC70D87E8f1623f3096efF05d066E59B36";
|
|
254
265
|
readonly metaMorphoFactory: "0x0cE9e3512CB4df8ae7e265e62Fb9258dc14f12e8";
|
|
255
266
|
readonly chainlinkOracleFactory: "0x7DA59Fa482F1F49fADc486d8e47BADc506fEb86d";
|
|
267
|
+
readonly preLiquidationFactory: "0xc72129DA4CC808e955699111b8c22B22Ca8A10b8";
|
|
256
268
|
readonly wNative: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38";
|
|
257
269
|
};
|
|
258
270
|
readonly 43111: {
|
|
@@ -265,6 +277,7 @@ export declare const addressesRegistry: {
|
|
|
265
277
|
readonly publicAllocator: "0x4107Ea1746909028d6212B315dE5fE9538F9eb39";
|
|
266
278
|
readonly metaMorphoFactory: "0x8e52179BeB18E882040b01632440d8Ca0f01da82";
|
|
267
279
|
readonly chainlinkOracleFactory: "0xB3cb32E6185446a6Bc7A047E4FfA138fA939e133";
|
|
280
|
+
readonly preLiquidationFactory: "0x40F2896C551194e364F7C846046C34d8a9FE97e4";
|
|
268
281
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
269
282
|
readonly usdc: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA";
|
|
270
283
|
};
|
|
@@ -278,6 +291,7 @@ export declare const addressesRegistry: {
|
|
|
278
291
|
readonly publicAllocator: "0xEE868Bf3359DA30c10ea472EAEBFC0a06E8F0120";
|
|
279
292
|
readonly metaMorphoFactory: "0xae5b0884bfff430493D6C844B9fd052Af7d79278";
|
|
280
293
|
readonly chainlinkOracleFactory: "0xf9380f7898423Bd7FDe3C9fDD1b2671A2471f39D";
|
|
294
|
+
readonly preLiquidationFactory: "0x249E4808264c545861e43728186a731dE7c7D745";
|
|
281
295
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
282
296
|
};
|
|
283
297
|
readonly 21000000: {
|
|
@@ -290,6 +304,7 @@ export declare const addressesRegistry: {
|
|
|
290
304
|
readonly publicAllocator: "0xDFde06e2B2A2D718eE5560b73dA4F830E56A2f10";
|
|
291
305
|
readonly metaMorphoFactory: "0xe430821595602eA5DD0cD350f86987437c7362fA";
|
|
292
306
|
readonly chainlinkOracleFactory: "0x16278156D366fC91536b6b81482ffaC47EEa06D6";
|
|
307
|
+
readonly preLiquidationFactory: "0xb9065AC18d3EBdb3263B77B587f9c5CD570545D1";
|
|
293
308
|
readonly wNative: "0xda5dDd7270381A7C2717aD10D1c0ecB19e3CDFb2";
|
|
294
309
|
readonly usdc: "0xDF0B24095e15044538866576754F3C964e902Ee6";
|
|
295
310
|
};
|
package/lib/addresses.js
CHANGED
|
@@ -40,6 +40,7 @@ exports.addressesRegistry = {
|
|
|
40
40
|
publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D",
|
|
41
41
|
metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24",
|
|
42
42
|
chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766",
|
|
43
|
+
preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476",
|
|
43
44
|
wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
44
45
|
morphoToken: "0x9994E35Db50125E0DF82e4c2dde62496CE330999",
|
|
45
46
|
// Must implement DAI specific permit (otherwise breaks permit signatures).
|
|
@@ -96,6 +97,7 @@ exports.addressesRegistry = {
|
|
|
96
97
|
publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467",
|
|
97
98
|
metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918",
|
|
98
99
|
chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d",
|
|
100
|
+
preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef",
|
|
99
101
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
100
102
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
101
103
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
@@ -117,6 +119,7 @@ exports.addressesRegistry = {
|
|
|
117
119
|
publicAllocator: "0xfac15aff53ADd2ff80C2962127C434E8615Df0d3",
|
|
118
120
|
metaMorphoFactory: "0xa9c87daB340631C34BB738625C70499e29ddDC98",
|
|
119
121
|
chainlinkOracleFactory: "0x1ff7895Eb842794c5d07C4c547b6730e61295215",
|
|
122
|
+
preLiquidationFactory: "0xeDadDe37D76c72b98725614d0b41C20Fe612d304",
|
|
120
123
|
wNative: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
|
|
121
124
|
},
|
|
122
125
|
[chain_js_1.ChainId.ArbitrumMainnet]: {
|
|
@@ -131,6 +134,7 @@ exports.addressesRegistry = {
|
|
|
131
134
|
publicAllocator: "0x769583Af5e9D03589F159EbEC31Cc2c23E8C355E",
|
|
132
135
|
metaMorphoFactory: "0x878988f5f561081deEa117717052164ea1Ef0c82",
|
|
133
136
|
chainlinkOracleFactory: "0x98Ce5D183DC0c176f54D37162F87e7eD7f2E41b5",
|
|
137
|
+
preLiquidationFactory: "0x635c31B5DF1F7EFbCbC07E302335Ef4230758e3d",
|
|
134
138
|
wNative: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
135
139
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
136
140
|
usdc: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
@@ -147,6 +151,7 @@ exports.addressesRegistry = {
|
|
|
147
151
|
publicAllocator: "0x0d68a97324E602E02799CD83B42D337207B40658",
|
|
148
152
|
metaMorphoFactory: "0x3Bb6A6A0Bc85b367EFE0A5bAc81c5E52C892839a",
|
|
149
153
|
chainlinkOracleFactory: "0x1ec408D4131686f727F3Fd6245CF85Bc5c9DAD70",
|
|
154
|
+
preLiquidationFactory: "0x3d05C01EE8e97361b9E19D172128255eaE5F98B9",
|
|
150
155
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
151
156
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
152
157
|
usdc: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
@@ -161,6 +166,7 @@ exports.addressesRegistry = {
|
|
|
161
166
|
publicAllocator: "0xef9889B4e443DEd35FA0Bd060f2104Cca94e6A43",
|
|
162
167
|
metaMorphoFactory: "0x4DBB3a642a2146d5413750Cca3647086D9ba5F12",
|
|
163
168
|
chainlinkOracleFactory: "0xd706690BA1Fe26b70c4AD89e60ff62cEB3A2eD02",
|
|
169
|
+
preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695",
|
|
164
170
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
165
171
|
},
|
|
166
172
|
[chain_js_1.ChainId.FraxtalMainnet]: {
|
|
@@ -173,6 +179,7 @@ exports.addressesRegistry = {
|
|
|
173
179
|
publicAllocator: "0x37a888192165fC39884f87c64E2476BfD2C09675",
|
|
174
180
|
metaMorphoFactory: "0x27D4Af0AC9E7FDfA6D0853236f249CC27AE79488",
|
|
175
181
|
chainlinkOracleFactory: "0x39d8622C607A691D7705E8842fbB12E3c38dCD41",
|
|
182
|
+
preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695",
|
|
176
183
|
wNative: "0xfc00000000000000000000000000000000000006",
|
|
177
184
|
},
|
|
178
185
|
[chain_js_1.ChainId.ScrollMainnet]: {
|
|
@@ -185,6 +192,7 @@ exports.addressesRegistry = {
|
|
|
185
192
|
publicAllocator: "0x8a7f671E45E51dE245649Cf916cA0256FB8a9927",
|
|
186
193
|
metaMorphoFactory: "0x56b65742ade55015e6480959808229Ad6dbc9295",
|
|
187
194
|
chainlinkOracleFactory: "0xb5961902E60b188b1c665B7b72Ef616656A9e24E",
|
|
195
|
+
preLiquidationFactory: "0xeD960178e4aDA0296786Fa79D84e8FDF7bd44B25",
|
|
188
196
|
wNative: "0x5300000000000000000000000000000000000004",
|
|
189
197
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
190
198
|
usdc: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
|
|
@@ -199,6 +207,7 @@ exports.addressesRegistry = {
|
|
|
199
207
|
publicAllocator: "0x85416891752a6B81106c1C2999AE1AF5d8Cd3357",
|
|
200
208
|
metaMorphoFactory: "0xd3f39505d0c48AFED3549D625982FdC38Ea9904b",
|
|
201
209
|
chainlinkOracleFactory: "0x3FFFE273ee348b9E1ef89533025C7f165B17B439",
|
|
210
|
+
preLiquidationFactory: "0x30607fEa77168d2c0401B6f60F0B40E32F9339E3",
|
|
202
211
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
203
212
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
204
213
|
usdc: "0xF1815bd50389c46847f0Bda824eC8da914045D14",
|
|
@@ -213,6 +222,7 @@ exports.addressesRegistry = {
|
|
|
213
222
|
publicAllocator: "0xB0c9a107fA17c779B3378210A7a593e88938C7C9",
|
|
214
223
|
metaMorphoFactory: "0xe9EdE3929F43a7062a007C3e8652e4ACa610Bdc0",
|
|
215
224
|
chainlinkOracleFactory: "0x43269546e1D586a1f7200a0AC07e26f9631f7539",
|
|
225
|
+
preLiquidationFactory: "0xb04e4D3D59Ee47Ca9BA192707AF13A7D02969911",
|
|
216
226
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
217
227
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
218
228
|
usdc: "0x078D782b760474a361dDA0AF3839290b0EF57AD6",
|
|
@@ -227,6 +237,7 @@ exports.addressesRegistry = {
|
|
|
227
237
|
publicAllocator: "0x6Cef2EDC70D87E8f1623f3096efF05d066E59B36",
|
|
228
238
|
metaMorphoFactory: "0x0cE9e3512CB4df8ae7e265e62Fb9258dc14f12e8",
|
|
229
239
|
chainlinkOracleFactory: "0x7DA59Fa482F1F49fADc486d8e47BADc506fEb86d",
|
|
240
|
+
preLiquidationFactory: "0xc72129DA4CC808e955699111b8c22B22Ca8A10b8",
|
|
230
241
|
wNative: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
|
|
231
242
|
},
|
|
232
243
|
[chain_js_1.ChainId.HemiMainnet]: {
|
|
@@ -239,6 +250,7 @@ exports.addressesRegistry = {
|
|
|
239
250
|
publicAllocator: "0x4107Ea1746909028d6212B315dE5fE9538F9eb39",
|
|
240
251
|
metaMorphoFactory: "0x8e52179BeB18E882040b01632440d8Ca0f01da82",
|
|
241
252
|
chainlinkOracleFactory: "0xB3cb32E6185446a6Bc7A047E4FfA138fA939e133",
|
|
253
|
+
preLiquidationFactory: "0x40F2896C551194e364F7C846046C34d8a9FE97e4",
|
|
242
254
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
243
255
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
244
256
|
usdc: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA",
|
|
@@ -253,6 +265,7 @@ exports.addressesRegistry = {
|
|
|
253
265
|
publicAllocator: "0xEE868Bf3359DA30c10ea472EAEBFC0a06E8F0120",
|
|
254
266
|
metaMorphoFactory: "0xae5b0884bfff430493D6C844B9fd052Af7d79278",
|
|
255
267
|
chainlinkOracleFactory: "0xf9380f7898423Bd7FDe3C9fDD1b2671A2471f39D",
|
|
268
|
+
preLiquidationFactory: "0x249E4808264c545861e43728186a731dE7c7D745",
|
|
256
269
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
257
270
|
},
|
|
258
271
|
[chain_js_1.ChainId.CornMainnet]: {
|
|
@@ -265,6 +278,7 @@ exports.addressesRegistry = {
|
|
|
265
278
|
publicAllocator: "0xDFde06e2B2A2D718eE5560b73dA4F830E56A2f10",
|
|
266
279
|
metaMorphoFactory: "0xe430821595602eA5DD0cD350f86987437c7362fA",
|
|
267
280
|
chainlinkOracleFactory: "0x16278156D366fC91536b6b81482ffaC47EEa06D6",
|
|
281
|
+
preLiquidationFactory: "0xb9065AC18d3EBdb3263B77B587f9c5CD570545D1",
|
|
268
282
|
wNative: "0xda5dDd7270381A7C2717aD10D1c0ecB19e3CDFb2",
|
|
269
283
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
270
284
|
usdc: "0xDF0B24095e15044538866576754F3C964e902Ee6",
|
package/lib/errors.d.ts
CHANGED
|
@@ -21,7 +21,16 @@ export declare class UnsupportedChainIdError extends Error {
|
|
|
21
21
|
readonly chainId: number;
|
|
22
22
|
constructor(chainId: number);
|
|
23
23
|
}
|
|
24
|
+
export declare class UnsupportedPreLiquidationParamsError extends Error {
|
|
25
|
+
readonly lltv: bigint;
|
|
26
|
+
constructor(lltv: bigint);
|
|
27
|
+
}
|
|
24
28
|
export declare namespace BlueErrors {
|
|
29
|
+
class AlreadySet extends Error {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly value: string;
|
|
32
|
+
constructor(name: string, value: string);
|
|
33
|
+
}
|
|
25
34
|
class InvalidInterestAccrual extends Error {
|
|
26
35
|
readonly marketId: MarketId;
|
|
27
36
|
readonly timestamp: bigint;
|
package/lib/errors.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlueErrors = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
|
|
3
|
+
exports.BlueErrors = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
|
|
4
4
|
exports._try = _try;
|
|
5
|
+
const viem_1 = require("viem");
|
|
5
6
|
class UnknownDataError extends Error {
|
|
6
7
|
}
|
|
7
8
|
exports.UnknownDataError = UnknownDataError;
|
|
@@ -45,8 +46,26 @@ class UnsupportedChainIdError extends Error {
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
exports.UnsupportedChainIdError = UnsupportedChainIdError;
|
|
49
|
+
class UnsupportedPreLiquidationParamsError extends Error {
|
|
50
|
+
lltv;
|
|
51
|
+
constructor(lltv) {
|
|
52
|
+
super(`unsupported pre liquidation params for lltv ${(0, viem_1.formatUnits)(lltv, 16)}%`);
|
|
53
|
+
this.lltv = lltv;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.UnsupportedPreLiquidationParamsError = UnsupportedPreLiquidationParamsError;
|
|
48
57
|
var BlueErrors;
|
|
49
58
|
(function (BlueErrors) {
|
|
59
|
+
class AlreadySet extends Error {
|
|
60
|
+
name;
|
|
61
|
+
value;
|
|
62
|
+
constructor(name, value) {
|
|
63
|
+
super(`${name} is already set to ${value}`);
|
|
64
|
+
this.name = name;
|
|
65
|
+
this.value = value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
BlueErrors.AlreadySet = AlreadySet;
|
|
50
69
|
class InvalidInterestAccrual extends Error {
|
|
51
70
|
marketId;
|
|
52
71
|
timestamp;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -26,3 +26,4 @@ __exportStar(require("./user/index.js"), exports);
|
|
|
26
26
|
__exportStar(require("./holding/index.js"), exports);
|
|
27
27
|
__exportStar(require("./position/index.js"), exports);
|
|
28
28
|
__exportStar(require("./vault/index.js"), exports);
|
|
29
|
+
__exportStar(require("./preLiquidation.js"), exports);
|
package/lib/market/Market.d.ts
CHANGED
|
@@ -275,7 +275,7 @@ export declare class Market implements IMarket {
|
|
|
275
275
|
getHealthFactor(position: {
|
|
276
276
|
collateral: bigint;
|
|
277
277
|
borrowShares: bigint;
|
|
278
|
-
}): bigint |
|
|
278
|
+
}): bigint | undefined;
|
|
279
279
|
/**
|
|
280
280
|
* Returns the loan-to-value ratio of a given borrow position (scaled by WAD).
|
|
281
281
|
* @param position The borrow position to consider.
|
|
@@ -225,8 +225,8 @@ export declare namespace MarketUtils {
|
|
|
225
225
|
}): bigint | null | undefined;
|
|
226
226
|
/**
|
|
227
227
|
* Returns the health factor of a given borrow position (scaled by WAD).
|
|
228
|
+
* If the debt is 0, health factor is `MaxUint256`.
|
|
228
229
|
* Returns `undefined` iff the market's price is undefined.
|
|
229
|
-
* Returns null if the position is not a borrow.
|
|
230
230
|
*/
|
|
231
231
|
function getHealthFactor({ collateral, borrowShares, }: {
|
|
232
232
|
collateral: BigIntish;
|
|
@@ -237,7 +237,7 @@ export declare namespace MarketUtils {
|
|
|
237
237
|
price?: BigIntish;
|
|
238
238
|
}, marketParams: {
|
|
239
239
|
lltv: BigIntish;
|
|
240
|
-
}): bigint |
|
|
240
|
+
}): bigint | undefined;
|
|
241
241
|
/**
|
|
242
242
|
* Returns the loan-to-value ratio of a given borrow position (scaled by WAD).
|
|
243
243
|
* Returns `undefined` iff the market's price is undefined.
|
|
@@ -272,14 +272,10 @@ var MarketUtils;
|
|
|
272
272
|
MarketUtils.getPriceVariationToLiquidationPrice = getPriceVariationToLiquidationPrice;
|
|
273
273
|
/**
|
|
274
274
|
* Returns the health factor of a given borrow position (scaled by WAD).
|
|
275
|
+
* If the debt is 0, health factor is `MaxUint256`.
|
|
275
276
|
* Returns `undefined` iff the market's price is undefined.
|
|
276
|
-
* Returns null if the position is not a borrow.
|
|
277
277
|
*/
|
|
278
278
|
function getHealthFactor({ collateral, borrowShares, }, market, marketParams) {
|
|
279
|
-
borrowShares = BigInt(borrowShares);
|
|
280
|
-
market.totalBorrowShares = BigInt(market.totalBorrowShares);
|
|
281
|
-
if (borrowShares === 0n || market.totalBorrowShares === 0n)
|
|
282
|
-
return null;
|
|
283
279
|
const borrowAssets = toBorrowAssets(borrowShares, market);
|
|
284
280
|
if (borrowAssets === 0n)
|
|
285
281
|
return index_js_1.MathLib.MAX_UINT_256;
|
|
@@ -33,66 +33,73 @@ export declare class Position implements IPosition {
|
|
|
33
33
|
export interface IAccrualPosition extends Omit<IPosition, "marketId"> {
|
|
34
34
|
}
|
|
35
35
|
export declare class AccrualPosition extends Position implements IAccrualPosition {
|
|
36
|
+
protected readonly _market: Market;
|
|
37
|
+
constructor(position: IAccrualPosition, market: IMarket);
|
|
36
38
|
/**
|
|
37
39
|
* The market on which this position is held.
|
|
38
40
|
*/
|
|
39
|
-
|
|
40
|
-
constructor(position: IAccrualPosition, market: IMarket);
|
|
41
|
+
get market(): Market;
|
|
41
42
|
get supplyAssets(): bigint;
|
|
42
43
|
get borrowAssets(): bigint;
|
|
43
44
|
/**
|
|
44
45
|
* The value of this position's collateral quoted in loan assets.
|
|
45
|
-
* `undefined`
|
|
46
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
46
47
|
*/
|
|
47
48
|
get collateralValue(): bigint | undefined;
|
|
48
49
|
/**
|
|
49
50
|
* The maximum amount of loan assets that can be borrowed against this position's collateral.
|
|
50
|
-
* `undefined`
|
|
51
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
51
52
|
*/
|
|
52
53
|
get maxBorrowAssets(): bigint | undefined;
|
|
53
54
|
/**
|
|
54
55
|
* The maximum additional amount of assets that can be borrowed against this position's collateral.
|
|
55
|
-
* `undefined`
|
|
56
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
56
57
|
*/
|
|
57
58
|
get maxBorrowableAssets(): bigint | undefined;
|
|
58
59
|
/**
|
|
59
60
|
* The maximum amount of collateral that can be seized in exchange for the outstanding debt.
|
|
60
|
-
* `undefined`
|
|
61
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
61
62
|
*/
|
|
62
63
|
get seizableCollateral(): bigint | undefined;
|
|
63
64
|
/**
|
|
64
65
|
* The maximum amount of collateral that can be withdrawn.
|
|
65
|
-
* `undefined`
|
|
66
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
66
67
|
*/
|
|
67
68
|
get withdrawableCollateral(): bigint | undefined;
|
|
68
69
|
/**
|
|
69
70
|
* Whether this position is healthy.
|
|
70
|
-
* `undefined`
|
|
71
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
71
72
|
*/
|
|
72
73
|
get isHealthy(): boolean | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Whether this position can be liquidated.
|
|
76
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
77
|
+
*/
|
|
78
|
+
get isLiquidatable(): boolean | undefined;
|
|
73
79
|
/**
|
|
74
80
|
* The price of the collateral quoted in loan assets that would allow this position to be liquidated.
|
|
81
|
+
* `null` if the position has no borrow.
|
|
75
82
|
*/
|
|
76
83
|
get liquidationPrice(): bigint | null;
|
|
77
84
|
/**
|
|
78
85
|
* The price variation required for the position to reach its liquidation threshold (scaled by WAD).
|
|
79
86
|
* Negative when healthy (the price needs to drop x%), positive when unhealthy (the price needs to soar x%).
|
|
80
|
-
* `undefined`
|
|
81
|
-
*
|
|
87
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
88
|
+
* `null` if the position is not a borrow.
|
|
82
89
|
*/
|
|
83
90
|
get priceVariationToLiquidationPrice(): bigint | null | undefined;
|
|
84
91
|
/**
|
|
85
92
|
* This position's Loan-To-Value (debt over collateral power, scaled by WAD).
|
|
86
93
|
* If the collateral price is 0, LTV is `MaxUint256`.
|
|
87
|
-
* `undefined`
|
|
94
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
88
95
|
*/
|
|
89
96
|
get ltv(): bigint | null | undefined;
|
|
90
97
|
/**
|
|
91
98
|
* This position's health factor (collateral power over debt, scaled by WAD).
|
|
92
99
|
* If the debt is 0, health factor is `MaxUint256`.
|
|
93
|
-
* `undefined`
|
|
100
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
94
101
|
*/
|
|
95
|
-
get healthFactor(): bigint |
|
|
102
|
+
get healthFactor(): bigint | undefined;
|
|
96
103
|
/**
|
|
97
104
|
* The percentage of this position's borrow power currently used (scaled by WAD).
|
|
98
105
|
* If the collateral price is 0, usage is `MaxUint256`.
|
package/lib/position/Position.js
CHANGED
|
@@ -35,38 +35,41 @@ class Position {
|
|
|
35
35
|
}
|
|
36
36
|
exports.Position = Position;
|
|
37
37
|
class AccrualPosition extends Position {
|
|
38
|
-
|
|
39
|
-
* The market on which this position is held.
|
|
40
|
-
*/
|
|
41
|
-
market;
|
|
38
|
+
_market;
|
|
42
39
|
constructor(position, market) {
|
|
43
40
|
const _market = new index_js_1.Market(market);
|
|
44
41
|
super({ ...position, marketId: _market.id });
|
|
45
|
-
this.
|
|
42
|
+
this._market = _market;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The market on which this position is held.
|
|
46
|
+
*/
|
|
47
|
+
get market() {
|
|
48
|
+
return this._market;
|
|
46
49
|
}
|
|
47
50
|
get supplyAssets() {
|
|
48
|
-
return this.
|
|
51
|
+
return this._market.toSupplyAssets(this.supplyShares);
|
|
49
52
|
}
|
|
50
53
|
get borrowAssets() {
|
|
51
|
-
return this.
|
|
54
|
+
return this._market.toBorrowAssets(this.borrowShares);
|
|
52
55
|
}
|
|
53
56
|
/**
|
|
54
57
|
* The value of this position's collateral quoted in loan assets.
|
|
55
|
-
* `undefined`
|
|
58
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
56
59
|
*/
|
|
57
60
|
get collateralValue() {
|
|
58
|
-
return this.
|
|
61
|
+
return this._market.getCollateralValue(this.collateral);
|
|
59
62
|
}
|
|
60
63
|
/**
|
|
61
64
|
* The maximum amount of loan assets that can be borrowed against this position's collateral.
|
|
62
|
-
* `undefined`
|
|
65
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
63
66
|
*/
|
|
64
67
|
get maxBorrowAssets() {
|
|
65
|
-
return this.
|
|
68
|
+
return this._market.getMaxBorrowAssets(this.collateral);
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
71
|
* The maximum additional amount of assets that can be borrowed against this position's collateral.
|
|
69
|
-
* `undefined`
|
|
72
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
70
73
|
*/
|
|
71
74
|
get maxBorrowableAssets() {
|
|
72
75
|
const { maxBorrowAssets } = this;
|
|
@@ -76,86 +79,97 @@ class AccrualPosition extends Position {
|
|
|
76
79
|
}
|
|
77
80
|
/**
|
|
78
81
|
* The maximum amount of collateral that can be seized in exchange for the outstanding debt.
|
|
79
|
-
* `undefined`
|
|
82
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
80
83
|
*/
|
|
81
84
|
get seizableCollateral() {
|
|
82
|
-
return this.
|
|
85
|
+
return this._market.getSeizableCollateral(this);
|
|
83
86
|
}
|
|
84
87
|
/**
|
|
85
88
|
* The maximum amount of collateral that can be withdrawn.
|
|
86
|
-
* `undefined`
|
|
89
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
87
90
|
*/
|
|
88
91
|
get withdrawableCollateral() {
|
|
89
|
-
return this.
|
|
92
|
+
return this._market.getWithdrawableCollateral(this);
|
|
90
93
|
}
|
|
91
94
|
/**
|
|
92
95
|
* Whether this position is healthy.
|
|
93
|
-
* `undefined`
|
|
96
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
94
97
|
*/
|
|
95
98
|
get isHealthy() {
|
|
96
|
-
return this.
|
|
99
|
+
return this._market.isHealthy(this);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Whether this position can be liquidated.
|
|
103
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
104
|
+
*/
|
|
105
|
+
get isLiquidatable() {
|
|
106
|
+
const isHealthy = this._market.isHealthy(this);
|
|
107
|
+
if (isHealthy == null)
|
|
108
|
+
return;
|
|
109
|
+
return !isHealthy;
|
|
97
110
|
}
|
|
98
111
|
/**
|
|
99
112
|
* The price of the collateral quoted in loan assets that would allow this position to be liquidated.
|
|
113
|
+
* `null` if the position has no borrow.
|
|
100
114
|
*/
|
|
101
115
|
get liquidationPrice() {
|
|
102
|
-
return this.
|
|
116
|
+
return this._market.getLiquidationPrice(this);
|
|
103
117
|
}
|
|
104
118
|
/**
|
|
105
119
|
* The price variation required for the position to reach its liquidation threshold (scaled by WAD).
|
|
106
120
|
* Negative when healthy (the price needs to drop x%), positive when unhealthy (the price needs to soar x%).
|
|
107
|
-
* `undefined`
|
|
108
|
-
*
|
|
121
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
122
|
+
* `null` if the position is not a borrow.
|
|
109
123
|
*/
|
|
110
124
|
get priceVariationToLiquidationPrice() {
|
|
111
|
-
return this.
|
|
125
|
+
return this._market.getPriceVariationToLiquidationPrice(this);
|
|
112
126
|
}
|
|
113
127
|
/**
|
|
114
128
|
* This position's Loan-To-Value (debt over collateral power, scaled by WAD).
|
|
115
129
|
* If the collateral price is 0, LTV is `MaxUint256`.
|
|
116
|
-
* `undefined`
|
|
130
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
117
131
|
*/
|
|
118
132
|
get ltv() {
|
|
119
|
-
return this.
|
|
133
|
+
return this._market.getLtv(this);
|
|
120
134
|
}
|
|
121
135
|
/**
|
|
122
136
|
* This position's health factor (collateral power over debt, scaled by WAD).
|
|
123
137
|
* If the debt is 0, health factor is `MaxUint256`.
|
|
124
|
-
* `undefined`
|
|
138
|
+
* `undefined` if the market's oracle is undefined or reverts.
|
|
125
139
|
*/
|
|
126
140
|
get healthFactor() {
|
|
127
|
-
return this.
|
|
141
|
+
return this._market.getHealthFactor(this);
|
|
128
142
|
}
|
|
129
143
|
/**
|
|
130
144
|
* The percentage of this position's borrow power currently used (scaled by WAD).
|
|
131
145
|
* If the collateral price is 0, usage is `MaxUint256`.
|
|
132
146
|
*/
|
|
133
147
|
get borrowCapacityUsage() {
|
|
134
|
-
return this.
|
|
148
|
+
return this._market.getBorrowCapacityUsage(this);
|
|
135
149
|
}
|
|
136
150
|
/**
|
|
137
151
|
* Returns the maximum amount of loan assets that can be withdrawn given a certain supply position
|
|
138
152
|
* and a balance of loan assets, and the reason for the limit.
|
|
139
153
|
*/
|
|
140
154
|
get withdrawCapacityLimit() {
|
|
141
|
-
return this.
|
|
155
|
+
return this._market.getWithdrawCapacityLimit(this);
|
|
142
156
|
}
|
|
143
157
|
/**
|
|
144
158
|
* Returns a new position derived from this position, whose interest has been accrued up to the given timestamp.
|
|
145
159
|
* @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the market's `lastUpdate`.
|
|
146
160
|
*/
|
|
147
161
|
accrueInterest(timestamp) {
|
|
148
|
-
return new AccrualPosition(this, this.
|
|
162
|
+
return new AccrualPosition(this, this._market.accrueInterest(timestamp));
|
|
149
163
|
}
|
|
150
164
|
supply(assets, shares, timestamp) {
|
|
151
|
-
let { market } = this;
|
|
165
|
+
let { _market: market } = this;
|
|
152
166
|
({ market, assets, shares } = market.supply(assets, shares, timestamp));
|
|
153
167
|
const position = new AccrualPosition(this, market);
|
|
154
168
|
position.supplyShares += shares;
|
|
155
169
|
return { position, assets, shares };
|
|
156
170
|
}
|
|
157
171
|
withdraw(assets, shares, timestamp) {
|
|
158
|
-
let { market } = this;
|
|
172
|
+
let { _market: market } = this;
|
|
159
173
|
({ market, assets, shares } = market.withdraw(assets, shares, timestamp));
|
|
160
174
|
const position = new AccrualPosition(this, market);
|
|
161
175
|
position.supplyShares -= shares;
|
|
@@ -165,10 +179,10 @@ class AccrualPosition extends Position {
|
|
|
165
179
|
}
|
|
166
180
|
supplyCollateral(assets) {
|
|
167
181
|
this.collateral += assets;
|
|
168
|
-
return new AccrualPosition(this, new index_js_1.Market(this.
|
|
182
|
+
return new AccrualPosition(this, new index_js_1.Market(this._market));
|
|
169
183
|
}
|
|
170
184
|
withdrawCollateral(assets, timestamp) {
|
|
171
|
-
if (this.
|
|
185
|
+
if (this._market.price == null)
|
|
172
186
|
throw new errors_js_1.BlueErrors.UnknownOraclePrice(this.marketId);
|
|
173
187
|
const position = this.accrueInterest(timestamp);
|
|
174
188
|
position.collateral -= assets;
|
|
@@ -179,7 +193,7 @@ class AccrualPosition extends Position {
|
|
|
179
193
|
return position;
|
|
180
194
|
}
|
|
181
195
|
borrow(assets, shares, timestamp) {
|
|
182
|
-
let { market } = this;
|
|
196
|
+
let { _market: market } = this;
|
|
183
197
|
if (market.price == null)
|
|
184
198
|
throw new errors_js_1.BlueErrors.UnknownOraclePrice(market.id);
|
|
185
199
|
({ market, assets, shares } = market.borrow(assets, shares, timestamp));
|
|
@@ -190,7 +204,7 @@ class AccrualPosition extends Position {
|
|
|
190
204
|
return { position, assets, shares };
|
|
191
205
|
}
|
|
192
206
|
repay(assets, shares, timestamp) {
|
|
193
|
-
let { market } = this;
|
|
207
|
+
let { _market: market } = this;
|
|
194
208
|
({ market, assets, shares } = market.repay(assets, shares, timestamp));
|
|
195
209
|
const position = new AccrualPosition(this, market);
|
|
196
210
|
position.borrowShares -= shares;
|
|
@@ -199,13 +213,13 @@ class AccrualPosition extends Position {
|
|
|
199
213
|
return { position, assets, shares };
|
|
200
214
|
}
|
|
201
215
|
getBorrowCapacityLimit(options) {
|
|
202
|
-
return this.
|
|
216
|
+
return this._market.getBorrowCapacityLimit(this, options);
|
|
203
217
|
}
|
|
204
218
|
getWithdrawCollateralCapacityLimit(options) {
|
|
205
|
-
return this.
|
|
219
|
+
return this._market.getWithdrawCollateralCapacityLimit(this, options);
|
|
206
220
|
}
|
|
207
221
|
getRepayCapacityLimit(loanTokenBalance) {
|
|
208
|
-
return this.
|
|
222
|
+
return this._market.getRepayCapacityLimit(this.borrowShares, loanTokenBalance);
|
|
209
223
|
}
|
|
210
224
|
getMaxCapacities(loanTokenBalance, collateralTokenBalance, options) {
|
|
211
225
|
return {
|