mirror of
https://github.com/status-im/codex-contracts-eth.git
synced 2025-01-31 02:35:36 +00:00
8ff26ca577
- 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
24 lines
537 B
Solidity
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));
|
|
}
|
|
}
|