QuestBoard

Storage

GAUGE_CONTROLLER

address GAUGE_CONTROLLER

Address of the Curve Gauge Controller

nextID

uint256 nextID

ID for the next Quest to be created

quests

mapping(uint256 => struct IQuestBoard.Quest) quests

List of Quest (indexed by ID)

periodsByQuest

mapping(uint256 => mapping(uint256 => struct IQuestBoard.QuestPeriod)) periodsByQuest

Mapping of all QuestPeriod struct for each period of each Quest

questDistributors

mapping(uint256 => address) questDistributors

Mapping of Distributors used by each Quest to send rewards

questWithdrawableAmount

mapping(uint256 => uint256) questWithdrawableAmount

Amount not distributed, for Quest creators to redeem

platformFeeRatio

uint256 platformFeeRatio

Platform fees ratio (in BPS)

customPlatformFeeRatio

mapping(address => uint256) customPlatformFeeRatio

Mapping of specific fee ratio for some Quest creators

objectiveMinimalThreshold

uint256 objectiveMinimalThreshold

Minimum Objective required

questChest

address questChest

Address of the Chest to receive platform fees

distributor

address distributor

Address of the reward Distributor contract

biasCalculator

address biasCalculator

Address of the Bias Calculator Module

approvedManagers

mapping(address => bool) approvedManagers

Mapping of addresses allowed to call manager methods

whitelistedTokens

mapping(address => bool) whitelistedTokens

Whitelisted tokens that can be used as reward tokens

minRewardPerVotePerToken

mapping(address => uint256) minRewardPerVotePerToken

Min rewardPerVote per token (to avoid spam creation of useless Quest)

isKilled

bool isKilled

Boolean, true if the cotnract was killed, stopping main user functions

killTs

uint256 killTs

Timestamp when the contract was killed

Structs

QuestPeriod

struct QuestPeriod {
    uint256 rewardAmountPerPeriod;
    uint256 minRewardPerVote;
    uint256 maxRewardPerVote;
    uint256 minObjectiveVotes;
    uint256 maxObjectiveVotes;
    uint256 rewardAmountDistributed;
    uint48 periodStart;
    QuestDataTypes.PeriodState currentState;
}

Struct for a Period of a Quest

  • rewardAmountPerPeriod : Total reward amount that can be distributed for that period

  • minRewardPerVote : Min Amount of reward for each vote (for 1 veToken)

  • maxRewardPerVote : Max Amount of reward for each vote (for 1 veToken)

  • minObjectiveVotes : Min Target Bias for the Gauge

  • maxObjectiveVotes : Max Target Bias for the Gauge

  • rewardAmountDistributed : Amount of reward to distribute, at period closing

  • periodStart : Timestamp of the Period start

  • currentState : Current state of the Period

Quest

struct Quest {
    address creator;
    address rewardToken;
    address gauge;
    uint48 duration;
    uint48 periodStart;
    uint256 totalRewardAmount;
    QuestTypes types;
}

Struct holding the parameters of the Quest common for all periods

  • creator : Address of the Quest creator

  • rewardToken : Address of the ERC20 used for rewards

  • gauge : Address of the target Gauge

  • duration : Total number of periods for the Quest

  • periodStart : Timestamp where the 1st QuestPeriod starts

  • totalRewardAmount : Total amount of rewards paid for this Quest

  • types : Quest Types

QuestTypes

struct QuestTypes {
    QuestDataTypes.QuestVoteType voteType;
    QuestDataTypes.QuestRewardsType rewardsType;
    QuestDataTypes.QuestCloseType closeType;
}

Struct with all the Quest types

Events

Init

event Init(address distributor, address biasCalculator)

Event emitted when the Board is Initialized

NewQuest

event NewQuest(uint256 questID, address creator, address gauge, address rewardToken, uint48 duration, uint256 startPeriod)

Event emitted when a new Quest is created

ExtendQuestDuration

event ExtendQuestDuration(uint256 questID, uint256 addedDuration, uint256 addedRewardAmount)

