mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-10 17:23:12 +00:00
vault: _getAccount updates to the latest timestamp
This commit is contained in:
parent
2108f1265a
commit
bdc721bfaa
@ -5,8 +5,8 @@ import "./Timestamps.sol";
|
||||
import "./TokensPerSecond.sol";
|
||||
|
||||
struct Flow {
|
||||
Timestamp start;
|
||||
TokensPerSecond rate;
|
||||
Timestamp updated;
|
||||
}
|
||||
|
||||
library Flows {
|
||||
@ -15,7 +15,7 @@ library Flows {
|
||||
Timestamp timestamp
|
||||
) internal pure returns (int128) {
|
||||
int128 rate = TokensPerSecond.unwrap(flow.rate);
|
||||
Timestamp start = flow.start;
|
||||
Timestamp start = flow.updated;
|
||||
Timestamp end = timestamp;
|
||||
uint64 duration = Timestamp.unwrap(end) - Timestamp.unwrap(start);
|
||||
return rate * int128(uint128(duration));
|
||||
|
||||
@ -60,6 +60,7 @@ abstract contract VaultBase {
|
||||
result.available -= uint128(-accumulated);
|
||||
}
|
||||
}
|
||||
result.flow.updated = timestamp;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -173,10 +174,7 @@ abstract contract VaultBase {
|
||||
Account memory senderAccount = _getAccount(controller, fund, from);
|
||||
Account memory receiverAccount = _getAccount(controller, fund, to);
|
||||
|
||||
Timestamp start = Timestamps.currentTime();
|
||||
senderAccount.flow.start = start;
|
||||
senderAccount.flow.rate = senderAccount.flow.rate - rate;
|
||||
receiverAccount.flow.start = start;
|
||||
receiverAccount.flow.rate = receiverAccount.flow.rate + rate;
|
||||
|
||||
_checkAccountInvariant(senderAccount, lock);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user