@morpho-org/blue-sdk 4.14.0-next.2 → 5.0.1
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 -122
- package/lib/addresses.js +8 -48
- package/lib/errors.d.ts +0 -12
- package/lib/errors.js +1 -24
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/market/Market.d.ts +14 -28
- package/lib/market/Market.js +10 -29
- package/lib/market/MarketUtils.d.ts +3 -21
- package/lib/market/MarketUtils.js +3 -27
- package/lib/types.d.ts +0 -1
- package/lib/types.js +0 -5
- package/lib/vault/Vault.d.ts +8 -8
- package/lib/vault/Vault.js +9 -7
- package/lib/vault/index.d.ts +0 -1
- package/lib/vault/index.js +0 -1
- package/package.json +4 -4
- package/lib/utils.d.ts +0 -2
- package/lib/utils.js +0 -67
- package/lib/vault/v2/VaultV2.d.ts +0 -65
- package/lib/vault/v2/VaultV2.js +0 -96
- package/lib/vault/v2/VaultV2Adapter.d.ts +0 -18
- package/lib/vault/v2/VaultV2Adapter.js +0 -16
- package/lib/vault/v2/VaultV2MorphoVaultV1Adapter.d.ts +0 -21
- package/lib/vault/v2/VaultV2MorphoVaultV1Adapter.js +0 -28
- package/lib/vault/v2/index.d.ts +0 -3
- package/lib/vault/v2/index.js +0 -19
package/lib/addresses.d.ts
CHANGED
|
@@ -9,30 +9,6 @@ export declare const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEe
|
|
|
9
9
|
export interface ChainAddresses {
|
|
10
10
|
morpho: Address;
|
|
11
11
|
permit2?: Address;
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
14
|
-
*/
|
|
15
|
-
bundler?: Address;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
18
|
-
*/
|
|
19
|
-
aaveV3OptimizerBundler?: Address;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
22
|
-
*/
|
|
23
|
-
aaveV2Bundler?: Address;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
26
|
-
*/
|
|
27
|
-
aaveV3Bundler?: Address;
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
30
|
-
*/
|
|
31
|
-
compoundV3Bundler?: Address;
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
34
|
-
*/
|
|
35
|
-
compoundV2Bundler?: Address;
|
|
36
12
|
bundler3: {
|
|
37
13
|
bundler3: Address;
|
|
38
14
|
generalAdapter1: Address;
|
|
@@ -49,6 +25,8 @@ export interface ChainAddresses {
|
|
|
49
25
|
adaptiveCurveIrm: Address;
|
|
50
26
|
publicAllocator?: Address;
|
|
51
27
|
metaMorphoFactory?: Address;
|
|
28
|
+
vaultV2Factory?: Address;
|
|
29
|
+
morphoVaultV1AdapterFactory?: Address;
|
|
52
30
|
registryList?: Address;
|
|
53
31
|
chainlinkOracleFactory?: Address;
|
|
54
32
|
preLiquidationFactory?: Address;
|
|
@@ -64,17 +42,11 @@ export interface ChainAddresses {
|
|
|
64
42
|
usdc?: Address;
|
|
65
43
|
stEth?: Address;
|
|
66
44
|
wstEth?: Address;
|
|
67
|
-
vaultV2Factory?: Address;
|
|
68
|
-
morphoVaultV1AdapterFactory?: Address;
|
|
69
45
|
}
|
|
70
46
|
declare const _addressesRegistry: {
|
|
71
47
|
readonly 1: {
|
|
72
48
|
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
73
49
|
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
76
|
-
*/
|
|
77
|
-
readonly bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077";
|
|
78
50
|
readonly bundler3: {
|
|
79
51
|
readonly bundler3: "0x6566194141eefa99Af43Bb5Aa71460Ca2Dc90245";
|
|
80
52
|
readonly generalAdapter1: "0x4A6c312ec70E8747a587EE860a0353cd42Be0aE0";
|
|
@@ -88,29 +60,11 @@ declare const _addressesRegistry: {
|
|
|
88
60
|
readonly aaveV3EtherFiMigrationAdapter: "0x4011dc6581fA05F9B0c7A12AdCd676e2b1a59ca3";
|
|
89
61
|
readonly aaveV3OptimizerMigrationAdapter: "0x9e2ea2d5785598a163D569D795f286F5C55ad972";
|
|
90
62
|
};
|
|
91
|
-
/**
|
|
92
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
93
|
-
*/
|
|
94
|
-
readonly aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c";
|
|
95
|
-
/**
|
|
96
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
97
|
-
*/
|
|
98
|
-
readonly aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76";
|
|
99
|
-
/**
|
|
100
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
101
|
-
*/
|
|
102
|
-
readonly aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC";
|
|
103
|
-
/**
|
|
104
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
105
|
-
*/
|
|
106
|
-
readonly compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558";
|
|
107
|
-
/**
|
|
108
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
109
|
-
*/
|
|
110
|
-
readonly compoundV2Bundler: "0x26bF52a84360Ad3d01d7CDc28FC2dDC04d8c8647";
|
|
111
63
|
readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
|
|
112
64
|
readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
|
|
113
65
|
readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
|
|
66
|
+
readonly vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405";
|
|
67
|
+
readonly morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394";
|
|
114
68
|
readonly registryList: "0x3696c5eAe4a7Ffd04Ea163564571E9CD8Ed9364e";
|
|
115
69
|
readonly chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766";
|
|
116
70
|
readonly preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476";
|
|
@@ -141,16 +95,10 @@ declare const _addressesRegistry: {
|
|
|
141
95
|
readonly crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14";
|
|
142
96
|
readonly "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e";
|
|
143
97
|
readonly "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726";
|
|
144
|
-
readonly vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405";
|
|
145
|
-
readonly morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394";
|
|
146
98
|
};
|
|
147
99
|
readonly 8453: {
|
|
148
100
|
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
149
101
|
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
150
|
-
/**
|
|
151
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
152
|
-
*/
|
|
153
|
-
readonly bundler: "0x23055618898e202386e6c13955a58D3C68200BFB";
|
|
154
102
|
readonly bundler3: {
|
|
155
103
|
readonly bundler3: "0x6BFd8137e702540E7A42B74178A4a49Ba43920C4";
|
|
156
104
|
readonly generalAdapter1: "0xb98c948CFA24072e58935BC004a8A7b376AE746A";
|
|
@@ -159,21 +107,11 @@ declare const _addressesRegistry: {
|
|
|
159
107
|
readonly compoundV3MigrationAdapter: "0x85D4812Ef92c040d4270eD8547b6835e41FbbB70";
|
|
160
108
|
readonly aaveV3CoreMigrationAdapter: "0xb27Aa2a964eAd5ed661D86974b37e4fB995b36f5";
|
|
161
109
|
};
|
|
162
|
-
/**
|
|
163
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
164
|
-
*/
|
|
165
|
-
readonly compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223";
|
|
166
|
-
/**
|
|
167
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
168
|
-
*/
|
|
169
|
-
readonly aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108";
|
|
170
|
-
/**
|
|
171
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
172
|
-
*/
|
|
173
|
-
readonly compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA";
|
|
174
110
|
readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
|
|
175
111
|
readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
|
|
176
112
|
readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
|
|
113
|
+
readonly vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857";
|
|
114
|
+
readonly morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642";
|
|
177
115
|
readonly registryList: "0x5C2531Cbd2cf112Cf687da3Cd536708aDd7DB10a";
|
|
178
116
|
readonly chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d";
|
|
179
117
|
readonly preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef";
|
|
@@ -181,8 +119,6 @@ declare const _addressesRegistry: {
|
|
|
181
119
|
readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
182
120
|
readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
|
|
183
121
|
readonly testUsdc: "0xBC77067f829979812d795d516E523C4033b66409";
|
|
184
|
-
readonly vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857";
|
|
185
|
-
readonly morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642";
|
|
186
122
|
};
|
|
187
123
|
readonly 137: {
|
|
188
124
|
readonly morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67";
|
|
@@ -494,11 +430,11 @@ declare const _deployments: {
|
|
|
494
430
|
readonly adaptiveCurveIrm: 18883124n;
|
|
495
431
|
readonly publicAllocator: 19375099n;
|
|
496
432
|
readonly metaMorphoFactory: 21439510n;
|
|
433
|
+
readonly vaultV2Factory: 23375073n;
|
|
434
|
+
readonly morphoVaultV1AdapterFactory: 23375073n;
|
|
497
435
|
readonly registryList: 23375119n;
|
|
498
436
|
readonly chainlinkOracleFactory: 19375066n;
|
|
499
437
|
readonly preLiquidationFactory: 21414664n;
|
|
500
|
-
readonly vaultV2Factory: 23375073n;
|
|
501
|
-
readonly morphoVaultV1AdapterFactory: 23375073n;
|
|
502
438
|
};
|
|
503
439
|
readonly 8453: {
|
|
504
440
|
readonly morpho: 13977148n;
|
|
@@ -514,11 +450,11 @@ declare const _deployments: {
|
|
|
514
450
|
readonly adaptiveCurveIrm: 13977152n;
|
|
515
451
|
readonly publicAllocator: 13979545n;
|
|
516
452
|
readonly metaMorphoFactory: 23928808n;
|
|
453
|
+
readonly vaultV2Factory: 35615206n;
|
|
454
|
+
readonly morphoVaultV1AdapterFactory: 35615206n;
|
|
517
455
|
readonly registryList: 35615358n;
|
|
518
456
|
readonly chainlinkOracleFactory: 13978286n;
|
|
519
457
|
readonly preLiquidationFactory: 23779056n;
|
|
520
|
-
readonly vaultV2Factory: 35615206n;
|
|
521
|
-
readonly morphoVaultV1AdapterFactory: 35615206n;
|
|
522
458
|
};
|
|
523
459
|
readonly 137: {
|
|
524
460
|
readonly morpho: 66931042n;
|
|
@@ -809,10 +745,6 @@ export declare let addressesRegistry: {
|
|
|
809
745
|
readonly 1: {
|
|
810
746
|
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
811
747
|
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
812
|
-
/**
|
|
813
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
814
|
-
*/
|
|
815
|
-
readonly bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077";
|
|
816
748
|
readonly bundler3: {
|
|
817
749
|
readonly bundler3: "0x6566194141eefa99Af43Bb5Aa71460Ca2Dc90245";
|
|
818
750
|
readonly generalAdapter1: "0x4A6c312ec70E8747a587EE860a0353cd42Be0aE0";
|
|
@@ -826,29 +758,11 @@ export declare let addressesRegistry: {
|
|
|
826
758
|
readonly aaveV3EtherFiMigrationAdapter: "0x4011dc6581fA05F9B0c7A12AdCd676e2b1a59ca3";
|
|
827
759
|
readonly aaveV3OptimizerMigrationAdapter: "0x9e2ea2d5785598a163D569D795f286F5C55ad972";
|
|
828
760
|
};
|
|
829
|
-
/**
|
|
830
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
831
|
-
*/
|
|
832
|
-
readonly aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c";
|
|
833
|
-
/**
|
|
834
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
835
|
-
*/
|
|
836
|
-
readonly aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76";
|
|
837
|
-
/**
|
|
838
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
839
|
-
*/
|
|
840
|
-
readonly aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC";
|
|
841
|
-
/**
|
|
842
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
843
|
-
*/
|
|
844
|
-
readonly compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558";
|
|
845
|
-
/**
|
|
846
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
847
|
-
*/
|
|
848
|
-
readonly compoundV2Bundler: "0x26bF52a84360Ad3d01d7CDc28FC2dDC04d8c8647";
|
|
849
761
|
readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
|
|
850
762
|
readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
|
|
851
763
|
readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
|
|
764
|
+
readonly vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405";
|
|
765
|
+
readonly morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394";
|
|
852
766
|
readonly registryList: "0x3696c5eAe4a7Ffd04Ea163564571E9CD8Ed9364e";
|
|
853
767
|
readonly chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766";
|
|
854
768
|
readonly preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476";
|
|
@@ -879,16 +793,10 @@ export declare let addressesRegistry: {
|
|
|
879
793
|
readonly crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14";
|
|
880
794
|
readonly "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e";
|
|
881
795
|
readonly "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726";
|
|
882
|
-
readonly vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405";
|
|
883
|
-
readonly morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394";
|
|
884
796
|
};
|
|
885
797
|
readonly 8453: {
|
|
886
798
|
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
887
799
|
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
888
|
-
/**
|
|
889
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
890
|
-
*/
|
|
891
|
-
readonly bundler: "0x23055618898e202386e6c13955a58D3C68200BFB";
|
|
892
800
|
readonly bundler3: {
|
|
893
801
|
readonly bundler3: "0x6BFd8137e702540E7A42B74178A4a49Ba43920C4";
|
|
894
802
|
readonly generalAdapter1: "0xb98c948CFA24072e58935BC004a8A7b376AE746A";
|
|
@@ -897,21 +805,11 @@ export declare let addressesRegistry: {
|
|
|
897
805
|
readonly compoundV3MigrationAdapter: "0x85D4812Ef92c040d4270eD8547b6835e41FbbB70";
|
|
898
806
|
readonly aaveV3CoreMigrationAdapter: "0xb27Aa2a964eAd5ed661D86974b37e4fB995b36f5";
|
|
899
807
|
};
|
|
900
|
-
/**
|
|
901
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
902
|
-
*/
|
|
903
|
-
readonly compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223";
|
|
904
|
-
/**
|
|
905
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
906
|
-
*/
|
|
907
|
-
readonly aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108";
|
|
908
|
-
/**
|
|
909
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
910
|
-
*/
|
|
911
|
-
readonly compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA";
|
|
912
808
|
readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
|
|
913
809
|
readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
|
|
914
810
|
readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
|
|
811
|
+
readonly vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857";
|
|
812
|
+
readonly morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642";
|
|
915
813
|
readonly registryList: "0x5C2531Cbd2cf112Cf687da3Cd536708aDd7DB10a";
|
|
916
814
|
readonly chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d";
|
|
917
815
|
readonly preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef";
|
|
@@ -919,8 +817,6 @@ export declare let addressesRegistry: {
|
|
|
919
817
|
readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
920
818
|
readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
|
|
921
819
|
readonly testUsdc: "0xBC77067f829979812d795d516E523C4033b66409";
|
|
922
|
-
readonly vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857";
|
|
923
|
-
readonly morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642";
|
|
924
820
|
};
|
|
925
821
|
readonly 137: {
|
|
926
822
|
readonly morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67";
|
|
@@ -1230,11 +1126,11 @@ export declare let deployments: {
|
|
|
1230
1126
|
readonly adaptiveCurveIrm: 18883124n;
|
|
1231
1127
|
readonly publicAllocator: 19375099n;
|
|
1232
1128
|
readonly metaMorphoFactory: 21439510n;
|
|
1129
|
+
readonly vaultV2Factory: 23375073n;
|
|
1130
|
+
readonly morphoVaultV1AdapterFactory: 23375073n;
|
|
1233
1131
|
readonly registryList: 23375119n;
|
|
1234
1132
|
readonly chainlinkOracleFactory: 19375066n;
|
|
1235
1133
|
readonly preLiquidationFactory: 21414664n;
|
|
1236
|
-
readonly vaultV2Factory: 23375073n;
|
|
1237
|
-
readonly morphoVaultV1AdapterFactory: 23375073n;
|
|
1238
1134
|
};
|
|
1239
1135
|
readonly 8453: {
|
|
1240
1136
|
readonly morpho: 13977148n;
|
|
@@ -1250,11 +1146,11 @@ export declare let deployments: {
|
|
|
1250
1146
|
readonly adaptiveCurveIrm: 13977152n;
|
|
1251
1147
|
readonly publicAllocator: 13979545n;
|
|
1252
1148
|
readonly metaMorphoFactory: 23928808n;
|
|
1149
|
+
readonly vaultV2Factory: 35615206n;
|
|
1150
|
+
readonly morphoVaultV1AdapterFactory: 35615206n;
|
|
1253
1151
|
readonly registryList: 35615358n;
|
|
1254
1152
|
readonly chainlinkOracleFactory: 13978286n;
|
|
1255
1153
|
readonly preLiquidationFactory: 23779056n;
|
|
1256
|
-
readonly vaultV2Factory: 35615206n;
|
|
1257
|
-
readonly morphoVaultV1AdapterFactory: 35615206n;
|
|
1258
1154
|
};
|
|
1259
1155
|
readonly 137: {
|
|
1260
1156
|
readonly morpho: 66931042n;
|
package/lib/addresses.js
CHANGED
|
@@ -20,10 +20,6 @@ const _addressesRegistry = {
|
|
|
20
20
|
[chain_js_1.ChainId.EthMainnet]: {
|
|
21
21
|
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
22
22
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
25
|
-
*/
|
|
26
|
-
bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077",
|
|
27
23
|
bundler3: {
|
|
28
24
|
bundler3: "0x6566194141eefa99Af43Bb5Aa71460Ca2Dc90245",
|
|
29
25
|
generalAdapter1: "0x4A6c312ec70E8747a587EE860a0353cd42Be0aE0",
|
|
@@ -37,29 +33,11 @@ const _addressesRegistry = {
|
|
|
37
33
|
aaveV3EtherFiMigrationAdapter: "0x4011dc6581fA05F9B0c7A12AdCd676e2b1a59ca3",
|
|
38
34
|
aaveV3OptimizerMigrationAdapter: "0x9e2ea2d5785598a163D569D795f286F5C55ad972",
|
|
39
35
|
},
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
42
|
-
*/
|
|
43
|
-
aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c",
|
|
44
|
-
/**
|
|
45
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
46
|
-
*/
|
|
47
|
-
aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76",
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
50
|
-
*/
|
|
51
|
-
aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC",
|
|
52
|
-
/**
|
|
53
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
54
|
-
*/
|
|
55
|
-
compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558",
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
58
|
-
*/
|
|
59
|
-
compoundV2Bundler: "0x26bF52a84360Ad3d01d7CDc28FC2dDC04d8c8647",
|
|
60
36
|
adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
|
|
61
37
|
publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D",
|
|
62
38
|
metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24",
|
|
39
|
+
vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405",
|
|
40
|
+
morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394",
|
|
63
41
|
registryList: "0x3696c5eAe4a7Ffd04Ea163564571E9CD8Ed9364e",
|
|
64
42
|
chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766",
|
|
65
43
|
preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476",
|
|
@@ -96,16 +74,10 @@ const _addressesRegistry = {
|
|
|
96
74
|
crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14",
|
|
97
75
|
"stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e",
|
|
98
76
|
"2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726",
|
|
99
|
-
vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405",
|
|
100
|
-
morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394",
|
|
101
77
|
},
|
|
102
78
|
[chain_js_1.ChainId.BaseMainnet]: {
|
|
103
79
|
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
104
80
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
105
|
-
/**
|
|
106
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
107
|
-
*/
|
|
108
|
-
bundler: "0x23055618898e202386e6c13955a58D3C68200BFB",
|
|
109
81
|
bundler3: {
|
|
110
82
|
bundler3: "0x6BFd8137e702540E7A42B74178A4a49Ba43920C4",
|
|
111
83
|
generalAdapter1: "0xb98c948CFA24072e58935BC004a8A7b376AE746A",
|
|
@@ -114,21 +86,11 @@ const _addressesRegistry = {
|
|
|
114
86
|
compoundV3MigrationAdapter: "0x85D4812Ef92c040d4270eD8547b6835e41FbbB70",
|
|
115
87
|
aaveV3CoreMigrationAdapter: "0xb27Aa2a964eAd5ed661D86974b37e4fB995b36f5",
|
|
116
88
|
},
|
|
117
|
-
/**
|
|
118
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
119
|
-
*/
|
|
120
|
-
compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223",
|
|
121
|
-
/**
|
|
122
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
123
|
-
*/
|
|
124
|
-
aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108",
|
|
125
|
-
/**
|
|
126
|
-
* @deprecated All bundles should use Bundler3 instead.
|
|
127
|
-
*/
|
|
128
|
-
compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA",
|
|
129
89
|
adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687",
|
|
130
90
|
publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467",
|
|
131
91
|
metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918",
|
|
92
|
+
vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857",
|
|
93
|
+
morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642",
|
|
132
94
|
registryList: "0x5C2531Cbd2cf112Cf687da3Cd536708aDd7DB10a",
|
|
133
95
|
chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d",
|
|
134
96
|
preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef",
|
|
@@ -137,8 +99,6 @@ const _addressesRegistry = {
|
|
|
137
99
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
138
100
|
verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b",
|
|
139
101
|
testUsdc: "0xBC77067f829979812d795d516E523C4033b66409",
|
|
140
|
-
vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857",
|
|
141
|
-
morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642",
|
|
142
102
|
},
|
|
143
103
|
[chain_js_1.ChainId.PolygonMainnet]: {
|
|
144
104
|
morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67",
|
|
@@ -456,11 +416,11 @@ const _deployments = {
|
|
|
456
416
|
adaptiveCurveIrm: 18883124n,
|
|
457
417
|
publicAllocator: 19375099n,
|
|
458
418
|
metaMorphoFactory: 21439510n,
|
|
419
|
+
vaultV2Factory: 23375073n,
|
|
420
|
+
morphoVaultV1AdapterFactory: 23375073n,
|
|
459
421
|
registryList: 23375119n,
|
|
460
422
|
chainlinkOracleFactory: 19375066n,
|
|
461
423
|
preLiquidationFactory: 21414664n,
|
|
462
|
-
vaultV2Factory: 23375073n,
|
|
463
|
-
morphoVaultV1AdapterFactory: 23375073n,
|
|
464
424
|
},
|
|
465
425
|
[chain_js_1.ChainId.BaseMainnet]: {
|
|
466
426
|
morpho: 13977148n,
|
|
@@ -476,11 +436,11 @@ const _deployments = {
|
|
|
476
436
|
adaptiveCurveIrm: 13977152n,
|
|
477
437
|
publicAllocator: 13979545n,
|
|
478
438
|
metaMorphoFactory: 23928808n,
|
|
439
|
+
vaultV2Factory: 35615206n,
|
|
440
|
+
morphoVaultV1AdapterFactory: 35615206n,
|
|
479
441
|
registryList: 35615358n,
|
|
480
442
|
chainlinkOracleFactory: 13978286n,
|
|
481
443
|
preLiquidationFactory: 23779056n,
|
|
482
|
-
vaultV2Factory: 35615206n,
|
|
483
|
-
morphoVaultV1AdapterFactory: 35615206n,
|
|
484
444
|
},
|
|
485
445
|
[chain_js_1.ChainId.PolygonMainnet]: {
|
|
486
446
|
morpho: 66931042n,
|
package/lib/errors.d.ts
CHANGED
|
@@ -25,10 +25,6 @@ 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
|
-
}
|
|
32
28
|
export declare namespace BlueErrors {
|
|
33
29
|
class AlreadySet extends Error {
|
|
34
30
|
readonly name: string;
|
|
@@ -69,14 +65,6 @@ export declare namespace BlueErrors {
|
|
|
69
65
|
constructor(deadline: bigint);
|
|
70
66
|
}
|
|
71
67
|
}
|
|
72
|
-
export declare namespace VaultV2Errors {
|
|
73
|
-
class InvalidInterestAccrual extends Error {
|
|
74
|
-
readonly vault: Address;
|
|
75
|
-
readonly timestamp: bigint;
|
|
76
|
-
readonly lastUpdate: bigint;
|
|
77
|
-
constructor(vault: Address, timestamp: bigint, lastUpdate: bigint);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
68
|
export interface ErrorClass<E extends Error> {
|
|
81
69
|
new (...args: any[]): E;
|
|
82
70
|
}
|
package/lib/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
5
|
const viem_1 = require("viem");
|
|
6
6
|
class UnknownDataError extends Error {
|
|
@@ -54,14 +54,6 @@ 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;
|
|
65
57
|
var BlueErrors;
|
|
66
58
|
(function (BlueErrors) {
|
|
67
59
|
class AlreadySet extends Error {
|
|
@@ -141,21 +133,6 @@ var BlueErrors;
|
|
|
141
133
|
}
|
|
142
134
|
BlueErrors.ExpiredSignature = ExpiredSignature;
|
|
143
135
|
})(BlueErrors || (exports.BlueErrors = BlueErrors = {}));
|
|
144
|
-
var VaultV2Errors;
|
|
145
|
-
(function (VaultV2Errors) {
|
|
146
|
-
class InvalidInterestAccrual extends Error {
|
|
147
|
-
vault;
|
|
148
|
-
timestamp;
|
|
149
|
-
lastUpdate;
|
|
150
|
-
constructor(vault, timestamp, lastUpdate) {
|
|
151
|
-
super(`invalid interest accrual on vault ${vault}: accrual timestamp ${timestamp} can't be prior to last update ${lastUpdate}`);
|
|
152
|
-
this.vault = vault;
|
|
153
|
-
this.timestamp = timestamp;
|
|
154
|
-
this.lastUpdate = lastUpdate;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
VaultV2Errors.InvalidInterestAccrual = InvalidInterestAccrual;
|
|
158
|
-
})(VaultV2Errors || (exports.VaultV2Errors = VaultV2Errors = {}));
|
|
159
136
|
function _try(accessor, ...errorClasses) {
|
|
160
137
|
const maybeCatchError = (error) => {
|
|
161
138
|
if (errorClasses.length === 0 ||
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -27,4 +27,3 @@ __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("./utils.js"), exports);
|
package/lib/market/Market.d.ts
CHANGED
|
@@ -98,19 +98,9 @@ export declare class Market implements IMarket {
|
|
|
98
98
|
*/
|
|
99
99
|
get utilization(): bigint;
|
|
100
100
|
/**
|
|
101
|
-
* The market's Annual Percentage Yield (APY) at the IRM's target utilization rate, if applicable
|
|
101
|
+
* The market's Annual Percentage Yield (APY) at the IRM's target utilization rate, if applicable.
|
|
102
102
|
*/
|
|
103
|
-
get apyAtTarget():
|
|
104
|
-
/**
|
|
105
|
-
* Returns the rate at which interest accrued for suppliers of this market,
|
|
106
|
-
* since the last time the market was updated (scaled by WAD).
|
|
107
|
-
* @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
|
|
108
|
-
*/
|
|
109
|
-
get supplyRate(): bigint;
|
|
110
|
-
/**
|
|
111
|
-
* @deprecated Use `avgBorrowRate` instead.
|
|
112
|
-
*/
|
|
113
|
-
get borrowRate(): bigint;
|
|
103
|
+
get apyAtTarget(): number | undefined;
|
|
114
104
|
/**
|
|
115
105
|
* Returns the instantaneous rate at which interest accrues for borrowers of this market,
|
|
116
106
|
* if `accrueInterest` was called immediately onchain (scaled by WAD).
|
|
@@ -137,19 +127,15 @@ export declare class Market implements IMarket {
|
|
|
137
127
|
*/
|
|
138
128
|
get avgBorrowRate(): bigint;
|
|
139
129
|
/**
|
|
140
|
-
* The market's current, instantaneous supply-side Annual Percentage Yield (APY)
|
|
130
|
+
* The market's current, instantaneous supply-side Annual Percentage Yield (APY).
|
|
141
131
|
* If interested in the APY at a specific timestamp, use `getSupplyApy(timestamp)` instead.
|
|
142
132
|
*/
|
|
143
|
-
get supplyApy():
|
|
133
|
+
get supplyApy(): number;
|
|
144
134
|
/**
|
|
145
|
-
* The market's current, instantaneous borrow-side Annual Percentage Yield (APY)
|
|
135
|
+
* The market's current, instantaneous borrow-side Annual Percentage Yield (APY).
|
|
146
136
|
* If interested in the APY at a specific timestamp, use `getBorrowApy(timestamp)` instead.
|
|
147
137
|
*/
|
|
148
|
-
get borrowApy():
|
|
149
|
-
/**
|
|
150
|
-
* @deprecated Use `getEndBorrowRate(timestamp)` instead.
|
|
151
|
-
*/
|
|
152
|
-
getBorrowRate(timestamp?: BigIntish): bigint;
|
|
138
|
+
get borrowApy(): number;
|
|
153
139
|
/**
|
|
154
140
|
* Returns the instantaneous rate at which interest accrues for borrowers of this market,
|
|
155
141
|
* at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
|
|
@@ -183,36 +169,36 @@ export declare class Market implements IMarket {
|
|
|
183
169
|
};
|
|
184
170
|
/**
|
|
185
171
|
* The market's instantaneous borrow-side Annual Percentage Yield (APY) at the given timestamp,
|
|
186
|
-
* if the state remains unchanged (not accrued)
|
|
172
|
+
* if the state remains unchanged (not accrued).
|
|
187
173
|
* @param timestamp The timestamp at which to calculate the borrow APY.
|
|
188
174
|
* Must be greater than or equal to `lastUpdate`.
|
|
189
175
|
* Defaults to `Time.timestamp()` (returns the current borrow APY).
|
|
190
176
|
*/
|
|
191
|
-
getBorrowApy(timestamp?: BigIntish):
|
|
177
|
+
getBorrowApy(timestamp?: BigIntish): number;
|
|
192
178
|
/**
|
|
193
179
|
* The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
|
|
194
|
-
* if the state remains unchanged (not accrued)
|
|
180
|
+
* if the state remains unchanged (not accrued).
|
|
195
181
|
* @param timestamp The timestamp at which to calculate the supply APY.
|
|
196
182
|
* Must be greater than or equal to `lastUpdate`.
|
|
197
183
|
* Defaults to `Time.timestamp()` (returns the current supply APY).
|
|
198
184
|
*/
|
|
199
|
-
getSupplyApy(timestamp?: BigIntish):
|
|
185
|
+
getSupplyApy(timestamp?: BigIntish): number;
|
|
200
186
|
/**
|
|
201
187
|
* The market's experienced borrow-side Annual Percentage Yield (APY),
|
|
202
|
-
* if interest was to be accrued at the given timestamp
|
|
188
|
+
* if interest was to be accrued at the given timestamp.
|
|
203
189
|
* @param timestamp The timestamp at which to calculate the borrow APY.
|
|
204
190
|
* Must be greater than or equal to `lastUpdate`.
|
|
205
191
|
* Defaults to `Time.timestamp()` (returns the current borrow APY).
|
|
206
192
|
*/
|
|
207
|
-
getAvgBorrowApy(timestamp?: BigIntish):
|
|
193
|
+
getAvgBorrowApy(timestamp?: BigIntish): number;
|
|
208
194
|
/**
|
|
209
195
|
* The market's experienced supply-side Annual Percentage Yield (APY),
|
|
210
|
-
* if interest was to be accrued at the given timestamp
|
|
196
|
+
* if interest was to be accrued at the given timestamp.
|
|
211
197
|
* @param timestamp The timestamp at which to calculate the supply APY.
|
|
212
198
|
* Must be greater than or equal to `lastUpdate`.
|
|
213
199
|
* Defaults to `Time.timestamp()` (returns the current supply APY).
|
|
214
200
|
*/
|
|
215
|
-
getAvgSupplyApy(timestamp?: BigIntish):
|
|
201
|
+
getAvgSupplyApy(timestamp?: BigIntish): number;
|
|
216
202
|
/**
|
|
217
203
|
* Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
|
|
218
204
|
* @param timestamp The timestamp at which to accrue interest.
|
package/lib/market/Market.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.Market = exports.CapacityLimitReason = void 0;
|
|
|
4
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
5
|
const errors_js_1 = require("../errors.js");
|
|
6
6
|
const index_js_1 = require("../math/index.js");
|
|
7
|
+
const viem_1 = require("viem");
|
|
7
8
|
const MarketParams_js_1 = require("./MarketParams.js");
|
|
8
9
|
const MarketUtils_js_1 = require("./MarketUtils.js");
|
|
9
10
|
var CapacityLimitReason;
|
|
@@ -94,27 +95,13 @@ class Market {
|
|
|
94
95
|
return MarketUtils_js_1.MarketUtils.getUtilization(this);
|
|
95
96
|
}
|
|
96
97
|
/**
|
|
97
|
-
* The market's Annual Percentage Yield (APY) at the IRM's target utilization rate, if applicable
|
|
98
|
+
* The market's Annual Percentage Yield (APY) at the IRM's target utilization rate, if applicable.
|
|
98
99
|
*/
|
|
99
100
|
get apyAtTarget() {
|
|
100
101
|
if (this.rateAtTarget == null)
|
|
101
102
|
return;
|
|
102
103
|
return MarketUtils_js_1.MarketUtils.rateToApy(this.rateAtTarget);
|
|
103
104
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Returns the rate at which interest accrued for suppliers of this market,
|
|
106
|
-
* since the last time the market was updated (scaled by WAD).
|
|
107
|
-
* @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
|
|
108
|
-
*/
|
|
109
|
-
get supplyRate() {
|
|
110
|
-
return MarketUtils_js_1.MarketUtils.getSupplyRate(this.avgBorrowRate, this);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* @deprecated Use `avgBorrowRate` instead.
|
|
114
|
-
*/
|
|
115
|
-
get borrowRate() {
|
|
116
|
-
return this.getAccrualBorrowRates().avgBorrowRate;
|
|
117
|
-
}
|
|
118
105
|
/**
|
|
119
106
|
* Returns the instantaneous rate at which interest accrues for borrowers of this market,
|
|
120
107
|
* if `accrueInterest` was called immediately onchain (scaled by WAD).
|
|
@@ -145,25 +132,19 @@ class Market {
|
|
|
145
132
|
return this.getAccrualBorrowRates().avgBorrowRate;
|
|
146
133
|
}
|
|
147
134
|
/**
|
|
148
|
-
* The market's current, instantaneous supply-side Annual Percentage Yield (APY)
|
|
135
|
+
* The market's current, instantaneous supply-side Annual Percentage Yield (APY).
|
|
149
136
|
* If interested in the APY at a specific timestamp, use `getSupplyApy(timestamp)` instead.
|
|
150
137
|
*/
|
|
151
138
|
get supplyApy() {
|
|
152
139
|
return this.getSupplyApy();
|
|
153
140
|
}
|
|
154
141
|
/**
|
|
155
|
-
* The market's current, instantaneous borrow-side Annual Percentage Yield (APY)
|
|
142
|
+
* The market's current, instantaneous borrow-side Annual Percentage Yield (APY).
|
|
156
143
|
* If interested in the APY at a specific timestamp, use `getBorrowApy(timestamp)` instead.
|
|
157
144
|
*/
|
|
158
145
|
get borrowApy() {
|
|
159
146
|
return this.getBorrowApy();
|
|
160
147
|
}
|
|
161
|
-
/**
|
|
162
|
-
* @deprecated Use `getEndBorrowRate(timestamp)` instead.
|
|
163
|
-
*/
|
|
164
|
-
getBorrowRate(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
165
|
-
return this.getAccrualBorrowRates(timestamp).endBorrowRate;
|
|
166
|
-
}
|
|
167
148
|
/**
|
|
168
149
|
* Returns the instantaneous rate at which interest accrues for borrowers of this market,
|
|
169
150
|
* at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
|
|
@@ -211,7 +192,7 @@ class Market {
|
|
|
211
192
|
}
|
|
212
193
|
/**
|
|
213
194
|
* The market's instantaneous borrow-side Annual Percentage Yield (APY) at the given timestamp,
|
|
214
|
-
* if the state remains unchanged (not accrued)
|
|
195
|
+
* if the state remains unchanged (not accrued).
|
|
215
196
|
* @param timestamp The timestamp at which to calculate the borrow APY.
|
|
216
197
|
* Must be greater than or equal to `lastUpdate`.
|
|
217
198
|
* Defaults to `Time.timestamp()` (returns the current borrow APY).
|
|
@@ -222,18 +203,18 @@ class Market {
|
|
|
222
203
|
}
|
|
223
204
|
/**
|
|
224
205
|
* The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
|
|
225
|
-
* if the state remains unchanged (not accrued)
|
|
206
|
+
* if the state remains unchanged (not accrued).
|
|
226
207
|
* @param timestamp The timestamp at which to calculate the supply APY.
|
|
227
208
|
* Must be greater than or equal to `lastUpdate`.
|
|
228
209
|
* Defaults to `Time.timestamp()` (returns the current supply APY).
|
|
229
210
|
*/
|
|
230
211
|
getSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
231
212
|
const borrowApy = this.getBorrowApy(timestamp);
|
|
232
|
-
return
|
|
213
|
+
return (borrowApy * +(0, viem_1.formatEther)(this.utilization) * (1 - +(0, viem_1.formatEther)(this.fee)));
|
|
233
214
|
}
|
|
234
215
|
/**
|
|
235
216
|
* The market's experienced borrow-side Annual Percentage Yield (APY),
|
|
236
|
-
* if interest was to be accrued at the given timestamp
|
|
217
|
+
* if interest was to be accrued at the given timestamp.
|
|
237
218
|
* @param timestamp The timestamp at which to calculate the borrow APY.
|
|
238
219
|
* Must be greater than or equal to `lastUpdate`.
|
|
239
220
|
* Defaults to `Time.timestamp()` (returns the current borrow APY).
|
|
@@ -244,14 +225,14 @@ class Market {
|
|
|
244
225
|
}
|
|
245
226
|
/**
|
|
246
227
|
* The market's experienced supply-side Annual Percentage Yield (APY),
|
|
247
|
-
* if interest was to be accrued at the given timestamp
|
|
228
|
+
* if interest was to be accrued at the given timestamp.
|
|
248
229
|
* @param timestamp The timestamp at which to calculate the supply APY.
|
|
249
230
|
* Must be greater than or equal to `lastUpdate`.
|
|
250
231
|
* Defaults to `Time.timestamp()` (returns the current supply APY).
|
|
251
232
|
*/
|
|
252
233
|
getAvgSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
253
234
|
const borrowApy = this.getAvgBorrowApy(timestamp);
|
|
254
|
-
return
|
|
235
|
+
return (borrowApy * +(0, viem_1.formatEther)(this.utilization) * (1 - +(0, viem_1.formatEther)(this.fee)));
|
|
255
236
|
}
|
|
256
237
|
/**
|
|
257
238
|
* Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
|
|
@@ -26,29 +26,11 @@ export declare namespace MarketUtils {
|
|
|
26
26
|
totalBorrowAssets: BigIntish;
|
|
27
27
|
}): bigint;
|
|
28
28
|
/**
|
|
29
|
-
* Returns the rate
|
|
30
|
-
* since the last time the market was updated (scaled by WAD).
|
|
31
|
-
* @param borrowRate The average borrow rate since the last market update (scaled by WAD).
|
|
32
|
-
* @param market The market state.
|
|
33
|
-
* @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
|
|
34
|
-
*/
|
|
35
|
-
function getSupplyRate(borrowRate: BigIntish, { utilization, fee }: {
|
|
36
|
-
utilization: BigIntish;
|
|
37
|
-
fee: BigIntish;
|
|
38
|
-
}): bigint;
|
|
39
|
-
/**
|
|
40
|
-
* Returns the per-second rate continuously compounded over the given period, as calculated in Morpho Blue (scaled by WAD).
|
|
41
|
-
* @param rate The per-second rate to compound (scaled by WAD).
|
|
42
|
-
* @param period The period to compound the rate over (in seconds). Defaults to 1 year.
|
|
43
|
-
* @deprecated The compounded rate is inaccurate if rate * period >> 0. If interested in the APY, use `rateToApy` instead.
|
|
44
|
-
*/
|
|
45
|
-
function compoundRate(rate: BigIntish, period?: BigIntish): bigint;
|
|
46
|
-
/**
|
|
47
|
-
* Returns the per-second rate continuously compounded over a year (scaled by WAD),
|
|
29
|
+
* Returns the per-second rate continuously compounded over a year,
|
|
48
30
|
* as calculated in Morpho Blue assuming the market is frequently accrued onchain.
|
|
49
|
-
* @param rate The per-second rate to compound annually
|
|
31
|
+
* @param rate The per-second rate to compound annually.
|
|
50
32
|
*/
|
|
51
|
-
function rateToApy(rate: BigIntish):
|
|
33
|
+
function rateToApy(rate: BigIntish): number;
|
|
52
34
|
/**
|
|
53
35
|
* Returns the interest accrued on both sides of the given market
|
|
54
36
|
* as well as the supply shares minted to the fee recipient.
|
|
@@ -6,7 +6,6 @@ const utils_1 = require("@noble/hashes/utils");
|
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
7
|
const constants_js_1 = require("../constants.js");
|
|
8
8
|
const index_js_1 = require("../math/index.js");
|
|
9
|
-
const utils_js_1 = require("../utils.js");
|
|
10
9
|
/**
|
|
11
10
|
* Namespace of utility functions to ease market-related calculations.
|
|
12
11
|
*/
|
|
@@ -52,35 +51,12 @@ var MarketUtils;
|
|
|
52
51
|
}
|
|
53
52
|
MarketUtils.getUtilization = getUtilization;
|
|
54
53
|
/**
|
|
55
|
-
* Returns the rate
|
|
56
|
-
* since the last time the market was updated (scaled by WAD).
|
|
57
|
-
* @param borrowRate The average borrow rate since the last market update (scaled by WAD).
|
|
58
|
-
* @param market The market state.
|
|
59
|
-
* @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
|
|
60
|
-
*/
|
|
61
|
-
function getSupplyRate(borrowRate, { utilization, fee }) {
|
|
62
|
-
const borrowRateWithoutFees = index_js_1.MathLib.wMulUp(borrowRate, utilization);
|
|
63
|
-
return index_js_1.MathLib.wMulUp(borrowRateWithoutFees, index_js_1.MathLib.WAD - BigInt(fee));
|
|
64
|
-
}
|
|
65
|
-
MarketUtils.getSupplyRate = getSupplyRate;
|
|
66
|
-
/**
|
|
67
|
-
* Returns the per-second rate continuously compounded over the given period, as calculated in Morpho Blue (scaled by WAD).
|
|
68
|
-
* @param rate The per-second rate to compound (scaled by WAD).
|
|
69
|
-
* @param period The period to compound the rate over (in seconds). Defaults to 1 year.
|
|
70
|
-
* @deprecated The compounded rate is inaccurate if rate * period >> 0. If interested in the APY, use `rateToApy` instead.
|
|
71
|
-
*/
|
|
72
|
-
function compoundRate(rate, period = constants_js_1.SECONDS_PER_YEAR) {
|
|
73
|
-
return index_js_1.MathLib.wTaylorCompounded(rate, period);
|
|
74
|
-
}
|
|
75
|
-
MarketUtils.compoundRate = compoundRate;
|
|
76
|
-
/**
|
|
77
|
-
* Returns the per-second rate continuously compounded over a year (scaled by WAD),
|
|
54
|
+
* Returns the per-second rate continuously compounded over a year,
|
|
78
55
|
* as calculated in Morpho Blue assuming the market is frequently accrued onchain.
|
|
79
|
-
* @param rate The per-second rate to compound annually
|
|
56
|
+
* @param rate The per-second rate to compound annually.
|
|
80
57
|
*/
|
|
81
|
-
// TODO: return a Number for APYs.
|
|
82
58
|
function rateToApy(rate) {
|
|
83
|
-
return
|
|
59
|
+
return Math.expm1(+(0, viem_1.formatEther)(BigInt(rate) * constants_js_1.SECONDS_PER_YEAR));
|
|
84
60
|
}
|
|
85
61
|
MarketUtils.rateToApy = rateToApy;
|
|
86
62
|
/**
|
package/lib/types.d.ts
CHANGED
|
@@ -23,5 +23,4 @@ export declare enum TransactionType {
|
|
|
23
23
|
export type Loadable<T> = T | undefined;
|
|
24
24
|
export type Failable<T> = T | null;
|
|
25
25
|
export type Fetchable<T> = Failable<Loadable<T>>;
|
|
26
|
-
export declare function isFetched<T>(v: Fetchable<T>): v is T;
|
|
27
26
|
export declare const isMarketId: (value: unknown) => value is MarketId;
|
package/lib/types.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isMarketId = exports.TransactionType = void 0;
|
|
4
|
-
exports.isFetched = isFetched;
|
|
5
4
|
/**
|
|
6
5
|
* The possible transaction type on the Blue contract
|
|
7
6
|
*/
|
|
@@ -14,9 +13,5 @@ var TransactionType;
|
|
|
14
13
|
TransactionType["Borrow"] = "Borrow";
|
|
15
14
|
TransactionType["Repay"] = "Repay";
|
|
16
15
|
})(TransactionType || (exports.TransactionType = TransactionType = {}));
|
|
17
|
-
// TODO: replace with isDefined
|
|
18
|
-
function isFetched(v) {
|
|
19
|
-
return v !== undefined && v !== null;
|
|
20
|
-
}
|
|
21
16
|
const isMarketId = (value) => typeof value === "string" && /^0x[0-9A-Fa-f]{64}$/.test(value);
|
|
22
17
|
exports.isMarketId = isMarketId;
|
package/lib/vault/Vault.d.ts
CHANGED
|
@@ -149,28 +149,28 @@ export declare class AccrualVault extends Vault implements IAccrualVault {
|
|
|
149
149
|
get liquidity(): bigint;
|
|
150
150
|
/**
|
|
151
151
|
* The MetaMorpho vault's current instantaneous Annual Percentage Yield (APY)
|
|
152
|
-
* weighted-averaged over its market deposits, before deducting the performance fee
|
|
152
|
+
* weighted-averaged over its market deposits, before deducting the performance fee.
|
|
153
153
|
* If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
|
|
154
154
|
*/
|
|
155
|
-
get apy():
|
|
155
|
+
get apy(): number;
|
|
156
156
|
/**
|
|
157
157
|
* The MetaMorpho vault's current instantaneous Annual Percentage Yield (APY)
|
|
158
|
-
* weighted-averaged over its market deposits, after deducting the performance fee
|
|
158
|
+
* weighted-averaged over its market deposits, after deducting the performance fee.
|
|
159
159
|
* If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
|
|
160
160
|
*/
|
|
161
|
-
get netApy():
|
|
161
|
+
get netApy(): number;
|
|
162
162
|
/**
|
|
163
163
|
* The MetaMorpho vault's experienced Annual Percentage Yield (APY)
|
|
164
164
|
* weighted-averaged over its market deposits, before deducting the performance fee,
|
|
165
|
-
* if interest was to be accrued on each market at the given timestamp
|
|
165
|
+
* if interest was to be accrued on each market at the given timestamp.
|
|
166
166
|
*/
|
|
167
|
-
getApy(timestamp?: BigIntish):
|
|
167
|
+
getApy(timestamp?: BigIntish): number;
|
|
168
168
|
/**
|
|
169
169
|
* The MetaMorpho vault's experienced Annual Percentage Yield (APY)
|
|
170
170
|
* weighted-averaged over its market deposits, after deducting the performance fee,
|
|
171
|
-
* if interest was to be accrued on each market at the given timestamp
|
|
171
|
+
* if interest was to be accrued on each market at the given timestamp.
|
|
172
172
|
*/
|
|
173
|
-
getNetApy(timestamp?: BigIntish):
|
|
173
|
+
getNetApy(timestamp?: BigIntish): number;
|
|
174
174
|
getAllocationProportion(marketId: MarketId): bigint;
|
|
175
175
|
getDepositCapacityLimit(assets: bigint): CapacityLimit;
|
|
176
176
|
getWithdrawCapacityLimit(shares: bigint): CapacityLimit;
|
package/lib/vault/Vault.js
CHANGED
|
@@ -5,6 +5,7 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
|
5
5
|
const index_js_1 = require("../market/index.js");
|
|
6
6
|
const index_js_2 = require("../math/index.js");
|
|
7
7
|
const index_js_3 = require("../token/index.js");
|
|
8
|
+
const viem_1 = require("viem");
|
|
8
9
|
const VaultMarketAllocation_js_1 = require("./VaultMarketAllocation.js");
|
|
9
10
|
class Vault extends index_js_3.VaultToken {
|
|
10
11
|
/**
|
|
@@ -155,7 +156,7 @@ class AccrualVault extends Vault {
|
|
|
155
156
|
}
|
|
156
157
|
/**
|
|
157
158
|
* The MetaMorpho vault's current instantaneous Annual Percentage Yield (APY)
|
|
158
|
-
* weighted-averaged over its market deposits, before deducting the performance fee
|
|
159
|
+
* weighted-averaged over its market deposits, before deducting the performance fee.
|
|
159
160
|
* If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
|
|
160
161
|
*/
|
|
161
162
|
get apy() {
|
|
@@ -163,7 +164,7 @@ class AccrualVault extends Vault {
|
|
|
163
164
|
}
|
|
164
165
|
/**
|
|
165
166
|
* The MetaMorpho vault's current instantaneous Annual Percentage Yield (APY)
|
|
166
|
-
* weighted-averaged over its market deposits, after deducting the performance fee
|
|
167
|
+
* weighted-averaged over its market deposits, after deducting the performance fee.
|
|
167
168
|
* If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
|
|
168
169
|
*/
|
|
169
170
|
get netApy() {
|
|
@@ -172,23 +173,24 @@ class AccrualVault extends Vault {
|
|
|
172
173
|
/**
|
|
173
174
|
* The MetaMorpho vault's experienced Annual Percentage Yield (APY)
|
|
174
175
|
* weighted-averaged over its market deposits, before deducting the performance fee,
|
|
175
|
-
* if interest was to be accrued on each market at the given timestamp
|
|
176
|
+
* if interest was to be accrued on each market at the given timestamp.
|
|
176
177
|
*/
|
|
177
178
|
getApy(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
178
179
|
if (this.totalAssets === 0n)
|
|
179
|
-
return
|
|
180
|
+
return 0;
|
|
180
181
|
return (this.allocations
|
|
181
182
|
.values()
|
|
182
183
|
.reduce((total, { position }) => total +
|
|
183
|
-
position.market.getAvgSupplyApy(timestamp) *
|
|
184
|
+
position.market.getAvgSupplyApy(timestamp) *
|
|
185
|
+
Number(position.supplyAssets), 0) / Number(this.totalAssets));
|
|
184
186
|
}
|
|
185
187
|
/**
|
|
186
188
|
* The MetaMorpho vault's experienced Annual Percentage Yield (APY)
|
|
187
189
|
* weighted-averaged over its market deposits, after deducting the performance fee,
|
|
188
|
-
* if interest was to be accrued on each market at the given timestamp
|
|
190
|
+
* if interest was to be accrued on each market at the given timestamp.
|
|
189
191
|
*/
|
|
190
192
|
getNetApy(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
191
|
-
return
|
|
193
|
+
return this.getApy(timestamp) * (1 - +(0, viem_1.formatEther)(this.fee));
|
|
192
194
|
}
|
|
193
195
|
getAllocationProportion(marketId) {
|
|
194
196
|
if (this.totalAssets === 0n)
|
package/lib/vault/index.d.ts
CHANGED
package/lib/vault/index.js
CHANGED
|
@@ -21,4 +21,3 @@ __exportStar(require("./VaultMarketConfig.js"), exports);
|
|
|
21
21
|
__exportStar(require("./VaultMarketPublicAllocatorConfig.js"), exports);
|
|
22
22
|
__exportStar(require("./VaultUser.js"), exports);
|
|
23
23
|
__exportStar(require("./Vault.js"), exports);
|
|
24
|
-
__exportStar(require("./v2"), 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
|
+
"version": "5.0.1",
|
|
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.23.0",
|
|
33
33
|
"vitest": "^3.0.5",
|
|
34
|
-
"@morpho-org/
|
|
35
|
-
"@morpho-org/
|
|
34
|
+
"@morpho-org/test": "^2.6.0",
|
|
35
|
+
"@morpho-org/morpho-ts": "^2.4.3"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"prepublish": "$npm_execpath build",
|
package/lib/utils.d.ts
DELETED
package/lib/utils.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.safeParseUnits = exports.safeParseNumber = void 0;
|
|
4
|
-
// Alternative to Number.toFixed that doesn't use scientific notation for excessively small or large numbers.
|
|
5
|
-
const toFixed = (x, decimals) => new Intl.NumberFormat("en-US", {
|
|
6
|
-
style: "decimal",
|
|
7
|
-
useGrouping: false,
|
|
8
|
-
maximumFractionDigits: decimals,
|
|
9
|
-
minimumFractionDigits: decimals,
|
|
10
|
-
}).format(x);
|
|
11
|
-
const safeParseNumber = (value, decimals = 18) => (0, exports.safeParseUnits)(toFixed(value, decimals), decimals);
|
|
12
|
-
exports.safeParseNumber = safeParseNumber;
|
|
13
|
-
const safeParseUnits = (strValue, decimals = 18) => {
|
|
14
|
-
if (!/[-+]?[0-9]*\.?[0-9]+/.test(strValue))
|
|
15
|
-
throw Error(`invalid number: ${strValue}`);
|
|
16
|
-
let [whole, dec = ""] = strValue.split(".");
|
|
17
|
-
dec = dec.slice(0, decimals);
|
|
18
|
-
return parseUnits([whole || "0", dec].filter((v) => v.length > 0).join("."), decimals);
|
|
19
|
-
};
|
|
20
|
-
exports.safeParseUnits = safeParseUnits;
|
|
21
|
-
/**
|
|
22
|
-
* Multiplies a string representation of a number by a given exponent of base 10 (10exponent).
|
|
23
|
-
*
|
|
24
|
-
* - Docs: https://viem.sh/docs/utilities/parseUnits
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* import { parseUnits } from 'viem'
|
|
28
|
-
*
|
|
29
|
-
* parseUnits('420', 9)
|
|
30
|
-
* // 420000000000n
|
|
31
|
-
*/
|
|
32
|
-
// TODO: get rid of this copy.
|
|
33
|
-
function parseUnits(value, decimals) {
|
|
34
|
-
let [integer, fraction = "0"] = value.split(".");
|
|
35
|
-
const negative = integer.startsWith("-");
|
|
36
|
-
if (negative)
|
|
37
|
-
integer = integer.slice(1);
|
|
38
|
-
// trim trailing zeros.
|
|
39
|
-
fraction = fraction.replace(/(0+)$/, "");
|
|
40
|
-
// round off if the fraction is larger than the number of decimals.
|
|
41
|
-
if (decimals === 0) {
|
|
42
|
-
if (Math.round(Number(`.${fraction}`)) === 1)
|
|
43
|
-
integer = `${BigInt(integer) + 1n}`;
|
|
44
|
-
fraction = "";
|
|
45
|
-
}
|
|
46
|
-
else if (fraction.length > decimals) {
|
|
47
|
-
const [left, unit, right] = [
|
|
48
|
-
fraction.slice(0, decimals - 1),
|
|
49
|
-
fraction.slice(decimals - 1, decimals),
|
|
50
|
-
fraction.slice(decimals),
|
|
51
|
-
];
|
|
52
|
-
const rounded = Math.round(Number(`${unit}.${right}`));
|
|
53
|
-
if (rounded > 9)
|
|
54
|
-
fraction = `${BigInt(left) + BigInt(1)}0`.padStart(left.length + 1, "0");
|
|
55
|
-
else
|
|
56
|
-
fraction = `${left}${rounded}`;
|
|
57
|
-
if (fraction.length > decimals) {
|
|
58
|
-
fraction = fraction.slice(1);
|
|
59
|
-
integer = `${BigInt(integer) + 1n}`;
|
|
60
|
-
}
|
|
61
|
-
fraction = fraction.slice(0, decimals);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
fraction = fraction.padEnd(decimals, "0");
|
|
65
|
-
}
|
|
66
|
-
return BigInt(`${negative ? "-" : ""}${integer}${fraction}`);
|
|
67
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
/**
|
|
9
|
-
* The total assets, *including* virtually accrued interest.
|
|
10
|
-
*/
|
|
11
|
-
totalAssets: bigint;
|
|
12
|
-
/**
|
|
13
|
-
* The total assets, *excluding* virtually accrued interest.
|
|
14
|
-
*/
|
|
15
|
-
_totalAssets: bigint;
|
|
16
|
-
/**
|
|
17
|
-
* The total supply of shares.
|
|
18
|
-
*/
|
|
19
|
-
totalSupply: bigint;
|
|
20
|
-
virtualShares: bigint;
|
|
21
|
-
maxRate: bigint;
|
|
22
|
-
lastUpdate: bigint;
|
|
23
|
-
adapters: Address[];
|
|
24
|
-
liquidityAdapter: Address;
|
|
25
|
-
performanceFee: bigint;
|
|
26
|
-
managementFee: bigint;
|
|
27
|
-
performanceFeeRecipient: Address;
|
|
28
|
-
managementFeeRecipient: Address;
|
|
29
|
-
}
|
|
30
|
-
export declare class VaultV2 extends WrappedToken implements IVaultV2 {
|
|
31
|
-
readonly asset: Address;
|
|
32
|
-
totalAssets: bigint;
|
|
33
|
-
_totalAssets: bigint;
|
|
34
|
-
totalSupply: bigint;
|
|
35
|
-
virtualShares: bigint;
|
|
36
|
-
maxRate: bigint;
|
|
37
|
-
lastUpdate: bigint;
|
|
38
|
-
adapters: Address[];
|
|
39
|
-
liquidityAdapter: Address;
|
|
40
|
-
performanceFee: bigint;
|
|
41
|
-
managementFee: bigint;
|
|
42
|
-
performanceFeeRecipient: Address;
|
|
43
|
-
managementFeeRecipient: Address;
|
|
44
|
-
constructor({ asset, totalAssets, _totalAssets, totalSupply, virtualShares, lastUpdate, adapters, maxRate, performanceFee, managementFee, liquidityAdapter, performanceFeeRecipient, managementFeeRecipient, ...config }: IVaultV2);
|
|
45
|
-
toAssets(shares: bigint): bigint;
|
|
46
|
-
toShares(assets: bigint): bigint;
|
|
47
|
-
protected _wrap(amount: bigint, rounding: RoundingDirection): bigint;
|
|
48
|
-
protected _unwrap(amount: bigint, rounding: RoundingDirection): bigint;
|
|
49
|
-
}
|
|
50
|
-
export interface IAccrualVaultV2 extends Omit<IVaultV2, "adapters"> {
|
|
51
|
-
}
|
|
52
|
-
export declare class AccrualVaultV2 extends VaultV2 implements IAccrualVaultV2 {
|
|
53
|
-
readonly accrualAdapters: IAccrualVaultV2Adapter[];
|
|
54
|
-
readonly assetBalance: bigint;
|
|
55
|
-
constructor(vault: IAccrualVaultV2, accrualAdapters: IAccrualVaultV2Adapter[], assetBalance: bigint);
|
|
56
|
-
/**
|
|
57
|
-
* Returns a new vault derived from this vault, whose interest has been accrued up to the given timestamp.
|
|
58
|
-
* @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the vault's `lastUpdate`.
|
|
59
|
-
*/
|
|
60
|
-
accrueInterest(timestamp: BigIntish): {
|
|
61
|
-
vault: AccrualVaultV2;
|
|
62
|
-
performanceFeeShares: bigint;
|
|
63
|
-
managementFeeShares: bigint;
|
|
64
|
-
};
|
|
65
|
-
}
|
package/lib/vault/v2/VaultV2.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccrualVaultV2 = exports.VaultV2 = void 0;
|
|
4
|
-
const errors_1 = require("../../errors");
|
|
5
|
-
const math_1 = require("../../math");
|
|
6
|
-
const token_1 = require("../../token");
|
|
7
|
-
class VaultV2 extends token_1.WrappedToken {
|
|
8
|
-
asset;
|
|
9
|
-
totalAssets;
|
|
10
|
-
_totalAssets;
|
|
11
|
-
totalSupply;
|
|
12
|
-
virtualShares;
|
|
13
|
-
maxRate;
|
|
14
|
-
lastUpdate;
|
|
15
|
-
adapters;
|
|
16
|
-
liquidityAdapter;
|
|
17
|
-
performanceFee;
|
|
18
|
-
managementFee;
|
|
19
|
-
performanceFeeRecipient;
|
|
20
|
-
managementFeeRecipient;
|
|
21
|
-
constructor({ asset, totalAssets, _totalAssets, totalSupply, virtualShares, lastUpdate, adapters, maxRate, performanceFee, managementFee, liquidityAdapter, performanceFeeRecipient, managementFeeRecipient, ...config }) {
|
|
22
|
-
super(config, asset);
|
|
23
|
-
this.asset = asset;
|
|
24
|
-
this.totalAssets = totalAssets;
|
|
25
|
-
this._totalAssets = _totalAssets;
|
|
26
|
-
this.totalSupply = totalSupply;
|
|
27
|
-
this.virtualShares = virtualShares;
|
|
28
|
-
this.maxRate = maxRate;
|
|
29
|
-
this.lastUpdate = lastUpdate;
|
|
30
|
-
this.adapters = adapters;
|
|
31
|
-
this.liquidityAdapter = liquidityAdapter;
|
|
32
|
-
this.performanceFee = performanceFee;
|
|
33
|
-
this.managementFee = managementFee;
|
|
34
|
-
this.performanceFeeRecipient = performanceFeeRecipient;
|
|
35
|
-
this.managementFeeRecipient = managementFeeRecipient;
|
|
36
|
-
}
|
|
37
|
-
toAssets(shares) {
|
|
38
|
-
return this._unwrap(shares, "Down");
|
|
39
|
-
}
|
|
40
|
-
toShares(assets) {
|
|
41
|
-
return this._wrap(assets, "Down");
|
|
42
|
-
}
|
|
43
|
-
_wrap(amount, rounding) {
|
|
44
|
-
return math_1.MathLib.mulDiv(amount, this.totalSupply + this.virtualShares, this.totalAssets + 1n, rounding);
|
|
45
|
-
}
|
|
46
|
-
_unwrap(amount, rounding) {
|
|
47
|
-
return math_1.MathLib.mulDiv(amount, this.totalAssets + 1n, this.totalSupply + this.virtualShares, rounding);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.VaultV2 = VaultV2;
|
|
51
|
-
class AccrualVaultV2 extends VaultV2 {
|
|
52
|
-
accrualAdapters;
|
|
53
|
-
assetBalance;
|
|
54
|
-
constructor(vault, accrualAdapters, assetBalance) {
|
|
55
|
-
super({ ...vault, adapters: accrualAdapters.map((a) => a.address) });
|
|
56
|
-
this.accrualAdapters = accrualAdapters;
|
|
57
|
-
this.assetBalance = assetBalance;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Returns a new vault derived from this vault, whose interest has been accrued up to the given timestamp.
|
|
61
|
-
* @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the vault's `lastUpdate`.
|
|
62
|
-
*/
|
|
63
|
-
accrueInterest(timestamp) {
|
|
64
|
-
const vault = new AccrualVaultV2(this, this.accrualAdapters, this.assetBalance);
|
|
65
|
-
timestamp = BigInt(timestamp);
|
|
66
|
-
const elapsed = timestamp - this.lastUpdate;
|
|
67
|
-
if (elapsed < 0n)
|
|
68
|
-
throw new errors_1.VaultV2Errors.InvalidInterestAccrual(this.address, timestamp, this.lastUpdate);
|
|
69
|
-
// Corresponds to the `firstTotalAssets == 0` onchain check.
|
|
70
|
-
if (elapsed === 0n)
|
|
71
|
-
return { vault, performanceFeeShares: 0n, managementFeeShares: 0n };
|
|
72
|
-
const realAssets = vault.accrualAdapters.reduce((curr, adapter) => curr + adapter.realAssets(timestamp), vault.assetBalance);
|
|
73
|
-
const maxTotalAssets = vault._totalAssets +
|
|
74
|
-
math_1.MathLib.wMulDown(vault._totalAssets * elapsed, vault.maxRate);
|
|
75
|
-
const newTotalAssets = math_1.MathLib.min(realAssets, maxTotalAssets);
|
|
76
|
-
const interest = math_1.MathLib.zeroFloorSub(newTotalAssets, vault._totalAssets);
|
|
77
|
-
const performanceFeeAssets = interest > 0n && vault.performanceFee > 0n
|
|
78
|
-
? math_1.MathLib.wMulDown(interest, vault.performanceFee)
|
|
79
|
-
: 0n;
|
|
80
|
-
const managementFeeAssets = elapsed > 0n && vault.managementFee > 0n
|
|
81
|
-
? math_1.MathLib.wMulDown(newTotalAssets * elapsed, vault.managementFee)
|
|
82
|
-
: 0n;
|
|
83
|
-
const newTotalAssetsWithoutFees = newTotalAssets - performanceFeeAssets - managementFeeAssets;
|
|
84
|
-
const performanceFeeShares = math_1.MathLib.mulDivDown(performanceFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
|
|
85
|
-
const managementFeeShares = math_1.MathLib.mulDivDown(managementFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
|
|
86
|
-
vault.totalAssets = newTotalAssets;
|
|
87
|
-
vault._totalAssets = newTotalAssets;
|
|
88
|
-
if (performanceFeeShares)
|
|
89
|
-
vault.totalSupply += performanceFeeShares;
|
|
90
|
-
if (managementFeeShares)
|
|
91
|
-
vault.totalSupply += managementFeeShares;
|
|
92
|
-
vault.lastUpdate = BigInt(timestamp);
|
|
93
|
-
return { vault, performanceFeeShares, managementFeeShares };
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.AccrualVaultV2 = AccrualVaultV2;
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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;
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
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;
|
package/lib/vault/v2/index.d.ts
DELETED
package/lib/vault/v2/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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);
|