Add Smart Contract qRWA for QMINE ecosystem #703
+3,893
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
qRWA Smart Contract
Version: 1.0
Platform: Qubic
Language: C++
1. Executive Summary
The qRWA (Qubic Real World Asset) smart contract is a decentralized governance and revenue distribution protocol designed for the Qubic ecosystem. It serves as a DAO (Decentralized Autonomous Organization) for the QMINE asset, allowing token holders to govern protocol parameters and manage a diversified treasury of assets. The contract automates the ingestion of revenue (QUs), applies a configurable fee structure for operational costs (e.g., mining electricity/maintenance), and distributes net yields to QMINE holders (90%) and the contract's own shareholders (10%), while routing any dividends forfeited by moved tokens to the protocol developer.
2. Core Architecture
2.1 Asset Management
The contract manages two distinct categories of assets:
Asset Name: QMINE or 297666170193and a specific issuer ID. This token dictates voting power and dividend claims.HashMapimplementation stores balances for arbitrary Qubic assets (shares of other SCs, IPO tokens, etc.) that have been deposited into the contract.2.2 Revenue Streams & "Splitter" Logic
The contract distinguishes revenue based on its source to apply different fee models:
min(Begin, End)), tokens that are moved or sold during an epoch result in "unclaimed" portions of the dividend pool. These remainder funds are automatically calculated and transferred to theqmineDevAddress.2.3 Governance Module
The governance model utilizes a "Snapshot" mechanism, calculating voting power as
min(Balance_Begin_Epoch, Balance_End_Epoch)to prevent flash-voting attacks.Parameter Governance:
mGovPolls).qRWAGovParams(Admin ID, Fee Receiver IDs, Fee Percentages).END_EPOCH.Treasury Governance (Asset Release):
bit_64bitfields, allowing users to track votes on 64 simultaneous polls with minimal memory footprint.qpi.transferShareOwnershipAndPossessionto execute the transaction trustlessly.3. State Machine Lifecycle
3.1 Initialization (
INITIALIZE)Sets default governance parameters (Fees: 35% Electricity, 5% Maintenance, 10% Reinvestment), designates the initial Admin, and zeros out all revenue pools and maps.
3.2 Epoch Transition
BEGIN_EPOCH:mBeginEpochBalancessnapshot.END_EPOCH:mEndEpochBalancessnapshot.min(Begin, End)voting power logic.mPayout...maps for the dividend distributor.3.3 Tick Processing (
END_TICK)QRWA_MIN_PAYOUT_INTERVAL_MShas elapsed.electricityAddress,maintenanceAddress, etc.mQmineDividendPool(min(Begin, End) * mQmineDividendPool) / Total_Supply_Begin, wheremQmineDividendPoolis the accumulation of 90% of the net revenue collected by the contract since the last payout. (mQmineDividendPool = 90% of (Pool A (after mining fees) + Pool B)).min(Begin, End)balances is always less than or equal toTotal_Supply_Begin(due to token transfers), a remainder is left in the pool. This remainder—representing dividends for "moved" shares—is transferred entirely to the QMINE Developer Address (qmineDevAddress).mQRWADividendPool(Broadcast viaqpi.distributeDividendsto SC shareholders).4. Interface Specification
4.1 Public Procedures (Write)
DonateToTreasuryVoteGovParamsCreateAssetReleasePollVoteAssetReleaseDepositGeneralAssetrevokeAssetManagementRights4.2 Public Functions (Read)
GetGovParamsqRWAGovParams, including admin ID, fee addresses (electricity, maintenance, reinvestment), and fee percentages.GetGovPollqRWAGovProposal) of a specific governance proposal by ID, including its status and current vote score.GetAssetReleasePollAssetReleaseProposal) of a specific asset release proposal by ID, including the asset, amount, destination, and vote counts.GetTreasuryBalancemTreasuryBalance).GetDividendBalancesGetTotalDistributedGetActiveAssetReleasePollIdsGetActiveGovPollIdsGetGeneralAssetBalanceAssetstruct.GetGeneralAssets5. System Procedures (Callbacks)
POST_INCOMING_TRANSFER: intercepts incoming QUs. It analyzesinput.sourceIdto route funds to either Pool A (Funds from Mining) or Pool B (Other General Asset dividends). If theinput.sourceIdis a Smart Contract, it will route to Pool A. If theinput.sourceIdis a user, it will route to Pool B.PRE_ACQUIRE_SHARES: Returnstrue, allowing any entity to transfer asset management rights to this contract without restriction.6. Data Structures
QRWA_MAX_QMINE_HOLDERS = 2^21).mGovPolls,mAssetPolls).7. Security & Limitations
2^21)._localsstructs to manage stack memory safely during execution.