@morpho-org/blue-sdk 5.2.0-next.1 → 5.2.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.js CHANGED
@@ -36,6 +36,9 @@ const _addressesRegistry = {
36
36
  adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
37
37
  publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D",
38
38
  metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24",
39
+ vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405",
40
+ morphoMarketV1AdapterFactory: "0xb049465969ac6355127cDf9E88deE63d25204d5D",
41
+ morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394",
39
42
  registryList: "0x3696c5eAe4a7Ffd04Ea163564571E9CD8Ed9364e",
40
43
  chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766",
41
44
  preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476",
@@ -72,8 +75,6 @@ const _addressesRegistry = {
72
75
  crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14",
73
76
  "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e",
74
77
  "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726",
75
- vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405",
76
- morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394",
77
78
  },
78
79
  [chain_js_1.ChainId.BaseMainnet]: {
79
80
  morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
@@ -89,6 +90,9 @@ const _addressesRegistry = {
89
90
  adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687",
90
91
  publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467",
91
92
  metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918",
93
+ vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857",
94
+ morphoMarketV1AdapterFactory: "0x133baC94306B99f6dAD85c381a5be851d8DD717c",
95
+ morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642",
92
96
  registryList: "0x5C2531Cbd2cf112Cf687da3Cd536708aDd7DB10a",
93
97
  chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d",
94
98
  preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef",
@@ -97,8 +101,6 @@ const _addressesRegistry = {
97
101
  usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
98
102
  verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b",
99
103
  testUsdc: "0xBC77067f829979812d795d516E523C4033b66409",
100
- vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857",
101
- morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642",
102
104
  },
103
105
  [chain_js_1.ChainId.PolygonMainnet]: {
104
106
  morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67",
@@ -114,6 +116,10 @@ const _addressesRegistry = {
114
116
  adaptiveCurveIrm: "0xe675A2161D4a6E2de2eeD70ac98EEBf257FBF0B0",
115
117
  publicAllocator: "0xfac15aff53ADd2ff80C2962127C434E8615Df0d3",
116
118
  metaMorphoFactory: "0xa9c87daB340631C34BB738625C70499e29ddDC98",
119
+ vaultV2Factory: "0xC11a53eE9B1eCc7a068D8e40F8F17926584F97Cf",
120
+ morphoMarketV1AdapterFactory: "0xD1A0C86F28ecD1657Ad06415c2B230cC89D9b6dd",
121
+ morphoVaultV1AdapterFactory: "0xEb174FEA51Da241eB3B516959B216e013de2888a",
122
+ registryList: "0xb70a43821d2707fA9d0EDd9511CC499F468Ba564",
117
123
  chainlinkOracleFactory: "0x1ff7895Eb842794c5d07C4c547b6730e61295215",
118
124
  preLiquidationFactory: "0xeDadDe37D76c72b98725614d0b41C20Fe612d304",
119
125
  wNative: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
@@ -133,6 +139,10 @@ const _addressesRegistry = {
133
139
  adaptiveCurveIrm: "0x66F30587FB8D4206918deb78ecA7d5eBbafD06DA",
134
140
  publicAllocator: "0x769583Af5e9D03589F159EbEC31Cc2c23E8C355E",
135
141
  metaMorphoFactory: "0x878988f5f561081deEa117717052164ea1Ef0c82",
142
+ vaultV2Factory: "0x6b46fa3cc9EBF8aB230aBAc664E37F2966Bf7971",
143
+ morphoMarketV1AdapterFactory: "0x96456Bf888D4de607Bf3ca0b3C8e4DF9b0d0Ad47",
144
+ morphoVaultV1AdapterFactory: "0xD8Fc8a85779551e78B516da9f74061cb3b086793",
145
+ registryList: "0xc00eb3c7aD1aE986A7f05F5A9d71aCa39c763C65",
136
146
  chainlinkOracleFactory: "0x98Ce5D183DC0c176f54D37162F87e7eD7f2E41b5",
137
147
  preLiquidationFactory: "0x635c31B5DF1F7EFbCbC07E302335Ef4230758e3d",
138
148
  wNative: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
@@ -150,6 +160,10 @@ const _addressesRegistry = {
150
160
  adaptiveCurveIrm: "0x8cD70A8F399428456b29546BC5dBe10ab6a06ef6",
151
161
  publicAllocator: "0x0d68a97324E602E02799CD83B42D337207B40658",
152
162
  metaMorphoFactory: "0x3Bb6A6A0Bc85b367EFE0A5bAc81c5E52C892839a",
163
+ vaultV2Factory: "0x6128b680b277Bf4Df80DFE9D8c55A498660870ef",
164
+ morphoMarketV1AdapterFactory: "0x65956d5Ba4974983ecCe111612FC0A0c22650A11",
165
+ morphoVaultV1AdapterFactory: "0xEe9F7C64dD827ED7b5CAA2272936366FAca00CF3",
166
+ registryList: "0xD1346be260cd22Eab9E6163010b0D5CbfAAAD32b",
153
167
  chainlinkOracleFactory: "0x1ec408D4131686f727F3Fd6245CF85Bc5c9DAD70",
154
168
  preLiquidationFactory: "0x3d05C01EE8e97361b9E19D172128255eaE5F98B9",
155
169
  wNative: "0x4200000000000000000000000000000000000006",
@@ -165,6 +179,10 @@ const _addressesRegistry = {
165
179
  adaptiveCurveIrm: "0x34E99D604751a72cF8d0CFDf87069292d82De472",
166
180
  publicAllocator: "0xef9889B4e443DEd35FA0Bd060f2104Cca94e6A43",
167
181
  metaMorphoFactory: "0x4DBB3a642a2146d5413750Cca3647086D9ba5F12",
182
+ vaultV2Factory: "0x6846EA318B6B987Ee6b28eBFd87c3409F1d13108",
183
+ morphoMarketV1AdapterFactory: "0xAf93F2d8508053432659d509b0210fdF1472493D",
184
+ morphoVaultV1AdapterFactory: "0xbF7DEa3756668C7E396C655D646C039826ba8416",
185
+ registryList: "0x06A47994B4890dcA28C076969cedE1151d86EFCF",
168
186
  chainlinkOracleFactory: "0xd706690BA1Fe26b70c4AD89e60ff62cEB3A2eD02",
169
187
  preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695",
170
188
  wNative: "0x4200000000000000000000000000000000000006",
@@ -224,6 +242,10 @@ const _addressesRegistry = {
224
242
  adaptiveCurveIrm: "0x9a6061d51743B31D2c3Be75D83781Fa423f53F0E",
225
243
  publicAllocator: "0xB0c9a107fA17c779B3378210A7a593e88938C7C9",
226
244
  metaMorphoFactory: "0xe9EdE3929F43a7062a007C3e8652e4ACa610Bdc0",
245
+ vaultV2Factory: "0xC9b34c108014B44e5a189A830e7e04c56704a0c9",
246
+ morphoMarketV1AdapterFactory: "0x117b92Ab1C025B175ED38a0CDe5A067a745224a0",
247
+ morphoVaultV1AdapterFactory: "0xf1Ab9e885C0faa0cbCEd407498BBA895537aD754",
248
+ registryList: "0xB9130D2A87d7c60ED7E7e4b25bdA6e3E6841becB",
227
249
  chainlinkOracleFactory: "0x43269546e1D586a1f7200a0AC07e26f9631f7539",
228
250
  preLiquidationFactory: "0xb04e4D3D59Ee47Ca9BA192707AF13A7D02969911",
229
251
  wNative: "0x4200000000000000000000000000000000000006",
@@ -321,6 +343,10 @@ const _addressesRegistry = {
321
343
  adaptiveCurveIrm: "0x4F708C0ae7deD3d74736594C2109C2E3c065B428",
322
344
  publicAllocator: "0x39EB6Da5e88194C82B13491Df2e8B3E213eD2412",
323
345
  metaMorphoFactory: "0x1c8De6889acee12257899BFeAa2b7e534de32E16",
346
+ vaultV2Factory: "0xFcb8b57E56787bB29e130Fca67f3c5a1232975D1",
347
+ morphoMarketV1AdapterFactory: "0x2e6BE3a3A27fb45c6AbA2D1833eeA48E8788538e",
348
+ morphoVaultV1AdapterFactory: "0xc8D22B1adD3D176600E9952e7876e9249254cAAF",
349
+ registryList: "0xA9132a09838fD20304dF2B2892679d06A4cc6371",
324
350
  chainlinkOracleFactory: "0x7D047fB910Bc187C18C81a69E30Fa164f8c536eC",
325
351
  preLiquidationFactory: "0x678EB53A3bB79111263f47B84989d16D81c36D85",
326
352
  wNative: "0xEE7D8BCFb72bC1880D0Cf19822eB0A2e6577aB62",
@@ -376,6 +402,7 @@ const _addressesRegistry = {
376
402
  publicAllocator: "0x517505be22D9068687334e69ae7a02fC77edf4Fc",
377
403
  metaMorphoFactory: "0xec051b19d654C48c357dC974376DeB6272f24e53",
378
404
  vaultV2Factory: "0xD7217E5687FF1071356C780b5fe4803D9D967da7",
405
+ morphoMarketV1AdapterFactory: "0xc6b8B565C715134b0Ca3D6fa3D29B25759D0b9e2",
379
406
  morphoVaultV1AdapterFactory: "0xdf5202e29654e02011611A086f15477880580CAc",
380
407
  registryList: "0x857B55cEb57dA0C2A83EE08a8dB529B931089aee",
381
408
  chainlinkOracleFactory: "0xeb476f124FaD625178759d13557A72394A6f9aF5",
@@ -386,6 +413,7 @@ const _addressesRegistry = {
386
413
  },
387
414
  [chain_js_1.ChainId.SeiMainnet]: {
388
415
  morpho: "0xc9cDAc20FCeAAF616f7EB0bb6Cd2c69dcfa9094c",
416
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
389
417
  bundler3: {
390
418
  bundler3: "0xF9457356F18A3349Bb317Ac144c3Bcc62e5761aD",
391
419
  generalAdapter1: "0x02e0e71e145f254820B9D89c9E6068f08256F601",
@@ -396,6 +424,7 @@ const _addressesRegistry = {
396
424
  chainlinkOracleFactory: "0x4bD68c2FF3274207EC07ED281C915758b6F23F07",
397
425
  preLiquidationFactory: "0x65eD61058cEB4895B7d62437BaCEA39b04f6D27B",
398
426
  wNative: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7",
427
+ usdc: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392",
399
428
  },
400
429
  };
401
430
  const _deployments = {
@@ -418,11 +447,12 @@ const _deployments = {
418
447
  adaptiveCurveIrm: 18883124n,
419
448
  publicAllocator: 19375099n,
420
449
  metaMorphoFactory: 21439510n,
450
+ vaultV2Factory: 23375073n,
451
+ morphoMarketV1AdapterFactory: 23375073n,
452
+ morphoVaultV1AdapterFactory: 23375073n,
421
453
  registryList: 23375119n,
422
454
  chainlinkOracleFactory: 19375066n,
423
455
  preLiquidationFactory: 21414664n,
424
- vaultV2Factory: 23375073n,
425
- morphoVaultV1AdapterFactory: 23375073n,
426
456
  },
427
457
  [chain_js_1.ChainId.BaseMainnet]: {
428
458
  morpho: 13977148n,
@@ -438,11 +468,12 @@ const _deployments = {
438
468
  adaptiveCurveIrm: 13977152n,
439
469
  publicAllocator: 13979545n,
440
470
  metaMorphoFactory: 23928808n,
471
+ vaultV2Factory: 35615206n,
472
+ morphoMarketV1AdapterFactory: 35615206n,
473
+ morphoVaultV1AdapterFactory: 35615206n,
441
474
  registryList: 35615358n,
442
475
  chainlinkOracleFactory: 13978286n,
443
476
  preLiquidationFactory: 23779056n,
444
- vaultV2Factory: 35615206n,
445
- morphoVaultV1AdapterFactory: 35615206n,
446
477
  },
447
478
  [chain_js_1.ChainId.PolygonMainnet]: {
448
479
  morpho: 66931042n,
@@ -458,6 +489,10 @@ const _deployments = {
458
489
  adaptiveCurveIrm: 66931042n,
459
490
  publicAllocator: 66931042n,
460
491
  metaMorphoFactory: 66931042n,
492
+ vaultV2Factory: 77371907n,
493
+ morphoMarketV1AdapterFactory: 77371907n,
494
+ morphoVaultV1AdapterFactory: 77371907n,
495
+ registryList: 77372020n,
461
496
  chainlinkOracleFactory: 66931042n,
462
497
  preLiquidationFactory: 68074185n,
463
498
  },
@@ -474,6 +509,10 @@ const _deployments = {
474
509
  adaptiveCurveIrm: 296446593n,
475
510
  publicAllocator: 296446593n,
476
511
  metaMorphoFactory: 296447195n,
512
+ vaultV2Factory: 387016724n,
513
+ morphoMarketV1AdapterFactory: 387016724n,
514
+ morphoVaultV1AdapterFactory: 387016724n,
515
+ registryList: 387017701n,
477
516
  chainlinkOracleFactory: 296447195n,
478
517
  preLiquidationFactory: 307326238n,
479
518
  },
@@ -488,6 +527,10 @@ const _deployments = {
488
527
  adaptiveCurveIrm: 130770075n,
489
528
  publicAllocator: 130770075n,
490
529
  metaMorphoFactory: 130770189n,
530
+ vaultV2Factory: 142122059n,
531
+ morphoMarketV1AdapterFactory: 142122059n,
532
+ morphoVaultV1AdapterFactory: 142122059n,
533
+ registryList: 142122170n,
491
534
  chainlinkOracleFactory: 130770189n,
492
535
  preLiquidationFactory: 132139369n,
493
536
  },
@@ -500,6 +543,10 @@ const _deployments = {
500
543
  adaptiveCurveIrm: 9025669n,
501
544
  publicAllocator: 9025669n,
502
545
  metaMorphoFactory: 9025733n,
546
+ vaultV2Factory: 20253005n,
547
+ morphoMarketV1AdapterFactory: 20253005n,
548
+ morphoVaultV1AdapterFactory: 20253005n,
549
+ registryList: 20253132n,
503
550
  chainlinkOracleFactory: 9025733n,
504
551
  preLiquidationFactory: 10273494n,
505
552
  },
@@ -551,6 +598,10 @@ const _deployments = {
551
598
  adaptiveCurveIrm: 9139027n,
552
599
  publicAllocator: 9139027n,
553
600
  metaMorphoFactory: 9316789n,
601
+ vaultV2Factory: 29092109n,
602
+ morphoMarketV1AdapterFactory: 29092109n,
603
+ morphoVaultV1AdapterFactory: 29092109n,
604
+ registryList: 29092328n,
554
605
  chainlinkOracleFactory: 9316789n,
555
606
  preLiquidationFactory: 9381237n,
556
607
  },
@@ -635,6 +686,10 @@ const _deployments = {
635
686
  adaptiveCurveIrm: 2741069n,
636
687
  publicAllocator: 2741069n,
637
688
  metaMorphoFactory: 2741420n,
689
+ vaultV2Factory: 13096629n,
690
+ morphoMarketV1AdapterFactory: 13096629n,
691
+ morphoVaultV1AdapterFactory: 13096629n,
692
+ registryList: 13096853n,
638
693
  chainlinkOracleFactory: 2741420n,
639
694
  preLiquidationFactory: 2741993n,
640
695
  },
@@ -684,6 +739,7 @@ const _deployments = {
684
739
  publicAllocator: 1988429n,
685
740
  metaMorphoFactory: 1988677n,
686
741
  vaultV2Factory: 14188393n,
742
+ morphoMarketV1AdapterFactory: 14188393n,
687
743
  morphoVaultV1AdapterFactory: 14188393n,
688
744
  registryList: 14188698n,
689
745
  chainlinkOracleFactory: 1988677n,
@@ -695,11 +751,13 @@ const _deployments = {
695
751
  bundler3: 168897284n,
696
752
  generalAdapter1: 168897284n,
697
753
  },
754
+ permit2: 118721449n,
698
755
  adaptiveCurveIrm: 166036723n,
699
756
  publicAllocator: 166036723n,
700
757
  metaMorphoFactory: 168896078n,
701
758
  chainlinkOracleFactory: 168896078n,
702
759
  preLiquidationFactory: 168897284n,
760
+ usdc: 154131168n,
703
761
  },
704
762
  };
705
763
  const getChainAddresses = (chainId) => {
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,18 +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
- class UnsupportedLiquidityAdapter extends Error {
80
- readonly address: Address;
81
- constructor(address: Address);
82
- }
83
- }
84
68
  export interface ErrorClass<E extends Error> {
85
69
  new (...args: any[]): E;
86
70
  }
package/lib/errors.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VaultV2Errors = exports.BlueErrors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
3
+ exports.BlueErrors = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
4
4
  exports._try = _try;
5
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,29 +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
- class UnsupportedLiquidityAdapter extends Error {
159
- address;
160
- constructor(address) {
161
- super(`unsupported liquidity adapter "${address}"`);
162
- this.address = address;
163
- }
164
- }
165
- VaultV2Errors.UnsupportedLiquidityAdapter = UnsupportedLiquidityAdapter;
166
- })(VaultV2Errors || (exports.VaultV2Errors = VaultV2Errors = {}));
167
136
  function _try(accessor, ...errorClasses) {
168
137
  const maybeCatchError = (error) => {
169
138
  if (errorClasses.length === 0 ||
package/lib/index.d.ts CHANGED
@@ -11,4 +11,3 @@ export * from "./holding/index.js";
11
11
  export * from "./position/index.js";
12
12
  export * from "./vault/index.js";
13
13
  export * from "./preLiquidation.js";
14
- export * from "./utils.js";
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);
@@ -1,7 +1,17 @@
1
1
  import { type RoundingDirection } from "../math/index.js";
2
2
  import type { BigIntish } from "../types.js";
3
- import { type CapacityLimit } from "../utils.js";
4
3
  import { type IMarketParams, MarketParams } from "./MarketParams.js";
4
+ export declare enum CapacityLimitReason {
5
+ liquidity = "Liquidity",
6
+ balance = "Balance",
7
+ position = "Position",
8
+ collateral = "Collateral",
9
+ cap = "Cap"
10
+ }
11
+ export interface CapacityLimit {
12
+ value: bigint;
13
+ limiter: CapacityLimitReason;
14
+ }
5
15
  export interface MaxBorrowOptions {
6
16
  maxLtv?: bigint;
7
17
  }
@@ -1,12 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Market = void 0;
3
+ 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 utils_js_1 = require("../utils.js");
8
7
  const MarketParams_js_1 = require("./MarketParams.js");
9
8
  const MarketUtils_js_1 = require("./MarketUtils.js");
9
+ var CapacityLimitReason;
10
+ (function (CapacityLimitReason) {
11
+ CapacityLimitReason["liquidity"] = "Liquidity";
12
+ CapacityLimitReason["balance"] = "Balance";
13
+ CapacityLimitReason["position"] = "Position";
14
+ CapacityLimitReason["collateral"] = "Collateral";
15
+ CapacityLimitReason["cap"] = "Cap";
16
+ })(CapacityLimitReason || (exports.CapacityLimitReason = CapacityLimitReason = {}));
10
17
  /**
11
18
  * Represents a lending market on Morpho Blue.
12
19
  */
@@ -490,11 +497,11 @@ class Market {
490
497
  if (maxBorrowableAssets > liquidity)
491
498
  return {
492
499
  value: liquidity,
493
- limiter: utils_js_1.CapacityLimitReason.liquidity,
500
+ limiter: CapacityLimitReason.liquidity,
494
501
  };
495
502
  return {
496
503
  value: maxBorrowableAssets,
497
- limiter: utils_js_1.CapacityLimitReason.collateral,
504
+ limiter: CapacityLimitReason.collateral,
498
505
  };
499
506
  }
500
507
  /**
@@ -507,11 +514,11 @@ class Market {
507
514
  if (borrowAssets > loanTokenBalance)
508
515
  return {
509
516
  value: loanTokenBalance,
510
- limiter: utils_js_1.CapacityLimitReason.balance,
517
+ limiter: CapacityLimitReason.balance,
511
518
  };
512
519
  return {
513
520
  value: borrowAssets,
514
- limiter: utils_js_1.CapacityLimitReason.position,
521
+ limiter: CapacityLimitReason.position,
515
522
  };
516
523
  }
517
524
  /**
@@ -525,11 +532,11 @@ class Market {
525
532
  if (supplyAssets > liquidity)
526
533
  return {
527
534
  value: liquidity,
528
- limiter: utils_js_1.CapacityLimitReason.liquidity,
535
+ limiter: CapacityLimitReason.liquidity,
529
536
  };
530
537
  return {
531
538
  value: supplyAssets,
532
- limiter: utils_js_1.CapacityLimitReason.position,
539
+ limiter: CapacityLimitReason.position,
533
540
  };
534
541
  }
535
542
  /**
@@ -545,11 +552,11 @@ class Market {
545
552
  if (position.collateral > withdrawableCollateral)
546
553
  return {
547
554
  value: withdrawableCollateral,
548
- limiter: utils_js_1.CapacityLimitReason.collateral,
555
+ limiter: CapacityLimitReason.collateral,
549
556
  };
550
557
  return {
551
558
  value: position.collateral,
552
- limiter: utils_js_1.CapacityLimitReason.position,
559
+ limiter: CapacityLimitReason.position,
553
560
  };
554
561
  }
555
562
  /**
@@ -563,14 +570,14 @@ class Market {
563
570
  return {
564
571
  supply: {
565
572
  value: loanTokenBalance,
566
- limiter: utils_js_1.CapacityLimitReason.balance,
573
+ limiter: CapacityLimitReason.balance,
567
574
  },
568
575
  withdraw: this.getWithdrawCapacityLimit(position),
569
576
  borrow: this.getBorrowCapacityLimit(position, options?.borrow),
570
577
  repay: this.getRepayCapacityLimit(position.borrowShares, loanTokenBalance),
571
578
  supplyCollateral: {
572
579
  value: collateralTokenBalance,
573
- limiter: utils_js_1.CapacityLimitReason.balance,
580
+ limiter: CapacityLimitReason.balance,
574
581
  },
575
582
  withdrawCollateral: this.getWithdrawCollateralCapacityLimit(position, options?.withdrawCollateral),
576
583
  };
@@ -109,7 +109,7 @@ export declare class AccrualPosition extends Position implements IAccrualPositio
109
109
  * Returns the maximum amount of loan assets that can be withdrawn given a certain supply position
110
110
  * and a balance of loan assets, and the reason for the limit.
111
111
  */
112
- get withdrawCapacityLimit(): import("../utils.js").CapacityLimit;
112
+ get withdrawCapacityLimit(): import("../market/Market.js").CapacityLimit;
113
113
  /**
114
114
  * Returns a new position derived from this position, whose interest has been accrued up to the given timestamp.
115
115
  * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the market's `lastUpdate`.
@@ -137,9 +137,9 @@ export declare class AccrualPosition extends Position implements IAccrualPositio
137
137
  assets: bigint;
138
138
  shares: bigint;
139
139
  };
140
- getBorrowCapacityLimit(options?: MaxBorrowOptions): import("../utils.js").CapacityLimit | undefined;
141
- getWithdrawCollateralCapacityLimit(options?: MaxWithdrawCollateralOptions): import("../utils.js").CapacityLimit | undefined;
142
- getRepayCapacityLimit(loanTokenBalance: bigint): import("../utils.js").CapacityLimit;
140
+ getBorrowCapacityLimit(options?: MaxBorrowOptions): import("../market/Market.js").CapacityLimit | undefined;
141
+ getWithdrawCollateralCapacityLimit(options?: MaxWithdrawCollateralOptions): import("../market/Market.js").CapacityLimit | undefined;
142
+ getRepayCapacityLimit(loanTokenBalance: bigint): import("../market/Market.js").CapacityLimit;
143
143
  getMaxCapacities(loanTokenBalance: bigint, collateralTokenBalance: bigint, options?: {
144
144
  borrow?: MaxBorrowOptions;
145
145
  withdrawCollateral?: MaxWithdrawCollateralOptions;
@@ -4,7 +4,6 @@ exports.AccrualPosition = exports.Position = void 0;
4
4
  const errors_js_1 = require("../errors.js");
5
5
  const index_js_1 = require("../market/index.js");
6
6
  const MathLib_js_1 = require("../math/MathLib.js");
7
- const utils_js_1 = require("../utils.js");
8
7
  class Position {
9
8
  /**
10
9
  * The user holding this position.
@@ -226,14 +225,14 @@ class AccrualPosition extends Position {
226
225
  return {
227
226
  supply: {
228
227
  value: loanTokenBalance,
229
- limiter: utils_js_1.CapacityLimitReason.balance,
228
+ limiter: index_js_1.CapacityLimitReason.balance,
230
229
  },
231
230
  withdraw: this.withdrawCapacityLimit,
232
231
  borrow: this.getBorrowCapacityLimit(options?.borrow),
233
232
  repay: this.getRepayCapacityLimit(loanTokenBalance),
234
233
  supplyCollateral: {
235
234
  value: collateralTokenBalance,
236
- limiter: utils_js_1.CapacityLimitReason.balance,
235
+ limiter: index_js_1.CapacityLimitReason.balance,
237
236
  },
238
237
  withdrawCollateral: this.getWithdrawCollateralCapacityLimit(options?.withdrawCollateral),
239
238
  };
@@ -1,5 +1,5 @@
1
1
  import type { RoundingDirection } from "../math/index.js";
2
- import type { Address, BigIntish } from "../types.js";
2
+ import type { Address } from "../types.js";
3
3
  import type { IVaultConfig } from "../vault/VaultConfig.js";
4
4
  import { WrappedToken } from "./WrappedToken.js";
5
5
  export interface IVaultToken {
@@ -18,6 +18,6 @@ export declare class VaultToken extends WrappedToken implements IVaultToken {
18
18
  */
19
19
  totalAssets: bigint;
20
20
  constructor(config: IVaultConfig, { totalAssets, totalSupply }: IVaultToken);
21
- protected _wrap(amount: BigIntish, rounding: RoundingDirection): bigint;
22
- protected _unwrap(amount: BigIntish, rounding: RoundingDirection): bigint;
21
+ protected _wrap(amount: bigint, rounding: RoundingDirection): bigint;
22
+ protected _unwrap(amount: bigint, rounding: RoundingDirection): bigint;
23
23
  }
@@ -1,7 +1,7 @@
1
+ import { type CapacityLimit } from "../market/index.js";
1
2
  import { type RoundingDirection } from "../math/index.js";
2
3
  import { VaultToken } from "../token/index.js";
3
4
  import type { Address, BigIntish, MarketId } from "../types.js";
4
- import { type CapacityLimit } from "../utils.js";
5
5
  import type { IVaultConfig } from "./VaultConfig.js";
6
6
  import { type IVaultMarketAllocation, VaultMarketAllocation } from "./VaultMarketAllocation.js";
7
7
  export interface Pending<T> {
@@ -116,8 +116,8 @@ export declare class Vault extends VaultToken implements IVault {
116
116
  * The amount of interest in assets accrued since the last interaction with the vault.
117
117
  */
118
118
  get totalInterest(): bigint;
119
- toAssets(shares: BigIntish, rounding?: RoundingDirection): bigint;
120
- toShares(assets: BigIntish, rounding?: RoundingDirection): bigint;
119
+ toAssets(shares: bigint, rounding?: RoundingDirection): bigint;
120
+ toShares(assets: bigint, rounding?: RoundingDirection): bigint;
121
121
  }
122
122
  export interface CollateralAllocation {
123
123
  address: Address;
@@ -178,28 +178,8 @@ export declare class AccrualVault extends Vault implements IAccrualVault {
178
178
  */
179
179
  getNetApy(timestamp?: BigIntish): number;
180
180
  getAllocationProportion(marketId: MarketId): bigint;
181
- /**
182
- * Returns the deposit capacity limit of a given amount of assets on the vault.
183
- * @param assets The maximum amount of assets to deposit.
184
- * @deprecated Use `maxDeposit` instead.
185
- */
186
181
  getDepositCapacityLimit(assets: bigint): CapacityLimit;
187
- /**
188
- * Returns the withdraw capacity limit corresponding to a given amount of shares of the vault.
189
- * @param shares The maximum amount of shares to redeem.
190
- * @deprecated Use `maxWithdraw` instead.
191
- */
192
182
  getWithdrawCapacityLimit(shares: bigint): CapacityLimit;
193
- /**
194
- * Returns the maximum amount of assets that can be deposited to the vault.
195
- * @param assets The maximum amount of assets to deposit.
196
- */
197
- maxDeposit(assets: BigIntish): CapacityLimit;
198
- /**
199
- * Returns the maximum amount of assets that can be withdrawn from the vault.
200
- * @param shares The maximum amount of shares to redeem.
201
- */
202
- maxWithdraw(shares: BigIntish): CapacityLimit;
203
183
  /**
204
184
  * Returns a new vault derived from this vault, whose interest has been accrued up to the given timestamp.
205
185
  * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to each of the vault's market's `lastUpdate`.
@@ -5,7 +5,6 @@ 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 utils_js_1 = require("../utils.js");
9
8
  const VaultMarketAllocation_js_1 = require("./VaultMarketAllocation.js");
10
9
  class Vault extends index_js_3.VaultToken {
11
10
  /**
@@ -209,28 +208,7 @@ class AccrualVault extends Vault {
209
208
  return 0n;
210
209
  return index_js_2.MathLib.wDivDown(allocation.position.supplyAssets, this.totalAssets);
211
210
  }
212
- /**
213
- * Returns the deposit capacity limit of a given amount of assets on the vault.
214
- * @param assets The maximum amount of assets to deposit.
215
- * @deprecated Use `maxDeposit` instead.
216
- */
217
211
  getDepositCapacityLimit(assets) {
218
- return this.maxDeposit(assets);
219
- }
220
- /**
221
- * Returns the withdraw capacity limit corresponding to a given amount of shares of the vault.
222
- * @param shares The maximum amount of shares to redeem.
223
- * @deprecated Use `maxWithdraw` instead.
224
- */
225
- getWithdrawCapacityLimit(shares) {
226
- return this.maxWithdraw(shares);
227
- }
228
- /**
229
- * Returns the maximum amount of assets that can be deposited to the vault.
230
- * @param assets The maximum amount of assets to deposit.
231
- */
232
- maxDeposit(assets) {
233
- assets = BigInt(assets);
234
212
  const suppliable = this.allocations
235
213
  .values()
236
214
  .reduce((total, { config: { cap }, position: { marketId, supplyAssets } }) => index_js_2.MathLib.min(total +
@@ -240,28 +218,24 @@ class AccrualVault extends Vault {
240
218
  if (assets > suppliable)
241
219
  return {
242
220
  value: suppliable,
243
- limiter: utils_js_1.CapacityLimitReason.cap,
221
+ limiter: index_js_1.CapacityLimitReason.cap,
244
222
  };
245
223
  return {
246
224
  value: assets,
247
- limiter: utils_js_1.CapacityLimitReason.balance,
225
+ limiter: index_js_1.CapacityLimitReason.balance,
248
226
  };
249
227
  }
250
- /**
251
- * Returns the maximum amount of assets that can be withdrawn from the vault.
252
- * @param shares The maximum amount of shares to redeem.
253
- */
254
- maxWithdraw(shares) {
228
+ getWithdrawCapacityLimit(shares) {
255
229
  const assets = this.toAssets(shares);
256
230
  const { liquidity } = this;
257
231
  if (assets > liquidity)
258
232
  return {
259
233
  value: liquidity,
260
- limiter: utils_js_1.CapacityLimitReason.liquidity,
234
+ limiter: index_js_1.CapacityLimitReason.liquidity,
261
235
  };
262
236
  return {
263
237
  value: assets,
264
- limiter: utils_js_1.CapacityLimitReason.balance,
238
+ limiter: index_js_1.CapacityLimitReason.balance,
265
239
  };
266
240
  }
267
241
  /**
@@ -5,4 +5,3 @@ export * from "./VaultMarketConfig.js";
5
5
  export * from "./VaultMarketPublicAllocatorConfig.js";
6
6
  export * from "./VaultUser.js";
7
7
  export * from "./Vault.js";
8
- export * from "./v2";
@@ -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": "5.2.0-next.1",
4
+ "version": "5.2.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.7.2",
32
- "viem": "^2.33.3",
32
+ "viem": "^2.23.0",
33
33
  "vitest": "^3.0.5",
34
34
  "@morpho-org/morpho-ts": "^2.4.3",
35
35
  "@morpho-org/test": "^2.6.0"