Skip to content

Commit f6e7565

Browse files
committed
save space in Vault with internal functions and private buckets
1 parent ba8c685 commit f6e7565

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Vault.sol

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,17 @@ contract Vault is IVault, ERC4626 {
3737
// STATE VARIABLES
3838
uint8 private bolt; // reentrancy lock: 0 = off, 1 = on
3939

40-
uint256[] public buckets;
40+
uint256[] private buckets;
4141
mapping(uint256 => uint256) public bucketsIndex; // (bucketIndex => index location in buckets)
4242
uint256 public bufferLps;
4343
mapping(uint256 => uint256) public lps; // (bucketIndex => lps)
4444
uint256 public removedCollateralValue;
4545

4646
// MODIFIERS
4747
modifier lock() {
48-
if (bolt != 0) revert ReentrancyLockActive();
49-
bolt = 1;
48+
_lock();
5049
_;
51-
bolt = 0;
50+
_unlock();
5251
}
5352

5453
modifier notPaused() {
@@ -503,4 +502,14 @@ contract Vault is IVault, ERC4626 {
503502
function _decimalsOffset() internal view override returns (uint8) {
504503
return 18 - assetDecimals;
505504
}
505+
506+
// REENTRANCY LOCK Functions (to shrink contract size)
507+
function _lock() internal {
508+
if (bolt != 0) revert ReentrancyLockActive();
509+
bolt = 1;
510+
}
511+
512+
function _unlock() internal {
513+
bolt = 0;
514+
}
506515
}

0 commit comments

Comments
 (0)