Blockchain / Global / Address
Contract
0xa69aaEC37bA37A67f5A3956b856625Ec87abcEEE
- Balance
- 0.226439 SOMI
- Transactions sent
- 1
- Type
- Contract · 5,342 bytes of code
AgentModerationStrategy Verified
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- Solidity
- Optimization
- Yes, 50 runs
- EVM version
- cancun
- License
- —
- Verified
- 2026-10-12
contracts/AgentModerationStrategy.sol
and 4 more files
Solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import { IModerationStrategy } from "./interfaces/IModerationStrategy.sol";
import { IProphecyCore } from "./interfaces/IProphecyCore.sol";
enum ResponseStatus {
None,
Pending,
Success,
Failed,
TimedOut
}
enum ConsensusType {
Majority,
Threshold
}
struct AgentResponse {
address validator;
bytes result;
ResponseStatus status;
uint256 receipt;
uint256 timestamp;
uint256 executionCost;
}
struct AgentRequest {
uint256 id;
address requester;
address callbackAddress;
bytes4 callbackSelector;
address[] subcommittee;
AgentResponse[] responses;
uint256 responseCount;
uint256 failureCount;
uint256 threshold;
uint256 createdAt;
uint256 deadline;
ResponseStatus status;
ConsensusType consensusType;
uint256 remainingBudget;
}
error ZeroAddress();
error OnlyProphecyCore();
error OnlyPlatform();
error OnlyOwner();
error InsufficientDeposit();
error ZeroCommitteeSize();
interface ISomniaAgents {
function createAdvancedRequest(
uint256 agentId,
address callbackAddress,
bytes4 callbackSelector,
bytes calldata payload,
uint256 subcommitteeSize,
uint256 threshold,
ConsensusType consensusType,
uint256 timeout
) external payable returns (uint256 requestId);
function getAdvancedRequestDeposit(
uint256 subcommitteeSize
) external view returns (uint256);
}
interface IAgent {
function inferString(
string memory prompt,
string memory system,
bool chainOfThought,
string[] memory allowedValues
) external returns (string memory);
}
/// @title AgentModerationStrategy
/// @notice Moderation strategy that uses Somnia's on-chain AI agents to
/// classify prediction market events as ACCEPTED or REJECTED.
contract AgentModerationStrategy is IModerationStrategy {
uint256 private constant _TIMEOUT = 5 minutes;
IProphecyCore public immutable prophecyCore;
ISomniaAgents public immutable platform;
uint256 public immutable agentId;
address public owner;
uint256 public committeeSize;
mapping(uint256 => uint256) public requestToEvent;
string public systemPrompt;
event ModerationRequested(uint256 indexed eventId, uint256 indexed requestId);
event ModerationResponse(uint256 indexed eventId, uint256 indexed requestId, bool accepted, string response);
event CommitteeSizeSet(uint256 size);
modifier onlyOwner() {
if (msg.sender != owner) revert OnlyOwner();
_;
}
constructor(
address _prophecyCore,
address _platform,
uint256 _agentId,
string memory _systemPrompt,
uint256 _committeeSize
) {
if (_prophecyCore == address(0)) revert ZeroAddress();
if (_platform == address(0)) revert ZeroAddress();
prophecyCore = IProphecyCore(_prophecyCore);
platform = ISomniaAgents(_platform);
agentId = _agentId;
systemPrompt = _systemPrompt;
if (_committeeSize == 0) revert ZeroCommitteeSize();
committeeSize = _committeeSize;
owner = msg.sender;
}
receive() external payable { }
/// @inheritdoc IModerationStrategy
function onEventCreated(
uint256 eventId,
string calldata name,
bytes calldata eventContext
) external payable override {
if (msg.sender != address(prophecyCore)) revert OnlyProphecyCore();
if (msg.value == 0) revert InsufficientDeposit();
string[] memory allowed = new string[](2);
allowed[0] = "ACCEPTED";
allowed[1] = "REJECTED";
bytes memory payload = abi.encodeWithSelector(
IAgent.inferString.selector, _buildPrompt(name, eventContext), systemPrompt, false, allowed
);
// Threshold is majority (size/2 + 1)
uint256 threshold = (committeeSize / 2) + 1;
uint256 requestId = platform.createAdvancedRequest{ value: msg.value }(
agentId,
address(this),
this.handleResponse.selector,
payload,
committeeSize,
threshold,
ConsensusType.Majority,
_TIMEOUT
);
requestToEvent[requestId] = eventId;
emit ModerationRequested(eventId, requestId);
}
/// @notice Called by the Somnia Agents platform when the agent reaches consensus.
function handleResponse(
uint256 requestId,
AgentResponse[] calldata responses,
ResponseStatus status,
AgentRequest calldata /* details */
) external {
if (msg.sender != address(platform)) revert OnlyPlatform();
uint256 eventId = requestToEvent[requestId];
delete requestToEvent[requestId];
if (status == ResponseStatus.Success && responses.length > 0) {
bool foundSuccessfulResponse;
string memory response;
for (uint256 i; i < responses.length; i++) {
if (responses[i].status == ResponseStatus.Success) {
response = abi.decode(responses[i].result, (string));
foundSuccessfulResponse = true;
break;
}
}
if (!foundSuccessfulResponse) {
emit ModerationResponse(eventId, requestId, false, "No successful agent response");
prophecyCore.rejectEvent(eventId, "No successful agent response");
return;
}
bool accepted = _startsWithAccepted(response);
emit ModerationResponse(eventId, requestId, accepted, response);
if (accepted) {
prophecyCore.approveEvent(eventId);
} else {
prophecyCore.rejectEvent(eventId, response);
}
} else {
emit ModerationResponse(eventId, requestId, false, "Agent moderation failed or timed out");
prophecyCore.rejectEvent(eventId, "Agent moderation failed or timed out");
}
}
function setSystemPrompt(
string calldata _systemPrompt
) external onlyOwner {
systemPrompt = _systemPrompt;
}
function transferOwnership(
address newOwner
) external onlyOwner {
owner = newOwner;
}
function setCommitteeSize(
uint256 _committeeSize
) external onlyOwner {
if (_committeeSize == 0) revert ZeroCommitteeSize();
committeeSize = _committeeSize;
emit CommitteeSizeSet(_committeeSize);
}
/// @inheritdoc IModerationStrategy
/// @dev Sum of the contract-side operations reserve (via
/// `getAdvancedRequestDeposit`, covers callback/finalisation gas) and
/// the per-agent execution reward. Matches the runner's admission rule
/// `perAgentBudget >= scheduledExecutionCost` (see AGT-282).
function getModerationCost() external view override returns (uint256) {
uint256 reserve = platform.getAdvancedRequestDeposit(committeeSize);
uint256 reward = prophecyCore.llmInferenceCostPerAgent() * committeeSize;
return reserve + reward;
}
function _buildPrompt(
string calldata name,
bytes calldata eventContext
) internal pure returns (string memory) {
if (eventContext.length == 0) {
return string.concat("Content: ", name, " Answer:");
}
// eventContext layout: abi.encode(string nameGenCtx, string moderationPrompt, string[] moderationOptions)
(, string memory prompt, string[] memory options) = abi.decode(eventContext, (string, string, string[]));
if (bytes(prompt).length == 0 && options.length == 0) {
return string.concat("Content: ", name, " Answer:");
}
string memory result = string.concat("Content: ", name, "\nPrompt: ", prompt);
if (options.length > 0) {
result = string.concat(result, "\nOptions: ");
for (uint256 i; i < options.length; i++) {
if (i > 0) result = string.concat(result, ", ");
result = string.concat(result, options[i]);
}
}
return string.concat(result, " Answer:");
}
function _startsWithAccepted(
string memory s
) internal pure returns (bool) {
if (bytes(s).length < 8) return false;
return bytes(s)[0] == "A" && bytes(s)[1] == "C" && bytes(s)[2] == "C" && bytes(s)[3] == "E"
&& bytes(s)[4] == "P" && bytes(s)[5] == "T" && bytes(s)[6] == "E" && bytes(s)[7] == "D";
}
}
Other files
contracts/interfaces/IModerationStrategy.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.30; /// @title IModerationStrategy /// @notice Interface for pluggable event moderation strategies. /// Implementations are notified when an event is created and must call back /// `ProphecyCore.approveEvent()` or `ProphecyCore.rejectEvent()`. interface IModerationStrategy { /// @notice Called by ProphecyCore when a new event is created while moderation is active. /// @param eventId The ProphecyCore event ID. /// @param name The event name (the question being moderated). /// @param eventContext ABI-encoded context for moderation (e.g. resolution prompt + string options). /// @dev msg.value contains the moderation deposit to be forwarded to the agent platform. function onEventCreated( uint256 eventId, string calldata name, bytes calldata eventContext ) external payable; /// @notice Returns the cost required for moderation. /// @return The moderation cost in wei that must be sent with onEventCreated(). function getModerationCost() external view returns (uint256); }contracts/interfaces/IProphecyCore.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.30; import { IProphecySettlement } from "./IProphecySettlement.sol"; import { IVenueRegistry } from "./IVenueRegistry.sol"; import { IModerationStrategy } from "./IModerationStrategy.sol"; enum ResolverType { NONE, ON_CHAIN, AI, CREATOR, MULTI_OUTCOME } /// @notice Moderation status for a market. enum ModerationStatus { None, // 0 — no moderation required (default, backwards-compatible) Pending, // 1 — awaiting moderation decision, not yet tradeable Approved, // 2 — moderation passed, tradeable Rejected // 3 — moderation failed, market voided, permanently untradeable } /// @notice Lifecycle status for a market. enum MarketStatus { PENDING, // 0 — pre-market tasks incomplete ACTIVE, // 1 — tasks complete, trading open (or ready to open) CLOSED, // 2 — trading window ended, awaiting resolution RESOLVED, // 3 — outcome determined (YES/NO) VOIDED, // 4 — voided (outcome=2) SETTLED // 5 — settlement finalized } /// @notice Trade action IDs used in the TradePermit EIP-712 signature. enum TradeAction { BUY_YES, // 0 BUY_NO, // 1 SELL_YES, // 2 SELL_NO, // 3 ADD_LIQUIDITY, // 4 REMOVE_LIQUIDITY, // 5 ADD_LIQUIDITY_FROM_SHARES, // 6 REMOVE_LIQUIDITY_TO_SHARES // 7 } /// @title IProphecyCore /// @notice Interface for the core Prophecy CPMM prediction market contract. /// Handles market registration, trading, liquidity provision, and settlement preparation. interface IProphecyCore { // ========================================================================= // Structs // ========================================================================= /// @notice Core on-chain state for a single binary prediction market. struct MarketCore { uint256 tradingStartTs; uint256 tradingEndTs; uint256 resolutionStartTs; uint256 resolutionEndTs; address creator; address resolver; // market implementation (registering contract) address stakeToken; // address(0) native bool resolved; uint8 outcome; // 0=NO, 1=YES, 2=VOIDED uint256 totalYesShares; uint256 totalNoShares; uint256 totalShares; // sum of the above uint256 participantCount; // unique traders (holding any shares or traded at least once) uint256 initialLiquidityBase; // initial liquidity in base units (wei for native token) uint256 feeBps; // per-market LP trading fee in basis points (locked at creation from protocol) } /// @notice A user's share position in a market. struct SharePosition { uint256 yes; uint256 no; bool claimed; } /// @notice Parameters for registering a new market via a resolver contract. /// @dev Venue signature verification is handled by the calling resolver, not ProphecyCore. /// venueSignature and deadline are kept for frontend compatibility but ignored by ProphecyCore. struct MarketRegistrationParams { string name; uint256 venueId; bytes venueSignature; address creator; address stakeToken; uint256 tradingStartTs; uint256 tradingEndTs; uint256 resolutionStartTs; uint256 resolutionEndTs; uint256 initialLiquidityBase; uint8 noMatchOutcome; // 0=NO, 2=VOIDED - what happens if no resolution event uint8 resolverType; // must match the resolver's ResolverType (1=ON_CHAIN, 2=AI, 3=CREATOR) uint256 deadline; } // ========================================================================= // Events // ========================================================================= event MarketEventCreated(uint256 indexed eventId, string name, address indexed resolver); event MarketRegistered( uint256 indexed marketId, address indexed creator, address stakeToken, string name, uint256 venueId, uint256 openTs, uint256 closeTs, uint256 resolutionStartTs, uint256 resolutionEndTs, uint256 initialLiquidity, address resolverOrigin, ResolverType resolverType ); event MarketRegisteredV2( uint256 indexed marketId, address indexed creator, address stakeToken, string name, uint256 venueId, uint256 openTs, uint256 closeTs, uint256 resolutionStartTs, uint256 resolutionEndTs, uint256 initialLiquidity, address resolverOrigin, ResolverType resolverType, uint256 indexed eventId ); event MarketResolved(uint256 indexed marketId, uint8 outcome); event MarketNameGenerated(uint256 indexed marketId, string generatedName); event MarketComputedNameSet(uint256 indexed marketId, string computedName); event EventNameGenerated(uint256 indexed eventId, string generatedName); event WinningsClaimed(uint256 indexed marketId, address indexed user, uint256 payout); // CPMM specific event Trade( uint256 indexed marketId, address indexed trader, bool indexed sideYes, bool isBuy, uint256 tokenAmount, uint256 shareAmount, uint256 fee ); /// @notice Emitted after every trade with updated raw pool reserves. event PriceChange(uint256 indexed marketId, uint256 yesPool, uint256 noPool); event MarketRegistrationRejected(uint256 indexed venueId, address indexed creator, string reason); event VenueTradeFeeClaimed(uint256 indexed venueId, address indexed owner, address stakeToken, uint256 amount); event ModerationStrategySet(address indexed strategy); event EventPendingModeration(uint256 indexed eventId, address indexed strategy); event EventModerationApproved(uint256 indexed eventId); event EventModerationRejected(uint256 indexed eventId, string reason); // Pre-market readiness events event EventTaskCompleted(uint256 indexed eventId, uint256 taskBit); event EventReady(uint256 indexed eventId); event EventTaskDeadlineExpired(uint256 indexed eventId); event DeferredModerationDepositRefunded(uint256 indexed eventId, uint256 amount); // Market lifecycle events event MarketStatusChanged(uint256 indexed marketId, MarketStatus indexed status); // Agent cost events event LLMInferenceCostPerAgentSet(uint256 cost); event WebFetchCostPerAgentSet(uint256 cost); event ModerationCommitteeSizeSet(uint256 size); // ========================================================================= // Custom Errors // ========================================================================= /// @notice Thrown when the caller is not a whitelisted resolver contract. error NotResolver(); /// @notice Thrown when the caller is not the settlement contract. error NotSettlement(); /// @notice Thrown when the supplied market ID does not correspond to an existing market. error MarketNotFound(); /// @notice Thrown when a native-token operation is called with msg.value == 0. error NoValueSent(); /// @notice Thrown when a required amount parameter is zero. error ZeroAmount(); /// @notice Thrown when a required address parameter is the zero address. error ZeroAddress(); /// @notice Thrown when a native token transfer fails. error TransferFailed(); /// @notice Thrown when the market name is an empty string. error EmptyName(); /// @notice Thrown when tradingStartTs is not in the future. error TradingStartInPast(); /// @notice Thrown when tradingEndTs <= tradingStartTs. error InvalidTradingWindow(); /// @notice Thrown when resolutionStartTs < tradingEndTs. error InvalidResolutionStart(); /// @notice Thrown when resolutionEndTs <= resolutionStartTs. error InvalidResolutionEnd(); /// @notice Thrown when the resolution window is shorter than the minimum. error ResolutionWindowTooShort(); /// @notice Thrown when an EIP-712 permit has expired. error PermitExpired(); /// @notice Thrown when noMatchOutcome is neither 0 (NO) nor 2 (VOIDED). error InvalidNoMatchOutcome(); /// @notice Thrown when msg.value does not match the required initial liquidity for native-token markets. error IncorrectValue(); /// @notice Thrown when msg.value > 0 for an ERC20-staked operation. error NativeNotExpected(); /// @notice Thrown when the sum of creator + LP + venue reward rates exceeds 100 %. error ExcessiveRake(); /// @notice Thrown when the pool has not been initialized (both reserves are zero). error PoolNotInitialized(); /// @notice Thrown when a liquidity deposit is too small to mint any LP shares. error DepositTooSmall(); /// @notice Thrown when the output amount or shares fall below the caller's minimum. error SlippageExceeded(); /// @notice Thrown on a buy whose effective price (amountIn / sharesOut) exceeds 1. /// @dev Each winning share redeems for at most 1 stake (minus rake), so paying /// more than 1 stake per share is objectively irrational regardless of /// outcome prediction. Catches the thin-pool footgun where fees and /// slippage combine to push the per-share cost above par. See review #10. error EffectivePriceAbovePar(); /// @notice Thrown when the caller does not hold enough shares or LP tokens. error InsufficientBalance(); /// @notice Thrown when reducing extracted collateral would underflow. error ExtractedCollateralUnderflow(); /// @notice Thrown when an operation is attempted on an already-finalized market. error MarketFinalized(); /// @notice Thrown when there are no LP shares, so no liquidity exists for trading. error NoLiquidity(); /// @notice Thrown when the combined LP + venue fee exceeds the caller's maxFeeBps. error ExcessiveFees(); /// @notice Thrown when trading is attempted outside the trading window. error MarketClosed(); /// @notice Thrown when an action requires the market to be resolved but it is not. error NotResolved(); /// @notice Thrown when the settlement contract address has not been configured. error SettlementNotSet(); /// @notice Thrown when a user attempts to claim winnings that have already been claimed. error AlreadyClaimed(); /// @notice Thrown when amountIn is non-zero for a native-token buy (should use msg.value). error UnexpectedAmountParam(); /// @notice Thrown when a payout transfer to the recipient fails. error PayoutFailed(); /// @notice Thrown when the resolverType in params does not match the resolver's registered type. error ResolverTypeMismatch(); /// @notice Thrown when the supplied eventId does not exist. error EventNotFound(); /// @notice Thrown when the caller is not the resolver that created the event. error EventResolverMismatch(); /// @notice Thrown when there are no pending fees or rewards to claim. error NothingToClaim(); /// @notice Thrown when the caller is not the venue owner. error NotVenueOwner(); /// @notice Thrown when the caller is not the moderation strategy. error NotModerator(); /// @notice Thrown when a market's event is pending moderation or rejected. error EventNotApproved(); /// @notice Thrown when the event's pre-market task deadline has expired. error EventDeadlineExpired(); /// @notice Thrown when the event's pre-market tasks are not yet complete. error EventNotReady(); /// @notice Thrown when trying to void an event that is already ready. error EventAlreadyReady(); /// @notice Thrown when trying to void an event whose deadline has not expired. error DeadlineNotExpired(); /// @notice Thrown when setting a deadline that is not in the future. error DeadlineInPast(); /// @notice Thrown when a moderation action targets a non-pending market. error NotPendingModeration(); // ========================================================================= // Market Registration // ========================================================================= /// @notice Called by a whitelisted resolver to register a new prediction market. /// @param params The market registration parameters including name, timing, and stake token. /// @param resolver The address of the resolver contract that will determine the outcome. /// @return marketId The unique identifier assigned to the newly created market. /// @dev Reverts with `EmptyName` if `params.name` is empty. /// @dev Reverts with `TradingStartInPast` if `params.tradingStartTs <= block.timestamp`. /// @dev Reverts with `InvalidTradingWindow` if `params.tradingEndTs <= params.tradingStartTs`. /// @dev Reverts with `InvalidResolutionStart` if `params.resolutionStartTs < params.tradingEndTs`. /// @dev Reverts with `InvalidResolutionEnd` if `params.resolutionEndTs <= params.resolutionStartTs`. /// @dev Reverts with `InvalidNoMatchOutcome` if `params.noMatchOutcome` is not 0 or 2. /// @dev Reverts with `IncorrectValue` if native-token msg.value does not match initial liquidity. /// @dev Reverts with `NativeNotExpected` if msg.value > 0 for an ERC20-staked market. /// @dev Reverts with `ExcessiveRake` if creator + LP + venue reward rates exceed 100 %. /// @dev Reverts with "Venue inactive" if the venue is not active. /// @dev Reverts with "Invalid signature" if the venue permit signature is invalid. function registerMarket( MarketRegistrationParams calldata params, address resolver, address resolverOrigin, uint256 eventId, bytes calldata eventContext ) external payable returns (uint256); /// @notice Create a new market event. Only callable by whitelisted resolvers. /// @param name Human-readable name for the event (the "question"). /// @param eventContext ABI-encoded context for name generation and moderation. /// @return eventId The unique identifier assigned to the newly created event. /// @dev If moderation is enabled, msg.value is forwarded as the moderation deposit. function createMarketEvent( string calldata name, bytes calldata eventContext ) external payable returns (uint256 eventId); /// @notice Return all market IDs belonging to an event. /// @param eventId The event to query. /// @return marketIds The array of market IDs in the event. function getEventMarkets( uint256 eventId ) external view returns (uint256[] memory marketIds); // ========================================================================= // CPMM Trading // ========================================================================= /// @notice Buy YES shares by depositing tokens into the pool. /// @param marketId The market to trade on. /// @param amountIn Token amount to spend (ignored for native-token markets; use msg.value). /// @param minSharesOut Minimum shares to receive (slippage protection). /// @param maxFeeBps Maximum acceptable total fee in basis points. /// @param venueId Venue through which the trade is routed. /// @param signature EIP-712 trade permit signed by the venue signer. /// @return sharesOut The number of YES shares received. /// @dev Reverts with `MarketNotFound` if the market does not exist. /// @dev Reverts with `MarketClosed` if trading is outside the open window. /// @dev Reverts with `MarketFinalized` if the market has been finalized. /// @dev Reverts with `ZeroAmount` if the effective amount is zero. /// @dev Reverts with `NoLiquidity` if there are no LP shares. /// @dev Reverts with `ExcessiveFees` if LP + venue fee exceeds `maxFeeBps`. /// @dev Reverts with `SlippageExceeded` if `sharesOut < minSharesOut`. /// @dev Reverts with `NoValueSent` if native-token market and msg.value == 0. /// @dev Reverts with `NativeNotExpected` if ERC20 market and msg.value > 0. /// @dev Reverts with `PayoutFailed` if the venue fee transfer fails. /// @dev Reverts with "Venue inactive" if the venue is not active. /// @dev Reverts with "Invalid signature" if the trade permit is invalid. function buyYes( uint256 marketId, uint256 amountIn, uint256 minSharesOut, uint256 maxFeeBps, uint256 venueId, uint256 deadline, bytes calldata signature ) external payable returns (uint256 sharesOut); /// @notice Buy NO shares by depositing tokens into the pool. /// @param marketId The market to trade on. /// @param amountIn Token amount to spend (ignored for native-token markets; use msg.value). /// @param minSharesOut Minimum shares to receive (slippage protection). /// @param maxFeeBps Maximum acceptable total fee in basis points. /// @param venueId Venue through which the trade is routed. /// @param signature EIP-712 trade permit signed by the venue signer. /// @return sharesOut The number of NO shares received. /// @dev Reverts with `MarketNotFound` if the market does not exist. /// @dev Reverts with `MarketClosed` if trading is outside the open window. /// @dev Reverts with `MarketFinalized` if the market has been finalized. /// @dev Reverts with `ZeroAmount` if the effective amount is zero. /// @dev Reverts with `NoLiquidity` if there are no LP shares. /// @dev Reverts with `ExcessiveFees` if LP + venue fee exceeds `maxFeeBps`. /// @dev Reverts with `SlippageExceeded` if `sharesOut < minSharesOut`. /// @dev Reverts with `NoValueSent` if native-token market and msg.value == 0. /// @dev Reverts with `NativeNotExpected` if ERC20 market and msg.value > 0. /// @dev Reverts with `PayoutFailed` if the venue fee transfer fails. /// @dev Reverts with "Venue inactive" if the venue is not active. /// @dev Reverts with "Invalid signature" if the trade permit is invalid. function buyNo( uint256 marketId, uint256 amountIn, uint256 minSharesOut, uint256 maxFeeBps, uint256 venueId, uint256 deadline, bytes calldata signature ) external payable returns (uint256 sharesOut); /// @notice Sell YES shares to withdraw tokens from the pool. /// @param marketId The market to trade on. /// @param sharesIn Number of YES shares to sell. /// @param minAmountOut Minimum token amount to receive (slippage protection). /// @param maxFeeBps Maximum acceptable total fee in basis points. /// @param venueId Venue through which the trade is routed. /// @param signature EIP-712 trade permit signed by the venue signer. /// @return amountOut The token amount received after fees. /// @dev Reverts with `MarketNotFound` if the market does not exist. /// @dev Reverts with `MarketClosed` if trading is outside the open window. /// @dev Reverts with `MarketFinalized` if the market has been finalized. /// @dev Reverts with `ZeroAmount` if sharesIn is zero. /// @dev Reverts with `NoLiquidity` if there are no LP shares. /// @dev Reverts with `InsufficientBalance` if the caller does not hold enough YES shares. /// @dev Reverts with `ExcessiveFees` if LP + venue fee exceeds `maxFeeBps`. /// @dev Reverts with `SlippageExceeded` if `amountOut < minAmountOut`. /// @dev Reverts with "Venue inactive" if the venue is not active. /// @dev Reverts with "Invalid signature" if the trade permit is invalid. function sellYes( uint256 marketId, uint256 sharesIn, uint256 minAmountOut, uint256 maxFeeBps, uint256 venueId, uint256 deadline, bytes calldata signature ) external returns (uint256 amountOut); /// @notice Sell NO shares to withdraw tokens from the pool. /// @param marketId The market to trade on. /// @param sharesIn Number of NO shares to sell. /// @param minAmountOut Minimum token amount to receive (slippage protection). /// @param maxFeeBps Maximum acceptable total fee in basis points. /// @param venueId Venue through which the trade is routed. /// @param signature EIP-712 trade permit signed by the venue signer. /// @return amountOut The token amount received after fees. /// @dev Reverts with `MarketNotFound` if the market does not exist. /// @dev Reverts with `MarketClosed` if trading is outside the open window. /// @dev Reverts with `MarketFinalized` if the market has been finalized. /// @dev Reverts with `ZeroAmount` if sharesIn is zero. /// @dev Reverts with `NoLiquidity` if there are no LP shares. /// @dev Reverts with `InsufficientBalance` if the caller does not hold enough NO shares. /// @dev Reverts with `ExcessiveFees` if LP + venue fee exceeds `maxFeeBps`. /// @dev Reverts with `SlippageExceeded` if `amountOut < minAmountOut`. /// @dev Reverts with "Venue inactive" if the venue is not active. /// @dev Reverts with "Invalid signature" if the trade permit is invalid. function sellNo( uint256 marketId, uint256 sharesIn, uint256 minAmountOut, uint256 maxFeeBps, uint256 venueId, uint256 deadline, bytes calldata signature ) external returns (uint256 amountOut); // ========================================================================= // Liquidity // ========================================================================= /// @notice Add liquidity from stake tokens. Mints LP shares proportional to the deposit. /// @param marketId The market to add liquidity to. /// @param amountIn Token amount to deposit (ignored for native-token markets; use msg.value). /// @param minLpSharesOut Minimum LP shares to receive (slippage protection). /// @param venueId Venue for trade permit verification. /// @param signature EIP-712 trade permit signed by the venue signer. /// @return lpSharesMinted The number of LP shares minted. /// @dev Reverts with `MarketNotFound` if the market does not exist. /// @dev Reverts with `MarketClosed` if the market is outside the trading window. /// @dev Reverts with `MarketFinalized` if the market has been finalized. /// @dev Reverts with `ZeroAmount` if the effective amount is zero. /// @dev Reverts with `PoolNotInitialized` if the pool has no reserves. /// @dev Reverts with `DepositTooSmall` if no LP shares would be minted. /// @dev Reverts with `SlippageExceeded` if `lpSharesMinted < minLpSharesOut`. /// @dev Reverts with `NoValueSent` if native-token market and msg.value == 0. /// @dev Reverts with `NativeNotExpected` if ERC20 market and msg.value > 0. /// @dev Reverts with "Venue inactive" if the venue is not active. /// @dev Reverts with "Invalid signature" if the trade permit is invalid. function addLiquidity( uint256 marketId, uint256 amountIn, uint256 minLpSharesOut, uint256 venueId, uint256 deadline, bytes calldata signature ) external payable returns (uint256 lpSharesMinted); /// @notice Remove liquidity to receive stake tokens back. Burns LP shares. /// @param marketId The market to remove liquidity from. /// @param lpSharesAmount Number of LP shares to burn. /// @param minAmountOut Minimum token amount to receive (slippage protection). /// @param venueId Venue for trade permit verification. /// @param signature EIP-712 trade permit signed by the venue signer. /// @return amountOut The token amount withdrawn. /// @dev Reverts with `MarketNotFound` if the market does not exist. /// @dev Reverts with `MarketClosed` if the market is outside the trading window. /// @dev Reverts with `MarketFinalized` if the market has been finalized. /// @dev Reverts with `ZeroAmount` if lpSharesAmount is zero. /// @dev Reverts with `InsufficientBalance` if the caller does not hold enough LP shares. /// @dev Reverts with `SlippageExceeded` if `amountOut < minAmountOut`. /// @dev Reverts with "Venue inactive" if the venue is not active. /// @dev Reverts with "Invalid signature" if the trade permit is invalid. function removeLiquidity( uint256 marketId, uint256 lpSharesAmount, uint256 minAmountOut, uint256 venueId, uint256 deadline, bytes calldata signature ) external returns (uint256 amountOut); /// @notice Add liquidity by converting YES+NO share pairs into LP shares. /// @param marketId The market to add liquidity to. /// @param amount Number of share pairs to convert (1 pair = 1 YES + 1 NO). /// @param minLpSharesOut Minimum LP shares to receive (slippage protection). /// @param venueId Venue for trade permit verification. /// @param deadline EIP-712 permit deadline (0 = no deadline). /// @param signature EIP-712 trade permit signed by the venue signer. /// @return lpSharesMinted The number of LP shares minted. function addLiquidityFromShares( uint256 marketId, uint256 amount, uint256 minLpSharesOut, uint256 venueId, uint256 deadline, bytes calldata signature ) external returns (uint256 lpSharesMinted); /// @notice Remove liquidity to receive YES and NO shares instead of stake tokens. /// @param marketId The market to remove liquidity from. /// @param lpSharesAmount Number of LP shares to burn. /// @param minYesOut Minimum YES shares to receive (slippage protection). /// @param minNoOut Minimum NO shares to receive (slippage protection). /// @param venueId Venue for trade permit verification. /// @param deadline EIP-712 permit deadline (0 = no deadline). /// @param signature EIP-712 trade permit signed by the venue signer. /// @return yesOut The number of YES shares received. /// @return noOut The number of NO shares received. function removeLiquidityToShares( uint256 marketId, uint256 lpSharesAmount, uint256 minYesOut, uint256 minNoOut, uint256 venueId, uint256 deadline, bytes calldata signature ) external returns (uint256 yesOut, uint256 noOut); // ========================================================================= // Quote Helpers // ========================================================================= /// @notice Simulate a buy without executing it. /// @param marketId The market to quote. /// @param amountIn Token amount to spend. /// @param yesSide True to quote YES shares, false for NO. /// @param venueId Venue whose fee rate is included in the calculation. /// @return sharesOut Estimated shares received. /// @return fee Total fee that would be deducted. function quoteBuy( uint256 marketId, uint256 amountIn, bool yesSide, uint256 venueId ) external view returns (uint256 sharesOut, uint256 fee); /// @notice Simulate a sell without executing it. /// @param marketId The market to quote. /// @param sharesIn Number of shares to sell. /// @param yesSide True to quote selling YES shares, false for NO. /// @param venueId Venue whose fee rate is included in the calculation. /// @return amountOutNet Estimated token amount after fees. /// @return fee Total fee that would be deducted. function quoteSell( uint256 marketId, uint256 sharesIn, bool yesSide, uint256 venueId ) external view returns (uint256 amountOutNet, uint256 fee); // ========================================================================= // Views // ========================================================================= /// @notice Return core state and name for a market. Lazily resolves if the resolution window has passed. /// @param marketId The market to query. /// @return core The market's core state struct. /// @return name The market's human-readable name. /// @dev Reverts with `MarketNotFound` if the market does not exist. function getMarketCore( uint256 marketId ) external view returns (MarketCore memory core, string memory name); /// @notice Return a user's YES/NO share position for a market. /// @param marketId The market to query. /// @param user The address to look up. /// @return position The user's share position. function getUserPosition( uint256 marketId, address user ) external view returns (SharePosition memory position); /// @notice Return the current YES and NO pool reserves for a market. /// @param marketId The market to query. /// @return yesPool The current YES pool reserve. /// @return noPool The current NO pool reserve. function getCurrentReserves( uint256 marketId ) external view returns (uint256 yesPool, uint256 noPool); /// @notice Claim accrued venue trading fees (pull pattern). /// @param venueId The venue whose accumulated fees to claim. /// @param stakeToken The token address (address(0) for native). /// @return amount The amount claimed. /// @dev Reverts with `NotVenueOwner` if the caller is not the venue owner. /// @dev Reverts with `NothingToClaim` if there are no pending fees. function claimVenueTradeFees( uint256 venueId, address stakeToken ) external returns (uint256 amount); /// @notice Claim accrued LP trading fees for a market. /// @param marketId The market to claim fees from. /// @return amount The fee amount claimed. /// @dev Reverts with `NothingToClaim` if the caller has no pending fees. function claimLPFees( uint256 marketId ) external returns (uint256 amount); /// @notice Return the pending (unclaimed) LP trading fees for a user. /// @param marketId The market to query. /// @param user The LP address to look up. /// @return The pending fee amount. function getPendingLPFees( uint256 marketId, address user ) external view returns (uint256); /// @notice Return the next market ID that will be assigned. /// @return id The next market ID. function nextMarketId() external view returns (uint256 id); /// @notice Return the settlement contract address. /// @return settlement The ProphecySettlement contract. function settlementContract() external view returns (IProphecySettlement settlement); /// @notice Return the venue gating (VenueRegistry) contract. /// @return The VenueRegistry contract used for venue permits and conditions. function venueGating() external view returns (IVenueRegistry); // ========================================================================= // Moderation // ========================================================================= /// @notice Set the global moderation strategy. address(0) disables moderation. /// @param strategy The moderation strategy contract address. function setModerationStrategy( address strategy ) external; /// @notice Returns the cost required for moderation, or 0 if no strategy is set. /// @return The moderation cost in wei. function getModerationCost() external view returns (uint256); /// @notice Called by the moderation strategy to approve a pending event. /// Records the ready timestamp; trading start is lazily adjusted at trade time. /// @param eventId The event to approve. function approveEvent( uint256 eventId ) external; /// @notice Called by the moderation strategy to reject a pending event. /// All markets in the event are voided (outcome = 2). /// @param eventId The event to reject. /// @param reason Human-readable rejection reason. function rejectEvent( uint256 eventId, string calldata reason ) external; /// @notice Set an AI-generated name for a market. Only callable by the market's resolver. /// @param marketId The market to update. /// @param _generatedName The AI-generated display name. function setGeneratedName( uint256 marketId, string calldata _generatedName ) external; /// @notice Return the AI-generated name for a market, or empty string if not yet generated. /// @param marketId The market to query. function getGeneratedName( uint256 marketId ) external view returns (string memory); /// @notice Set the computed (derived) name for a market. Only callable by allowlisted resolvers. /// @param marketId The market to update. /// @param _computedName The computed display name (e.g. "5-10", "Red or Blue"). function setComputedName( uint256 marketId, string calldata _computedName ) external; /// @notice Return the computed name for a market, or empty string if not set. /// @param marketId The market to query. function getComputedName( uint256 marketId ) external view returns (string memory); /// @notice Set an AI-generated name for an event. Only callable by the event's resolver. /// @param eventId The event to update. /// @param name The AI-generated event display name. function setGeneratedEventName( uint256 eventId, string calldata name ) external; /// @notice Complete the event naming task without setting a generated name. /// Used as a fallback when AI name generation fails so that the event /// is not stuck in PENDING. Only callable by the event's resolver. /// @param eventId The event whose naming task should be marked complete. function completeEventNaming( uint256 eventId ) external; /// @notice Return the AI-generated event name, or empty string if not yet generated. /// @param eventId The event to query. function getGeneratedEventName( uint256 eventId ) external view returns (string memory); // ========================================================================= // Market Status // ========================================================================= /// @notice Return the derived lifecycle status for a market. /// @param marketId The market to query. /// @return status The current MarketStatus. function getMarketStatus( uint256 marketId ) external view returns (MarketStatus status); /// @notice Return derived lifecycle statuses for multiple markets. /// @param marketIds The markets to query. /// @return statuses The current MarketStatus for each market. function getMarketStatuses( uint256[] calldata marketIds ) external view returns (MarketStatus[] memory statuses); // ========================================================================= // Pre-Market Readiness // ========================================================================= /// @notice Check whether all required pre-market tasks for an event are complete. /// @param eventId The event to query. /// @return ready True if the event is ready for trading. function isEventReady( uint256 eventId ) external view returns (bool ready); /// @notice Set the task deadline for an event. Only callable by the event's resolver. /// @param eventId The event to update. /// @param deadline The timestamp by which all tasks must complete. function setEventTaskDeadline( uint256 eventId, uint256 deadline ) external; // ========================================================================= // Agent Cost Parameters // ========================================================================= /// @notice Return the cost per agent for LLM inference requests (moderation, naming). function llmInferenceCostPerAgent() external view returns (uint256); /// @notice Return the cost per agent for web fetch requests (resolution). function webFetchCostPerAgent() external view returns (uint256); /// @notice Set the cost per agent for LLM inference requests. /// @param cost The cost in wei per agent. function setLLMInferenceCostPerAgent( uint256 cost ) external; /// @notice Set the cost per agent for web fetch requests. /// @param cost The cost in wei per agent. function setWebFetchCostPerAgent( uint256 cost ) external; }contracts/interfaces/IProphecySettlement.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.30; /// @title IProphecySettlement /// @notice Interface for the Prophecy post-resolution settlement contract. /// Handles trader winnings, LP capital returns, creator rewards, and venue rewards. interface IProphecySettlement { // ========================================================================= // Custom Errors // ========================================================================= /// @notice Thrown when the caller has no winnings or rewards to claim. error NothingToClaim(); /// @notice Thrown when the caller has already claimed for this market. error AlreadyClaimed(); /// @notice Thrown when the caller has zero LP shares for the market. error NoLPShares(); /// @notice Thrown when the caller is not the market creator. error NotCreator(); /// @notice Thrown when the caller is not the venue owner. error NotVenueOwner(); /// @notice Thrown when a payout transfer to the recipient fails. error PaymentFailed(); /// @notice Thrown when a required amount parameter is zero. error ZeroAmount(); /// @notice Thrown when a required address parameter is the zero address. error ZeroAddress(); // ========================================================================= // Functions // ========================================================================= /// @notice Claim trader settlement from a resolved market. Caller receives their payout. /// @param marketId The resolved market to claim from. /// @return payout The token amount paid out to the caller. /// @dev Reverts with `NothingToClaim` if the caller has no winning shares. /// @dev Reverts with `AlreadyClaimed` if the caller's position was already claimed. /// @dev Reverts with `PaymentFailed` if the payout transfer fails. function claimSettlement( uint256 marketId ) external returns (uint256 payout); /// @notice Eagerly finalize settlement data for a market (idempotent). /// @param marketId The market to finalize. function finalizeMarket( uint256 marketId ) external; /// @notice Claim LP capital return, resolution rewards, and unclaimed trade-time fees. /// @param marketId The resolved market to claim from. /// @return capitalReturn The proportional LP capital returned. /// @return rewardAmount The proportional LP resolution reward. /// @dev Reverts with `AlreadyClaimed` if the LP settlement was already claimed. /// @dev Reverts with `NoLPShares` if the caller has no LP shares. function claimLPSettlement( uint256 marketId ) external returns (uint256 capitalReturn, uint256 rewardAmount); /// @notice Claim the creator's share of resolution-time rewards. /// @param marketId The resolved market to claim from. /// @return amount The creator reward amount. /// @dev Reverts with `AlreadyClaimed` if the creator reward was already claimed. /// @dev Reverts with `NotCreator` if the caller is not the market creator. function claimCreatorReward( uint256 marketId ) external returns (uint256 amount); /// @notice Claim the venue operator's share of resolution-time rewards. /// @param marketId The resolved market to claim from. /// @return amount The venue reward amount. /// @dev Reverts with `AlreadyClaimed` if the venue reward was already claimed. /// @dev Reverts with `NotVenueOwner` if the caller is not the venue owner. function claimVenueReward( uint256 marketId ) external returns (uint256 amount); /// @notice Batch-claim venue rewards across all outstanding markets for a venue. /// @param venueId The venue whose outstanding rewards to claim. /// @return totalAmount The total reward amount claimed across all markets. /// @dev Reverts with `NotVenueOwner` if the caller is not the venue owner. function claimVenueRewards( uint256 venueId ) external returns (uint256 totalAmount); /// @notice Return the list of market IDs with unclaimed venue rewards for a venue. /// @param venueId The venue to query. /// @return The array of market IDs with outstanding rewards. function getOutstandingVenueRewards( uint256 venueId ) external view returns (uint256[] memory); }contracts/interfaces/IVenueRegistry.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.30; /// @title IVenueRegistry /// @notice Interface for the Prophecy venue gating registry. Venues control market creation /// access via signature verification, wallet lists, and token-balance requirements. interface IVenueRegistry { // --- Enums --- enum ListMode { NONE, ALLOW, DENY } // --- Events --- event VenueCreated(uint256 indexed venueId, address indexed owner, address signer, bool active); event VenueUpdated(uint256 indexed venueId, address indexed owner, address signer, bool active); event VenueOwnerChanged(uint256 indexed venueId, address indexed newOwner); event ResolverSet(address indexed resolver, bool allowed); event NonceConsumed(uint256 indexed venueId, address indexed user, uint256 newNonce); event WalletListModeSet(uint256 indexed venueId, ListMode mode); event WalletListUpdated(uint256 indexed venueId, address[] wallets, bool onList); event NftRequirementsSet(uint256 indexed venueId); event Erc20RequirementsSet(uint256 indexed venueId); // Fee-related events event VenueFeeBpsSet(uint256 indexed venueId, uint256 bps); event VenueRewardBpsSet(uint256 indexed venueId, uint256 bps); // ========================================================================= // Venue Lifecycle // ========================================================================= /// @notice Create a new venue. The caller becomes the venue owner. /// @param signer The address that will sign EIP-712 permits for this venue. /// @param active Whether the venue is immediately active. /// @return venueId The ID of the newly created venue. /// @dev Reverts with "Venue ID already exists" if the venue slot is occupied. function createVenue( address signer, bool active ) external returns (uint256 venueId); /// @notice Transfer venue ownership to a new address. /// @param venueId The venue to transfer. /// @param newOwner The new owner address. /// @dev Reverts with "not venue owner" if the caller is not the current owner. /// @dev Reverts with "zero address for new owner" if `newOwner` is address(0). function transferVenueOwnership( uint256 venueId, address newOwner ) external; /// @notice Update the signer address for a venue. /// @param venueId The venue to update. /// @param signer The new signer address. /// @dev Reverts with "not venue owner" if the caller is not the venue owner. /// @dev Reverts with "zero address for active venue" if setting a zero signer on an active venue. function setVenueSigner( uint256 venueId, address signer ) external; /// @notice Activate or deactivate a venue. /// @param venueId The venue to update. /// @param active Whether the venue should be active. /// @dev Reverts with "not venue owner" if the caller is not the venue owner. /// @dev Reverts with "zero address for active venue" if activating a venue with no signer. function setVenueStatus( uint256 venueId, bool active ) external; /// @notice Set the venue's per-trade fee rate. /// @param venueId The venue to update. /// @param bps Fee rate in basis points. /// @dev Reverts with "not venue owner" if the caller is not the venue owner. /// @dev Reverts with "exceeds max venue fee" if `bps > MAX_VENUE_FEE_BPS`. function setVenueFeeBps( uint256 venueId, uint256 bps ) external; /// @notice Set the venue's resolution-time reward rate. /// @param venueId The venue to update. /// @param bps Reward rate in basis points. /// @dev Reverts with "not venue owner" if the caller is not the venue owner. /// @dev Reverts with "exceeds max venue reward" if `bps > MAX_VENUE_REWARD_BPS`. function setVenueRewardBps( uint256 venueId, uint256 bps ) external; // ========================================================================= // Signature Verification // ========================================================================= /// @notice Generic signature consumer. Verifies an EIP-712 permit and increments the nonce. /// @param venueId The venue whose signer is expected. /// @param user The user on whose behalf the permit is consumed. /// @param structHash The EIP-712 struct hash (caller is responsible for including the nonce). /// @param signature The EIP-712 signature bytes. /// @dev Reverts with "not resolver" if the caller is not a whitelisted resolver. /// @dev Reverts with "Venue inactive" if the venue is not active. /// @dev Reverts with "Invalid signature" if the recovered signer does not match. /// @dev Reverts with "Conditions not met" if on-chain conditions fail. function consumeGenericPermit( uint256 venueId, address user, bytes32 structHash, bytes calldata signature ) external; // ========================================================================= // Views // ========================================================================= /// @notice Get the current permit nonce for a (venue, user) pair. /// @param venueId The venue. /// @param user The user address. /// @return nonce The current nonce (auto-increments on each consumed permit). function getNonce( uint256 venueId, address user ) external view returns (uint256 nonce); /// @notice Returns the venue's trading fee rate in basis points. /// @param venueId The venue to query. /// @return bps The fee rate. function getVenueFeeBps( uint256 venueId ) external view returns (uint256 bps); /// @notice Returns the venue's resolution-time reward rate in basis points. /// @param venueId The venue to query. /// @return bps The reward rate. function getVenueRewardBps( uint256 venueId ) external view returns (uint256 bps); /// @notice Returns the venue's owner address (fee recipient). /// @param venueId The venue to query. /// @return owner The owner address. function getVenueOwner( uint256 venueId ) external view returns (address owner); }
ABI · 24 entries
json
[
{
"type": "constructor",
"inputs": [
{
"name": "_prophecyCore",
"type": "address",
"internalType": "address"
},
{
"name": "_platform",
"type": "address",
"internalType": "address"
},
{
"name": "_agentId",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "_systemPrompt",
"type": "string",
"internalType": "string"
},
{
"name": "_committeeSize",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "nonpayable"
},
{
"name": "InsufficientDeposit",
"type": "error",
"inputs": []
},
{
"name": "OnlyOwner",
"type": "error",
"inputs": []
},
{
"name": "OnlyPlatform",
"type": "error",
"inputs": []
},
{
"name": "OnlyProphecyCore",
"type": "error",
"inputs": []
},
{
"name": "ZeroAddress",
"type": "error",
"inputs": []
},
{
"name": "ZeroCommitteeSize",
"type": "error",
"inputs": []
},
{
"name": "CommitteeSizeSet",
"type": "event",
"inputs": [
{
"name": "size",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"name": "ModerationRequested",
"type": "event",
"inputs": [
{
"name": "eventId",
"type": "uint256",
"indexed": true,
"internalType": "uint256"
},
{
"name": "requestId",
"type": "uint256",
"indexed": true,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"name": "ModerationResponse",
"type": "event",
"inputs": [
{
"name": "eventId",
"type": "uint256",
"indexed": true,
"internalType": "uint256"
},
{
"name": "requestId",
"type": "uint256",
"indexed": true,
"internalType": "uint256"
},
{
"name": "accepted",
"type": "bool",
"indexed": false,
"internalType": "bool"
},
{
"name": "response",
"type": "string",
"indexed": false,
"internalType": "string"
}
],
"anonymous": false
},
{
"name": "agentId",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "committeeSize",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "getModerationCost",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "handleResponse",
"type": "function",
"inputs": [
{
"name": "requestId",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "responses",
"type": "tuple[]",
"components": [
{
"name": "validator",
"type": "address",
"internalType": "address"
},
{
"name": "result",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "status",
"type": "uint8",
"internalType": "enum ResponseStatus"
},
{
"name": "receipt",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "timestamp",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "executionCost",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct AgentResponse[]"
},
{
"name": "status",
"type": "uint8",
"internalType": "enum ResponseStatus"
},
{
"name": "",
"type": "tuple",
"components": [
{
"name": "id",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "requester",
"type": "address",
"internalType": "address"
},
{
"name": "callbackAddress",
"type": "address",
"internalType": "address"
},
{
"name": "callbackSelector",
"type": "bytes4",
"internalType": "bytes4"
},
{
"name": "subcommittee",
"type": "address[]",
"internalType": "address[]"
},
{
"name": "responses",
"type": "tuple[]",
"components": [
{
"name": "validator",
"type": "address",
"internalType": "address"
},
{
"name": "result",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "status",
"type": "uint8",
"internalType": "enum ResponseStatus"
},
{
"name": "receipt",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "timestamp",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "executionCost",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct AgentResponse[]"
},
{
"name": "responseCount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "failureCount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "threshold",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "createdAt",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "deadline",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "status",
"type": "uint8",
"internalType": "enum ResponseStatus"
},
{
"name": "consensusType",
"type": "uint8",
"internalType": "enum ConsensusType"
},
{
"name": "remainingBudget",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct AgentRequest"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "onEventCreated",
"type": "function",
"inputs": [
{
"name": "eventId",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "name",
"type": "string",
"internalType": "string"
},
{
"name": "eventContext",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [],
"stateMutability": "payable"
},
{
"name": "owner",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"name": "platform",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract ISomniaAgents"
}
],
"stateMutability": "view"
},
{
"name": "prophecyCore",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract IProphecyCore"
}
],
"stateMutability": "view"
},
{
"name": "requestToEvent",
"type": "function",
"inputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "setCommitteeSize",
"type": "function",
"inputs": [
{
"name": "_committeeSize",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "setSystemPrompt",
"type": "function",
"inputs": [
{
"name": "_systemPrompt",
"type": "string",
"internalType": "string"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "systemPrompt",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "view"
},
{
"name": "transferOwnership",
"type": "function",
"inputs": [
{
"name": "newOwner",
"type": "address",
"internalType": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "receive",
"stateMutability": "payable"
}
]