Event emitted when the Quest duration is extended

UpdateQuestParameters

event UpdateQuestParameters(uint256 questID, uint256 updatePeriod, uint256 newMinRewardPerVote, uint256 newMaxRewardPerVote, uint256 addedPeriodRewardAmount)

Event emitted when a Quest parameters are updated

WithdrawUnusedRewards

event WithdrawUnusedRewards(uint256 questID, address recipient, uint256 amount)

Event emitted when Quest creator withdraw undistributed rewards

PeriodClosed

event PeriodClosed(uint256 questID, uint256 period)

Event emitted when a Period is Closed

PeriodBiasFixed

event PeriodBiasFixed(uint256 questID, uint256 period, uint256 newBias)

Event emitted when a Period Bias is fixed

WhitelistToken

event WhitelistToken(address token, uint256 minRewardPerVote)

Event emitted when a new reward token is whitelisted

UpdateRewardToken

event UpdateRewardToken(address token, uint256 newMinRewardPerVote)

Event emitted when a reward token parameter is updated

Killed

event Killed(uint256 killTime)

Event emitted when the contract is killed

Unkilled

event Unkilled(uint256 unkillTime)

Event emitted when the contract is unkilled

EmergencyWithdraw

event EmergencyWithdraw(uint256 questID, address recipient, uint256 amount)

Event emitted when the Quest creator withdraw all unused funds (if the contract was killed)

ApprovedManager

event ApprovedManager(address manager)

Event emitted when a new manager is approved

RemovedManager

event RemovedManager(address manager)

Event emitted when a manager is removed

ChestUpdated

event ChestUpdated(address oldChest, address newChest)

Event emitted when the Chest address is updated

SetCustomFeeRatio

event SetCustomFeeRatio(address creator, uint256 customFeeRatio)

Event emitted when a custom fee ratio is set for a given address

DistributorUpdated

event DistributorUpdated(address oldDistributor, address newDistributor)

Event emitted when the Distributor address is updated

PlatformFeeRatioUpdated

event PlatformFeeRatioUpdated(uint256 oldFeeRatio, uint256 newFeeRatio)

Event emitted when the fee ratio is updated

MinObjectiveUpdated

event MinObjectiveUpdated(uint256 oldMinObjective, uint256 newMinObjective)

Event emitted when the minimum objective of votes is updated

Modifiers

onlyAllowed

modifier onlyAllowed()

Check the caller is either the admin or an approved manager

isAlive

modifier isAlive()

Check that contract was not killed

isInitialized

modifier isInitialized()

Check that contract was initialized

Constructor

constructor(address _gaugeController, address _chest) public

init

function init(address _distributor, address _biasCalculator) external

Initialize the contract

Parameters

View Methods

getCurrentPeriod

function getCurrentPeriod() public view returns (uint256)

Returns the current Period for the contract

Returns the current Period for the contract

getQuestIdsForPeriod

function getQuestIdsForPeriod(uint256 period) external view returns (uint256[])

Returns the list of all Quest IDs active on a given period

Returns the list of all Quest IDs active on a given period

Parameters

Return Values

getQuestIdsForPeriodForGauge

function getQuestIdsForPeriodForGauge(address gauge, uint256 period) external view returns (uint256[])

Returns the list of all Quest IDs active on a given period

Returns the list of all Quest IDs active on a given period

Parameters

Return Values

getAllPeriodsForQuestId

function getAllPeriodsForQuestId(uint256 questId) external view returns (uint48[])

Returns all periods for a Quest

Returns all period timestamps for a Quest ID

Parameters

Return Values

getAllQuestPeriodsForQuestId

function getAllQuestPeriodsForQuestId(uint256 questId) external view returns (struct IQuestBoard.QuestPeriod[])

Returns all QuestPeriod of a given Quest

Returns all QuestPeriod of a given Quest ID

Parameters

Return Values

_getRemainingDuration

function _getRemainingDuration(uint256 questID) internal view returns (uint256)

Returns the number of periods to come for a given Quest

