@morpho-org/blue-sdk 5.16.0 → 5.18.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.
Files changed (184) hide show
  1. package/lib/{addresses.d.ts → cjs/addresses.d.ts} +12 -0
  2. package/lib/{addresses.js → cjs/addresses.js} +6 -0
  3. package/lib/cjs/package.json +1 -0
  4. package/lib/{position → cjs/position}/PreLiquidationPosition.d.ts +3 -3
  5. package/lib/{position → cjs/position}/PreLiquidationPosition.js +16 -16
  6. package/lib/{preLiquidation.d.ts → cjs/preLiquidation.d.ts} +1 -1
  7. package/lib/{preLiquidation.js → cjs/preLiquidation.js} +2 -2
  8. package/lib/{vault → cjs/vault}/index.d.ts +1 -1
  9. package/lib/{vault → cjs/vault}/index.js +1 -1
  10. package/lib/{vault → cjs/vault}/v2/VaultV2.d.ts +5 -5
  11. package/lib/{vault → cjs/vault}/v2/VaultV2.js +25 -25
  12. package/lib/{vault → cjs/vault}/v2/VaultV2Adapter.d.ts +2 -2
  13. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoMarketV1Adapter.d.ts +7 -7
  14. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoMarketV1Adapter.js +9 -9
  15. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +6 -6
  16. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoMarketV1AdapterV2.js +8 -8
  17. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoVaultV1Adapter.d.ts +6 -6
  18. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoVaultV1Adapter.js +2 -2
  19. package/lib/esm/addresses.d.ts +2243 -0
  20. package/lib/esm/addresses.js +1315 -0
  21. package/lib/esm/chain.d.ts +405 -0
  22. package/lib/esm/chain.js +276 -0
  23. package/lib/esm/constants.d.ts +20 -0
  24. package/lib/esm/constants.js +21 -0
  25. package/lib/esm/errors.d.ts +101 -0
  26. package/lib/esm/errors.js +192 -0
  27. package/lib/esm/holding/AssetBalances.d.ts +48 -0
  28. package/lib/esm/holding/AssetBalances.js +38 -0
  29. package/lib/esm/holding/Holding.d.ts +63 -0
  30. package/lib/esm/holding/Holding.js +63 -0
  31. package/lib/esm/holding/index.d.ts +2 -0
  32. package/lib/esm/holding/index.js +2 -0
  33. package/lib/esm/index.d.ts +14 -0
  34. package/lib/esm/index.js +14 -0
  35. package/lib/esm/market/Market.d.ts +424 -0
  36. package/lib/esm/market/Market.js +576 -0
  37. package/lib/esm/market/MarketParams.d.ts +74 -0
  38. package/lib/esm/market/MarketParams.js +91 -0
  39. package/lib/esm/market/MarketUtils.d.ts +273 -0
  40. package/lib/esm/market/MarketUtils.js +323 -0
  41. package/lib/esm/market/index.d.ts +3 -0
  42. package/lib/esm/market/index.js +3 -0
  43. package/lib/esm/math/AdaptiveCurveIrmLib.d.ts +40 -0
  44. package/lib/esm/math/AdaptiveCurveIrmLib.js +133 -0
  45. package/lib/esm/math/MathLib.d.ts +102 -0
  46. package/lib/esm/math/MathLib.js +168 -0
  47. package/lib/esm/math/SharesMath.d.ts +12 -0
  48. package/lib/esm/math/SharesMath.js +18 -0
  49. package/lib/esm/math/index.d.ts +3 -0
  50. package/lib/esm/math/index.js +3 -0
  51. package/lib/esm/package.json +1 -0
  52. package/lib/esm/position/Position.d.ts +147 -0
  53. package/lib/esm/position/Position.js +237 -0
  54. package/lib/esm/position/PreLiquidationPosition.d.ts +60 -0
  55. package/lib/esm/position/PreLiquidationPosition.js +97 -0
  56. package/lib/esm/position/index.d.ts +2 -0
  57. package/lib/esm/position/index.js +2 -0
  58. package/lib/esm/preLiquidation.d.ts +15 -0
  59. package/lib/esm/preLiquidation.js +91 -0
  60. package/lib/esm/token/ConstantWrappedToken.d.ts +17 -0
  61. package/lib/esm/token/ConstantWrappedToken.js +30 -0
  62. package/lib/esm/token/Eip5267Domain.d.ts +55 -0
  63. package/lib/esm/token/Eip5267Domain.js +66 -0
  64. package/lib/esm/token/ExchangeRateWrappedToken.d.ts +11 -0
  65. package/lib/esm/token/ExchangeRateWrappedToken.js +17 -0
  66. package/lib/esm/token/Token.d.ts +52 -0
  67. package/lib/esm/token/Token.js +62 -0
  68. package/lib/esm/token/VaultToken.d.ts +23 -0
  69. package/lib/esm/token/VaultToken.js +27 -0
  70. package/lib/esm/token/WrappedToken.d.ts +17 -0
  71. package/lib/esm/token/WrappedToken.js +29 -0
  72. package/lib/esm/token/index.d.ts +6 -0
  73. package/lib/esm/token/index.js +6 -0
  74. package/lib/esm/types.d.ts +26 -0
  75. package/lib/esm/types.js +13 -0
  76. package/lib/esm/user/User.d.ts +20 -0
  77. package/lib/esm/user/User.js +19 -0
  78. package/lib/esm/user/index.d.ts +1 -0
  79. package/lib/esm/user/index.js +1 -0
  80. package/lib/esm/utils.d.ts +13 -0
  81. package/lib/esm/utils.js +10 -0
  82. package/lib/esm/vault/Vault.d.ts +214 -0
  83. package/lib/esm/vault/Vault.js +289 -0
  84. package/lib/esm/vault/VaultConfig.d.ts +11 -0
  85. package/lib/esm/vault/VaultConfig.js +10 -0
  86. package/lib/esm/vault/VaultMarketAllocation.d.ts +20 -0
  87. package/lib/esm/vault/VaultMarketAllocation.js +27 -0
  88. package/lib/esm/vault/VaultMarketConfig.d.ts +43 -0
  89. package/lib/esm/vault/VaultMarketConfig.js +39 -0
  90. package/lib/esm/vault/VaultMarketPublicAllocatorConfig.d.ts +29 -0
  91. package/lib/esm/vault/VaultMarketPublicAllocatorConfig.js +24 -0
  92. package/lib/esm/vault/VaultUser.d.ts +26 -0
  93. package/lib/esm/vault/VaultUser.js +24 -0
  94. package/lib/esm/vault/VaultUtils.d.ts +16 -0
  95. package/lib/esm/vault/VaultUtils.js +17 -0
  96. package/lib/esm/vault/index.d.ts +8 -0
  97. package/lib/esm/vault/index.js +8 -0
  98. package/lib/esm/vault/v2/VaultV2.d.ts +87 -0
  99. package/lib/esm/vault/v2/VaultV2.js +154 -0
  100. package/lib/esm/vault/v2/VaultV2Adapter.d.ts +29 -0
  101. package/lib/esm/vault/v2/VaultV2Adapter.js +12 -0
  102. package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +30 -0
  103. package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.js +54 -0
  104. package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +33 -0
  105. package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.js +63 -0
  106. package/lib/esm/vault/v2/VaultV2MorphoVaultV1Adapter.d.ts +24 -0
  107. package/lib/esm/vault/v2/VaultV2MorphoVaultV1Adapter.js +36 -0
  108. package/lib/esm/vault/v2/index.d.ts +5 -0
  109. package/lib/esm/vault/v2/index.js +5 -0
  110. package/package.json +16 -7
  111. package/src/index.ts +14 -0
  112. /package/lib/{chain.d.ts → cjs/chain.d.ts} +0 -0
  113. /package/lib/{chain.js → cjs/chain.js} +0 -0
  114. /package/lib/{constants.d.ts → cjs/constants.d.ts} +0 -0
  115. /package/lib/{constants.js → cjs/constants.js} +0 -0
  116. /package/lib/{errors.d.ts → cjs/errors.d.ts} +0 -0
  117. /package/lib/{errors.js → cjs/errors.js} +0 -0
  118. /package/lib/{holding → cjs/holding}/AssetBalances.d.ts +0 -0
  119. /package/lib/{holding → cjs/holding}/AssetBalances.js +0 -0
  120. /package/lib/{holding → cjs/holding}/Holding.d.ts +0 -0
  121. /package/lib/{holding → cjs/holding}/Holding.js +0 -0
  122. /package/lib/{holding → cjs/holding}/index.d.ts +0 -0
  123. /package/lib/{holding → cjs/holding}/index.js +0 -0
  124. /package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  125. /package/lib/{index.js → cjs/index.js} +0 -0
  126. /package/lib/{market → cjs/market}/Market.d.ts +0 -0
  127. /package/lib/{market → cjs/market}/Market.js +0 -0
  128. /package/lib/{market → cjs/market}/MarketParams.d.ts +0 -0
  129. /package/lib/{market → cjs/market}/MarketParams.js +0 -0
  130. /package/lib/{market → cjs/market}/MarketUtils.d.ts +0 -0
  131. /package/lib/{market → cjs/market}/MarketUtils.js +0 -0
  132. /package/lib/{market → cjs/market}/index.d.ts +0 -0
  133. /package/lib/{market → cjs/market}/index.js +0 -0
  134. /package/lib/{math → cjs/math}/AdaptiveCurveIrmLib.d.ts +0 -0
  135. /package/lib/{math → cjs/math}/AdaptiveCurveIrmLib.js +0 -0
  136. /package/lib/{math → cjs/math}/MathLib.d.ts +0 -0
  137. /package/lib/{math → cjs/math}/MathLib.js +0 -0
  138. /package/lib/{math → cjs/math}/SharesMath.d.ts +0 -0
  139. /package/lib/{math → cjs/math}/SharesMath.js +0 -0
  140. /package/lib/{math → cjs/math}/index.d.ts +0 -0
  141. /package/lib/{math → cjs/math}/index.js +0 -0
  142. /package/lib/{position → cjs/position}/Position.d.ts +0 -0
  143. /package/lib/{position → cjs/position}/Position.js +0 -0
  144. /package/lib/{position → cjs/position}/index.d.ts +0 -0
  145. /package/lib/{position → cjs/position}/index.js +0 -0
  146. /package/lib/{token → cjs/token}/ConstantWrappedToken.d.ts +0 -0
  147. /package/lib/{token → cjs/token}/ConstantWrappedToken.js +0 -0
  148. /package/lib/{token → cjs/token}/Eip5267Domain.d.ts +0 -0
  149. /package/lib/{token → cjs/token}/Eip5267Domain.js +0 -0
  150. /package/lib/{token → cjs/token}/ExchangeRateWrappedToken.d.ts +0 -0
  151. /package/lib/{token → cjs/token}/ExchangeRateWrappedToken.js +0 -0
  152. /package/lib/{token → cjs/token}/Token.d.ts +0 -0
  153. /package/lib/{token → cjs/token}/Token.js +0 -0
  154. /package/lib/{token → cjs/token}/VaultToken.d.ts +0 -0
  155. /package/lib/{token → cjs/token}/VaultToken.js +0 -0
  156. /package/lib/{token → cjs/token}/WrappedToken.d.ts +0 -0
  157. /package/lib/{token → cjs/token}/WrappedToken.js +0 -0
  158. /package/lib/{token → cjs/token}/index.d.ts +0 -0
  159. /package/lib/{token → cjs/token}/index.js +0 -0
  160. /package/lib/{types.d.ts → cjs/types.d.ts} +0 -0
  161. /package/lib/{types.js → cjs/types.js} +0 -0
  162. /package/lib/{user → cjs/user}/User.d.ts +0 -0
  163. /package/lib/{user → cjs/user}/User.js +0 -0
  164. /package/lib/{user → cjs/user}/index.d.ts +0 -0
  165. /package/lib/{user → cjs/user}/index.js +0 -0
  166. /package/lib/{utils.d.ts → cjs/utils.d.ts} +0 -0
  167. /package/lib/{utils.js → cjs/utils.js} +0 -0
  168. /package/lib/{vault → cjs/vault}/Vault.d.ts +0 -0
  169. /package/lib/{vault → cjs/vault}/Vault.js +0 -0
  170. /package/lib/{vault → cjs/vault}/VaultConfig.d.ts +0 -0
  171. /package/lib/{vault → cjs/vault}/VaultConfig.js +0 -0
  172. /package/lib/{vault → cjs/vault}/VaultMarketAllocation.d.ts +0 -0
  173. /package/lib/{vault → cjs/vault}/VaultMarketAllocation.js +0 -0
  174. /package/lib/{vault → cjs/vault}/VaultMarketConfig.d.ts +0 -0
  175. /package/lib/{vault → cjs/vault}/VaultMarketConfig.js +0 -0
  176. /package/lib/{vault → cjs/vault}/VaultMarketPublicAllocatorConfig.d.ts +0 -0
  177. /package/lib/{vault → cjs/vault}/VaultMarketPublicAllocatorConfig.js +0 -0
  178. /package/lib/{vault → cjs/vault}/VaultUser.d.ts +0 -0
  179. /package/lib/{vault → cjs/vault}/VaultUser.js +0 -0
  180. /package/lib/{vault → cjs/vault}/VaultUtils.d.ts +0 -0
  181. /package/lib/{vault → cjs/vault}/VaultUtils.js +0 -0
  182. /package/lib/{vault → cjs/vault}/v2/VaultV2Adapter.js +0 -0
  183. /package/lib/{vault → cjs/vault}/v2/index.d.ts +0 -0
  184. /package/lib/{vault → cjs/vault}/v2/index.js +0 -0
