@morpho-org/blue-sdk 3.0.0-next.8 → 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 +18 -0
- package/lib/addresses.js +17 -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";
|
|
@@ -139,12 +142,16 @@ export declare const addressesRegistry: {
|
|
|
139
142
|
readonly bundler3: "0x2d9C3A9E67c966C711208cc78b34fB9E9f8db589";
|
|
140
143
|
readonly generalAdapter1: "0xB261B51938A9767406ef83bbFbaAFE16691b7047";
|
|
141
144
|
readonly paraswapAdapter: "0x5F2617F12D1fDd1e43e72Cb80C92dFcE8124Db8d";
|
|
145
|
+
readonly compoundV3MigrationAdapter: "0xB34D2f54139bA12defC315C0822aDf9A5eB9A9b7";
|
|
146
|
+
readonly aaveV2MigrationAdapter: "0x43980Ae597f12Ff64690506b2AEEFFb4D8BeAF2a";
|
|
147
|
+
readonly aaveV3CoreMigrationAdapter: "0xEcB1662a1dff5C20650CF98c3334d2fddcD50742";
|
|
142
148
|
};
|
|
143
149
|
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
144
150
|
readonly adaptiveCurveIrm: "0xe675A2161D4a6E2de2eeD70ac98EEBf257FBF0B0";
|
|
145
151
|
readonly publicAllocator: "0xfac15aff53ADd2ff80C2962127C434E8615Df0d3";
|
|
146
152
|
readonly metaMorphoFactory: "0xa9c87daB340631C34BB738625C70499e29ddDC98";
|
|
147
153
|
readonly chainlinkOracleFactory: "0x1ff7895Eb842794c5d07C4c547b6730e61295215";
|
|
154
|
+
readonly preLiquidationFactory: "0xeDadDe37D76c72b98725614d0b41C20Fe612d304";
|
|
148
155
|
readonly wNative: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270";
|
|
149
156
|
};
|
|
150
157
|
readonly 42161: {
|
|
@@ -159,6 +166,7 @@ export declare const addressesRegistry: {
|
|
|
159
166
|
readonly publicAllocator: "0x769583Af5e9D03589F159EbEC31Cc2c23E8C355E";
|
|
160
167
|
readonly metaMorphoFactory: "0x878988f5f561081deEa117717052164ea1Ef0c82";
|
|
161
168
|
readonly chainlinkOracleFactory: "0x98Ce5D183DC0c176f54D37162F87e7eD7f2E41b5";
|
|
169
|
+
readonly preLiquidationFactory: "0x635c31B5DF1F7EFbCbC07E302335Ef4230758e3d";
|
|
162
170
|
readonly wNative: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
|
163
171
|
readonly usdc: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
164
172
|
};
|
|
@@ -174,6 +182,7 @@ export declare const addressesRegistry: {
|
|
|
174
182
|
readonly publicAllocator: "0x0d68a97324E602E02799CD83B42D337207B40658";
|
|
175
183
|
readonly metaMorphoFactory: "0x3Bb6A6A0Bc85b367EFE0A5bAc81c5E52C892839a";
|
|
176
184
|
readonly chainlinkOracleFactory: "0x1ec408D4131686f727F3Fd6245CF85Bc5c9DAD70";
|
|
185
|
+
readonly preLiquidationFactory: "0x3d05C01EE8e97361b9E19D172128255eaE5F98B9";
|
|
177
186
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
178
187
|
readonly usdc: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85";
|
|
179
188
|
};
|
|
@@ -187,6 +196,7 @@ export declare const addressesRegistry: {
|
|
|
187
196
|
readonly publicAllocator: "0xef9889B4e443DEd35FA0Bd060f2104Cca94e6A43";
|
|
188
197
|
readonly metaMorphoFactory: "0x4DBB3a642a2146d5413750Cca3647086D9ba5F12";
|
|
189
198
|
readonly chainlinkOracleFactory: "0xd706690BA1Fe26b70c4AD89e60ff62cEB3A2eD02";
|
|
199
|
+
readonly preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695";
|
|
190
200
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
191
201
|
};
|
|
192
202
|
readonly 252: {
|
|
@@ -199,6 +209,7 @@ export declare const addressesRegistry: {
|
|
|
199
209
|
readonly publicAllocator: "0x37a888192165fC39884f87c64E2476BfD2C09675";
|
|
200
210
|
readonly metaMorphoFactory: "0x27D4Af0AC9E7FDfA6D0853236f249CC27AE79488";
|
|
201
211
|
readonly chainlinkOracleFactory: "0x39d8622C607A691D7705E8842fbB12E3c38dCD41";
|
|
212
|
+
readonly preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695";
|
|
202
213
|
readonly wNative: "0xfc00000000000000000000000000000000000006";
|
|
203
214
|
};
|
|
204
215
|
readonly 534352: {
|
|
@@ -211,6 +222,7 @@ export declare const addressesRegistry: {
|
|
|
211
222
|
readonly publicAllocator: "0x8a7f671E45E51dE245649Cf916cA0256FB8a9927";
|
|
212
223
|
readonly metaMorphoFactory: "0x56b65742ade55015e6480959808229Ad6dbc9295";
|
|
213
224
|
readonly chainlinkOracleFactory: "0xb5961902E60b188b1c665B7b72Ef616656A9e24E";
|
|
225
|
+
readonly preLiquidationFactory: "0xeD960178e4aDA0296786Fa79D84e8FDF7bd44B25";
|
|
214
226
|
readonly wNative: "0x5300000000000000000000000000000000000004";
|
|
215
227
|
readonly usdc: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4";
|
|
216
228
|
};
|
|
@@ -224,6 +236,7 @@ export declare const addressesRegistry: {
|
|
|
224
236
|
readonly publicAllocator: "0x85416891752a6B81106c1C2999AE1AF5d8Cd3357";
|
|
225
237
|
readonly metaMorphoFactory: "0xd3f39505d0c48AFED3549D625982FdC38Ea9904b";
|
|
226
238
|
readonly chainlinkOracleFactory: "0x3FFFE273ee348b9E1ef89533025C7f165B17B439";
|
|
239
|
+
readonly preLiquidationFactory: "0x30607fEa77168d2c0401B6f60F0B40E32F9339E3";
|
|
227
240
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
228
241
|
readonly usdc: "0xF1815bd50389c46847f0Bda824eC8da914045D14";
|
|
229
242
|
};
|
|
@@ -237,6 +250,7 @@ export declare const addressesRegistry: {
|
|
|
237
250
|
readonly publicAllocator: "0xB0c9a107fA17c779B3378210A7a593e88938C7C9";
|
|
238
251
|
readonly metaMorphoFactory: "0xe9EdE3929F43a7062a007C3e8652e4ACa610Bdc0";
|
|
239
252
|
readonly chainlinkOracleFactory: "0x43269546e1D586a1f7200a0AC07e26f9631f7539";
|
|
253
|
+
readonly preLiquidationFactory: "0xb04e4D3D59Ee47Ca9BA192707AF13A7D02969911";
|
|
240
254
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
241
255
|
readonly usdc: "0x078D782b760474a361dDA0AF3839290b0EF57AD6";
|
|
242
256
|
};
|
|
@@ -250,6 +264,7 @@ export declare const addressesRegistry: {
|
|
|
250
264
|
readonly publicAllocator: "0x6Cef2EDC70D87E8f1623f3096efF05d066E59B36";
|
|
251
265
|
readonly metaMorphoFactory: "0x0cE9e3512CB4df8ae7e265e62Fb9258dc14f12e8";
|
|
252
266
|
readonly chainlinkOracleFactory: "0x7DA59Fa482F1F49fADc486d8e47BADc506fEb86d";
|
|
267
|
+
readonly preLiquidationFactory: "0xc72129DA4CC808e955699111b8c22B22Ca8A10b8";
|
|
253
268
|
readonly wNative: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38";
|
|
254
269
|
};
|
|
255
270
|
readonly 43111: {
|
|
@@ -262,6 +277,7 @@ export declare const addressesRegistry: {
|
|
|
262
277
|
readonly publicAllocator: "0x4107Ea1746909028d6212B315dE5fE9538F9eb39";
|
|
263
278
|
readonly metaMorphoFactory: "0x8e52179BeB18E882040b01632440d8Ca0f01da82";
|
|
264
279
|
readonly chainlinkOracleFactory: "0xB3cb32E6185446a6Bc7A047E4FfA138fA939e133";
|
|
280
|
+
readonly preLiquidationFactory: "0x40F2896C551194e364F7C846046C34d8a9FE97e4";
|
|
265
281
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
266
282
|
readonly usdc: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA";
|
|
267
283
|
};
|
|
@@ -275,6 +291,7 @@ export declare const addressesRegistry: {
|
|
|
275
291
|
readonly publicAllocator: "0xEE868Bf3359DA30c10ea472EAEBFC0a06E8F0120";
|
|
276
292
|
readonly metaMorphoFactory: "0xae5b0884bfff430493D6C844B9fd052Af7d79278";
|
|
277
293
|
readonly chainlinkOracleFactory: "0xf9380f7898423Bd7FDe3C9fDD1b2671A2471f39D";
|
|
294
|
+
readonly preLiquidationFactory: "0x249E4808264c545861e43728186a731dE7c7D745";
|
|
278
295
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
279
296
|
};
|
|
280
297
|
readonly 21000000: {
|
|
@@ -287,6 +304,7 @@ export declare const addressesRegistry: {
|
|
|
287
304
|
readonly publicAllocator: "0xDFde06e2B2A2D718eE5560b73dA4F830E56A2f10";
|
|
288
305
|
readonly metaMorphoFactory: "0xe430821595602eA5DD0cD350f86987437c7362fA";
|
|
289
306
|
readonly chainlinkOracleFactory: "0x16278156D366fC91536b6b81482ffaC47EEa06D6";
|
|
307
|
+
readonly preLiquidationFactory: "0xb9065AC18d3EBdb3263B77B587f9c5CD570545D1";
|
|
290
308
|
readonly wNative: "0xda5dDd7270381A7C2717aD10D1c0ecB19e3CDFb2";
|
|
291
309
|
readonly usdc: "0xDF0B24095e15044538866576754F3C964e902Ee6";
|
|
292
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",
|
|
@@ -108,12 +110,16 @@ exports.addressesRegistry = {
|
|
|
108
110
|
bundler3: "0x2d9C3A9E67c966C711208cc78b34fB9E9f8db589",
|
|
109
111
|
generalAdapter1: "0xB261B51938A9767406ef83bbFbaAFE16691b7047",
|
|
110
112
|
paraswapAdapter: "0x5F2617F12D1fDd1e43e72Cb80C92dFcE8124Db8d",
|
|
113
|
+
compoundV3MigrationAdapter: "0xB34D2f54139bA12defC315C0822aDf9A5eB9A9b7",
|
|
114
|
+
aaveV2MigrationAdapter: "0x43980Ae597f12Ff64690506b2AEEFFb4D8BeAF2a",
|
|
115
|
+
aaveV3CoreMigrationAdapter: "0xEcB1662a1dff5C20650CF98c3334d2fddcD50742",
|
|
111
116
|
},
|
|
112
117
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
113
118
|
adaptiveCurveIrm: "0xe675A2161D4a6E2de2eeD70ac98EEBf257FBF0B0",
|
|
114
119
|
publicAllocator: "0xfac15aff53ADd2ff80C2962127C434E8615Df0d3",
|
|
115
120
|
metaMorphoFactory: "0xa9c87daB340631C34BB738625C70499e29ddDC98",
|
|
116
121
|
chainlinkOracleFactory: "0x1ff7895Eb842794c5d07C4c547b6730e61295215",
|
|
122
|
+
preLiquidationFactory: "0xeDadDe37D76c72b98725614d0b41C20Fe612d304",
|
|
117
123
|
wNative: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
|
|
118
124
|
},
|
|
119
125
|
[chain_js_1.ChainId.ArbitrumMainnet]: {
|
|
@@ -128,6 +134,7 @@ exports.addressesRegistry = {
|
|
|
128
134
|
publicAllocator: "0x769583Af5e9D03589F159EbEC31Cc2c23E8C355E",
|
|
129
135
|
metaMorphoFactory: "0x878988f5f561081deEa117717052164ea1Ef0c82",
|
|
130
136
|
chainlinkOracleFactory: "0x98Ce5D183DC0c176f54D37162F87e7eD7f2E41b5",
|
|
137
|
+
preLiquidationFactory: "0x635c31B5DF1F7EFbCbC07E302335Ef4230758e3d",
|
|
131
138
|
wNative: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
132
139
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
133
140
|
usdc: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
@@ -144,6 +151,7 @@ exports.addressesRegistry = {
|
|
|
144
151
|
publicAllocator: "0x0d68a97324E602E02799CD83B42D337207B40658",
|
|
145
152
|
metaMorphoFactory: "0x3Bb6A6A0Bc85b367EFE0A5bAc81c5E52C892839a",
|
|
146
153
|
chainlinkOracleFactory: "0x1ec408D4131686f727F3Fd6245CF85Bc5c9DAD70",
|
|
154
|
+
preLiquidationFactory: "0x3d05C01EE8e97361b9E19D172128255eaE5F98B9",
|
|
147
155
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
148
156
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
149
157
|
usdc: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
@@ -158,6 +166,7 @@ exports.addressesRegistry = {
|
|
|
158
166
|
publicAllocator: "0xef9889B4e443DEd35FA0Bd060f2104Cca94e6A43",
|
|
159
167
|
metaMorphoFactory: "0x4DBB3a642a2146d5413750Cca3647086D9ba5F12",
|
|
160
168
|
chainlinkOracleFactory: "0xd706690BA1Fe26b70c4AD89e60ff62cEB3A2eD02",
|
|
169
|
+
preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695",
|
|
161
170
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
162
171
|
},
|
|
163
172
|
[chain_js_1.ChainId.FraxtalMainnet]: {
|
|
@@ -170,6 +179,7 @@ exports.addressesRegistry = {
|
|
|
170
179
|
publicAllocator: "0x37a888192165fC39884f87c64E2476BfD2C09675",
|
|
171
180
|
metaMorphoFactory: "0x27D4Af0AC9E7FDfA6D0853236f249CC27AE79488",
|
|
172
181
|
chainlinkOracleFactory: "0x39d8622C607A691D7705E8842fbB12E3c38dCD41",
|
|
182
|
+
preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695",
|
|
173
183
|
wNative: "0xfc00000000000000000000000000000000000006",
|
|
174
184
|
},
|
|
175
185
|
[chain_js_1.ChainId.ScrollMainnet]: {
|
|
@@ -182,6 +192,7 @@ exports.addressesRegistry = {
|
|
|
182
192
|
publicAllocator: "0x8a7f671E45E51dE245649Cf916cA0256FB8a9927",
|
|
183
193
|
metaMorphoFactory: "0x56b65742ade55015e6480959808229Ad6dbc9295",
|
|
184
194
|
chainlinkOracleFactory: "0xb5961902E60b188b1c665B7b72Ef616656A9e24E",
|
|
195
|
+
preLiquidationFactory: "0xeD960178e4aDA0296786Fa79D84e8FDF7bd44B25",
|
|
185
196
|
wNative: "0x5300000000000000000000000000000000000004",
|
|
186
197
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
187
198
|
usdc: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
|
|
@@ -196,6 +207,7 @@ exports.addressesRegistry = {
|
|
|
196
207
|
publicAllocator: "0x85416891752a6B81106c1C2999AE1AF5d8Cd3357",
|
|
197
208
|
metaMorphoFactory: "0xd3f39505d0c48AFED3549D625982FdC38Ea9904b",
|
|
198
209
|
chainlinkOracleFactory: "0x3FFFE273ee348b9E1ef89533025C7f165B17B439",
|
|
210
|
+
preLiquidationFactory: "0x30607fEa77168d2c0401B6f60F0B40E32F9339E3",
|
|
199
211
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
200
212
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
201
213
|
usdc: "0xF1815bd50389c46847f0Bda824eC8da914045D14",
|
|
@@ -210,6 +222,7 @@ exports.addressesRegistry = {
|
|
|
210
222
|
publicAllocator: "0xB0c9a107fA17c779B3378210A7a593e88938C7C9",
|
|
211
223
|
metaMorphoFactory: "0xe9EdE3929F43a7062a007C3e8652e4ACa610Bdc0",
|
|
212
224
|
chainlinkOracleFactory: "0x43269546e1D586a1f7200a0AC07e26f9631f7539",
|
|
225
|
+
preLiquidationFactory: "0xb04e4D3D59Ee47Ca9BA192707AF13A7D02969911",
|
|
213
226
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
214
227
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
215
228
|
usdc: "0x078D782b760474a361dDA0AF3839290b0EF57AD6",
|
|
@@ -224,6 +237,7 @@ exports.addressesRegistry = {
|
|
|
224
237
|
publicAllocator: "0x6Cef2EDC70D87E8f1623f3096efF05d066E59B36",
|
|
225
238
|
metaMorphoFactory: "0x0cE9e3512CB4df8ae7e265e62Fb9258dc14f12e8",
|
|
226
239
|
chainlinkOracleFactory: "0x7DA59Fa482F1F49fADc486d8e47BADc506fEb86d",
|
|
240
|
+
preLiquidationFactory: "0xc72129DA4CC808e955699111b8c22B22Ca8A10b8",
|
|
227
241
|
wNative: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
|
|
228
242
|
},
|
|
229
243
|
[chain_js_1.ChainId.HemiMainnet]: {
|
|
@@ -236,6 +250,7 @@ exports.addressesRegistry = {
|
|
|
236
250
|
publicAllocator: "0x4107Ea1746909028d6212B315dE5fE9538F9eb39",
|
|
237
251
|
metaMorphoFactory: "0x8e52179BeB18E882040b01632440d8Ca0f01da82",
|
|
238
252
|
chainlinkOracleFactory: "0xB3cb32E6185446a6Bc7A047E4FfA138fA939e133",
|
|
253
|
+
preLiquidationFactory: "0x40F2896C551194e364F7C846046C34d8a9FE97e4",
|
|
239
254
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
240
255
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
241
256
|
usdc: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA",
|
|
@@ -250,6 +265,7 @@ exports.addressesRegistry = {
|
|
|
250
265
|
publicAllocator: "0xEE868Bf3359DA30c10ea472EAEBFC0a06E8F0120",
|
|
251
266
|
metaMorphoFactory: "0xae5b0884bfff430493D6C844B9fd052Af7d79278",
|
|
252
267
|
chainlinkOracleFactory: "0xf9380f7898423Bd7FDe3C9fDD1b2671A2471f39D",
|
|
268
|
+
preLiquidationFactory: "0x249E4808264c545861e43728186a731dE7c7D745",
|
|
253
269
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
254
270
|
},
|
|
255
271
|
[chain_js_1.ChainId.CornMainnet]: {
|
|
@@ -262,6 +278,7 @@ exports.addressesRegistry = {
|
|
|
262
278
|
publicAllocator: "0xDFde06e2B2A2D718eE5560b73dA4F830E56A2f10",
|
|
263
279
|
metaMorphoFactory: "0xe430821595602eA5DD0cD350f86987437c7362fA",
|
|
264
280
|
chainlinkOracleFactory: "0x16278156D366fC91536b6b81482ffaC47EEa06D6",
|
|
281
|
+
preLiquidationFactory: "0xb9065AC18d3EBdb3263B77B587f9c5CD570545D1",
|
|
265
282
|
wNative: "0xda5dDd7270381A7C2717aD10D1c0ecB19e3CDFb2",
|
|
266
283
|
// Must implement USDC permit version 2 (otherwise breaks permit signatures).
|
|
267
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`.
|