Skip to content

Commit 6a7d559

Browse files
markspanbroekemizzleAuHau
committed
vault: rename update() -> accumulateFlows()
Reason: update() is too generic, and can easily be interpreted as changing the on-chain state, whereas it actually updates the in-memory struct. Co-Authored-By: Eric <[email protected]> Co-Authored-By: Adam Uhlíř <[email protected]>
1 parent 2f2c6d8 commit 6a7d559

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

contracts/vault/Accounts.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ library Accounts {
7676
/// outgoing and incoming flows up until the specified timestamp. Outgoing
7777
/// tokens are deducted from the available balance. Incoming tokens are added
7878
/// to the designated tokens.
79-
function update(Account memory account, Timestamp timestamp) internal pure {
79+
function accumulateFlows(Account memory account, Timestamp timestamp) internal pure {
8080
Duration duration = account.flow.updated.until(timestamp);
8181
account.balance.available -= account.flow.outgoing.accumulate(duration);
8282
account.balance.designated += account.flow.incoming.accumulate(duration);
@@ -86,7 +86,7 @@ library Accounts {
8686
/// Starts an incoming flow of tokens at the specified rate. If there already
8787
/// is a flow of incoming tokens, then its rate is increased accordingly.
8888
function flowIn(Account memory account, TokensPerSecond rate) internal view {
89-
account.update(Timestamps.currentTime());
89+
account.accumulateFlows(Timestamps.currentTime());
9090
account.flow.incoming = account.flow.incoming + rate;
9191
}
9292

@@ -95,7 +95,7 @@ library Accounts {
9595
/// outgoing flow. If there are insuffient incoming tokens, then the outgoing
9696
/// rate is increased.
9797
function flowOut(Account memory account, TokensPerSecond rate) internal view {
98-
account.update(Timestamps.currentTime());
98+
account.accumulateFlows(Timestamps.currentTime());
9999
if (rate <= account.flow.incoming) {
100100
account.flow.incoming = account.flow.incoming - rate;
101101
} else {

contracts/vault/VaultBase.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ abstract contract VaultBase {
8282
FundStatus status = fund.status();
8383
if (status == FundStatus.Locked) {
8484
Account memory account = _accounts[controller][fundId][accountId];
85-
account.update(Timestamps.currentTime());
85+
account.accumulateFlows(Timestamps.currentTime());
8686
return account.balance;
8787
}
8888
if (status == FundStatus.Withdrawing || status == FundStatus.Frozen) {
8989
Account memory account = _accounts[controller][fundId][accountId];
90-
account.update(fund.flowEnd());
90+
account.accumulateFlows(fund.flowEnd());
9191
return account.balance;
9292
}
9393
return Balance({available: 0, designated: 0});
@@ -255,7 +255,7 @@ abstract contract VaultBase {
255255
require(fund.status() == FundStatus.Withdrawing, VaultFundNotUnlocked());
256256

257257
Account memory account = _accounts[controller][fundId][accountId];
258-
account.update(fund.flowEnd());
258+
account.accumulateFlows(fund.flowEnd());
259259
uint128 amount = account.balance.available + account.balance.designated;
260260

261261
fund.value -= amount;

0 commit comments

Comments
 (0)