System Events
Receive results of CoreWriter operations as EVM events
System Events
After the core engine processes CoreWriter-originated transactions, results are injected as event logs from the system address (0x0900) in the next EVM block. Contracts and off-chain listeners can filter for these events.
System Address
0x0000000000000000000000000000000000000900Event Definitions
interface IOlympusSystemEvents {
event OrderAccepted(address indexed account, bytes32 indexed orderId);
event OrderRejected(
address indexed account,
bytes32 indexed orderId,
string reason
);
event OrderFilled(
address indexed account,
bytes32 indexed orderId,
uint256 fillPrice,
uint256 fillQuantity,
uint256 remainingQuantity
);
// TradeExecuted is defined in IOlympusSystemEvents.sol but not yet
// emitted by the system event encoder. Reserved for future use.
// event TradeExecuted(bytes32 indexed orderId, uint256 price,
// uint256 quantity, uint64 timestamp);
event AssetLockConfirmed(
address indexed account,
string instrumentId,
uint256 quantity
);
event AssetUnlockConfirmed(
address indexed account,
string instrumentId,
uint256 quantity
);
}Listening from a Contract
import "./IOlympusSystemEvents.sol";
contract OrderTracker {
address constant SYSTEM = address(0x0900);
// Subscribe to fills via event logs
// Contracts cannot directly subscribe to events, but off-chain
// indexers can filter for events from the system address
}Listening Off-Chain (viem)
import { createPublicClient, http, parseAbiItem } from 'viem';
const client = createPublicClient({
transport: http('http://localhost:8545'),
});
const SYSTEM_ADDRESS = '0x0000000000000000000000000000000000000900';
// Watch for OrderFilled events
const unwatch = client.watchEvent({
address: SYSTEM_ADDRESS,
event: parseAbiItem(
'event OrderFilled(address indexed account, bytes32 indexed orderId, uint256 fillPrice, uint256 fillQuantity, uint256 remainingQuantity)'
),
onLogs: (logs) => {
for (const log of logs) {
console.log('Fill:', {
account: log.args.account,
orderId: log.args.orderId,
price: log.args.fillPrice,
quantity: log.args.fillQuantity,
});
}
},
});Timing
System events appear in the EVM block after the core engine processes the CoreWriter transaction. This means there is always a 1-block delay between submitting a CoreWriter transaction and receiving its result event.