Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage refactor #69

Closed
wants to merge 11 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
formatting
dglowinski committed Mar 24, 2024

Verified

This commit was signed with the committer’s verified signature.
alexander-demicev Alexander Demicev
commit 1c5cd333bf5d4e637163ec3982600c95d7e2b228
4 changes: 2 additions & 2 deletions src/EVault/modules/Governance.sol
Original file line number Diff line number Diff line change
@@ -273,8 +273,8 @@ abstract contract GovernanceModule is IGovernance, Base, BalanceUtils, BorrowUti
VaultData storage vs = vaultStorage();

// Overwrite bits of locked ops with their currently set values
newDisabledOps = (newDisabledOps & ~vs.lockedOps.toUint32())
| (vs.disabledOps.toUint32() & vs.lockedOps.toUint32());
newDisabledOps =
(newDisabledOps & ~vs.lockedOps.toUint32()) | (vs.disabledOps.toUint32() & vs.lockedOps.toUint32());

// vault is updated because:
// if disabling interest accrual - the pending interest should be accrued
12 changes: 4 additions & 8 deletions src/EVault/shared/BalanceUtils.sol
Original file line number Diff line number Diff line change
@@ -22,8 +22,7 @@ abstract contract BalanceUtils is Base {
if (account == address(0)) revert E_BadSharesReceiver();

VaultData storage vs = vaultStorage();
(Shares origBalance, bool balanceForwarderEnabled) =
vs.users[account].getBalanceAndBalanceForwarder();
(Shares origBalance, bool balanceForwarderEnabled) = vs.users[account].getBalanceAndBalanceForwarder();
Shares newBalance = origBalance + amount;

vs.users[account].setBalance(newBalance);
@@ -47,8 +46,7 @@ abstract contract BalanceUtils is Base {
) internal {
VaultData storage vs = vaultStorage();

(Shares origBalance, bool balanceForwarderEnabled) =
vs.users[account].getBalanceAndBalanceForwarder();
(Shares origBalance, bool balanceForwarderEnabled) = vs.users[account].getBalanceAndBalanceForwarder();
if (origBalance < amount) revert E_InsufficientBalance();

Shares newBalance;
@@ -71,11 +69,9 @@ abstract contract BalanceUtils is Base {
VaultData storage vs = vaultStorage();

if (!amount.isZero()) {
(Shares origFromBalance, bool fromBalanceForwarderEnabled) =
vs.users[from].getBalanceAndBalanceForwarder();
(Shares origFromBalance, bool fromBalanceForwarderEnabled) = vs.users[from].getBalanceAndBalanceForwarder();

(Shares origToBalance, bool toBalanceForwarderEnabled) =
vs.users[to].getBalanceAndBalanceForwarder();
(Shares origToBalance, bool toBalanceForwarderEnabled) = vs.users[to].getBalanceAndBalanceForwarder();

if (origFromBalance < amount) revert E_InsufficientBalance();