Skip to content

Commit 9e8b89e

Browse files
committed
reduce contract size
1 parent 0bfe3ca commit 9e8b89e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Vault.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ contract Vault is IVault, ERC4626 {
2323
using SafeERC20 for IERC20;
2424

2525
// CONSTANTS
26-
uint256 public constant WAD = 1e18;
26+
uint256 private constant WAD = 1e18;
2727

2828
// IMMUTABLES
2929
IPool private immutable POOL;
@@ -35,11 +35,12 @@ contract Vault is IVault, ERC4626 {
3535
uint256 public immutable LP_DUST;
3636

3737
// STATE VARIABLES
38+
uint8 private bolt; // reentrancy lock: 0 = off, 1 = on
39+
3840
uint256[] public buckets;
3941
mapping(uint256 => uint256) public bucketsIndex; // (bucketIndex => index location in buckets)
4042
uint256 public bufferLps;
4143
mapping(uint256 => uint256) public lps; // (bucketIndex => lps)
42-
uint8 public bolt; // reentrancy lock: 0 = off, 1 = on
4344
uint256 public removedCollateralValue;
4445

4546
// MODIFIERS
@@ -433,7 +434,7 @@ contract Vault is IVault, ERC4626 {
433434
if (_paused()) return 0;
434435
// The max the user can redeem is the amount of shares
435436
// they have in the vault limited by the value the buffer holds
436-
return Maths.min(super.maxRedeem(owner), convertToShares(BUFFER.total()));
437+
return Maths.min(super.maxRedeem(owner), _convertToShares(BUFFER.total(), Math.Rounding.Down));
437438
}
438439

439440
function previewDeposit(uint256 assets) public view override returns (uint256) {

test/Vault4626.t.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,7 @@ contract Vault4626Test is VaultBaseTest {
512512
assertGt(vault.balanceOf(alice), bufferLps, "Alice should have more shares than buffer LPs");
513513

514514
// maxRedeem should be limited by buffer LPs, not alice's full shares
515-
// uint256 maxRedeemable = vault.maxRedeem(alice);
516-
uint256 maxRedeemable = vault.convertToShares(Buffer(vault.buffer()).total());
515+
uint256 maxRedeemable = vault.maxRedeem(alice);
517516
assertEq(maxRedeemable, bufferLps, "maxRedeem should be limited by buffer LPs");
518517
assertLt(maxRedeemable, aliceShares, "maxRedeem should be less than alice's full shares");
519518

0 commit comments

Comments
 (0)