@@ -0,0 +1,424 @@
1
+ import { type RoundingDirection } from "../math/index.js";
2
+ import type { BigIntish } from "../types.js";
3
+ import { type CapacityLimit } from "../utils.js";
4
+ import { type IMarketParams, MarketParams } from "./MarketParams.js";
5
+ export interface MaxBorrowOptions {
6
+ maxLtv?: bigint;
7
+ }
8
+ export interface MaxWithdrawCollateralOptions {
9
+ maxLtv?: bigint;
10
+ }
11
+ export interface MaxPositionCapacities {
12
+ supply: CapacityLimit;
13
+ withdraw: CapacityLimit;
14
+ borrow: CapacityLimit | undefined;
15
+ repay: CapacityLimit;
16
+ supplyCollateral: CapacityLimit;
17
+ withdrawCollateral: CapacityLimit | undefined;
18
+ }
19
+ export interface IMarket {
20
+ params: IMarketParams;
21
+ totalSupplyAssets: bigint;
22
+ totalBorrowAssets: bigint;
23
+ totalSupplyShares: bigint;
24
+ totalBorrowShares: bigint;
25
+ lastUpdate: bigint;
26
+ fee: bigint;
27
+ price?: bigint;
28
+ rateAtTarget?: bigint;
29
+ }
30
+ /**
31
+ * Represents a lending market on Morpho Blue.
32
+ */
33
+ export declare class Market implements IMarket {
34
+ /**
35
+ * The market's params.
36
+ */
37
+ readonly params: MarketParams;
38
+ /**
39
+ * The amount of loan assets supplied in total on the market.
40
+ */
41
+ totalSupplyAssets: bigint;
42
+ /**
43
+ * The amount of loan assets supplied in total on the market.
44
+ */
45
+ totalBorrowAssets: bigint;
46
+ /**
47
+ * The amount of loan assets supplied in total on the market.
48
+ */
49
+ totalSupplyShares: bigint;
50
+ /**
51
+ * The amount of loan assets supplied in total on the market.
52
+ */
53
+ totalBorrowShares: bigint;
54
+ /**
55
+ * The block timestamp (in __seconds__) when the interest was last accrued.
56
+ */
57
+ lastUpdate: bigint;
58
+ /**
59
+ * The fee percentage of the market, scaled by WAD.
60
+ */
61
+ fee: bigint;
62
+ /**
63
+ * The price as returned by the market's oracle.
64
+ * `undefined` if the oracle is undefined or reverts.
65
+ */
66
+ price?: bigint;
67
+ /**
68
+ * If the market uses the Adaptive Curve IRM, the rate at target utilization.
69
+ * Undefined otherwise.
70
+ */
71
+ rateAtTarget?: bigint;
72
+ constructor({ params, totalSupplyAssets, totalBorrowAssets, totalSupplyShares, totalBorrowShares, lastUpdate, fee, price, rateAtTarget, }: IMarket);
73
+ /**
74
+ * The market's hex-encoded id, defined as the hash of the market params.
75
+ */
76
+ get id(): import("../types.js").MarketId;
77
+ /**
78
+ * Whether the market satisfies the canonical definition of an idle market (i.e. collateral token is the zero address).
79
+ */
80
+ get isIdle(): boolean;
81
+ /**
82
+ * @warning Cannot be used to calculate the liquidity available inside a callback,
83
+ * because the balance of Blue may be lower than the market's liquidity due to assets being transferred out prior to the callback.
84
+ */
85
+ get liquidity(): bigint;
86
+ /**
87
+ * The market's utilization rate (scaled by WAD).
88
+ */
89
+ get utilization(): bigint;
90
+ /**
91
+ * The market's Annual Percentage Yield (APY) at the IRM's target utilization rate, if applicable.
92
+ */
93
+ get apyAtTarget(): number | undefined;
94
+ /**
95
+ * Returns the instantaneous rate at which interest accrues for borrowers of this market,
96
+ * if `accrueInterest` was called immediately onchain (scaled by WAD).
97
+ *
98
+ * Even if `accrueInterest` is called immediately onchain,
99
+ * the instantaneous rate only corresponds to an intermediary value used to calculate
100
+ * the actual average rate experienced by borrowers of this market.
101
+ *
102
+ * If interested in the instantaneous rate experienced by existing market actors at a specific timestamp,
103
+ * use `getEndBorrowRate(timestamp)`, `getBorrowApy(timestamp)`, or `getSupplyApy(timestamp)` instead.
104
+ */
105
+ get endBorrowRate(): bigint;
106
+ /**
107
+ * Returns the average rate at which interest _would_ accrue from `lastUpdate`
108
+ * till now, if `accrueInterest` was called immediately onchain (scaled by WAD).
109
+ * If `accrueInterest` was just called, the average rate equals the instantaneous rate,
110
+ * so it is equivalent to `getBorrowRate(lastUpdate)`.
111
+ *
112
+ * In most cases, `accrueInterest` will not be called immediately onchain,
113
+ * so the average rate is only an intermediary value.
114
+ *
115
+ * If interested in the average rate experienced by existing market actors at a specific timestamp,
116
+ * use `getAvgBorrowRate(timestamp)`, `getAvgBorrowApy(timestamp)`, or `getAvgSupplyApy(timestamp)` instead.
117
+ */
118
+ get avgBorrowRate(): bigint;
119
+ /**
120
+ * The market's current, instantaneous supply-side Annual Percentage Yield (APY).
121
+ * If interested in the APY at a specific timestamp, use `getSupplyApy(timestamp)` instead.
122
+ */
123
+ get supplyApy(): number;
124
+ /**
125
+ * The market's current, instantaneous borrow-side Annual Percentage Yield (APY).
126
+ * If interested in the APY at a specific timestamp, use `getBorrowApy(timestamp)` instead.
127
+ */
128
+ get borrowApy(): number;
129
+ /**
130
+ * Returns the instantaneous rate at which interest accrues for borrowers of this market,
131
+ * at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
132
+ * It is fundamentally different from the rate at which interest is paid by borrowers to lenders in the case of an interest accrual,
133
+ * as in the case of the AdaptiveCurveIRM, the (approximated) average rate since the last update is used instead.
134
+ * @param timestamp The timestamp at which to calculate the borrow rate.
135
+ * Must be greater than or equal to `lastUpdate`.
136
+ * Defaults to `Time.timestamp()` (returns the current borrow rate).
137
+ */
138
+ getEndBorrowRate(timestamp?: BigIntish): bigint;
139
+ /**
140
+ * Returns the average rate at which interest _would_ accrue for borrowers of this market,
141
+ * if `accrueInterest` was called at the given timestamp (scaled by WAD).
142
+ * @param timestamp The timestamp at which to calculate the average borrow rate.
143
+ * Must be greater than or equal to `lastUpdate`.
144
+ * Defaults to `Time.timestamp()` (returns the current average borrow rate).
145
+ */
146
+ getAvgBorrowRate(timestamp?: BigIntish): bigint;
147
+ /**
148
+ * Returns the rates that _would_ apply to interest accrual for borrowers of this market,
149
+ * if `accrueInterest` was called at the given timestamp (scaled by WAD).
150
+ * @param timestamp The timestamp at which to calculate the accrual borrow rate.
151
+ * Must be greater than or equal to `lastUpdate`.
152
+ * Defaults to `Time.timestamp()` (returns the current accrual borrow rate).
153
+ */
154
+ protected getAccrualBorrowRates(timestamp?: BigIntish): {
155
+ elapsed: bigint;
156
+ avgBorrowRate: bigint;
157
+ endBorrowRate: bigint;
158
+ endRateAtTarget?: bigint;
159
+ };
160
+ /**
161
+ * The market's instantaneous borrow-side Annual Percentage Yield (APY) at the given timestamp,
162
+ * if the state remains unchanged (not accrued).
163
+ * @param timestamp The timestamp at which to calculate the borrow APY.
164
+ * Must be greater than or equal to `lastUpdate`.
165
+ * Defaults to `Time.timestamp()` (returns the current borrow APY).
166
+ */
167
+ getBorrowApy(timestamp?: BigIntish): number;
168
+ /**
169
+ * The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
170
+ * if the state remains unchanged (not accrued).
171
+ * @param timestamp The timestamp at which to calculate the supply APY.
172
+ * Must be greater than or equal to `lastUpdate`.
173
+ * Defaults to `Time.timestamp()` (returns the current supply APY).
174
+ */
175
+ getSupplyApy(timestamp?: BigIntish): number;
176
+ /**
177
+ * The market's experienced borrow-side Annual Percentage Yield (APY),
178
+ * if interest was to be accrued at the given timestamp.
179
+ * @param timestamp The timestamp at which to calculate the borrow APY.
180
+ * Must be greater than or equal to `lastUpdate`.
181
+ * Defaults to `Time.timestamp()` (returns the current borrow APY).
182
+ */
183
+ getAvgBorrowApy(timestamp?: BigIntish): number;
184
+ /**
185
+ * Returns the average rate at which interest _would_ accrue for suppliers of this market,
186
+ * if `accrueInterest` was called at the given timestamp (scaled by WAD).
187
+ * @param timestamp The timestamp at which to calculate the average supply rate.
188
+ * Must be greater than or equal to `lastUpdate`.
189
+ * Defaults to `Time.timestamp()` (returns the current average supply rate).
190
+ */
191
+ getAvgSupplyRate(timestamp?: BigIntish): bigint;
192
+ /**
193
+ * The market's experienced supply-side Annual Percentage Yield (APY),
194
+ * if interest was to be accrued at the given timestamp.
195
+ * @param timestamp The timestamp at which to calculate the supply APY.
196
+ * Must be greater than or equal to `lastUpdate`.
197
+ * Defaults to `Time.timestamp()` (returns the current supply APY).
198
+ */
199
+ getAvgSupplyApy(timestamp?: BigIntish): number;
200
+ /**
201
+ * Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
202
+ * @param timestamp The timestamp at which to accrue interest.
203
+ * Must be greater than or equal to `lastUpdate`.
204
+ * Defaults to `lastUpdate` (returns a copy of the market).
205
+ */
206
+ accrueInterest(timestamp?: BigIntish): Market;
207
+ supply(assets: bigint, shares: bigint, timestamp?: BigIntish): {
208
+ market: Market;
209
+ assets: bigint;
210
+ shares: bigint;
211
+ };
212
+ withdraw(assets: bigint, shares: bigint, timestamp?: BigIntish): {
213
+ market: Market;
214
+ assets: bigint;
215
+ shares: bigint;
216
+ };
217
+ borrow(assets: bigint, shares: bigint, timestamp?: BigIntish): {
218
+ market: Market;
219
+ assets: bigint;
220
+ shares: bigint;
221
+ };
222
+ repay(assets: bigint, shares: bigint, timestamp?: BigIntish): {
223
+ market: Market;
224
+ assets: bigint;
225
+ shares: bigint;
226
+ };
227
+ /**
228
+ * Converts a given amount of supply shares into supply loan assets.
229
+ * @param shares The amount of shares to convert.
230
+ * @param rounding The rounding direction to use (defaults to "Down").
231
+ */
232
+ toSupplyAssets(shares: bigint, rounding?: RoundingDirection): bigint;
233
+ /**
234
+ * Converts a given amount of supply loan assets into supply shares.
235
+ * @param shares The amount of assets to convert.
236
+ * @param rounding The rounding direction to use (defaults to "Up").
237
+ */
238
+ toSupplyShares(assets: bigint, rounding?: RoundingDirection): bigint;
239
+ /**
240
+ * Converts a given amount of borrow shares into borrow loan assets.
241
+ * @param shares The amount of shares to convert.
242
+ * @param rounding The rounding direction to use (defaults to "Up").
243
+ */
244
+ toBorrowAssets(shares: bigint, rounding?: RoundingDirection): bigint;
245
+ /**
246
+ * Converts a given amount of borrow loan assets into borrow shares.
247
+ * @param shares The amount of assets to convert.
248
+ * @param rounding The rounding direction to use (defaults to "Down").
249
+ */
250
+ toBorrowShares(assets: bigint, rounding?: RoundingDirection): bigint;
251
+ /**
252
+ * Returns the smallest volume to supply until the market gets the closest to the given utilization rate.
253
+ * @param utilization The target utilization rate (scaled by WAD).
254
+ */
255
+ getSupplyToUtilization(utilization: bigint): bigint;
256
+ /**
257
+ * Returns the liquidity available to withdraw until the market gets the closest to the given utilization rate.
258
+ * @param utilization The target utilization rate (scaled by WAD).
259
+ */
260
+ getWithdrawToUtilization(utilization: bigint): bigint;
261
+ /**
262
+ * Returns the liquidity available to borrow until the market gets the closest to the given utilization rate.
263
+ * @param utilization The target utilization rate (scaled by WAD).
264
+ */
265
+ getBorrowToUtilization(utilization: bigint): bigint;
266
+ /**
267
+ * Returns the smallest volume to repay until the market gets the closest to the given utilization rate.
268
+ * @param utilization The target utilization rate (scaled by WAD).
269
+ */
270
+ getRepayToUtilization(utilization: bigint): bigint;
271
+ /**
272
+ * Returns the value of a given amount of collateral quoted in loan assets.
273
+ * `undefined` iff the market's oracle is undefined or reverts.
274
+ * @param collateral The amount of collateral to quote.
275
+ */
276
+ getCollateralValue(collateral: bigint): bigint | undefined;
277
+ /**
278
+ * Returns the maximum debt allowed given a certain amount of collateral.
279
+ * `undefined` iff the market's oracle is undefined or reverts.
280
+ * To calculate the amount of loan assets that can be borrowed, use `getMaxBorrowableAssets`.
281
+ * @param collateral The amount of collateral to consider.
282
+ */
283
+ getMaxBorrowAssets(collateral: bigint, { maxLtv }?: MaxBorrowOptions): bigint | undefined;
284
+ /**
285
+ * Returns the maximum amount of loan assets that can be borrowed given a certain borrow position.
286
+ * `undefined` iff the market's oracle is undefined or reverts.
287
+ * @param position The borrow position to consider.
288
+ */
289
+ getMaxBorrowableAssets(position: {
290
+ collateral: bigint;
291
+ borrowShares: bigint;
292
+ }): bigint | undefined;
293
+ /**
294
+ * Returns the amount of collateral that would be seized in a liquidation given a certain amount of repaid shares.
295
+ * `undefined` iff the market's oracle is undefined or reverts.
296
+ * @param repaidShares The amount of shares hypothetically repaid.
297
+ */
298
+ getLiquidationSeizedAssets(repaidShares: bigint): bigint | undefined;
299
+ /**
300
+ * Returns the amount of borrow shares that would be repaid in a liquidation given a certain amount of seized collateral.
301
+ * `undefined` iff the market's oracle is undefined or reverts.
302
+ * @param seizedAssets The amount of collateral hypothetically seized.
303
+ */
304
+ getLiquidationRepaidShares(seizedAssets: bigint): bigint | undefined;
305
+ /**
306
+ * Returns the maximum amount of collateral that is worth being seized in a liquidation given a certain borrow position.
307
+ * `undefined` iff the market's oracle is undefined or reverts.
308
+ * @param position The borrow position to consider.
309
+ */
310
+ getSeizableCollateral(position: {
311
+ collateral: bigint;
312
+ borrowShares: bigint;
313
+ }): bigint | undefined;
314
+ /**
315
+ * Returns the amount of collateral that can be withdrawn given a certain borrow position.
316
+ * `undefined` iff the market's oracle is undefined or reverts.
317
+ * @param position The borrow position to consider.
318
+ */
319
+ getWithdrawableCollateral(position: {
320
+ collateral: bigint;
321
+ borrowShares: bigint;
322
+ }, { maxLtv }?: MaxWithdrawCollateralOptions): bigint | undefined;
323
+ /**
324
+ * Returns whether a given borrow position is healthy.
325
+ * `undefined` iff the market's oracle is undefined or reverts.
326
+ * @param position The borrow position to check.
327
+ */
328
+ isHealthy(position: {
329
+ collateral: bigint;
330
+ borrowShares: bigint;
331
+ }): boolean | undefined;
332
+ /**
333
+ * Returns the liquidation price of a given borrow position.
334
+ * @param position The borrow position to consider.
335
+ */
336
+ getLiquidationPrice(position: {
337
+ collateral: bigint;
338
+ borrowShares: bigint;
339
+ }): bigint | null;
340
+ /**
341
+ * Returns the price variation required for the given position to reach its liquidation threshold (scaled by WAD).
342
+ * Negative when healthy (the price needs to drop x%), positive when unhealthy (the price needs to soar x%).
343
+ * Returns `undefined` iff the market's price is undefined.
344
+ * Returns null if the position is not a borrow.
345
+ * @param position The borrow position to consider.
346
+ */
347
+ getPriceVariationToLiquidationPrice(position: {
348
+ collateral: bigint;
349
+ borrowShares: bigint;
350
+ }): bigint | null | undefined;
351
+ /**
352
+ * Returns the health factor of a given borrow position (scaled by WAD).
353
+ * @param position The borrow position to consider.
354
+ */
355
+ getHealthFactor(position: {
356
+ collateral: bigint;
357
+ borrowShares: bigint;
358
+ }): bigint | undefined;
359
+ /**
360
+ * Returns the loan-to-value ratio of a given borrow position (scaled by WAD).
361
+ * @param position The borrow position to consider.
362
+ */
363
+ getLtv(position: {
364
+ collateral: bigint;
365
+ borrowShares: bigint;
366
+ }): bigint | null | undefined;
367
+ /**
368
+ * Returns the usage ratio of the maximum borrow capacity given a certain borrow position (scaled by WAD).
369
+ * @param position The borrow position to consider.
370
+ */
371
+ getBorrowCapacityUsage(position: {
372
+ collateral: bigint;
373
+ borrowShares: bigint;
374
+ }): bigint | undefined;
375
+ /**
376
+ * Returns the maximum amount of loan assets that can be borrowed given a certain borrow position
377
+ * and the reason for the limit.
378
+ * Returns `undefined` iff the market's price is undefined.
379
+ * @param position The borrow position to consider.
380
+ */
381
+ getBorrowCapacityLimit({ collateral, borrowShares, }: {
382
+ collateral: bigint;
383
+ borrowShares?: bigint;
384
+ }, options?: MaxBorrowOptions): CapacityLimit | undefined;
385
+ /**
386
+ * Returns the maximum amount of loan assets that can be repaid given a certain borrow position
387
+ * and a balance of loan assets, and the reason for the limit.
388
+ * @param position The borrow position to consider.
389
+ */
390
+ getRepayCapacityLimit(borrowShares: bigint, loanTokenBalance: bigint): CapacityLimit;
391
+ /**
392
+ * Returns the maximum amount of loan assets that can be withdrawn given a certain supply position
393
+ * and a balance of loan assets, and the reason for the limit.
394
+ * @param position The supply position to consider.
395
+ */
396
+ getWithdrawCapacityLimit({ supplyShares, }: {
397
+ supplyShares: bigint;
398
+ }): CapacityLimit;
399
+ /**
400
+ * Returns the maximum amount of collateral assets that can be withdrawn given a certain borrow position
401
+ * and the reason for the limit.
402
+ * Returns `undefined` iff the market's price is undefined.
403
+ * @param position The borrow position to consider.
404
+ */
405
+ getWithdrawCollateralCapacityLimit(position: {
406
+ collateral: bigint;
407
+ borrowShares: bigint;
408
+ }, options?: MaxWithdrawCollateralOptions): CapacityLimit | undefined;
409
+ /**
410
+ * Returns the maximum capacity for all interactions with Morpho Blue given a certain position
411
+ * and loan and collateral balances.
412
+ * @param position The position to consider.
413
+ * @param loanTokenBalance The balance of loan assets.
414
+ * @param collateralTokenBalance The balance of collateral assets.
415
+ */
416
+ getMaxCapacities(position: {
417
+ collateral: bigint;
418
+ supplyShares: bigint;
419
+ borrowShares: bigint;
420
+ }, loanTokenBalance: bigint, collateralTokenBalance: bigint, options?: {
421
+ borrow?: MaxBorrowOptions;
422
+ withdrawCollateral?: MaxWithdrawCollateralOptions;
423
+ }): MaxPositionCapacities;
424
+ }