Skip to content

Commit

Permalink
Removed DrawManager
Browse files Browse the repository at this point in the history
  • Loading branch information
asselstine committed Feb 14, 2024
1 parent 882296e commit abcfc12
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 46 deletions.
21 changes: 7 additions & 14 deletions src/PrizePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.19;

import { SafeCast } from "openzeppelin/utils/math/SafeCast.sol";
import { Ownable } from "openzeppelin/access/Ownable.sol";
import { IERC20 } from "openzeppelin/token/ERC20/IERC20.sol";
import { SafeERC20 } from "openzeppelin/token/ERC20/utils/SafeERC20.sol";
import { SD59x18, convert, sd } from "prb-math/SD59x18.sol";
Expand Down Expand Up @@ -120,6 +119,7 @@ error ClaimPeriodExpired();
struct ConstructorParams {
IERC20 prizeToken;
TwabController twabController; // 160bits
address drawManager;
uint48 drawPeriodSeconds;
uint48 firstDrawOpensAt; // 256bits WORD END
uint24 grandPrizePeriodDraws;
Expand All @@ -134,7 +134,7 @@ struct ConstructorParams {
* @author PoolTogether Inc Team
* @notice The Prize Pool holds the prize liquidity and allows vaults to claim prizes.
*/
contract PrizePool is TieredLiquidityDistributor, Ownable {
contract PrizePool is TieredLiquidityDistributor {
using SafeERC20 for IERC20;

/* ============ Events ============ */
Expand Down Expand Up @@ -279,7 +279,6 @@ contract PrizePool is TieredLiquidityDistributor, Ownable {
params.reserveShares,
params.grandPrizePeriodDraws
)
Ownable()
{
if (params.drawTimeout == 0) {
revert DrawTimeoutIsZero();
Expand Down Expand Up @@ -307,6 +306,11 @@ contract PrizePool is TieredLiquidityDistributor, Ownable {
revert IncompatibleTwabPeriodOffset();
}

if (params.drawManager == address(0)) {
revert DrawManagerIsZeroAddress();
}

drawManager = params.drawManager;
drawTimeout = params.drawTimeout;
prizeToken = params.prizeToken;
twabController = params.twabController;
Expand All @@ -326,17 +330,6 @@ contract PrizePool is TieredLiquidityDistributor, Ownable {

/* ============ External Write Functions ============ */

/// @notice Allows a caller to set the DrawManager if not already set.
/// @param _drawManager The draw manager
function setDrawManager(address _drawManager) external onlyOwner {
if (_drawManager == address(0)) {
revert DrawManagerIsZeroAddress();
}
drawManager = _drawManager;

emit DrawManagerSet(_drawManager);
}

/// @notice Contributes prize tokens on behalf of the given vault.
/// @dev The tokens should have already been transferred to the prize pool.
/// @dev The prize pool balance will be checked to ensure there is at least the given amount to deposit.
Expand Down
35 changes: 7 additions & 28 deletions test/PrizePool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ contract PrizePoolTest is Test {

TwabController public twabController;

address drawManager;

address sender1 = 0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990;
address sender2 = 0x4008Ed96594b645f057c9998a2924545fAbB6545;
address sender3 = 0x796486EBd82E427901511d130Ece93b94f06a980;
Expand Down Expand Up @@ -120,13 +122,14 @@ contract PrizePoolTest is Test {
abi.encode(drawPeriodSeconds)
);

address drawManager = address(this);
drawManager = address(this);
vault = address(this);
vault2 = address(0x1234);

params = ConstructorParams(
prizeToken,
twabController,
drawManager,
drawPeriodSeconds,
firstDrawOpensAt,
grandPrizePeriodDraws,
Expand All @@ -137,10 +140,6 @@ contract PrizePoolTest is Test {
);

prizePool = new PrizePool(params);

vm.expectEmit();
emit DrawManagerSet(drawManager);
prizePool.setDrawManager(drawManager);
}

function testConstructor() public {
Expand Down Expand Up @@ -827,6 +826,7 @@ contract PrizePoolTest is Test {
params = ConstructorParams(
prizeToken,
twabController,
drawManager,
drawPeriodSeconds,
firstDrawOpensAt,
grandPrizePeriodDraws,
Expand All @@ -851,6 +851,7 @@ contract PrizePoolTest is Test {
params = ConstructorParams(
prizeToken,
twabController,
drawManager,
drawPeriodSeconds,
firstDrawOpensAt,
grandPrizePeriodDraws,
Expand Down Expand Up @@ -976,26 +977,6 @@ contract PrizePoolTest is Test {
assertEq(prizePool.getTierRemainingLiquidity(2), 100e18);
}

function testSetDrawManager() public {
address bob = makeAddr("bob");
vm.expectEmit();
emit DrawManagerSet(address(bob));
prizePool.setDrawManager(address(bob));
assertEq(prizePool.drawManager(), address(bob));
}

function testSetDrawManager_DrawManagerIsZeroAddress() public {
vm.expectRevert(abi.encodeWithSelector(DrawManagerIsZeroAddress.selector));
prizePool.setDrawManager(address(0));
}

function testSetDrawManager_notOwner() public {
vm.startPrank(address(1));
vm.expectRevert("Ownable: caller is not the owner");
prizePool.setDrawManager(address(this));
vm.stopPrank();
}

function testIsWinner_noDraw() public {
vm.expectRevert(abi.encodeWithSelector(NoDrawsAwarded.selector));
prizePool.isWinner(address(this), msg.sender, 10, 0);
Expand Down Expand Up @@ -1712,8 +1693,6 @@ contract PrizePoolTest is Test {
}

function newPrizePool() public returns (PrizePool) {
PrizePool _prizePool = new PrizePool(params);
_prizePool.setDrawManager(address(this));
return _prizePool;
return new PrizePool(params);
}
}
5 changes: 1 addition & 4 deletions test/invariants/helpers/PrizePoolFuzzHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ contract PrizePoolFuzzHarness is CommonBase, StdCheats, StdUtils, CurrentTimeCon
ConstructorParams memory params = ConstructorParams(
token,
twabController,
drawManager,
drawPeriodSeconds,
awardDrawStartsAt,
grandPrizePeriod,
Expand All @@ -79,10 +80,6 @@ contract PrizePoolFuzzHarness is CommonBase, StdCheats, StdUtils, CurrentTimeCon
// console2.log("constructor 7");

prizePool = new PrizePool(params);

// console2.log("constructor 8");

prizePool.setDrawManager(drawManager);
}

function deposit(uint88 _amount, uint256 actorSeed) public useCurrentTime prankActor(actorSeed) {
Expand Down

0 comments on commit abcfc12

Please sign in to comment.