Skip to content

Commit

Permalink
Merge with latest changes from feature/pool-191
Browse files Browse the repository at this point in the history
  • Loading branch information
robsecord committed Jun 20, 2020
2 parents ca01771 + aa7fead commit 768eaf8
Show file tree
Hide file tree
Showing 26 changed files with 343 additions and 842 deletions.
630 changes: 89 additions & 541 deletions .openzeppelin/kovan.json

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions .openzeppelin/project.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
{
"manifestVersion": "2.2",
"contracts": {
"PeriodicPrizePoolFactory": "PeriodicPrizePoolFactory",
"PrizePoolBuilder": "PrizePoolBuilder",
"TicketFactory": "TicketFactory",
"RNGBlockhash": "RNGBlockhash",
"SingleRandomWinnerPrizePoolBuilder": "SingleRandomWinnerPrizePoolBuilder",
"SingleRandomWinnerPrizeStrategyFactory": "SingleRandomWinnerPrizeStrategyFactory",
"CompoundYieldServiceFactory": "CompoundYieldServiceFactory",
"PrizePoolModuleManagerFactory": "PrizePoolModuleManagerFactory",
"CreditFactory": "CreditFactory",
"TimelockFactory": "TimelockFactory",
"SponsorshipFactory": "SponsorshipFactory",
"InterestTrackerFactory": "InterestTrackerFactory"
"CompoundPeriodicPrizePoolFactory": "CompoundPeriodicPrizePoolFactory",
"ControlledTokenFactory": "ControlledTokenFactory"
},
"dependencies": {},
"name": "PoolTogether3",
Expand Down
2 changes: 1 addition & 1 deletion .oz-migrate/kovan
Original file line number Diff line number Diff line change
@@ -1 +1 @@
120
40
32 changes: 0 additions & 32 deletions contracts/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import "@openzeppelin/contracts-ethereum-package/contracts/introspection/IERC182
library Constants {
IERC1820Registry public constant REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);

// keccak("PoolTogetherV3/YieldServiceInterface")
bytes32 public constant YIELD_SERVICE_INTERFACE_HASH =
0x4ed5789bd358cc9b40d603c60561144ea3ac89cb64ba5d7aab9a193d06e99978;

// keccak256("ERC777TokensSender")
bytes32 public constant TOKENS_SENDER_INTERFACE_HASH =
0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895;
Expand All @@ -20,32 +16,4 @@ library Constants {
// keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC"));
bytes32 public constant ACCEPT_MAGIC =
0xa2ef4600d742022d532d4747cb3547474667d6f13804902513b2ec01c848f4b4;

// keccak256("PoolTogetherV3/TicketInterface")
bytes32 public constant TICKET_INTERFACE_HASH =
0xf22dc5a0b79862d03b1bd7a85ef07c37d8ab6be34838cd9c393ec1d671b9c818;

// keccak256("PoolTogetherV3/InterestTrackerInterface")
bytes32 public constant INTEREST_TRACKER_INTERFACE_HASH =
0xd024f1a00d323e421da1833cf865a55a44409b62b7315e96bce12d82e75eff6e;

// keccak256("PoolTogetherV3/SponsorshipCreditInterface")
bytes32 public constant SPONSORSHIP_CREDIT_INTERFACE_HASH =
0x65cc06ccca4f9e926e9e293d406c9b96ca68db73c98d6da23a19c26a179ff54a;

// keccak256("PoolTogetherV3/TicketCreditInterface")
bytes32 public constant TICKET_CREDIT_INTERFACE_HASH =
0xc256d403e0180e5f30c32c2bc8e872cd8283e97e05cbf1af15a2c10763ba659a;

// keccak256("PoolTogetherV3/SponsorshipInterface")
bytes32 public constant SPONSORSHIP_INTERFACE_HASH =
0xfdba083ea3843dc5ff273fd3f7fbc2e59baa10a2c2af369fca115112fda76d95;

// keccak256("PoolTogetherV3/TimelockInterface")
bytes32 public constant TIMELOCK_INTERFACE_HASH =
0x42e4d9828bdc3604a980d7d232f855652139270154bf191927d85bcf165e50a5;

// keccak256("PoolTogetherV3/PrizePoolInterface")
bytes32 public constant PRIZE_POOL_INTERFACE_HASH =
0xa9132fceb7d69949767df6f1c2fa3901378dc016d53edf4827074b8fa1271004;
}
9 changes: 2 additions & 7 deletions contracts/builder/PrizePoolBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,29 @@ contract PrizePoolBuilder is Initializable {
CompoundPeriodicPrizePoolFactory public periodicPrizePoolFactory;
TicketFactory public ticketFactory;
ControlledTokenFactory public controlledTokenFactory;
RNGInterface public rng;
address public trustedForwarder;

function initialize (
GovernorInterface _governor,
CompoundPeriodicPrizePoolFactory _periodicPrizePoolFactory,
TicketFactory _ticketFactory,
ControlledTokenFactory _controlledTokenFactory,
RNGInterface _rng,
address _trustedForwarder
) public initializer {
require(address(_governor) != address(0), "governor cannot be zero");
require(address(_periodicPrizePoolFactory) != address(0), "prize pool factory cannot be zero");
require(address(_ticketFactory) != address(0), "ticket factory cannot be zero");
require(address(_rng) != address(0), "rng cannot be zero");
require(address(_controlledTokenFactory) != address(0), "controlled token factory cannot be zero");
governor = _governor;
periodicPrizePoolFactory = _periodicPrizePoolFactory;
ticketFactory = _ticketFactory;
controlledTokenFactory = _controlledTokenFactory;
rng = _rng;
trustedForwarder = _trustedForwarder;
}

function createPeriodicPrizePool(
CTokenInterface _cToken,
PrizeStrategyInterface _prizeStrategy,
address _prizeStrategy,
uint256 _prizePeriodSeconds,
string memory _ticketName,
string memory _ticketSymbol,
Expand Down Expand Up @@ -82,14 +78,13 @@ contract PrizePoolBuilder is Initializable {
function initializePrizePool(
CompoundPeriodicPrizePool prizePool,
CTokenInterface _cToken,
PrizeStrategyInterface _prizeStrategy,
address _prizeStrategy,
uint256 _prizePeriodSeconds
) internal {
prizePool.initialize(
trustedForwarder,
governor,
_prizeStrategy,
rng,
_prizePeriodSeconds,
_cToken
);
Expand Down
8 changes: 6 additions & 2 deletions contracts/builder/SingleRandomWinnerPrizePoolBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "./PrizePoolBuilder.sol";
contract SingleRandomWinnerPrizePoolBuilder is Initializable {

PrizePoolBuilder public prizePoolBuilder;
RNGInterface public rng;
SingleRandomWinnerPrizeStrategyFactory public prizeStrategyFactory;

event SingleRandomWinnerPrizePoolCreated(
Expand All @@ -20,11 +21,14 @@ contract SingleRandomWinnerPrizePoolBuilder is Initializable {

function initialize (
PrizePoolBuilder _prizePoolBuilder,
RNGInterface _rng,
SingleRandomWinnerPrizeStrategyFactory _prizeStrategyFactory
) public initializer {
require(address(_prizePoolBuilder) != address(0), "prize pool builder must be defined");
require(address(_rng) != address(0), "rng cannot be zero");
require(address(_prizeStrategyFactory) != address(0), "prize strategy factory must be defined");
prizePoolBuilder = _prizePoolBuilder;
rng = _rng;
prizeStrategyFactory = _prizeStrategyFactory;
}

Expand All @@ -38,11 +42,11 @@ contract SingleRandomWinnerPrizePoolBuilder is Initializable {
) external returns (SingleRandomWinnerPrizeStrategy) {

SingleRandomWinnerPrizeStrategy prizeStrategy = prizeStrategyFactory.createSingleRandomWinner();
prizeStrategy.initialize();
prizeStrategy.initialize(prizePoolBuilder.trustedForwarder(), rng);

PeriodicPrizePool prizePool = prizePoolBuilder.createPeriodicPrizePool(
cToken,
prizeStrategy,
address(prizeStrategy),
prizePeriodInSeconds,
_ticketName,
_ticketSymbol,
Expand Down
4 changes: 1 addition & 3 deletions contracts/periodic-prize-pool/CompoundPeriodicPrizePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ contract CompoundPeriodicPrizePool is PeriodicPrizePool, CompoundYieldService {
function initialize (
address _trustedForwarder,
GovernorInterface _governor,
PrizeStrategyInterface _prizeStrategy,
RNGInterface _rng,
address _prizeStrategy,
uint256 _prizePeriodSeconds,
CTokenInterface _cToken
) public initializer {
PeriodicPrizePool.initialize(
_trustedForwarder,
_governor,
_prizeStrategy,
_rng,
_prizePeriodSeconds
);
cToken = _cToken;
Expand Down
4 changes: 4 additions & 0 deletions contracts/periodic-prize-pool/InterestTracker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ abstract contract InterestTracker is AbstractYieldService {
}

function captureInterest() internal returns (uint256) {
// console.log("POKE!");
poke();
uint256 interest = newInterest;
newInterest = 0;

emit InterestCaptured(msg.sender, interest);

// console.log("INTEREST CAPTURED: %", interest);

return interest;
}

Expand All @@ -87,6 +90,7 @@ abstract contract InterestTracker is AbstractYieldService {

function poke() internal {
uint256 unaccountedBalance = _unaccountedBalance();
// console.log("poke() unaccounted: %s", unaccountedBalance);
if (unaccountedBalance > 0) {
// console.log("CAPTURED %s", unaccountedBalance / 1 ether);
_capture(unaccountedBalance);
Expand Down
Loading

0 comments on commit 768eaf8

Please sign in to comment.