CoreWriter Contract
Submit trading intents from EVM smart contracts to the core matching engine
CoreWriter Contract
The OlympusCoreWriter is a system contract deployed at chain genesis at address 0x0A00. Smart contracts call it to submit trading intents to the core engine. Operations are asynchronous -- results arrive as system events in the next EVM block.
Contract Address
0x0000000000000000000000000000000000000A00Contract Interface
contract OlympusCoreWriter {
function placeOrder(
bytes32 orderId,
string calldata instrumentId,
uint8 side, // 0 = Buy, 1 = Sell
uint256 price, // 18-decimal fixed-point
uint256 quantity // 18-decimal fixed-point
) external;
function cancelOrder(bytes32 orderId) external;
function cancelReplace(
bytes32 oldOrderId,
bytes32 newOrderId,
uint256 newPrice,
uint256 newQuantity
) external;
function lockAsset(string calldata instrumentId, uint256 quantity) external;
function unlockAsset(
string calldata instrumentId,
uint256 quantity,
uint256 burnNonce
) external;
}How It Works
- Your contract calls
placeOrder(or another function) - The function validates inputs and emits an event log
- After the EVM block is sealed, the event processor extracts the log
- The log is decoded into a core
Transactionand injected into the sequencer - The core engine processes the transaction in the next tick
- Results are encoded as system events and injected into the next EVM block
Account Identity
msg.sender on the EVM side is the core AccountId. Both are 20-byte Ethereum addresses. No separate mapping or registration is required.
Usage Example
import "./CoreWriter.sol";
contract TradingBot {
OlympusCoreWriter public coreWriter;
constructor(address _coreWriter) {
coreWriter = OlympusCoreWriter(_coreWriter);
}
function placeBuyOrder(
string calldata instrumentId,
uint256 price,
uint256 quantity
) external {
bytes32 orderId = keccak256(
abi.encodePacked(msg.sender, block.number, instrumentId)
);
coreWriter.placeOrder(orderId, instrumentId, 0, price, quantity);
}
}Price/Quantity Encoding
All prices and quantities use 18-decimal fixed-point (same as ERC-20 wei convention):
150.50=150500000000000000000(150.50 * 10^18)25shares =25000000000000000000(25 * 10^18)
The CoreWriter decoder converts these back to the engine's native i64 fixed-point using the instrument's price_scale and qty_scale.