Mark Spanbroek 8ff26ca577 vault: flow to multiple recipients
- changes balance from uint256 -> uint128
  so that entire Balance can be read or written
  with a single operation
- moves Lock to library
- simplifies lock checks
2025-01-28 10:31:39 +01:00

24 lines
537 B
Solidity

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
import "./Timestamps.sol";
import "./TokensPerSecond.sol";
struct Flow {
Timestamp start;
TokensPerSecond rate;
}
library Flows {
function _totalAt(
Flow memory flow,
Timestamp timestamp
) internal pure returns (int128) {
int128 rate = TokensPerSecond.unwrap(flow.rate);
Timestamp start = flow.start;
Timestamp end = timestamp;
uint64 duration = Timestamp.unwrap(end) - Timestamp.unwrap(start);
return rate * int128(uint128(duration));
}
}