-
Notifications
You must be signed in to change notification settings - Fork 50
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
Migrate PrizeDistributorV2 & Unit Tests #264
Conversation
@@ -32,6 +32,8 @@ contract DrawCalculatorV3 is IDrawCalculatorV3, Manageable { | |||
|
|||
/// @notice DrawBuffer address | |||
IDrawBuffer public immutable drawBuffer; | |||
|
|||
IPrizeConfigHistory public immutable prizeConfigHistory; |
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.
Add Natspec doc.
@@ -67,6 +70,7 @@ contract DrawCalculatorV3 is IDrawCalculatorV3, Manageable { | |||
|
|||
gaugeController = _gaugeController; | |||
drawBuffer = _drawBuffer; | |||
prizeConfigHistory = _prizeConfigHistory; | |||
|
|||
emit Deployed(_gaugeController, _drawBuffer); |
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.
Log the _prizeConfigHistory
address in the Deployed event.
* @notice The PrizeDistributorV2 contract holds Tickets (captured interest) and distributes tickets to users with winning draw claims. | ||
PrizeDistributorV2 uses an external IDrawCalculatorV3 to validate a users draw claim, before awarding payouts. To prevent users | ||
from reclaiming prizes, a payout history for each draw claim is mapped to user accounts. Reclaiming a draw can occur | ||
if an "optimal" prize was not included in previous claim pick indices and the new claims updated payout is greater then |
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.
if an "optimal" prize was not included in previous claim pick indices and the new claims updated payout is greater then | |
if an "optimal" prize was not included in previous claim pick indices and the new claims updated payout is greater than |
IDrawCalculatorV3 _drawCalculator | ||
) Ownable(_owner) { | ||
_setDrawCalculator(_drawCalculator); | ||
require(address(_token) != address(0), "PrizeDistributorV2/token-not-zero-address"); |
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.
Update to fit in 32 bytes.
require(address(_token) != address(0), "PrizeDistributorV2/token-not-zero-address"); | |
require(address(_token) != address(0), "PrizeDist/token-not-zero-address"); |
uint32[] calldata _drawIds, | ||
bytes calldata _data | ||
) external returns (uint256) { | ||
|
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.
✂️
return token; | ||
} | ||
|
||
function setDrawCalculator(IDrawCalculatorV3 _newCalculator) |
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.
Add Natspec doc
|
||
/* ============ Internal Functions ============ */ | ||
|
||
function _getDrawPayoutBalanceOf(address _user, uint32 _drawId) |
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.
Add Natspec doc
return userDrawPayouts[_user][_drawId]; | ||
} | ||
|
||
function _setDrawPayoutBalanceOf( |
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.
Add Natspec doc
* @param _newCalculator IDrawCalculatorV3 address | ||
*/ | ||
function _setDrawCalculator(IDrawCalculatorV3 _newCalculator) internal { | ||
require(address(_newCalculator) != address(0), "PrizeDistributorV2/calc-not-zero"); |
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.
require(address(_newCalculator) != address(0), "PrizeDistributorV2/calc-not-zero"); | |
require(address(_newCalculator) != address(0), "PrizeDist/calc-not-zero-address"); |
* @param _to User address | ||
* @param _amount Transfer amount | ||
*/ | ||
function _awardPayout(address _to, uint256 _amount) internal { |
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.
This function is only called once, we could inline it in the claim
function.
No description provided.