@morpho-org/blue-sdk 4.12.1 → 4.14.0-next.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 +39 -0
- package/lib/addresses.js +18 -0
- package/lib/errors.d.ts +4 -0
- package/lib/errors.js +9 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/vault-v2/VaultV2.d.ts +56 -0
- package/lib/vault-v2/VaultV2.js +90 -0
- package/lib/vault-v2/VaultV2Adapter.d.ts +18 -0
- package/lib/vault-v2/VaultV2Adapter.js +16 -0
- package/lib/vault-v2/VaultV2MorphoVaultV1Adapter.d.ts +21 -0
- package/lib/vault-v2/VaultV2MorphoVaultV1Adapter.js +28 -0
- package/lib/vault-v2/index.d.ts +3 -0
- package/lib/vault-v2/index.js +19 -0
- package/package.json +3 -3
package/lib/addresses.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export interface ChainAddresses {
|
|
|
49
49
|
adaptiveCurveIrm: Address;
|
|
50
50
|
publicAllocator?: Address;
|
|
51
51
|
metaMorphoFactory?: Address;
|
|
52
|
+
registryList?: Address;
|
|
52
53
|
chainlinkOracleFactory?: Address;
|
|
53
54
|
preLiquidationFactory?: Address;
|
|
54
55
|
wNative?: Address;
|
|
@@ -63,6 +64,8 @@ export interface ChainAddresses {
|
|
|
63
64
|
usdc?: Address;
|
|
64
65
|
stEth?: Address;
|
|
65
66
|
wstEth?: Address;
|
|
67
|
+
vaultV2Factory?: Address;
|
|
68
|
+
morphoVaultV1AdapterFactory?: Address;
|
|
66
69
|
}
|
|
67
70
|
declare const _addressesRegistry: {
|
|
68
71
|
readonly 1: {
|
|
@@ -108,6 +111,7 @@ declare const _addressesRegistry: {
|
|
|
108
111
|
readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
|
|
109
112
|
readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
|
|
110
113
|
readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
|
|
114
|
+
readonly registryList: "0x3696c5eAe4a7Ffd04Ea163564571E9CD8Ed9364e";
|
|
111
115
|
readonly chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766";
|
|
112
116
|
readonly preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476";
|
|
113
117
|
readonly wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
|
@@ -137,6 +141,8 @@ declare const _addressesRegistry: {
|
|
|
137
141
|
readonly crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14";
|
|
138
142
|
readonly "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e";
|
|
139
143
|
readonly "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726";
|
|
144
|
+
readonly vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405";
|
|
145
|
+
readonly morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394";
|
|
140
146
|
};
|
|
141
147
|
readonly 8453: {
|
|
142
148
|
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
@@ -168,12 +174,15 @@ declare const _addressesRegistry: {
|
|
|
168
174
|
readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
|
|
169
175
|
readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
|
|
170
176
|
readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
|
|
177
|
+
readonly registryList: "0x5C2531Cbd2cf112Cf687da3Cd536708aDd7DB10a";
|
|
171
178
|
readonly chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d";
|
|
172
179
|
readonly preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef";
|
|
173
180
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
174
181
|
readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
175
182
|
readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
|
|
176
183
|
readonly testUsdc: "0xBC77067f829979812d795d516E523C4033b66409";
|
|
184
|
+
readonly vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857";
|
|
185
|
+
readonly morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642";
|
|
177
186
|
};
|
|
178
187
|
readonly 137: {
|
|
179
188
|
readonly morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67";
|
|
@@ -441,6 +450,9 @@ declare const _addressesRegistry: {
|
|
|
441
450
|
readonly adaptiveCurveIrm: "0xD4a426F010986dCad727e8dd6eed44cA4A9b7483";
|
|
442
451
|
readonly publicAllocator: "0x517505be22D9068687334e69ae7a02fC77edf4Fc";
|
|
443
452
|
readonly metaMorphoFactory: "0xec051b19d654C48c357dC974376DeB6272f24e53";
|
|
453
|
+
readonly vaultV2Factory: "0xD7217E5687FF1071356C780b5fe4803D9D967da7";
|
|
454
|
+
readonly morphoVaultV1AdapterFactory: "0xdf5202e29654e02011611A086f15477880580CAc";
|
|
455
|
+
readonly registryList: "0x857B55cEb57dA0C2A83EE08a8dB529B931089aee";
|
|
444
456
|
readonly chainlinkOracleFactory: "0xeb476f124FaD625178759d13557A72394A6f9aF5";
|
|
445
457
|
readonly preLiquidationFactory: "0x1b6782Ac7A859503cE953FBf4736311CC335B8f0";
|
|
446
458
|
readonly wNative: "0x5555555555555555555555555555555555555555";
|
|
@@ -469,8 +481,11 @@ declare const _deployments: {
|
|
|
469
481
|
readonly adaptiveCurveIrm: 18883124n;
|
|
470
482
|
readonly publicAllocator: 19375099n;
|
|
471
483
|
readonly metaMorphoFactory: 21439510n;
|
|
484
|
+
readonly registryList: 23375119n;
|
|
472
485
|
readonly chainlinkOracleFactory: 19375066n;
|
|
473
486
|
readonly preLiquidationFactory: 21414664n;
|
|
487
|
+
readonly vaultV2Factory: 23375073n;
|
|
488
|
+
readonly morphoVaultV1AdapterFactory: 23375073n;
|
|
474
489
|
};
|
|
475
490
|
readonly 8453: {
|
|
476
491
|
readonly morpho: 13977148n;
|
|
@@ -486,8 +501,11 @@ declare const _deployments: {
|
|
|
486
501
|
readonly adaptiveCurveIrm: 13977152n;
|
|
487
502
|
readonly publicAllocator: 13979545n;
|
|
488
503
|
readonly metaMorphoFactory: 23928808n;
|
|
504
|
+
readonly registryList: 35615358n;
|
|
489
505
|
readonly chainlinkOracleFactory: 13978286n;
|
|
490
506
|
readonly preLiquidationFactory: 23779056n;
|
|
507
|
+
readonly vaultV2Factory: 35615206n;
|
|
508
|
+
readonly morphoVaultV1AdapterFactory: 35615206n;
|
|
491
509
|
};
|
|
492
510
|
readonly 137: {
|
|
493
511
|
readonly morpho: 66931042n;
|
|
@@ -728,6 +746,9 @@ declare const _deployments: {
|
|
|
728
746
|
readonly adaptiveCurveIrm: 1988429n;
|
|
729
747
|
readonly publicAllocator: 1988429n;
|
|
730
748
|
readonly metaMorphoFactory: 1988677n;
|
|
749
|
+
readonly vaultV2Factory: 14188393n;
|
|
750
|
+
readonly morphoVaultV1AdapterFactory: 14188393n;
|
|
751
|
+
readonly registryList: 14188698n;
|
|
731
752
|
readonly chainlinkOracleFactory: 1988677n;
|
|
732
753
|
readonly preLiquidationFactory: 1988956n;
|
|
733
754
|
};
|
|
@@ -803,6 +824,7 @@ export declare let addressesRegistry: {
|
|
|
803
824
|
readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
|
|
804
825
|
readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
|
|
805
826
|
readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
|
|
827
|
+
readonly registryList: "0x3696c5eAe4a7Ffd04Ea163564571E9CD8Ed9364e";
|
|
806
828
|
readonly chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766";
|
|
807
829
|
readonly preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476";
|
|
808
830
|
readonly wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
|
@@ -832,6 +854,8 @@ export declare let addressesRegistry: {
|
|
|
832
854
|
readonly crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14";
|
|
833
855
|
readonly "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e";
|
|
834
856
|
readonly "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726";
|
|
857
|
+
readonly vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405";
|
|
858
|
+
readonly morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394";
|
|
835
859
|
};
|
|
836
860
|
readonly 8453: {
|
|
837
861
|
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
@@ -863,12 +887,15 @@ export declare let addressesRegistry: {
|
|
|
863
887
|
readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
|
|
864
888
|
readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
|
|
865
889
|
readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
|
|
890
|
+
readonly registryList: "0x5C2531Cbd2cf112Cf687da3Cd536708aDd7DB10a";
|
|
866
891
|
readonly chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d";
|
|
867
892
|
readonly preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef";
|
|
868
893
|
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
869
894
|
readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
870
895
|
readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
|
|
871
896
|
readonly testUsdc: "0xBC77067f829979812d795d516E523C4033b66409";
|
|
897
|
+
readonly vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857";
|
|
898
|
+
readonly morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642";
|
|
872
899
|
};
|
|
873
900
|
readonly 137: {
|
|
874
901
|
readonly morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67";
|
|
@@ -1136,6 +1163,9 @@ export declare let addressesRegistry: {
|
|
|
1136
1163
|
readonly adaptiveCurveIrm: "0xD4a426F010986dCad727e8dd6eed44cA4A9b7483";
|
|
1137
1164
|
readonly publicAllocator: "0x517505be22D9068687334e69ae7a02fC77edf4Fc";
|
|
1138
1165
|
readonly metaMorphoFactory: "0xec051b19d654C48c357dC974376DeB6272f24e53";
|
|
1166
|
+
readonly vaultV2Factory: "0xD7217E5687FF1071356C780b5fe4803D9D967da7";
|
|
1167
|
+
readonly morphoVaultV1AdapterFactory: "0xdf5202e29654e02011611A086f15477880580CAc";
|
|
1168
|
+
readonly registryList: "0x857B55cEb57dA0C2A83EE08a8dB529B931089aee";
|
|
1139
1169
|
readonly chainlinkOracleFactory: "0xeb476f124FaD625178759d13557A72394A6f9aF5";
|
|
1140
1170
|
readonly preLiquidationFactory: "0x1b6782Ac7A859503cE953FBf4736311CC335B8f0";
|
|
1141
1171
|
readonly wNative: "0x5555555555555555555555555555555555555555";
|
|
@@ -1162,8 +1192,11 @@ export declare let deployments: {
|
|
|
1162
1192
|
readonly adaptiveCurveIrm: 18883124n;
|
|
1163
1193
|
readonly publicAllocator: 19375099n;
|
|
1164
1194
|
readonly metaMorphoFactory: 21439510n;
|
|
1195
|
+
readonly registryList: 23375119n;
|
|
1165
1196
|
readonly chainlinkOracleFactory: 19375066n;
|
|
1166
1197
|
readonly preLiquidationFactory: 21414664n;
|
|
1198
|
+
readonly vaultV2Factory: 23375073n;
|
|
1199
|
+
readonly morphoVaultV1AdapterFactory: 23375073n;
|
|
1167
1200
|
};
|
|
1168
1201
|
readonly 8453: {
|
|
1169
1202
|
readonly morpho: 13977148n;
|
|
@@ -1179,8 +1212,11 @@ export declare let deployments: {
|
|
|
1179
1212
|
readonly adaptiveCurveIrm: 13977152n;
|
|
1180
1213
|
readonly publicAllocator: 13979545n;
|
|
1181
1214
|
readonly metaMorphoFactory: 23928808n;
|
|
1215
|
+
readonly registryList: 35615358n;
|
|
1182
1216
|
readonly chainlinkOracleFactory: 13978286n;
|
|
1183
1217
|
readonly preLiquidationFactory: 23779056n;
|
|
1218
|
+
readonly vaultV2Factory: 35615206n;
|
|
1219
|
+
readonly morphoVaultV1AdapterFactory: 35615206n;
|
|
1184
1220
|
};
|
|
1185
1221
|
readonly 137: {
|
|
1186
1222
|
readonly morpho: 66931042n;
|
|
@@ -1421,6 +1457,9 @@ export declare let deployments: {
|
|
|
1421
1457
|
readonly adaptiveCurveIrm: 1988429n;
|
|
1422
1458
|
readonly publicAllocator: 1988429n;
|
|
1423
1459
|
readonly metaMorphoFactory: 1988677n;
|
|
1460
|
+
readonly vaultV2Factory: 14188393n;
|
|
1461
|
+
readonly morphoVaultV1AdapterFactory: 14188393n;
|
|
1462
|
+
readonly registryList: 14188698n;
|
|
1424
1463
|
readonly chainlinkOracleFactory: 1988677n;
|
|
1425
1464
|
readonly preLiquidationFactory: 1988956n;
|
|
1426
1465
|
};
|
package/lib/addresses.js
CHANGED
|
@@ -60,6 +60,7 @@ const _addressesRegistry = {
|
|
|
60
60
|
adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
|
|
61
61
|
publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D",
|
|
62
62
|
metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24",
|
|
63
|
+
registryList: "0x3696c5eAe4a7Ffd04Ea163564571E9CD8Ed9364e",
|
|
63
64
|
chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766",
|
|
64
65
|
preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476",
|
|
65
66
|
wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
@@ -95,6 +96,8 @@ const _addressesRegistry = {
|
|
|
95
96
|
crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14",
|
|
96
97
|
"stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e",
|
|
97
98
|
"2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726",
|
|
99
|
+
vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405",
|
|
100
|
+
morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394",
|
|
98
101
|
},
|
|
99
102
|
[chain_js_1.ChainId.BaseMainnet]: {
|
|
100
103
|
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
@@ -126,6 +129,7 @@ const _addressesRegistry = {
|
|
|
126
129
|
adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687",
|
|
127
130
|
publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467",
|
|
128
131
|
metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918",
|
|
132
|
+
registryList: "0x5C2531Cbd2cf112Cf687da3Cd536708aDd7DB10a",
|
|
129
133
|
chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d",
|
|
130
134
|
preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef",
|
|
131
135
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
@@ -133,6 +137,8 @@ const _addressesRegistry = {
|
|
|
133
137
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
134
138
|
verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b",
|
|
135
139
|
testUsdc: "0xBC77067f829979812d795d516E523C4033b66409",
|
|
140
|
+
vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857",
|
|
141
|
+
morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642",
|
|
136
142
|
},
|
|
137
143
|
[chain_js_1.ChainId.PolygonMainnet]: {
|
|
138
144
|
morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67",
|
|
@@ -409,6 +415,9 @@ const _addressesRegistry = {
|
|
|
409
415
|
adaptiveCurveIrm: "0xD4a426F010986dCad727e8dd6eed44cA4A9b7483",
|
|
410
416
|
publicAllocator: "0x517505be22D9068687334e69ae7a02fC77edf4Fc",
|
|
411
417
|
metaMorphoFactory: "0xec051b19d654C48c357dC974376DeB6272f24e53",
|
|
418
|
+
vaultV2Factory: "0xD7217E5687FF1071356C780b5fe4803D9D967da7",
|
|
419
|
+
morphoVaultV1AdapterFactory: "0xdf5202e29654e02011611A086f15477880580CAc",
|
|
420
|
+
registryList: "0x857B55cEb57dA0C2A83EE08a8dB529B931089aee",
|
|
412
421
|
chainlinkOracleFactory: "0xeb476f124FaD625178759d13557A72394A6f9aF5",
|
|
413
422
|
preLiquidationFactory: "0x1b6782Ac7A859503cE953FBf4736311CC335B8f0",
|
|
414
423
|
wNative: "0x5555555555555555555555555555555555555555",
|
|
@@ -434,8 +443,11 @@ const _deployments = {
|
|
|
434
443
|
adaptiveCurveIrm: 18883124n,
|
|
435
444
|
publicAllocator: 19375099n,
|
|
436
445
|
metaMorphoFactory: 21439510n,
|
|
446
|
+
registryList: 23375119n,
|
|
437
447
|
chainlinkOracleFactory: 19375066n,
|
|
438
448
|
preLiquidationFactory: 21414664n,
|
|
449
|
+
vaultV2Factory: 23375073n,
|
|
450
|
+
morphoVaultV1AdapterFactory: 23375073n,
|
|
439
451
|
},
|
|
440
452
|
[chain_js_1.ChainId.BaseMainnet]: {
|
|
441
453
|
morpho: 13977148n,
|
|
@@ -451,8 +463,11 @@ const _deployments = {
|
|
|
451
463
|
adaptiveCurveIrm: 13977152n,
|
|
452
464
|
publicAllocator: 13979545n,
|
|
453
465
|
metaMorphoFactory: 23928808n,
|
|
466
|
+
registryList: 35615358n,
|
|
454
467
|
chainlinkOracleFactory: 13978286n,
|
|
455
468
|
preLiquidationFactory: 23779056n,
|
|
469
|
+
vaultV2Factory: 35615206n,
|
|
470
|
+
morphoVaultV1AdapterFactory: 35615206n,
|
|
456
471
|
},
|
|
457
472
|
[chain_js_1.ChainId.PolygonMainnet]: {
|
|
458
473
|
morpho: 66931042n,
|
|
@@ -693,6 +708,9 @@ const _deployments = {
|
|
|
693
708
|
adaptiveCurveIrm: 1988429n,
|
|
694
709
|
publicAllocator: 1988429n,
|
|
695
710
|
metaMorphoFactory: 1988677n,
|
|
711
|
+
vaultV2Factory: 14188393n,
|
|
712
|
+
morphoVaultV1AdapterFactory: 14188393n,
|
|
713
|
+
registryList: 14188698n,
|
|
696
714
|
chainlinkOracleFactory: 1988677n,
|
|
697
715
|
preLiquidationFactory: 1988956n,
|
|
698
716
|
},
|
package/lib/errors.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export declare class UnsupportedPreLiquidationParamsError extends Error {
|
|
|
25
25
|
readonly lltv: bigint;
|
|
26
26
|
constructor(lltv: bigint);
|
|
27
27
|
}
|
|
28
|
+
export declare class UnsupportedVaultV2AdapterError extends Error {
|
|
29
|
+
readonly address: Address;
|
|
30
|
+
constructor(address: Address);
|
|
31
|
+
}
|
|
28
32
|
export declare namespace BlueErrors {
|
|
29
33
|
class AlreadySet extends Error {
|
|
30
34
|
readonly name: string;
|
package/lib/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlueErrors = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
|
|
3
|
+
exports.BlueErrors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
|
|
4
4
|
exports._try = _try;
|
|
5
5
|
const viem_1 = require("viem");
|
|
6
6
|
class UnknownDataError extends Error {
|
|
@@ -54,6 +54,14 @@ class UnsupportedPreLiquidationParamsError extends Error {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
exports.UnsupportedPreLiquidationParamsError = UnsupportedPreLiquidationParamsError;
|
|
57
|
+
class UnsupportedVaultV2AdapterError extends Error {
|
|
58
|
+
address;
|
|
59
|
+
constructor(address) {
|
|
60
|
+
super(`vault v2 adapter "${address}" is not supported`);
|
|
61
|
+
this.address = address;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.UnsupportedVaultV2AdapterError = UnsupportedVaultV2AdapterError;
|
|
57
65
|
var BlueErrors;
|
|
58
66
|
(function (BlueErrors) {
|
|
59
67
|
class AlreadySet extends Error {
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -27,4 +27,5 @@ __exportStar(require("./holding/index.js"), exports);
|
|
|
27
27
|
__exportStar(require("./position/index.js"), exports);
|
|
28
28
|
__exportStar(require("./vault/index.js"), exports);
|
|
29
29
|
__exportStar(require("./preLiquidation.js"), exports);
|
|
30
|
+
__exportStar(require("./vault-v2/index.js"), exports);
|
|
30
31
|
__exportStar(require("./utils.js"), exports);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { type RoundingDirection } from "../math";
|
|
3
|
+
import { type IToken, WrappedToken } from "../token";
|
|
4
|
+
import type { BigIntish } from "../types";
|
|
5
|
+
import type { IAccrualVaultV2Adapter } from "./VaultV2Adapter";
|
|
6
|
+
export interface IVaultV2 extends IToken {
|
|
7
|
+
asset: Address;
|
|
8
|
+
totalSupply: bigint;
|
|
9
|
+
totalAssets: bigint;
|
|
10
|
+
performanceFee: bigint;
|
|
11
|
+
managementFee: bigint;
|
|
12
|
+
virtualShares: bigint;
|
|
13
|
+
lastUpdate: bigint;
|
|
14
|
+
adapters: Address[];
|
|
15
|
+
maxRate: bigint;
|
|
16
|
+
liquidityAdapter: Address;
|
|
17
|
+
performanceFeeRecipient: Address;
|
|
18
|
+
managementFeeRecipient: Address;
|
|
19
|
+
}
|
|
20
|
+
export declare class VaultV2 extends WrappedToken implements IVaultV2 {
|
|
21
|
+
readonly asset: Address;
|
|
22
|
+
/**
|
|
23
|
+
* The ERC4626 vault's total supply of shares.
|
|
24
|
+
*/
|
|
25
|
+
totalSupply: bigint;
|
|
26
|
+
/**
|
|
27
|
+
* The ERC4626 vault's total assets, without accrued interest
|
|
28
|
+
*/
|
|
29
|
+
totalAssets: bigint;
|
|
30
|
+
virtualShares: bigint;
|
|
31
|
+
lastUpdate: bigint;
|
|
32
|
+
adapters: Address[];
|
|
33
|
+
maxRate: bigint;
|
|
34
|
+
performanceFee: bigint;
|
|
35
|
+
managementFee: bigint;
|
|
36
|
+
liquidityAdapter: Address;
|
|
37
|
+
performanceFeeRecipient: Address;
|
|
38
|
+
managementFeeRecipient: Address;
|
|
39
|
+
constructor({ totalSupply, asset, totalAssets, virtualShares, lastUpdate, adapters, maxRate, performanceFee, managementFee, liquidityAdapter, performanceFeeRecipient, managementFeeRecipient, ...config }: IVaultV2);
|
|
40
|
+
toAssets(shares: bigint): bigint;
|
|
41
|
+
toShares(assets: bigint): bigint;
|
|
42
|
+
protected _wrap(amount: bigint, rounding: RoundingDirection): bigint;
|
|
43
|
+
protected _unwrap(amount: bigint, rounding: RoundingDirection): bigint;
|
|
44
|
+
}
|
|
45
|
+
export interface IAccrualVaultV2 extends Omit<IVaultV2, "adapters"> {
|
|
46
|
+
}
|
|
47
|
+
export declare class AccrualVaultV2 extends VaultV2 implements IAccrualVaultV2 {
|
|
48
|
+
readonly accrualAdapters: IAccrualVaultV2Adapter[];
|
|
49
|
+
readonly assetBalance: bigint;
|
|
50
|
+
constructor(vault: IAccrualVaultV2, accrualAdapters: IAccrualVaultV2Adapter[], assetBalance: bigint);
|
|
51
|
+
accrueInterest(timestamp: BigIntish): {
|
|
52
|
+
vault: AccrualVaultV2;
|
|
53
|
+
performanceFeeShares: bigint;
|
|
54
|
+
managementFeeShares: bigint;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccrualVaultV2 = exports.VaultV2 = void 0;
|
|
4
|
+
const math_1 = require("../math");
|
|
5
|
+
const token_1 = require("../token");
|
|
6
|
+
class VaultV2 extends token_1.WrappedToken {
|
|
7
|
+
asset;
|
|
8
|
+
/**
|
|
9
|
+
* The ERC4626 vault's total supply of shares.
|
|
10
|
+
*/
|
|
11
|
+
totalSupply;
|
|
12
|
+
/**
|
|
13
|
+
* The ERC4626 vault's total assets, without accrued interest
|
|
14
|
+
*/
|
|
15
|
+
totalAssets;
|
|
16
|
+
virtualShares;
|
|
17
|
+
lastUpdate;
|
|
18
|
+
adapters;
|
|
19
|
+
maxRate;
|
|
20
|
+
performanceFee;
|
|
21
|
+
managementFee;
|
|
22
|
+
liquidityAdapter;
|
|
23
|
+
performanceFeeRecipient;
|
|
24
|
+
managementFeeRecipient;
|
|
25
|
+
constructor({ totalSupply, asset, totalAssets, virtualShares, lastUpdate, adapters, maxRate, performanceFee, managementFee, liquidityAdapter, performanceFeeRecipient, managementFeeRecipient, ...config }) {
|
|
26
|
+
super(config, asset);
|
|
27
|
+
this.totalSupply = totalSupply;
|
|
28
|
+
this.totalAssets = totalAssets;
|
|
29
|
+
this.virtualShares = virtualShares;
|
|
30
|
+
this.lastUpdate = lastUpdate;
|
|
31
|
+
this.asset = asset;
|
|
32
|
+
this.maxRate = maxRate;
|
|
33
|
+
this.adapters = adapters;
|
|
34
|
+
this.performanceFee = performanceFee;
|
|
35
|
+
this.managementFee = managementFee;
|
|
36
|
+
this.liquidityAdapter = liquidityAdapter;
|
|
37
|
+
this.performanceFeeRecipient = performanceFeeRecipient;
|
|
38
|
+
this.managementFeeRecipient = managementFeeRecipient;
|
|
39
|
+
}
|
|
40
|
+
toAssets(shares) {
|
|
41
|
+
return this._unwrap(shares, "Down");
|
|
42
|
+
}
|
|
43
|
+
toShares(assets) {
|
|
44
|
+
return this._wrap(assets, "Down");
|
|
45
|
+
}
|
|
46
|
+
_wrap(amount, rounding) {
|
|
47
|
+
return math_1.MathLib.mulDiv(amount, this.totalSupply + this.virtualShares, this.totalAssets + 1n, rounding);
|
|
48
|
+
}
|
|
49
|
+
_unwrap(amount, rounding) {
|
|
50
|
+
return math_1.MathLib.mulDiv(amount, this.totalAssets + 1n, this.totalSupply + this.virtualShares, rounding);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.VaultV2 = VaultV2;
|
|
54
|
+
class AccrualVaultV2 extends VaultV2 {
|
|
55
|
+
accrualAdapters;
|
|
56
|
+
assetBalance;
|
|
57
|
+
constructor(vault, accrualAdapters, assetBalance) {
|
|
58
|
+
super({ ...vault, adapters: accrualAdapters.map((a) => a.address) });
|
|
59
|
+
this.accrualAdapters = accrualAdapters;
|
|
60
|
+
this.assetBalance = assetBalance;
|
|
61
|
+
}
|
|
62
|
+
accrueInterest(timestamp) {
|
|
63
|
+
const vault = new AccrualVaultV2(this, this.accrualAdapters, this.assetBalance);
|
|
64
|
+
const elapsed = BigInt(timestamp) - vault.lastUpdate;
|
|
65
|
+
if (elapsed <= 0n)
|
|
66
|
+
return { vault, performanceFeeShares: 0n, managementFeeShares: 0n };
|
|
67
|
+
const realAssets = vault.accrualAdapters.reduce((curr, adapter) => curr + adapter.realAssets(timestamp), vault.assetBalance);
|
|
68
|
+
const maxTotalAssets = vault.totalAssets +
|
|
69
|
+
math_1.MathLib.wMulDown(vault.totalAssets * elapsed, vault.maxRate);
|
|
70
|
+
const newTotalAssets = math_1.MathLib.min(realAssets, maxTotalAssets);
|
|
71
|
+
const interest = math_1.MathLib.zeroFloorSub(newTotalAssets, vault.totalAssets);
|
|
72
|
+
const performanceFeeAssets = interest > 0n && vault.performanceFee > 0n
|
|
73
|
+
? math_1.MathLib.wMulDown(interest, vault.performanceFee)
|
|
74
|
+
: 0n;
|
|
75
|
+
const managementFeeAssets = elapsed > 0n && vault.managementFee > 0n
|
|
76
|
+
? math_1.MathLib.wMulDown(newTotalAssets * elapsed, vault.managementFee)
|
|
77
|
+
: 0n;
|
|
78
|
+
const newTotalAssetsWithoutFees = newTotalAssets - performanceFeeAssets - managementFeeAssets;
|
|
79
|
+
const performanceFeeShares = math_1.MathLib.mulDivDown(performanceFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
|
|
80
|
+
const managementFeeShares = math_1.MathLib.mulDivDown(managementFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
|
|
81
|
+
vault.totalAssets = newTotalAssets;
|
|
82
|
+
if (performanceFeeShares)
|
|
83
|
+
vault.totalSupply += performanceFeeShares;
|
|
84
|
+
if (managementFeeShares)
|
|
85
|
+
vault.totalSupply += managementFeeShares;
|
|
86
|
+
vault.lastUpdate = BigInt(timestamp);
|
|
87
|
+
return { vault, performanceFeeShares, managementFeeShares };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.AccrualVaultV2 = AccrualVaultV2;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Address, Hash } from "viem";
|
|
2
|
+
import type { BigIntish } from "../types";
|
|
3
|
+
export interface IVaultV2Adapter {
|
|
4
|
+
address: Address;
|
|
5
|
+
parentVault: Address;
|
|
6
|
+
adapterId: Hash;
|
|
7
|
+
skimRecipient: Address;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class VaultV2Adapter implements IVaultV2Adapter {
|
|
10
|
+
readonly address: Address;
|
|
11
|
+
readonly parentVault: Address;
|
|
12
|
+
readonly adapterId: Hash;
|
|
13
|
+
skimRecipient: Address;
|
|
14
|
+
constructor({ address, parentVault, adapterId, skimRecipient, }: IVaultV2Adapter);
|
|
15
|
+
}
|
|
16
|
+
export interface IAccrualVaultV2Adapter extends IVaultV2Adapter {
|
|
17
|
+
realAssets(timestamp: BigIntish): bigint;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VaultV2Adapter = void 0;
|
|
4
|
+
class VaultV2Adapter {
|
|
5
|
+
address;
|
|
6
|
+
parentVault;
|
|
7
|
+
adapterId;
|
|
8
|
+
skimRecipient;
|
|
9
|
+
constructor({ address, parentVault, adapterId, skimRecipient, }) {
|
|
10
|
+
this.address = address;
|
|
11
|
+
this.parentVault = parentVault;
|
|
12
|
+
this.adapterId = adapterId;
|
|
13
|
+
this.skimRecipient = skimRecipient;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.VaultV2Adapter = VaultV2Adapter;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { VaultV2Adapter } from "./VaultV2Adapter";
|
|
3
|
+
export interface IVaultV2MorphoVaultV1Adapter extends IVaultV2Adapter {
|
|
4
|
+
morphoVaultV1: Address;
|
|
5
|
+
}
|
|
6
|
+
import type { BigIntish } from "../types";
|
|
7
|
+
import type { AccrualVault } from "../vault";
|
|
8
|
+
import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter";
|
|
9
|
+
export declare class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter implements IVaultV2MorphoVaultV1Adapter {
|
|
10
|
+
readonly morphoVaultV1: Address;
|
|
11
|
+
constructor({ morphoVaultV1, ...vaultV2Adapter }: IVaultV2MorphoVaultV1Adapter);
|
|
12
|
+
ids(): `0x${string}`[];
|
|
13
|
+
}
|
|
14
|
+
export interface IAccrualVaultV2MorphoVaultV1Adapter extends IVaultV2MorphoVaultV1Adapter {
|
|
15
|
+
}
|
|
16
|
+
export declare class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter implements IAccrualVaultV2MorphoVaultV1Adapter, IAccrualVaultV2Adapter {
|
|
17
|
+
vaultV1: AccrualVault;
|
|
18
|
+
shares: bigint;
|
|
19
|
+
constructor(adapter: IAccrualVaultV2MorphoVaultV1Adapter, vaultV1: AccrualVault, shares: bigint);
|
|
20
|
+
realAssets(timestamp: BigIntish): bigint;
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccrualVaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoVaultV1Adapter = void 0;
|
|
4
|
+
const VaultV2Adapter_1 = require("./VaultV2Adapter");
|
|
5
|
+
class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter_1.VaultV2Adapter {
|
|
6
|
+
morphoVaultV1;
|
|
7
|
+
constructor({ morphoVaultV1, ...vaultV2Adapter }) {
|
|
8
|
+
super(vaultV2Adapter);
|
|
9
|
+
this.morphoVaultV1 = morphoVaultV1;
|
|
10
|
+
}
|
|
11
|
+
ids() {
|
|
12
|
+
return [this.adapterId];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.VaultV2MorphoVaultV1Adapter = VaultV2MorphoVaultV1Adapter;
|
|
16
|
+
class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter {
|
|
17
|
+
vaultV1;
|
|
18
|
+
shares;
|
|
19
|
+
constructor(adapter, vaultV1, shares) {
|
|
20
|
+
super(adapter);
|
|
21
|
+
this.vaultV1 = vaultV1;
|
|
22
|
+
this.shares = shares;
|
|
23
|
+
}
|
|
24
|
+
realAssets(timestamp) {
|
|
25
|
+
return this.vaultV1.accrueInterest(timestamp).toAssets(this.shares);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AccrualVaultV2MorphoVaultV1Adapter = AccrualVaultV2MorphoVaultV1Adapter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./VaultV2.js"), exports);
|
|
18
|
+
__exportStar(require("./VaultV2Adapter.js"), exports);
|
|
19
|
+
__exportStar(require("./VaultV2MorphoVaultV1Adapter.js"), exports);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/blue-sdk",
|
|
3
3
|
"description": "Framework-agnostic package that defines Morpho-related entity classes (such as `Market`, `Token`, `Vault`).",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.14.0-next.0",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Rubilmax <rmilon@gmail.com>"
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "^5.7.2",
|
|
32
|
-
"viem": "^2.
|
|
32
|
+
"viem": "^2.33.3",
|
|
33
33
|
"vitest": "^3.0.5",
|
|
34
34
|
"@morpho-org/morpho-ts": "^2.4.2",
|
|
35
|
-
"@morpho-org/test": "^2.6.0"
|
|
35
|
+
"@morpho-org/test": "^2.6.1-next.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"prepublish": "$npm_execpath build",
|