Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 committed Nov 5, 2024
1 parent 99570a5 commit 6ac6072
Show file tree
Hide file tree
Showing 4 changed files with 356 additions and 2 deletions.
2 changes: 2 additions & 0 deletions contracts/src/interfaces/IPaymentVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ interface IPaymentVault {
event GlobalSymbolsPerSecondUpdated(uint256 previousValue, uint256 newValue);
/// @notice Emitted when reservationBinInterval is updated
event ReservationBinIntervalUpdated(uint256 previousValue, uint256 newValue);
/// @notice Emitted when globalRateBinInterval is updated
event GlobalRateBinIntervalUpdated(uint256 previousValue, uint256 newValue);
/// @notice Emitted when priceParams are updated
event PriceParamsUpdated(
uint256 previousMinChargeableSize,
Expand Down
12 changes: 10 additions & 2 deletions contracts/src/payments/PaymentVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ contract PaymentVault is PaymentVaultStorage, OwnableUpgradeable {
uint256 _globalSymbolsPerSecond,
uint256 _pricePerSymbol,
uint256 _reservationBinInterval,
uint256 _priceUpdateCooldown
uint256 _priceUpdateCooldown,
uint256 _globalRateBinInterval
) public initializer {
transferOwnership(_initialOwner);
_transferOwnership(_initialOwner);

minChargeableSize = _minChargeableSize;
globalSymbolsPerSecond = _globalSymbolsPerSecond;
pricePerSymbol = _pricePerSymbol;
reservationBinInterval = _reservationBinInterval;
priceUpdateCooldown = _priceUpdateCooldown;
globalRateBinInterval = _globalRateBinInterval;

lastPriceUpdateTime = block.timestamp;
}
Expand All @@ -52,6 +54,7 @@ contract PaymentVault is PaymentVaultStorage, OwnableUpgradeable {
Reservation memory _reservation
) external onlyOwner {
_checkQuorumSplit(_reservation.quorumNumbers, _reservation.quorumSplits);
require(_reservation.endTimestamp > _reservation.startTimestamp, "end timestamp must be greater than start timestamp");
reservations[_account] = _reservation;
emit ReservationUpdated(_account, _reservation);
}
Expand Down Expand Up @@ -91,6 +94,11 @@ contract PaymentVault is PaymentVaultStorage, OwnableUpgradeable {
reservationBinInterval = _reservationBinInterval;
}

function setGlobalRateBinInterval(uint256 _globalRateBinInterval) external onlyOwner {
emit GlobalRateBinIntervalUpdated(globalRateBinInterval, _globalRateBinInterval);
globalRateBinInterval = _globalRateBinInterval;
}

function withdraw(uint256 _amount) external onlyOwner {
(bool success,) = payable(owner()).call{value: _amount}("");
require(success);
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/payments/PaymentVaultStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ abstract contract PaymentVaultStorage is IPaymentVault {
uint256 public globalSymbolsPerSecond;
/// @notice reservation bin duration
uint256 public reservationBinInterval;
/// @notice global rate bin size
uint256 public globalRateBinInterval;

/// @notice timestamp of the last price update
uint256 public lastPriceUpdateTime;
Expand Down
Loading

0 comments on commit 6ac6072

Please sign in to comment.