-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Payments storage packing #942
Open
0x0aa0
wants to merge
5
commits into
master
Choose a base branch
from
payments-storage-packing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,12 +25,12 @@ contract PaymentVault is PaymentVaultStorage, OwnableUpgradeable { | |
|
||
function initialize( | ||
address _initialOwner, | ||
uint256 _minNumSymbols, | ||
uint256 _globalSymbolsPerBin, | ||
uint256 _pricePerSymbol, | ||
uint256 _reservationBinInterval, | ||
uint256 _priceUpdateCooldown, | ||
uint256 _globalRateBinInterval | ||
uint128 _minNumSymbols, | ||
uint128 _globalSymbolsPerBin, | ||
uint128 _pricePerSymbol, | ||
uint128 _reservationBinInterval, | ||
uint128 _priceUpdateCooldown, | ||
uint128 _globalRateBinInterval | ||
) public initializer { | ||
_transferOwnership(_initialOwner); | ||
|
||
|
@@ -41,7 +41,7 @@ contract PaymentVault is PaymentVaultStorage, OwnableUpgradeable { | |
priceUpdateCooldown = _priceUpdateCooldown; | ||
globalRateBinInterval = _globalRateBinInterval; | ||
|
||
lastPriceUpdateTime = block.timestamp; | ||
lastPriceUpdateTime = uint128(block.timestamp); | ||
} | ||
|
||
/** | ||
|
@@ -68,9 +68,9 @@ contract PaymentVault is PaymentVaultStorage, OwnableUpgradeable { | |
} | ||
|
||
function setPriceParams( | ||
uint256 _minNumSymbols, | ||
uint256 _pricePerSymbol, | ||
uint256 _priceUpdateCooldown | ||
uint128 _minNumSymbols, | ||
uint128 _pricePerSymbol, | ||
uint128 _priceUpdateCooldown | ||
) external onlyOwner { | ||
require(block.timestamp >= lastPriceUpdateTime + priceUpdateCooldown, "price update cooldown not surpassed"); | ||
emit PriceParamsUpdated( | ||
|
@@ -81,20 +81,20 @@ contract PaymentVault is PaymentVaultStorage, OwnableUpgradeable { | |
pricePerSymbol = _pricePerSymbol; | ||
minNumSymbols = _minNumSymbols; | ||
priceUpdateCooldown = _priceUpdateCooldown; | ||
lastPriceUpdateTime = block.timestamp; | ||
lastPriceUpdateTime = uint128(block.timestamp); | ||
} | ||
|
||
function setGlobalSymbolsPerBin(uint256 _globalSymbolsPerBin) external onlyOwner { | ||
function setGlobalSymbolsPerBin(uint128 _globalSymbolsPerBin) external onlyOwner { | ||
emit GlobalSymbolsPerBinUpdated(globalSymbolsPerBin, _globalSymbolsPerBin); | ||
globalSymbolsPerBin = _globalSymbolsPerBin; | ||
} | ||
|
||
function setReservationBinInterval(uint256 _reservationBinInterval) external onlyOwner { | ||
function setReservationBinInterval(uint128 _reservationBinInterval) external onlyOwner { | ||
emit ReservationBinIntervalUpdated(reservationBinInterval, _reservationBinInterval); | ||
reservationBinInterval = _reservationBinInterval; | ||
} | ||
|
||
function setGlobalRateBinInterval(uint256 _globalRateBinInterval) external onlyOwner { | ||
function setGlobalRateBinInterval(uint128 _globalRateBinInterval) external onlyOwner { | ||
emit GlobalRateBinIntervalUpdated(globalRateBinInterval, _globalRateBinInterval); | ||
globalRateBinInterval = _globalRateBinInterval; | ||
} | ||
|
@@ -116,8 +116,8 @@ contract PaymentVault is PaymentVaultStorage, OwnableUpgradeable { | |
} | ||
|
||
function _deposit(address _account, uint256 _amount) internal { | ||
onDemandPayments[_account] += _amount; | ||
emit OnDemandPaymentUpdated(_account, _amount, onDemandPayments[_account]); | ||
onDemandPayments[_account] += uint128(_amount); | ||
emit OnDemandPaymentUpdated(_account, uint128(_amount), uint128(onDemandPayments[_account])); | ||
} | ||
|
||
/// @notice Fetches the current reservation for an account | ||
|
@@ -134,13 +134,13 @@ contract PaymentVault is PaymentVaultStorage, OwnableUpgradeable { | |
} | ||
|
||
/// @notice Fetches the current total on demand balance of an account | ||
function getOnDemandAmount(address _account) external view returns (uint256) { | ||
function getOnDemandAmount(address _account) external view returns (uint128) { | ||
return onDemandPayments[_account]; | ||
} | ||
|
||
/// @notice Fetches the current total on demand balances for a set of accounts | ||
function getOnDemandAmounts(address[] memory _accounts) external view returns (uint256[] memory _payments) { | ||
_payments = new uint256[](_accounts.length); | ||
function getOnDemandAmounts(address[] memory _accounts) external view returns (uint128[] memory _payments) { | ||
_payments = new uint128[](_accounts.length); | ||
for(uint256 i; i < _accounts.length; ++i){ | ||
_payments[i] = onDemandPayments[_accounts[i]]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we validate if |
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much gas savings are we talking here? I assume we're going to price this in mwei, but I wonder if we should just keep this in wei if the cost savings are trivial. This allows us to express any pricing better granularity
(If we do need to use mwei, can we document that?)