Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Prep for NFL playoff 2023 edition #24

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 59 additions & 55 deletions contracts/DefifaDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
return _timesFor[_gameId].mintDuration;
}

function startOf(uint256 _gameId) external view override returns (uint256) {
return _timesFor[_gameId].start;
function refundPeriodDurationOf(uint256 _gameId) external view override returns (uint256) {
return _timesFor[_gameId].refundPeriodDuration;
}

function tradeDeadlineOf(uint256 _gameId) external view override returns (uint256) {
return _timesFor[_gameId].tradeDeadline;
function startOf(uint256 _gameId) external view override returns (uint256) {
return _timesFor[_gameId].start;
}

function endOf(uint256 _gameId) external view override returns (uint256) {
Expand Down Expand Up @@ -227,10 +227,8 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
) external override returns (uint256 gameId) {
// Make sure the provided gameplay timestamps are sequential.
if (
_launchProjectData.start - _launchProjectData.mintDuration < block.timestamp ||
_launchProjectData.tradeDeadline < _launchProjectData.start ||
_launchProjectData.end < _launchProjectData.start ||
_launchProjectData.end < _launchProjectData.tradeDeadline
_launchProjectData.start - _launchProjectData.refundPeriodDuration - _launchProjectData.mintDuration < block.timestamp ||
_launchProjectData.end < _launchProjectData.start
) revert INVALID_GAME_CONFIGURATION();

// Get the game ID, optimistically knowing it will be one greater than the current count.
Expand All @@ -243,8 +241,8 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
// Store the timestamps that'll define the game phases.
_timesFor[gameId] = DefifaTimeData({
mintDuration: _launchProjectData.mintDuration,
refundPeriodDuration: _launchProjectData.refundPeriodDuration,
start: _launchProjectData.start,
tradeDeadline: _launchProjectData.tradeDeadline,
end: _launchProjectData.end
});

Expand Down Expand Up @@ -413,6 +411,7 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
metadata: JBTiered721FundingCycleMetadataResolver.packFundingCycleGlobalMetadata(
JBTiered721FundingCycleMetadata({
pauseTransfers: false,
// Reserved tokens can't be minted during this funding cycle.
pauseMintingReserves: true
})
)
Expand All @@ -430,7 +429,7 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
Gets reconfiguration data for phase 2 of the game.

@dev
Phase 2 freezes the treasury and activates the pre-programmed distribution limit to the specified splits.
Phase 2 freezes mints, but continues to allow refund redemptions.

@param _gameId The ID of the project that's being reconfigured.
@param _dataSource The data source to use.
Expand All @@ -441,33 +440,6 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
internal
returns (uint256 configuration)
{
// Get a reference to the terminal being used by the project.
DefifaStoredOpsData memory _ops = _opsFor[_gameId];

// Set fund access constraints.
JBFundAccessConstraints[] memory fundAccessConstraints = new JBFundAccessConstraints[](1);
fundAccessConstraints[0] = JBFundAccessConstraints({
terminal: _ops.terminal,
token: token,
distributionLimit: _ops.distributionLimit,
distributionLimitCurrency: _ops.terminal.currencyForToken(token),
overflowAllowance: 0,
overflowAllowanceCurrency: 0
});

// Fetch splits.
JBSplit[] memory _splits = controller.splitsStore().splitsOf(SPLIT_PROJECT_ID, SPLIT_DOMAIN, _gameId);

// Make a group split for ETH payouts.
JBGroupedSplits[] memory _groupedSplits;

if (_splits.length != 0) {
_groupedSplits = new JBGroupedSplits[](1);
_groupedSplits[0] = JBGroupedSplits({group: JBSplitsGroups.ETH_PAYOUT, splits: _splits});
}
else {
_groupedSplits = new JBGroupedSplits[](0);
}

// Get a reference to the time data.
DefifaTimeData memory _times = _timesFor[_gameId];
Expand All @@ -476,7 +448,7 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
controller.reconfigureFundingCyclesOf(
_gameId,
JBFundingCycleData ({
duration: _times.tradeDeadline - _times.start,
duration: _times.refundPeriodDuration,
// Don't mint project tokens.
weight: 0,
discountRate: 0,
Expand All @@ -489,33 +461,36 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
pauseTransfers: false
}),
reservedRate: 0,
redemptionRate: 0,
ballotRedemptionRate: 0,
// Full refunds.
redemptionRate: JBConstants.MAX_REDEMPTION_RATE,
ballotRedemptionRate: JBConstants.MAX_REDEMPTION_RATE,
// No more payments.
pausePay: true,
pauseDistributions: false,
// No redemptions.
pauseRedeem: true,
// Allow redemptions.
pauseRedeem: false,
pauseBurn: false,
allowMinting: false,
allowTerminalMigration: false,
allowControllerMigration: false,
holdFees: _ops.holdFees,
holdFees: false,
preferClaimedTokenOverride: false,
useTotalOverflowForRedemptions: false,
useDataSourceForPay: true,
useDataSourceForRedeem: true,
dataSource: _dataSource,
// Set a metadata of 1 to impose token non-transferability.
metadata: JBTiered721FundingCycleMetadataResolver.packFundingCycleGlobalMetadata(
JBTiered721FundingCycleMetadata({
pauseTransfers: false,
pauseMintingReserves: false
// Reserved tokens can't be minted during this funding cycle.
pauseMintingReserves: true
})
)
}),
0, // mustStartAtOrAfter should be ASAP
_groupedSplits,
fundAccessConstraints,
new JBGroupedSplits[](0),
new JBFundAccessConstraints[](0),
'Defifa game phase 2.'
);
}
Expand All @@ -525,14 +500,44 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
Gets reconfiguration data for phase 3 of the game.

@dev
Phase 3 imposes a trade deadline.
Phase 3 freezes the treasury and activates the pre-programmed distribution limit to the specified splits.

@param _gameId The ID of the project that's being reconfigured.
@param _dataSource The data source to use.

@return configuration The configuration of the funding cycle that was successfully reconfigured.
*/
function _queuePhase3(uint256 _gameId, address _dataSource) internal returns (uint256 configuration) {
function _queuePhase3(uint256 _gameId, address _dataSource)
internal
returns (uint256 configuration)
{
// Get a reference to the terminal being used by the project.
DefifaStoredOpsData memory _ops = _opsFor[_gameId];

// Set fund access constraints.
JBFundAccessConstraints[] memory fundAccessConstraints = new JBFundAccessConstraints[](1);
fundAccessConstraints[0] = JBFundAccessConstraints({
terminal: _ops.terminal,
token: token,
distributionLimit: _ops.distributionLimit,
distributionLimitCurrency: _ops.terminal.currencyForToken(token),
overflowAllowance: 0,
overflowAllowanceCurrency: 0
});

// Fetch splits.
JBSplit[] memory _splits = controller.splitsStore().splitsOf(SPLIT_PROJECT_ID, SPLIT_DOMAIN, _gameId);

// Make a group split for ETH payouts.
JBGroupedSplits[] memory _groupedSplits;

if (_splits.length != 0) {
_groupedSplits = new JBGroupedSplits[](1);
_groupedSplits[0] = JBGroupedSplits({group: JBSplitsGroups.ETH_PAYOUT, splits: _splits});
}
else {
_groupedSplits = new JBGroupedSplits[](0);
}

// Get a reference to the time data.
DefifaTimeData memory _times = _timesFor[_gameId];
Expand All @@ -541,7 +546,7 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
controller.reconfigureFundingCyclesOf(
_gameId,
JBFundingCycleData ({
duration: _times.end - _times.tradeDeadline,
duration: _times.end - _times.start,
// Don't mint project tokens.
weight: 0,
discountRate: 0,
Expand All @@ -565,23 +570,22 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
allowMinting: false,
allowTerminalMigration: false,
allowControllerMigration: false,
holdFees: false,
holdFees: _ops.holdFees,
preferClaimedTokenOverride: false,
useTotalOverflowForRedemptions: false,
useDataSourceForPay: true,
useDataSourceForRedeem: true,
dataSource: _dataSource,
// Set a metadata of 1 to impose token non-transferability.
metadata: JBTiered721FundingCycleMetadataResolver.packFundingCycleGlobalMetadata(
JBTiered721FundingCycleMetadata({
pauseTransfers: true,
pauseTransfers: false,
pauseMintingReserves: false
})
)
}),
0, // mustStartAtOrAfter should be ASAP
new JBGroupedSplits[](0),
new JBFundAccessConstraints[](0),
_groupedSplits,
fundAccessConstraints,
'Defifa game phase 3.'
);
}
Expand All @@ -591,7 +595,7 @@ contract DefifaDeployer is IDefifaDeployer, IERC721Receiver {
Gets reconfiguration data for phase 4 of the game.

@dev
Phase 4 removes the trade deadline and open up redemptions.
Phase 4 removes the trade deadline and opens up redemptions.

@param _gameId The ID of the project that's being reconfigured.
@param _dataSource The data source to use.
Expand Down
7 changes: 2 additions & 5 deletions contracts/DefifaGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,6 @@ contract DefifaGovernor is Governor, GovernorCountingSimple, IDefifaGovernor {
@return The delay in number of blocks.
*/
function votingDelay() public view override(IGovernor) returns (uint256) {
if (votingStartTime > block.timestamp)
viraj124 marked this conversation as resolved.
Show resolved Hide resolved
return (votingStartTime - block.timestamp) / _BLOCKTIME_SECONDS;

// no voting delay once voting is active
return 0;
}

Expand All @@ -284,7 +280,8 @@ contract DefifaGovernor is Governor, GovernorCountingSimple, IDefifaGovernor {
The amount of time that must go by for voting on a proposal to no longer be allowed.
*/
function votingPeriod() public pure override(IGovernor) returns (uint256) {
return 45818; // one week
// the max value i.e 2**64 - 1
return 18446744073709551615; // longtime
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IDefifaDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface IDefifaDeployer {

function startOf(uint256 _gameId) external view returns (uint256);

function tradeDeadlineOf(uint256 _gameId) external view returns (uint256);
function refundPeriodDurationOf(uint256 _gameId) external view returns (uint256);

function endOf(uint256 _gameId) external view returns (uint256);

Expand Down
Loading