Returns the number of periods to come for a given Quest

Parameters

Return Values

getCurrentReducedBias

function getCurrentReducedBias(uint256 questID) external view returns (uint256)

Returns the current reduced bias of a gauge for a given Quest

Returns the current reduced bias of a gauge for a given Quest

Parameters

Return Values

getQuestCreator

function getQuestCreator(uint256 questID) external view returns (address)

Returns the address of the Quest creator

Returns the address of the Quest creator

Parameters

Return Values

State-changing Methods

createFixedQuest

function createFixedQuest(address gauge, address rewardToken, bool startNextPeriod, uint48 duration, uint256 rewardPerVote, uint256 totalRewardAmount, uint256 feeAmount, enum QuestDataTypes.QuestVoteType voteType, enum QuestDataTypes.QuestCloseType closeType, address[] voterList) external returns (uint256)

Creates a fixed rewards Quest based on the given parameters

Creates a Quest based on the given parameters & the given types with the Fixed Rewards type

Parameters

Return Values

createRangedQuest

function createRangedQuest(address gauge, address rewardToken, bool startNextPeriod, uint48 duration, uint256 minRewardPerVote, uint256 maxRewardPerVote, uint256 totalRewardAmount, uint256 feeAmount, enum QuestDataTypes.QuestVoteType voteType, enum QuestDataTypes.QuestCloseType closeType, address[] voterList) external returns (uint256)

Creates a ranged rewards Quest based on the given parameters

Creates a Quest based on the given parameters & the given types with the Ranged Rewards type

Parameters

Return Values

_createQuest

function _createQuest(address gauge, address rewardToken, struct IQuestBoard.QuestTypes types, bool startNextPeriod, uint48 duration, uint256 minRewardPerVote, uint256 maxRewardPerVote, uint256 totalRewardAmount, uint256 feeAmount, address[] voterList) internal returns (uint256 newQuestID)

Creates a Quest based on the given parameters

Creates a Quest based on the given parameters & the given types

Parameters

Return Values

extendQuestDuration

function extendQuestDuration(uint256 questID, uint48 addedDuration, uint256 addedRewardAmount, uint256 feeAmount) external

Increases the duration of a Quest

Adds more QuestPeriods and extends the duration of a Quest

Parameters

updateQuestParameters

function updateQuestParameters(uint256 questID, uint256 newMinRewardPerVote, uint256 newMaxRewardPerVote, uint256 addedPeriodRewardAmount, uint256 addedTotalRewardAmount, uint256 feeAmount) external

Updates the parametes of the Quest

Updates the reward/vote parameters, allowing to update the Quest objectives too

Parameters

withdrawUnusedRewards

function withdrawUnusedRewards(uint256 questID, address recipient) external

Withdraw all undistributed rewards from Closed Quest Periods

Withdraw all undistributed rewards from Closed Quest Periods

Parameters

emergencyWithdraw

function emergencyWithdraw(uint256 questID, address recipient) external

Emergency withdraws all undistributed rewards from Closed Quest Periods & all rewards for Active Periods

Emergency withdraws all undistributed rewards from Closed Quest Periods & all rewards for Active Periods

Parameters

Internal Methods

_getFeeRatio

function _getFeeRatio(address questCreator) internal view returns (uint256)

Get the fee ratio for a given Quest creator

Returns the custom fee ratio for a Quest creator if set, otherwise returns the general fee ratio

Parameters

Return Values

_getDistributionAmount

function _getDistributionAmount(enum QuestDataTypes.QuestRewardsType questRewardType, uint256 periodBias, struct IQuestBoard.QuestPeriod _questPeriod) internal pure returns (uint256)

Gets the amount of rewards to be distributed for the period

Gets the amount of rewards to be distributed for the

Parameters

Return Values

_handleUndistributedRewards

function _handleUndistributedRewards(uint256 questID, uint256 currentPeriod, enum QuestDataTypes.QuestCloseType questCloseType, address rewardToken, uint256 undistributedAmount) internal

