From 743526e4671633228e9acd9b4d0f1cf76008307a Mon Sep 17 00:00:00 2001 From: CargoAI-cpu Date: Thu, 28 May 2026 22:42:06 -0400 Subject: [PATCH 1/4] Add Qassandra prediction market scaffold --- src/contract_core/contract_def.h | 11 ++-- src/contracts/Qassandra.h | 87 ++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 src/contracts/Qassandra.h diff --git a/src/contract_core/contract_def.h b/src/contract_core/contract_def.h index c28cf012..51ac2625 100644 --- a/src/contract_core/contract_def.h +++ b/src/contract_core/contract_def.h @@ -15,10 +15,13 @@ #include "contracts/qpi.h" #include "qpi_proposal_voting.h" -// make interfaces to oracles available for all contracts -#include "oracle_core/oracle_interfaces_def.h" - -#define QX_CONTRACT_INDEX 1 +// make interfaces to oracles available for all contracts +#include "oracle_core/oracle_interfaces_def.h" + +// make inert Qassandra prediction-market scaffold types available for contracts +#include "contracts/Qassandra.h" + +#define QX_CONTRACT_INDEX 1 #define CONTRACT_INDEX QX_CONTRACT_INDEX #define CONTRACT_STATE_TYPE QX #define CONTRACT_STATE2_TYPE QX2 diff --git a/src/contracts/Qassandra.h b/src/contracts/Qassandra.h new file mode 100644 index 00000000..b79c201d --- /dev/null +++ b/src/contracts/Qassandra.h @@ -0,0 +1,87 @@ +using namespace QPI; + +// Inert scaffold for future Qassandra oracle-settled prediction markets. +// This header defines contract-safe identifiers, status/outcome values, and +// deterministic settlement comparison helpers without adding storage or runtime hooks. + +constexpr uint64 QASSANDRA_QUBIC_USD_PRICE_SCALE = 100000000ULL; + +enum QassandraMarketStatus : uint8 +{ + QASSANDRA_MARKET_STATUS_DRAFT = 0, + QASSANDRA_MARKET_STATUS_OPEN = 1, + QASSANDRA_MARKET_STATUS_LOCKED = 2, + QASSANDRA_MARKET_STATUS_SETTLED = 3, + QASSANDRA_MARKET_STATUS_CANCELLED = 4, +}; + +enum QassandraOutcome : uint8 +{ + QASSANDRA_OUTCOME_UNKNOWN = 0, + QASSANDRA_OUTCOME_NO = 1, + QASSANDRA_OUTCOME_YES = 2, +}; + +enum QassandraComparisonDirection : uint8 +{ + QASSANDRA_COMPARE_GT = 0, + QASSANDRA_COMPARE_GTE = 1, + QASSANDRA_COMPARE_LT = 2, + QASSANDRA_COMPARE_LTE = 3, +}; + +struct QassandraMarketId +{ + id eventId; + uint64 nonce; +}; + +struct QassandraOracleSettlement +{ + sint64 thresholdValue; + uint8 comparisonDirection; +}; + +// Agent-readable market metadata and deterministic settlement surfaces are planned +// for later Qassandra layers; no wallet, API, or off-chain orchestration is added here. +struct QassandraMarketDescriptor +{ + QassandraMarketId marketId; + id baseAsset; + id quoteAsset; + QassandraOracleSettlement settlement; +}; + +inline static bool qassandraIsValidPriceReply(const OI::Price::OracleReply& reply) +{ + return reply.numerator > 0 && reply.denominator > 0; +} + +inline static bool qassandraCompareScaledPrice(const OI::Price::OracleReply& reply, sint64 thresholdValue, uint8 comparisonDirection) +{ + if (!qassandraIsValidPriceReply(reply) || thresholdValue < 0) + { + return false; + } + + const uint128 left = uint128(reply.numerator) * uint128(QASSANDRA_QUBIC_USD_PRICE_SCALE); + const uint128 right = uint128(thresholdValue) * uint128(reply.denominator); + + if (comparisonDirection == QASSANDRA_COMPARE_GT) + { + return left > right; + } + if (comparisonDirection == QASSANDRA_COMPARE_GTE) + { + return left >= right; + } + if (comparisonDirection == QASSANDRA_COMPARE_LT) + { + return left < right; + } + if (comparisonDirection == QASSANDRA_COMPARE_LTE) + { + return left <= right; + } + return false; +} From 1d8eb256cac654902d28a7a3ea3586ed867d8d57 Mon Sep 17 00:00:00 2001 From: CargoAI-cpu Date: Fri, 29 May 2026 00:30:35 -0400 Subject: [PATCH 2/4] Refine Qassandra typed market metadata --- src/contracts/Qassandra.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/contracts/Qassandra.h b/src/contracts/Qassandra.h index b79c201d..650bb00d 100644 --- a/src/contracts/Qassandra.h +++ b/src/contracts/Qassandra.h @@ -15,6 +15,12 @@ enum QassandraMarketStatus : uint8 QASSANDRA_MARKET_STATUS_CANCELLED = 4, }; +enum QassandraMarketType : uint8 +{ + QASSANDRA_MARKET_TYPE_UNKNOWN = 0, + QASSANDRA_MARKET_TYPE_BINARY_PRICE = 1, +}; + enum QassandraOutcome : uint8 { QASSANDRA_OUTCOME_UNKNOWN = 0, @@ -30,6 +36,14 @@ enum QassandraComparisonDirection : uint8 QASSANDRA_COMPARE_LTE = 3, }; +enum QassandraOracleSettlementStatus : uint8 +{ + QASSANDRA_ORACLE_SETTLEMENT_STATUS_UNKNOWN = 0, + QASSANDRA_ORACLE_SETTLEMENT_STATUS_PENDING = 1, + QASSANDRA_ORACLE_SETTLEMENT_STATUS_READY = 2, + QASSANDRA_ORACLE_SETTLEMENT_STATUS_FINAL = 3, +}; + struct QassandraMarketId { id eventId; @@ -47,9 +61,15 @@ struct QassandraOracleSettlement struct QassandraMarketDescriptor { QassandraMarketId marketId; + uint8 marketType; id baseAsset; id quoteAsset; QassandraOracleSettlement settlement; + uint64 settlementTick; + uint64 settlementTime; + id oracleQueryId; + uint8 settlementStatus; + bool canAgentRead; }; inline static bool qassandraIsValidPriceReply(const OI::Price::OracleReply& reply) From ce9032ef84fc3638586ebeed674e3ccb5b1493cf Mon Sep 17 00:00:00 2001 From: CargoAI-cpu Date: Fri, 29 May 2026 01:02:13 -0400 Subject: [PATCH 3/4] Harden Qassandra scaffold types --- src/contracts/Qassandra.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/contracts/Qassandra.h b/src/contracts/Qassandra.h index 650bb00d..1b0cefcf 100644 --- a/src/contracts/Qassandra.h +++ b/src/contracts/Qassandra.h @@ -1,3 +1,5 @@ +#pragma once + using namespace QPI; // Inert scaffold for future Qassandra oracle-settled prediction markets. @@ -52,7 +54,7 @@ struct QassandraMarketId struct QassandraOracleSettlement { - sint64 thresholdValue; + uint64 thresholdValue; uint8 comparisonDirection; }; @@ -69,7 +71,7 @@ struct QassandraMarketDescriptor uint64 settlementTime; id oracleQueryId; uint8 settlementStatus; - bool canAgentRead; + uint8 canAgentRead; }; inline static bool qassandraIsValidPriceReply(const OI::Price::OracleReply& reply) @@ -77,9 +79,9 @@ inline static bool qassandraIsValidPriceReply(const OI::Price::OracleReply& repl return reply.numerator > 0 && reply.denominator > 0; } -inline static bool qassandraCompareScaledPrice(const OI::Price::OracleReply& reply, sint64 thresholdValue, uint8 comparisonDirection) +inline static bool qassandraCompareScaledPrice(const OI::Price::OracleReply& reply, uint64 thresholdValue, uint8 comparisonDirection) { - if (!qassandraIsValidPriceReply(reply) || thresholdValue < 0) + if (!qassandraIsValidPriceReply(reply)) { return false; } @@ -103,5 +105,6 @@ inline static bool qassandraCompareScaledPrice(const OI::Price::OracleReply& rep { return left <= right; } + // Unknown comparison directions fail closed. return false; } From 390463975dd7ac3189acf49211271b34f03b2520 Mon Sep 17 00:00:00 2001 From: CargoAI-cpu Date: Mon, 1 Jun 2026 12:24:39 -0400 Subject: [PATCH 4/4] Add Qassandra ContractBase scaffold --- src/contracts/Qassandra.h | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/contracts/Qassandra.h b/src/contracts/Qassandra.h index 1b0cefcf..b27c2d9c 100644 --- a/src/contracts/Qassandra.h +++ b/src/contracts/Qassandra.h @@ -108,3 +108,58 @@ inline static bool qassandraCompareScaledPrice(const OI::Price::OracleReply& rep // Unknown comparison directions fail closed. return false; } + +struct Qassandra : public ContractBase +{ + struct StateData + { + }; + + REGISTER_USER_FUNCTIONS_AND_PROCEDURES() + { + } + + INITIALIZE() + { + } + + BEGIN_EPOCH() + { + } + + END_EPOCH() + { + } + + BEGIN_TICK() + { + } + + END_TICK() + { + } + + PRE_ACQUIRE_SHARES() + { + } + + POST_ACQUIRE_SHARES() + { + } + + PRE_RELEASE_SHARES() + { + } + + POST_RELEASE_SHARES() + { + } + + POST_INCOMING_TRANSFER() + { + } + + EXPAND() + { + } +};