|
2 | 2 | pragma solidity ^0.8.22; |
3 | 3 |
|
4 | 4 | import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; |
5 | | -import { IERC4626 } from "@openzeppelin/contracts/interfaces/IERC4626.sol"; |
| 5 | +import { ERC4626, IERC4626 } from "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; |
6 | 6 |
|
7 | 7 | import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; |
8 | 8 |
|
@@ -273,22 +273,34 @@ contract VaultComposerSync is IVaultComposerSync, ReentrancyGuard { |
273 | 273 | /** |
274 | 274 | * @notice Quotes the send operation for the given OFT and SendParam |
275 | 275 | * @dev Revert on slippage will be thrown by the OFT and not _assertSlippage |
| 276 | + * @param _from The "sender address" used for the quote |
276 | 277 | * @param _targetOFT The OFT contract address to quote |
277 | 278 | * @param _vaultInAmount The amount of tokens to send to the vault |
278 | 279 | * @param _sendParam The parameters for the send operation |
279 | 280 | * @return MessagingFee The estimated fee for the send operation |
280 | 281 | * @dev This function can be overridden to implement custom quoting logic |
281 | 282 | */ |
282 | 283 | function quoteSend( |
| 284 | + address _from, |
283 | 285 | address _targetOFT, |
284 | 286 | uint256 _vaultInAmount, |
285 | 287 | SendParam memory _sendParam |
286 | 288 | ) external view virtual returns (MessagingFee memory) { |
287 | 289 | /// @dev When quoting the asset OFT, the function input is shares and the SendParam.amountLD into quoteSend() should be assets (and vice versa) |
288 | 290 |
|
289 | 291 | if (_targetOFT == ASSET_OFT) { |
| 292 | + uint256 maxRedeem = VAULT.maxRedeem(_from); |
| 293 | + if (_vaultInAmount > maxRedeem) { |
| 294 | + revert ERC4626.ERC4626ExceededMaxRedeem(_from, _vaultInAmount, maxRedeem); |
| 295 | + } |
| 296 | + |
290 | 297 | _sendParam.amountLD = VAULT.previewRedeem(_vaultInAmount); |
291 | 298 | } else { |
| 299 | + uint256 maxDeposit = VAULT.maxDeposit(_from); |
| 300 | + if (_vaultInAmount > maxDeposit) { |
| 301 | + revert ERC4626.ERC4626ExceededMaxDeposit(_from, _vaultInAmount, maxDeposit); |
| 302 | + } |
| 303 | + |
292 | 304 | _sendParam.amountLD = VAULT.previewDeposit(_vaultInAmount); |
293 | 305 | } |
294 | 306 | return IOFT(_targetOFT).quoteSend(_sendParam, false); |
|
0 commit comments