Handles the Quest period undistributed rewards

Handles the Quest period undistributed rewards based on the Quest Close type

Parameters

_closeQuestPeriod

function _closeQuestPeriod(uint256 period, uint256 questID) internal returns (bool)

Closes the Period, and all QuestPeriods for this period

Closes all QuestPeriod for the given period, calculating rewards to distribute & send them to distributor

Parameters

Manager Methods

closeQuestPeriod

function closeQuestPeriod(uint256 period) external returns (uint256 closed, uint256 skipped)

Closes the Period, and all QuestPeriods for this period

Closes all QuestPeriod for the given period, calculating rewards to distribute & send them to distributor

Parameters

closePartOfQuestPeriod

function closePartOfQuestPeriod(uint256 period, uint256[] questIDs) external returns (uint256 closed, uint256 skipped)

Closes the given QuestPeriods for the Period

Closes the given QuestPeriods for the Period, calculating rewards to distribute & send them to distributor

Parameters

_addMerkleRoot

function _addMerkleRoot(uint256 questID, uint256 period, uint256 totalAmount, bytes32 merkleRoot) internal

Sets the QuestPeriod as disitrbuted, and adds the MerkleRoot to the Distributor contract

Parameters

addMerkleRoot

function addMerkleRoot(uint256 questID, uint256 period, uint256 totalAmount, bytes32 merkleRoot) external

Sets the QuestPeriod as disitrbuted, and adds the MerkleRoot to the Distributor contract

_internal call to addMerkleRoot()

Parameters

addMultipleMerkleRoot

function addMultipleMerkleRoot(uint256[] questIDs, uint256 period, uint256[] totalAmounts, bytes32[] merkleRoots) external

Sets a list of QuestPeriods as disitrbuted, and adds the MerkleRoot to the Distributor contract for each

_Loop and internal call to addMerkleRoot()

Parameters

whitelistToken

function whitelistToken(address newToken, uint256 minRewardPerVote) public

Whitelists a reward token

Whitelists a reward token

Parameters

whitelistMultipleTokens

function whitelistMultipleTokens(address[] newTokens, uint256[] minRewardPerVotes) external

Whitelists a list of reward tokens

Whitelists a list of reward tokens

Parameters

updateRewardToken

function updateRewardToken(address newToken, uint256 newMinRewardPerVote) external

Updates a reward token parameters

Updates a reward token parameters

Parameters

Admin Methods

fixQuestPeriodBias

function fixQuestPeriodBias(uint256 period, uint256 questID, uint256 correctReducedBias) external

Approves a new address as manager

Approves a new address as manager

Parameters

approveManager

function approveManager(address newManager) external

Approves a new address as manager

Approves a new address as manager

Parameters

removeManager

function removeManager(address manager) external

Removes an address from the managers

Removes an address from the managers

Parameters

updateChest

function updateChest(address chest) external

Updates the Chest address

Updates the Chest address

Parameters

updateDistributor

function updateDistributor(address newDistributor) external

Updates the Distributor address

Updates the Distributor address

Parameters

updatePlatformFee

function updatePlatformFee(uint256 newFee) external

Updates the Platfrom fees BPS ratio

Updates the Platfrom fees BPS ratio

Parameters

updateMinObjective

function updateMinObjective(uint256 newMinObjective) external

Updates the min objective value

Updates the min objective value

Parameters

setCustomFeeRatio

function setCustomFeeRatio(address user, uint256 customFeeRatio) external

Sets a custom fee ratio for a given address

Sets a custom fee ratio for a given address

Parameters

recoverERC20

function recoverERC20(address token) external returns (bool)

Recovers ERC2O tokens sent by mistake to the contract

Recovers ERC2O tokens sent by mistake to the contract

Parameters

Return Values

killBoard

function killBoard() external

Kills the contract

Kills the contract

unkillBoard

function unkillBoard() external

Unkills the contract

Unkills the contract

Maths

safe48

function safe48(uint256 n) internal pure returns (uint48)

Last updated