Orchestrator Contract
The Orchestrator contract manages the intent (order) lifecycle and orchestrates P2P trading of fiat currency and onchain assets. It coordinates with the Escrow contract to lock/unlock funds and handles intent fulfillment.Overview
- Contract:
Orchestrator.sol - Inherits:
Ownable,Pausable,ReentrancyGuard,IOrchestrator - Purpose: Manages intent lifecycle and orchestrates P2P trading
Key State Variables
IEscrowRegistry
Registry of escrow contracts
IPaymentVerifierRegistry
Registry of payment verifiers
IPostIntentHookRegistry
Registry of post intent hooks
IRelayerRegistry
Registry of relayers
uint256
Protocol fee taken from taker (in preciseUnits, 1e16 = 1%)
address
Address that receives protocol fees
bool
Whether to allow multiple intents per account
uint256
Counter for number of intents created; nonce for unique intent hashes
Core Functions
Intent Lifecycle
signalIntent
Signals intent to pay the depositor off-chain to unlock funds on-chain.SignalIntentParams
Struct containing all intent parameters:
escrow: Address of the escrow contractdepositId: The deposit ID to take fromamount: Amount of tokens to receiveto: Address to receive the fundspaymentMethod: Payment method identifierfiatCurrency: Fiat currency codeconversionRate: Conversion rate for the transactionreferrer: Optional referrer addressreferrerFee: Fee for the referrer (in preciseUnits)postIntentHook: Optional post-intent hook contractdata: Additional data for hooksgatingServiceSignature: Signature from the deposit’s gating servicesignatureExpiration: Expiration timestamp for the signature
IntentSignaled(intentHash, escrow, depositId, paymentMethod, owner, to, amount, fiatCurrency, conversionRate, timestamp)
cancelIntent
Cancels an outstanding intent. Only callable by the intent owner.bytes32
Hash of intent being cancelled
IntentPruned(intentHash)
fulfillIntent
Fulfills an intent by verifying the off-chain payment proof.FulfillIntentParams
Struct containing all fulfillment parameters:
intentHash: The intent hash to fulfillpaymentProof: Proof of the off-chain paymentverificationData: Additional data for payment verificationpostIntentHookData: Data to pass to the post-intent hook
IntentFulfilled(intentHash, to, netAmount, isManualRelease)IntentPruned(intentHash)
releaseFundsToPayer
Allows depositor to release funds to the payer in case of failed fulfillment or other arrangement.bytes32
Hash of intent to resolve by releasing the funds
IntentFulfilled(intentHash, to, netAmount, true)IntentPruned(intentHash)
Escrow Functions
pruneIntents
ESCROW ONLY: Called by escrow to prune specific expired intents.bytes32[]
Array of intent hashes to prune
Governance Functions
setEscrowRegistry
Updates the escrow registry address.address
New escrow registry address
setProtocolFee
Updates the protocol fee.uint256
New protocol fee in preciseUnits (1e16 = 1%)
MAX_PROTOCOL_FEE (10%)
setProtocolFeeRecipient
Updates the protocol fee recipient address.address
New protocol fee recipient address
setAllowMultipleIntents
Sets whether all accounts can signal multiple intents.bool
True to allow all accounts to signal multiple intents
Pause/Unpause
- Intent creation (signalIntent)
- Intent fulfillment (fulfillIntent)
- Intent cancellation (cancelIntent)
- Manual fund release (releaseFundsToPayer)
- Intent pruning by escrow (pruneIntents)
View Functions
getIntent
Returns the intent struct for a given intent hash.address
Address of the intent owner
address
Address to receive the funds
address
Escrow contract address
uint256
Deposit ID being taken from
uint256
Amount of tokens to receive
bytes32
Payment method identifier
bytes32
Fiat currency code
uint256
Conversion rate for the transaction
bytes32
Payee identifier hash
uint256
Timestamp when the intent was signaled
address
Referrer address
uint256
Fee for the referrer
IPostIntentHook
Post-intent hook contract
bytes
Additional data for hooks
getAccountIntents
Returns all active intent hashes for an account.getIntentMinAtSignal
Returns the minimum intent amount that was enforced when the intent was signaled.Events
IntentSignaled
Emitted when a new intent is signaled.IntentFulfilled
Emitted when an intent is fulfilled.IntentPruned
Emitted when an intent is pruned (cancelled or expired).Constants
uint256
1e18 - Precision unit for fee calculationsuint256
21888242871839275222246405745257275088548364400416034343698204186575808495617 - Prime field for intent hash calculationsuint256
5e17 - Maximum referrer fee (50%)uint256
1e17 - Maximum protocol fee (10%)Fee Structure
Fees are deducted from the release amount in the following order:- Protocol Fee: Taken from the release amount and sent to
protocolFeeRecipient - Referrer Fee: Taken from the release amount and sent to
referrer - Net Amount: Remaining amount sent to the intent recipient or post-intent hook