Skip to content
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

Merged
merged 1 commit into from
May 17, 2022

Conversation

kamescg
Copy link
Contributor

@kamescg kamescg commented May 13, 2022

No description provided.

@kamescg kamescg requested a review from PierrickGT May 13, 2022 15:47
@kamescg kamescg self-assigned this May 13, 2022
@linear
Copy link

linear bot commented May 13, 2022

@@ -32,6 +32,8 @@ contract DrawCalculatorV3 is IDrawCalculatorV3, Manageable {

/// @notice DrawBuffer address
IDrawBuffer public immutable drawBuffer;

IPrizeConfigHistory public immutable prizeConfigHistory;
Copy link
Contributor

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);
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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");
Copy link
Contributor

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.

Suggested change
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) {

Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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(
Copy link
Contributor

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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
Copy link
Contributor

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.

@kamescg kamescg marked this pull request as ready for review May 17, 2022 01:40
@kamescg kamescg merged commit 954c9c1 into staging May 17, 2022
@kamescg kamescg deleted the pool-2264-migrate-prizedistributor branch May 17, 2022 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants