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
Registry of escrow contracts
Registry of payment verifiers
Registry of post intent hooks
Registry of relayers
Protocol fee taken from taker (in preciseUnits, 1e16 = 1%)
Address that receives protocol fees
Whether to allow multiple intents per account
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.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.Hash of intent being cancelled
IntentPruned(intentHash)
fulfillIntent
Fulfills an intent by verifying the off-chain payment proof.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.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.Array of intent hashes to prune
Governance Functions
setEscrowRegistry
Updates the escrow registry address.New escrow registry address
setProtocolFee
Updates the protocol fee.New protocol fee in preciseUnits (1e16 = 1%)
MAX_PROTOCOL_FEE (10%)
setProtocolFeeRecipient
Updates the protocol fee recipient address.New protocol fee recipient address
setAllowMultipleIntents
Sets whether all accounts can signal multiple intents.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 of the intent owner
Address to receive the funds
Escrow contract address
Deposit ID being taken from
Amount of tokens to receive
Payment method identifier
Fiat currency code
Conversion rate for the transaction
Payee identifier hash
Timestamp when the intent was signaled
Referrer address
Fee for the referrer
Post-intent hook contract
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
1e18 - Precision unit for fee calculations21888242871839275222246405745257275088548364400416034343698204186575808495617 - Prime field for intent hash calculations5e17 - Maximum referrer fee (50%)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