
Technicals
Governance Proposal Handling:
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 }); }
This function allows the DAO governance to submit asset proposals for the treasury to consider. It’s essential for asset management decisions.
Proposals are tracked by an incremented
proposalCount
and stored in a mapping,proposals
, that tracks the asset address, vote count, and whether the proposal has been finalized.
Voting Mechanism:
solidityCopyfunction voteOnAsset(uint256 proposalId, bool support) external { // Voting mechanism for DAO members to vote on the 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 } }
This function allows sQD holders to vote on asset proposals. Voting is token-weighted, where users vote according to the amount of sQD they hold.
The proposal can only be voted on if it hasn’t already been finalized, ensuring governance integrity.
Finalize Proposal & Execute Actions:
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); }
After sufficient votes are collected, the proposal is finalized and relevant actions are executed, like asset purchases and burns.
This ensures that only approved proposals are executed, ensuring that the treasury's operations are in line with community consensus.
Reward Distribution to Stakers:
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); } }
This function is responsible for distributing $QD rewards to sQD stakers at the end of each cycle.
It calculates each staker’s share of the reward based on their proportion of staked sQD and then automatically transfers the rewards.
Technical Considerations:
Gas Efficiency:
The contract uses gas-efficient mechanisms to ensure that the treasury’s activities are conducted in a way that minimizes costs for users and stakers.
For example, the automated reward distribution and cycle management are designed to reduce the number of manual interventions and thus optimize gas costs for each transaction.
Security Measures:
Built-in slippage protection ensures that when assets are bought or sold, the transactions will not cause significant price slippage.
Circuit breakers are implemented to halt certain actions if market conditions or other parameters exceed predefined thresholds, which helps protect the treasury from unexpected volatility.
Upgradeable via Proxy:
The contract should be designed with upgradability in mind, utilizing proxy patterns (e.g., OpenZeppelin’s Proxy contract) to ensure future enhancements can be deployed without disrupting the existing system.
Last updated