# QuestBoard

#### GAUGE\_CONTROLLER

```solidity
address GAUGE_CONTROLLER
```

Address of the Curve Gauge Controller

#### nextID

```solidity
uint256 nextID
```

ID for the next Quest to be created

#### quests

```solidity
mapping(uint256 => struct IQuestBoard.Quest) quests
```

List of Quest (indexed by ID)

#### periodStateByQuest

```solidity
mapping(uint256 => mapping(uint256 => enum QuestDataTypes.PeriodState)) periodStateByQuest
```

Mapping of all state for each period of each Quest

#### periodAmountDistributedByQuest

```solidity
mapping(uint256 => mapping(uint256 => uint256)) periodAmountDistributedByQuest
```

Mapping of distributed reward amounts for each period of each Quest

#### originalRewardPerPeriod

```solidity
mapping(uint256 => uint256) originalRewardPerPeriod
```

Original Reward per period for Rollover Quests

#### questDistributors

```solidity
mapping(uint256 => address) questDistributors
```

Mapping of Distributors used by each Quest to send rewards

#### questWithdrawableAmount

```solidity
mapping(uint256 => uint256) questWithdrawableAmount
```

Amount not distributed, for Quest creators to redeem

#### platformFeeRatio

```solidity
uint256 platformFeeRatio
```

Platform fees ratio (in BPS)

#### customPlatformFeeRatio

```solidity
mapping(address => uint256) customPlatformFeeRatio
```

Mapping of specific fee ratio for some Quest creators

#### objectiveMinimalThreshold

```solidity
uint256 objectiveMinimalThreshold
```

Minimum Objective required

#### questChest

```solidity
address questChest
```

Address of the Chest to receive platform fees

#### distributor

```solidity
address distributor
```

Address of the reward Distributor contract

#### whitelistedTokens

```solidity
mapping(address => bool) whitelistedTokens
```

Whitelisted tokens that can be used as reward tokens

#### minRewardPerVotePerToken

```solidity
mapping(address => uint256) minRewardPerVotePerToken
```

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

#### isKilled

```solidity
bool isKilled
```

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

#### killTs

```solidity
uint256 killTs
```

Timestamp when the contract was killed

**Parameters**

| Name          | Type    | Description                |
| ------------- | ------- | -------------------------- |
| \_distributor | address | Address of the Distributor |

#### getCurrentPeriod

```solidity
function getCurrentPeriod() public view returns (uint256)
```

Returns the current Period for the contract

#### getQuestIdsForPeriodForGauge

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

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

**Parameters**

| Name   | Type    | Description             |
| ------ | ------- | ----------------------- |
| gauge  | address |                         |
| period | uint256 | Timestamp of the period |

**Return Values**

| Name | Type       | Description                           |
| ---- | ---------- | ------------------------------------- |
| \[0] | uint256\[] | uint256\[] : Quest IDs for the period |

#### getQuestIdsForPeriod

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

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

**Parameters**

| Name   | Type    | Description             |
| ------ | ------- | ----------------------- |
| period | uint256 | Timestamp of the period |

**Return Values**

| Name | Type       | Description                           |
| ---- | ---------- | ------------------------------------- |
| \[0] | uint256\[] | uint256\[] : Quest IDs for the period |

#### getAllPeriodsForQuestId

```solidity
function getAllPeriodsForQuestId(uint256 questID) external view returns (uint48[])
```

Returns all periods for a Quest

**Parameters**

| Name    | Type    | Description     |
| ------- | ------- | --------------- |
| questID | uint256 | ID of the Quest |

**Return Values**

| Name | Type      | Description                            |
| ---- | --------- | -------------------------------------- |
| \[0] | uint48\[] | uint256\[] : List of period timestamps |

#### \_getRemainingDuration

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

Returns the number of periods to come for a given Quest

**Parameters**

| Name    | Type    | Description     |
| ------- | ------- | --------------- |
| questID | uint256 | ID of the Quest |

