-
Notifications
You must be signed in to change notification settings - Fork 151
Add Smart Contract qRWA for QMINE ecosystem #703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
c043ea1 to
f612ae2
Compare
Franziska-Mueller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in addition to the comments, please fix all the issues flagged by the contract-verify tool. to enable fast iteration, I suggest that you download/build the tool locally (see https://github.com/qubic/core/blob/main/doc/contracts.md#review-and-tests)
f612ae2 to
7e359a7
Compare
|
Hi @Franziska-Mueller, thanks for your review. All have been updated accordingly. Let me know if I'm missing anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your changes, looking good now!
For future PRs, please avoid force pushing after the initial review. It's impossible to track your changes otherwise.
Sure. Thank you for your feedback. Will do that in the future. |
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.