
Technicals
1. Governance Proposal Handling
Function: proposeAsset(address assetAddress)
solidityCopyfunction proposeAsset(address assetAddress) external onlyGovernance {
// Allows governance to propose assets to be purchased by the DAO
proposalCount++;
proposals[proposalCount] = AssetProposal({
asset: assetAddress,
votes: 0,
finalized: false
});
}
Purpose: This function enables the DAO’s governance (via sQD holders) to submit proposals for assets to be included in the treasury’s asset pool.
How it works: It creates a proposal, stores it in the proposals mapping, and increments the proposalCount. Each proposal is tracked with its respective votes and a finalized status to ensure it is only acted upon once enough community support is gathered.
2. Voting Mechanism for Proposals
Function: voteOnAsset(uint256 proposalId, bool support)
solidityCopyfunction voteOnAsset(uint256 proposalId, bool support) external {
// Voting mechanism for DAO members to vote on asset proposals
require(sQD.balanceOf(msg.sender) > 0, "Must hold sQD to vote");
AssetProposal storage proposal = proposals[proposalId];
require(!proposal.finalized, "Proposal already finalized");
if (support) {
proposal.votes += sQD.balanceOf(msg.sender); // Token-weighted voting
}
}
Purpose: This function enables sQD token holders to vote on the asset proposals submitted to the DAO. Voting is token-weighted, meaning users vote according to the amount of sQD they hold.
How it works: The function checks if the sender has sQD tokens to vote, ensures the proposal hasn’t been finalized, and adds their vote to the proposal’s total votes if they support it. The proposal will only be executed if enough votes are collected.
3. Finalizing Proposal and Executing Actions
Function: finalizeProposal(uint256 proposalId)
solidityCopyfunction finalizeProposal(uint256 proposalId) external {
// Finalizes the proposal and executes the market actions if it's approved
AssetProposal storage proposal = proposals[proposalId];
require(proposal.votes > threshold, "Insufficient votes");
proposal.finalized = true;
// Trigger actions such as asset purchase, burn, or buyback
QDTreasuryOperations.executeMarketActions(proposal.asset);
}
Purpose: This function finalizes the proposal once enough votes are collected, and the community-approved action is executed.
How it works: The proposal is marked as finalized, and once it meets the minimum threshold of votes, the function triggers the execution of the market actions (such as buying or selling assets) through the QDTreasuryOperations Contract.
4. Reward Distribution to Stakers
Function: distributeRewards()
solidityCopyfunction distributeRewards() external {
uint256 rewardAmount = calculateRewards();
for (address staker in stakers) {
uint256 stakerShare = sQD.balanceOf(staker);
uint256 reward = (stakerShare / totalSupply) * rewardAmount;
// Transfer rewards to each staker
IERC20(QD).transfer(staker, reward);
}
}
Purpose: This function distributes $QD rewards to the sQD stakers after each treasury cycle is completed.
How it works: It calculates the reward amount and distributes it proportionally to all stakers based on their share of sQD tokens. The reward is sent to each staker’s wallet using the
IERC20(QD).transfer
function.
5. Cycle Management and Treasury Action Initiation
Function: startCycle()
solidityCopyfunction startCycle() external onlyGovernance {
// Initiates a new treasury cycle
currentCycle++;
cycleStartTime = block.timestamp;
cycleStatus = CycleStatus.Active;
// Trigger next market action if necessary
QDTreasuryOperations.executeMarketActions(currentAsset);
}
Purpose: This function marks the start of a new treasury cycle, which may include buyback, sell, or burn operations as defined by governance.
How it works: The contract increments the currentCycle, updates the cycleStartTime, and activates the cycle. The QDTreasuryOperations Contract is triggered to execute the market actions.
6. Automated Reward Calculation
Function: calculateRewards()
solidityCopyfunction calculateRewards() internal view returns (uint256) {
// Calculate the total rewards for the current cycle
uint256 totalTaxRevenue = getTotalTaxRevenue();
uint256 reward = totalTaxRevenue * rewardRate;
return reward;
}
Purpose: This function calculates the rewards to be distributed to stakers based on the revenue generated by treasury operations (e.g., taxes and buybacks).
How it works: The function calculates the total revenue from taxes or other treasury operations and determines how much of it should be allocated as rewards, based on the defined rewardRate.
Last updated