**Return Values**

| Name | Type    | Description                                    |
| ---- | ------- | ---------------------------------------------- |
| \[0] | uint256 | uint : remaining duration (non active periods) |

#### getQuestCreator

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

Returns the address of the Quest creator

**Parameters**

| Name    | Type    | Description     |
| ------- | ------- | --------------- |
| questID | uint256 | ID of the Quest |

**Return Values**

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| \[0] | address | address : creator of the Quest |

#### getQuestVoterList

```solidity
function getQuestVoterList(uint256 questID) external view returns (address[])
```

Returns the voter list for a given Quest

**Parameters**

| Name    | Type    | Description     |
| ------- | ------- | --------------- |
| questID | uint256 | ID of the Quest |

**Return Values**

| Name | Type       | Description            |
| ---- | ---------- | ---------------------- |
| \[0] | address\[] | address\[] : vote list |

#### getCurrentReducedBias

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

Returns the current reduced bias for a given gauge (based on a Quest's voter list)

**Parameters**

| Name    | Type    | Description     |
| ------- | ------- | --------------- |
| questID | uint256 | ID of the Quest |

**Return Values**

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| \[0] | uint256 | uint256 : current reduced bias |

#### getReducedBias

```solidity
function getReducedBias(uint256 period, uint256 questID) public view returns (uint256)
```

Returns the reduced bias for a given gauge for a given period (based on a Quest's voter list)

**Parameters**

| Name    | Type    | Description             |
| ------- | ------- | ----------------------- |
| period  | uint256 | timestamp of the period |
| questID | uint256 | ID of the Quest         |

**Return Values**

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| \[0] | uint256 | uint256 : current reduced bias |

#### createFixedQuest

```solidity
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

**Parameters**

| Name              | Type                               | Description                                                          |
| ----------------- | ---------------------------------- | -------------------------------------------------------------------- |
| gauge             | address                            | Address of the gauge                                                 |
| rewardToken       | address                            | Address of the reward token                                          |
| startNextPeriod   | bool                               | (bool) true to start the Quest the next period                       |
| duration          | uint48                             | Duration of the Quest (in weeks)                                     |
| rewardPerVote     | uint256                            | Amount of reward/vote (in wei)                                       |
| totalRewardAmount | uint256                            | Total amount of rewards available for the full Quest duration        |
| feeAmount         | uint256                            | Amount of fees paid at creation                                      |
| voteType          | enum QuestDataTypes.QuestVoteType  | Vote type for the Quest                                              |
| closeType         | enum QuestDataTypes.QuestCloseType | Close type for the Quest                                             |
| voterList         | address\[]                         | List of voters for the Quest (to be used for Blacklist or Whitelist) |

**Return Values**

| Name | Type    | Description                             |
| ---- | ------- | --------------------------------------- |
| \[0] | uint256 | uint256 : ID of the newly created Quest |

#### createRangedQuest

```solidity
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

**Parameters**

| Name              | Type                               | Description                                                          |
| ----------------- | ---------------------------------- | -------------------------------------------------------------------- |
| gauge             | address                            | Address of the gauge                                                 |
| rewardToken       | address                            | Address of the reward token                                          |
| startNextPeriod   | bool                               | (bool) true to start the Quest the next period                       |
| duration          | uint48                             | Duration of the Quest (in weeks)                                     |
| minRewardPerVote  | uint256                            | Minimum amount of reward/vote (in wei)                               |
| maxRewardPerVote  | uint256                            | Maximum amount of reward/vote (in wei)                               |
| totalRewardAmount | uint256                            | Total amount of rewards available for the full Quest duration        |
| feeAmount         | uint256                            | Amount of fees paid at creation                                      |
| voteType          | enum QuestDataTypes.QuestVoteType  | Vote type for the Quest                                              |
| closeType         | enum QuestDataTypes.QuestCloseType | Close type for the Quest                                             |
| voterList         | address\[]                         | List of voters for the Quest (to be used for Blacklist or Whitelist) |

**Return Values**

| Name | Type    | Description                             |
| ---- | ------- | --------------------------------------- |
| \[0] | uint256 | uint256 : ID of the newly created Quest |

#### extendQuestDuration

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

Increases the duration of a Quest

**Parameters**

| Name              | Type    | Description                                          |
| ----------------- | ------- | ---------------------------------------------------- |
| questID           | uint256 | ID of the Quest                                      |
| addedDuration     | uint48  | Number of period to add                              |
| addedRewardAmount | uint256 | Amount of reward to add for the new periods (in wei) |
| feeAmount         | uint256 | Platform fees amount (in wei)                        |

#### updateQuestParameters

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

Updates the parametes of the Quest

**Parameters**

| Name                    | Type    | Description                                      |
| ----------------------- | ------- | ------------------------------------------------ |
| questID                 | uint256 | ID of the Quest                                  |
| newMinRewardPerVote     | uint256 | New min reward/vote value (in wei)               |
| newMaxRewardPerVote     | uint256 | New max reward/vote value (in wei)               |
| addedPeriodRewardAmount | uint256 | Amount of reward to add for each period (in wei) |
| addedTotalRewardAmount  | uint256 | Amount of reward to add for all periods (in wei) |
| feeAmount               | uint256 | Platform fees amount (in wei)                    |

#### addToVoterList

```solidity
function addToVoterList(uint256 questID, address[] accounts) external
```

Adds a given list of addresses to a Quest's voter list

**Parameters**

| Name     | Type       | Description     |
| -------- | ---------- | --------------- |
| questID  | uint256    | ID of the Quest |
| accounts | address\[] | list of voters  |

#### removeFromVoterList

```solidity
function removeFromVoterList(uint256 questID, address account) external
```

Removes a given address from a Quest's voter list

**Parameters**

| Name    | Type    | Description          |
| ------- | ------- | -------------------- |
| questID | uint256 | ID of the Quest      |
| account | address | address of the voter |

#### withdrawUnusedRewards

```solidity
function withdrawUnusedRewards(uint256 questID, address recipient) external
```

Withdraw all undistributed rewards from Closed Quest Periods

**Parameters**

| Name      | Type    | Description                          |
| --------- | ------- | ------------------------------------ |
| questID   | uint256 | ID of the Quest                      |
| recipient | address | Address to send the reward tokens to |

#### multipleWithdrawUnusedRewards

```solidity
function multipleWithdrawUnusedRewards(uint256[] questIDs, address recipient) external
```

#### emergencyWithdraw

```solidity
function emergencyWithdraw(uint256 questID, address recipient) external
```

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

**Parameters**

| Name      | Type    | Description                          |
| --------- | ------- | ------------------------------------ |
| questID   | uint256 | ID of the Quest                      |
| recipient | address | Address to send the reward tokens to |

#### closeQuestPeriod

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

Closes the Period, and all QuestPeriods for this period

**Parameters**

| Name   | Type    | Description             |
| ------ | ------- | ----------------------- |
| period | uint256 | Timestamp of the period |

#### closePartOfQuestPeriod

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

Closes the given QuestPeriods for the Period

**Parameters**

| Name     | Type       | Description                    |
| -------- | ---------- | ------------------------------ |
| period   | uint256    | Timestamp of the period        |
| questIDs | uint256\[] | List of the Quest IDs to close |

#### addMultipleMerkleRoot

```solidity
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

**Parameters**

| Name         | Type       | Description                                     |
| ------------ | ---------- | ----------------------------------------------- |
| questIDs     | uint256\[] | List of Quest IDs                               |
| period       | uint256    | Timestamp of the period                         |
| totalAmounts | uint256\[] | List of sums of all rewards for the Merkle Tree |
| merkleRoots  | bytes32\[] | List of MerkleRoots to add                      |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.paladin.vote/quest-v2/smart-contracts-v2.1/questboard.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
