Skip to content

Commit bdca796

Browse files
committed
Make Drips balances uint256 (#347)
1 parent a8932b9 commit bdca796

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Drips.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ contract Drips is Managed, Streams, Splits {
7878
uint8 public constant DRIVER_ID_OFFSET = 224;
7979
/// @notice The total amount the protocol can store of each token.
8080
/// It's the minimum of _MAX_STREAMS_BALANCE and _MAX_SPLITS_BALANCE.
81-
uint128 public constant MAX_TOTAL_BALANCE = _MAX_STREAMS_BALANCE;
81+
uint256 public constant MAX_TOTAL_BALANCE = _MAX_STREAMS_BALANCE;
8282
/// @notice On every timestamp `T`, which is a multiple of `cycleSecs`, the receivers
8383
/// gain access to steams received during `T - cycleSecs` to `T - 1`.
8484
/// Always higher than 1.
@@ -232,7 +232,7 @@ contract Drips is Managed, Streams, Splits {
232232
public
233233
view
234234
onlyProxy
235-
returns (uint128 streamsBalance, uint128 splitsBalance)
235+
returns (uint256 streamsBalance, uint256 splitsBalance)
236236
{
237237
Balance storage balance = _dripsStorage().balances[erc20];
238238
return (balance.streams, balance.splits);
@@ -294,7 +294,7 @@ contract Drips is Managed, Streams, Splits {
294294
/// @param erc20 The used ERC-20 token.
295295
/// @param amt The amount to increase the streams or splits balance by.
296296
function _verifyBalanceIncrease(IERC20 erc20, uint128 amt) internal view {
297-
(uint256 streamsBalance, uint128 splitsBalance) = balances(erc20);
297+
(uint256 streamsBalance, uint256 splitsBalance) = balances(erc20);
298298
uint256 newTotalBalance = streamsBalance + splitsBalance + amt;
299299
require(newTotalBalance <= MAX_TOTAL_BALANCE, "Total balance too high");
300300
require(newTotalBalance <= erc20.balanceOf(address(this)), "Token balance too low");
@@ -316,7 +316,7 @@ contract Drips is Managed, Streams, Splits {
316316
/// It must be at most the difference between the balance of the token held by the Drips
317317
/// contract address and the sum of balances managed by the protocol as indicated by `balances`.
318318
function withdraw(IERC20 erc20, address receiver, uint256 amt) public onlyProxy {
319-
(uint128 streamsBalance, uint128 splitsBalance) = balances(erc20);
319+
(uint256 streamsBalance, uint256 splitsBalance) = balances(erc20);
320320
uint256 withdrawable = erc20.balanceOf(address(this)) - streamsBalance - splitsBalance;
321321
require(amt <= withdrawable, "Withdrawal amount too high");
322322
emit Withdrawn(erc20, receiver, amt);

src/Giver.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ contract GiversRegistry is Managed {
4646
/// @notice The `Drips` contract used by `addressDriver`.
4747
Drips internal immutable _drips;
4848
/// @notice The maximum balance of each token that Drips can hold.
49-
uint128 internal immutable _maxTotalBalance;
49+
uint256 internal immutable _maxTotalBalance;
5050

5151
/// @param addressDriver_ The driver to use to `give`.
5252
constructor(AddressDriver addressDriver_) {
@@ -136,7 +136,7 @@ contract GiversRegistry is Managed {
136136
address(erc20), "", address(this).balance, "Failed to wrap native tokens"
137137
);
138138
}
139-
(uint128 streamsBalance, uint128 splitsBalance) = _drips.balances(erc20);
139+
(uint256 streamsBalance, uint256 splitsBalance) = _drips.balances(erc20);
140140
uint256 maxAmt = _maxTotalBalance - streamsBalance - splitsBalance;
141141
// The balance of the `Giver` clone contract.
142142
amt = erc20.balanceOf(address(this));

test/Drips.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ contract DripsTest is Test {
643643
}
644644

645645
function testMaxBalanceIsNotTooHigh() public {
646-
uint128 maxBalance = drips.MAX_TOTAL_BALANCE();
646+
uint256 maxBalance = drips.MAX_TOTAL_BALANCE();
647647
Constants consts = new Constants();
648648
assertLe(maxBalance, consts.MAX_SPLITS_BALANCE(), "Max balance over max splits balance");
649649
assertLe(maxBalance, consts.MAX_STREAMS_BALANCE(), "Max balance over max streams balance");

0 commit comments

Comments
 (0)