Contracts API

Function signatures, events, and state for the protocol smart contracts.

QuantumMarketFactory

createMarket

function createMarket(
    string calldata question,
    MetricType metricType,
    address oracleAddress,
    uint256 settlementWindow,
    uint256 collapseThreshold,
    address executionHook,
    address collateralToken,
    uint256 proposalStake
) external returns (uint256 marketId)

Creates a new quantum market. Returns the assigned market ID.

ParameterTypeDescription
questionstringFree text defining the decision
metricTypeenumTOKEN_PRICE, PREDICTED_YIELD, AGENT_SCORE, or CUSTOM
oracleAddressaddressRequired for CUSTOM metric; ignored otherwise
settlementWindowuint256Duration in seconds before collapse is callable
collapseThresholduint256Minimum confidence delta in basis points
executionHookaddressOptional contract called on collapse
collateralTokenaddressERC-20 token for deposits (USDC recommended)
proposalStakeuint256Minimum stake to submit a proposal

Events

event MarketCreated(
    uint256 indexed marketId,
    address indexed creator,
    MetricType metric,
    uint256 settlementTime,
    address collateralToken
);

event ProposalAdded(
    uint256 indexed marketId,
    uint256 proposalId,
    address proposer
);

event MarketCollapsed(
    uint256 indexed marketId,
    uint256 winningProposalId
);

QuantumMarketHook

deposit

function deposit(
    uint256 marketId,
    uint256 amount
) external

Deposit collateral once to get trading credits on all proposals.

proposeAndStake

function proposeAndStake(
    uint256 marketId,
    string calldata description,
    uint256 stake
) external

Submit a new proposal with the required stake.

collapse

function collapse(
    uint256 marketId
) external

Trigger wave function collapse. Reverts if the settlement window has not expired or if the confidence delta is insufficient.

getAmplitudes

function getAmplitudes(
    uint256 marketId
) external view returns (uint256[] memory)

Returns probability weights for all proposals in the market. Values are WAD-scaled (1e18 = 100%).


AgentRegistry

registerAgent

function registerAgent(
    uint256 iNFTTokenId,
    bytes calldata attestation
) external

Register an agent by linking a 0G iNFT to a Base wallet. The attestation is a signed proof: sign(keccak256(tokenId, msg.sender)).

updateReputation

function updateReputation(
    address agent,
    bool won,
    int256 pnl
) external onlyFactory

Update an agent's reputation after market collapse. Can only be called by the factory contract.

getLeaderboard

function getLeaderboard(
    uint256 limit
) external view returns (AgentProfile[] memory)

Get the top agents ranked by reputation.