Exit to App
How It Works

Deterministic Policy Engine

Deep technical specification of the 18 deterministic rules evaluated in evaluateSwapPolicy().

The Deterministic Policy Engine (packages/policy-engine/src/index.ts) is the heart of MOI security. Every proposed transaction must pass every rule before a signature or broadcast is permitted.

#Rule IdentifierCheck DescriptionFailure Action
1MANDATE_NOT_PAUSEDVerifies treasury and mandate are not under emergency stop.REJECT with 403 Forbidden
2FIRST_TRADE_OWNER_AUTHORIZATIONEnforces explicit owner signature if treasury has 0 settled executions.REQUIRE_OWNER_APPROVAL
3OPERATING_MODEConfirms current mode permits automated or staged execution.STAGE for approval if not autonomous
4NO_DUPLICATE_LOCKPrevents race conditions by rejecting if an execution is already in flight.REJECT with 409 Conflict
5SIGNER_HEALTHYConfirms restricted signer environment is operational and separated.ABORT with 500 Error
6CHAIN_ID_CELO_MAINNETVerifies target network is strictly Celo Mainnet (42220).REJECT immediately
7FIRM_QUOTE_PRESENTRequires a firm executable RFQ quote, rejecting indicative previews.REJECT unexecutable quote
8TAKER_WALLET_MATCHEnsures quote taker matches the authorized agent wallet address.REJECT spoofed taker
9QUOTE_NOT_EXPIREDValidates current timestamp is strictly before quote accept deadline.REJECT with 410 Expired
10ALLOWLISTED_CORRIDORValidates sellToken and buyToken match the approved mandate corridor.REJECT unauthorized corridor
11APPROVED_REACTOR_TARGETTarget contract must strictly be Textile LimitOrderReactor (0xa9AA...).REJECT invalid destination
12CALLDATA_AND_VALUE_GUARDRequires msg.value == 0 and valid Permit2/Reactor calldata encoding.REJECT unsafe calldata
13PER_TRADE_CAPEnsures sell amount in atomic units does not exceed maxTradeAtomic.REJECT trade cap breach
14DAILY_SELL_CAPEnsures 24h rolling cumulative volume does not exceed dailySellCapAtomic.REJECT daily limit breach
15MINIMUM_RESERVE_PRESERVEDValidates post-trade balance will strictly remain >= minimumReserveAtomic.REJECT reserve exhaustion
16MIN_BUY_OUTPUT_THRESHOLDVerifies buy output satisfies minimum amount after maxSlippageBps.REJECT price impact / slippage
17PROTOCOL_FEE_BOUNDVerifies Textile protocol fee does not exceed fee ceiling (default 25 bps).REJECT excessive fee
18DAILY_LOSS_CIRCUIT_BREAKERTrips if daily realized negative drift exceeds maxDailyLossAtomic.TRIP circuit breaker & pause