The documentation of smart contracts is essential to understand the internal workings of the RealToken DAO. It includes:
REGGovernor.sol: Main governance contract, this contract manages the governance process, including proposal creation, voting, and execution.
Main non-standard functions added:
function setProposerMode(ProposerMode proposerMode) external
Description: Allows governance to set the proposer mode, determining the criteria that addresses must meet to create proposals.
Parameters:
proposerMode: The new proposer mode to set, which can be one of the following:
ProposerWithRole
: Only addresses with the PROPOSER_ROLE
can propose.ProposerWithVotingPower
: Only addresses with sufficient voting power can propose.ProposerWithRoleAndVotingPower
: Only addresses with the PROPOSER_ROLE
and sufficient voting power can propose.ProposerWithRoleOrVotingPower
: Addresses with either the PROPOSER_ROLE
or sufficient voting power can propose.Access Control: Can only be called via a successful governance proposal (onlyGovernance
).
Event Emitted: SetProposerMode
function setIncentiveEnabled(bool status) external
Description: Enables or disables the incentive mechanism, which records votes in the incentive vault to reward participants.
Parameters: status
A boolean indicating whether to enable (true
) or disable (false
) the incentive mechanism.
Access Control: Can only be called via a successful governance proposal.
Event Emitted: SetIncentiveEnabled
function setRegIncentiveVault(IREGIncentiveVault regIncentiveVault) external
Description: Sets the address of the REG incentive vault contract used to record votes and distribute incentives.
Parameters: regIncentiveVault
The address of the new REG incentive vault contract.
Access Control: Can only be called via a successful governance proposal.
Event Emitted: SetRegIncentiveVault
function getProposerMode() external view returns (ProposerMode)
Description: Returns the current proposer mode, indicating the criteria required for an address to create proposals.
Returns: The current ProposerMode
.
function getIncentiveEnabled() external view returns (bool)
Description: Indicates whether the incentive mechanism is currently enabled.
Returns: true
if the incentive mechanism is enabled, false
otherwise.
function getRegIncentiveVault() external view returns (IREGIncentiveVault)
Description: Returns the address of the REG incentive vault contract.
Returns: The address of the IREGIncentiveVault
contract.
function cancelByAdmin(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash) external returns (uint256)
Description: Allows an administrator with the CANCELLER_ROLE
to cancel a proposal matching the given parameters.
Parameters:
targets
: An array of target addresses for the proposal's actions.values
: An array of ETH values to send with each action.calldatas
: An array of call data for each action.descriptionHash
: The keccak256 hash of the proposal description.Returns: The ID of the cancelled proposal.
Access Control: Restricted to addresses with the CANCELLER_ROLE
.
REGTreasuryDAO.sol: DAO treasury management, this contract manages the DAO's funds and executes approved transactions after a security timelock delay.
There are no main non-standard functions added.
REGIncentiveVault.sol: Incentive and reward system, this contract manages the calculation and distribution of rewards to DAO participants if activated by the DAO.
Contract entirely created by RealT, the main functions are:
function setNewEpoch(uint256 subscriptionStart,uint256 subscriptionEnd,uint256 lockPeriodEnd,address bonusToken,uint256 totalBonus ) external onlyRole(DEFAULT_ADMIN_ROLE)
Description: Sets a new epoch (period) for the incentive program. This function initializes a new epoch with the specified parameters.
Parameters:
subscriptionStart
: Timestamp of the start of the subscription period.subscriptionEnd
: Timestamp of the end of the subscription period.lockPeriodEnd
: Timestamp of the end of the lock period.bonusToken
: Address of the token used as reward.totalBonus
: Total amount of bonus tokens to distribute for this epoch.Access Control: Only the DEFAULT_ADMIN_ROLE
can call this function.
Event Emitted: SetNewEpoch
function deposit(uint256 amount) public whenNotPaused;
Description: Allows users to deposit REG tokens into the vault during the subscription period to participate in the incentive program.
Parameters: amount
: Amount of REG tokens to deposit.
Conditions: The function can only be called when the contract is not paused and during the subscription period.
Event Emitted: Deposit
function depositWithPermit(uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external whenNotPaused;
Description: Allows users to deposit REG tokens using EIP-2612 approval (permit), which allows deposit in a single transaction without prior approval.
Parameters: :
amount
: Amount of REG tokens to deposit.deadline
: Timestamp after which the signature is no longer valid.v, r, s
: Signature components for approval.Conditions: The function can only be called when the contract is not paused and during the subscription period.
Event Emitted: Deposit
function withdraw(uint256 amount) external whenNotPaused;
Description: Allows users to withdraw their deposited REG tokens after the end of the lock period.
Parameters: amount
: Amount of REG tokens to withdraw.
Conditions: The function can only be called when the contract is not paused and after the end of the lock period.
Event Emitted: Withdraw
function recordVote(address user, uint256 proposalId) external onlyGovernance;
Description: Records a user's vote on a proposal during the lock period to calculate incentive rewards.
Parameters:
user
: Address of the user who voted.proposalId
: Identifier of the proposal the user voted on.Access Control: Only the governance contract can call this function.
Event Emitted: RecordVote
or RecordVoteNotActive
function calculateBonus(address user) external view returns (address[] memory, uint256[] memory)
Description: Calculates the amount of bonus a user can claim for each past epoch.
Parameters:
user
: Address of the user for which to calculate the bonus.Returns:
address[]
: Array of bonus token addresses.uint256[]
: Array of corresponding bonus amounts.function claimBonus() public whenNotPaused;
Description: Allows users to claim their accumulated bonuses for all eligible epochs.
Conditions: The function can only be called when the contract is not paused.
Event Emitted: ClaimBonus
function getRegGovernor() external view returns (address)
Description: Returns the address of the associated REG governance contract.
function getRegToken() external view returns (IERC20)
Description: Returns the address of the REG token used by the vault.
function getCurrentTotalDeposit() external view returns (uint256)
Description: Returns the total amount of REG tokens currently deposited in the vault.
function getCurrentEpoch() external view returns (uint256)
Description: Returns the number of the current epoch.
function getCurrentEpochState() external view returns (EpochState memory)
Description: Returns information about the state of the current epoch.
function getEpochState(uint256 epoch) external view returns (EpochState memory)
Description: Returns information about the state of a specific epoch.
Parameters: epoch
Number of the epoch for which to get information.
function getUserEpochState(address user, uint256 epoch) external view returns (UserEpochState memory)
Description: Returns information about a user's state for a specific epoch.
Parameters:
user
: Address of the user.epoch
: Number of the epoch.function getUserGlobalState(address user) external view returns (UserGlobalState memory)
Description: Returns global information about a user's state.
Parameters:
user
: Address of the user.REGPowerVotingRegistry.sol: Registration of voting powers, this contract records the voting power of participants calculated off-chain by RealT according to the algorithm defined and validated by the DAO.
Contract entirely created by RealT, the main functions are: - registerVotingPower(VotingPower[] calldata votingPower) external override onlyRole(REGISTER_ROLE)
You will notice that for reasons of compatibility with standards and the operation of the Governor contract, the PowerVotingRegistry contract is based on the ERC20 standard with a modification of the behaviors of basic functions such as:
- transfer, transferFrom, approve, etc. are overridden to return false
- delegate is overridden to return an error `REGVotingPowerRegistryErrors.DelegateToOtherNotAllowed()` if a user tries to delegate their vote to another user.
Main methods:
propose()
in REGGovernor to create a proposal,castVote()
in REGGovernor to vote on a proposal,queue()
in REGGovernor to queue a proposal,execute()
in REGTreasuryDAO to execute an approved proposal.Important events:
ProposalCreated
emitted when a proposal is created,VoteCast
emitted when a vote is recorded,callExecuted()
emitted when a proposal action is executed.[A diagram showing the interactions between contracts]
There are currently no security audit reports. As the contracts are close to standard versions (already audited) and governance is exercised with rights restrictions, it was deemed more relevant to conserve resources for future audits of v2. V1 being a provisional experimental version intended to initialize the DAO, its scope of action is limited.
This section details the DAO's governance processes:
Interactions mainly occur through the following interfaces: