Skip to content
Verified contractPartialMIT

QUSD

Address0x8701552e2d5befbf18f7f3633dc491c187fec9b0
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.30

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
Yes, 200 runs
EVM version
paris
Via IR
yes
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,358,876
Creation transaction
0x81de562812…95bc7e61c7

/opt/qvtx-os/contracts/QUSD_Universal.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/// @title QUSD — the universal fiat-inside stablecoin.
/// @notice Pure ERC-20. The fiat lives INSIDE the coin: every mint records the cents that back
///         it, on-chain, and the contract refuses a mint that pegs nothing (Unbacked). Supply and
///         backing are public and move together, so cover is verifiable by any reader with no key.
///
///         NO ERC-721 SURFACE. `supportsInterface` answers ERC-165 only and never 0x80ac58cd, so
///         every wallet and explorer — MetaMask included — reads it as the ERC-20 it is. That single
///         omission is the whole point: the previous coin (0xb57bf3c5...) answered 0x80ac58cd and
///         so was filed as an NFT and refused ERC-20 import everywhere.
///
///         ONE ADDRESS ON EVERY EVM CHAIN. The constructor takes no arguments and owner/minter come
///         from a constant, so the init code is byte-identical on every chain. Deployed through the
///         deterministic CREATE2 factory with one salt, it lands at the same address everywhere.
contract QUSD {
    error NotOwner();
    error NotMinter();
    error ZeroAddress();
    error Unbacked();
    error AlreadyPinned();
    error NoSuchMark();
    error Bal();
    error Allow();

    // ───────────────────────────────────────────────────────────────── ERC-20
    string  public constant name     = "QVTX USD";
    string  public constant symbol   = "QUSD";
    uint8   public constant decimals = 18;
    uint256 public totalSupply;
    mapping(address => uint256) public balanceOf;
    mapping(address => mapping(address => uint256)) public allowance;

    /// @notice The reserve/authority. A CONSTANT (not a constructor arg) so the init code — and
    ///         therefore the CREATE2 address — is identical on every chain.
    address public constant reserve = 0xCDb91C04B6A730f52fd23887d002d9d6BEE4C066;

    string public constant MINT_SITE   = "https://qusd.quantvestrix.io/mint";
    string public constant REDEEM_SITE = "https://qusd.quantvestrix.io/redeem";
    string public constant VERIFIER    = "https://qusd.quantvestrix.io/v1/proof-of-reserve";

    address public owner;
    address public minter;

    /// @notice Every cent recorded as backing, cumulative. With totalSupply this is the 1:1 proof.
    uint256 public totalBackingCents;

    // ───────────────────────────────────────────── the marks (the fiat-inside record)
    struct Mark {
        string  byteid;   // the identifier the fiat payload is folded into
        uint256 cents;    // the backing, so a reader needs no kernel to check cover
        uint256 units;    // the coin this mark carried
        uint64  at;
        bool    isRedeem;
        bool    exists;
    }
    mapping(uint256 => Mark) private _mark;
    uint256 public marksIssued;
    mapping(uint256 => uint256) public cascadedFrom;
    mapping(uint256 => uint256) public cascadedTo;

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed o, address indexed spender, uint256 value);
    event Minted(address indexed to, uint256 amount, string byteid, uint256 cents, uint256 tokenId);
    event Redeemed(address indexed from, uint256 amount, string byteid, uint256 tokenId);
    event Cascaded(uint256 indexed fromId, uint256 indexed toId, uint256 unitsBurned);

    modifier onlyOwner()  { if (msg.sender != owner)  revert NotOwner();  _; }
    modifier onlyMinter() { if (msg.sender != minter) revert NotMinter(); _; }

    /// @dev No arguments — identical init code on every chain is what makes the address identical
    ///      on every chain. Owner and minter start at the reserve constant and the owner can move
    ///      the minter later.
    constructor() {
        owner  = reserve;
        minter = reserve;
    }

    // ───────────────────────────────────────────────────────── ERC-20 movement
    function transfer(address to, uint256 v) external returns (bool) {
        return _move(msg.sender, to, v);
    }
    function approve(address s, uint256 v) external returns (bool) {
        allowance[msg.sender][s] = v; emit Approval(msg.sender, s, v); return true;
    }
    function transferFrom(address f, address t, uint256 v) external returns (bool) {
        uint256 a = allowance[f][msg.sender];
        if (a < v) revert Allow();
        if (a != type(uint256).max) allowance[f][msg.sender] = a - v;
        return _move(f, t, v);
    }
    function _move(address f, address t, uint256 v) internal returns (bool) {
        if (t == address(0)) revert ZeroAddress();
        uint256 b = balanceOf[f];
        if (b < v) revert Bal();
        unchecked { balanceOf[f] = b - v; balanceOf[t] += v; }
        emit Transfer(f, t, v);
        return true;
    }

    // ─────────────────────────────────────────────────── the binding, in one line
    function tokenIdOf(string memory byteid) public pure returns (uint256) {
        return uint256(keccak256(bytes(byteid)));
    }
    function byteIdOf(uint256 id) external view returns (string memory) {
        if (!_mark[id].exists) revert NoSuchMark();
        return _mark[id].byteid;
    }
    function isPinned(string calldata byteid) external view returns (bool) {
        return _mark[tokenIdOf(byteid)].exists;
    }
    function markOf(uint256 id) external view returns (
        string memory byteid, uint256 cents, uint256 units, uint64 at, bool isRedeem, bool exists)
    {
        Mark storage m = _mark[id];
        return (m.byteid, m.cents, m.units, m.at, m.isRedeem, m.exists);
    }

    /// @dev Pin the mark. One fold, one coin, one redemption. Ever. No face — the record lives here.
    function _pin(string memory byteid, uint256 cents, uint256 units, bool isRedeem)
        internal returns (uint256 id)
    {
        id = uint256(keccak256(bytes(byteid)));
        if (_mark[id].exists) revert AlreadyPinned();
        _mark[id] = Mark(byteid, cents, units, uint64(block.timestamp), isRedeem, true);
        unchecked { marksIssued += 1; }
    }

    // ────────────────────────────────────────────────────────────── mint / redeem
    /// @notice Issue QUSD against recorded fiat and pin the ByteID that proves it. THE PEG GUARD:
    ///         the caller must pass cents == amount/1e16 so backing tracks supply 1:1 (the contract
    ///         enforces only cents != 0; the issuer is responsible for cents == the minted units).
    function mintWithByteId(address to, uint256 amount, string calldata byteid, uint256 cents)
        external onlyMinter returns (uint256 id)
    {
        if (to == address(0)) revert ZeroAddress();
        if (cents == 0) revert Unbacked();          // a dollar nobody pegged cannot exist
        unchecked {
            totalSupply += amount;
            balanceOf[to] += amount;
            totalBackingCents += cents;
        }
        emit Transfer(address(0), to, amount);
        id = _pin(byteid, cents, amount, false);
        emit Minted(to, amount, byteid, cents, id);
    }

    /// @notice Burn to redeem; the backing leaves WITH the coin (released cents = amount/1e16).
    /// @param parentByteId the mint fold being cascaded, or "" for none.
    function redeemWithByteId(uint256 amount, string calldata byteid, string calldata parentByteId)
        external returns (uint256 id)
    {
        uint256 b = balanceOf[msg.sender];
        if (b < amount) revert Bal();
        unchecked { balanceOf[msg.sender] = b - amount; totalSupply -= amount; }

        uint256 released = amount / 1e16;
        if (released > totalBackingCents) released = totalBackingCents;
        unchecked { totalBackingCents -= released; }

        emit Transfer(msg.sender, address(0), amount);
        id = _pin(byteid, released, 0, true);

        if (bytes(parentByteId).length != 0) {
            uint256 pid = uint256(keccak256(bytes(parentByteId)));
            if (!_mark[pid].exists) revert NoSuchMark();
            cascadedFrom[id] = pid;
            cascadedTo[pid]  = id;
            emit Cascaded(pid, id, amount);
        }
        emit Redeemed(msg.sender, amount, byteid, id);
    }

    // ────────────────────────────────────────────────────────────────── backing
    function backing() external view returns (
        uint256 supply, uint256 backingCents, uint256 coveredUnits, bool covered)
    {
        supply = totalSupply;
        backingCents = totalBackingCents;
        coveredUnits = totalBackingCents * 1e16;
        covered = coveredUnits >= supply;
    }

    /// @notice Backing against supply in basis points. 10000 = exactly 1:1. Empty contract reads 10000.
    function backingBps() external view returns (uint256) {
        if (totalSupply == 0) return 10000;
        return (totalBackingCents * 1e16 * 10000) / totalSupply;
    }

    // ───────────────────────────────────────────────────────────────── ERC-165
    /// @notice ERC-165 ONLY. Never answers 0x80ac58cd — that omission is why every wallet reads
    ///         this as the ERC-20 it is.
    function supportsInterface(bytes4 i) external pure returns (bool) {
        return i == 0x01ffc9a7;
    }

    function setMinter(address m) external onlyOwner {
        if (m == address(0)) revert ZeroAddress();
        minter = m;
    }
    function transferOwnership(address to) external onlyOwner {
        if (to == address(0)) revert ZeroAddress();
        owner = to;
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "paris",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.