Skip to main content

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 contract
  • depositId: The deposit ID to take from
  • amount: Amount of tokens to receive
  • to: Address to receive the funds
  • paymentMethod: Payment method identifier
  • fiatCurrency: Fiat currency code
  • conversionRate: Conversion rate for the transaction
  • referrer: Optional referrer address
  • referrerFee: Fee for the referrer (in preciseUnits)
  • postIntentHook: Optional post-intent hook contract
  • data: Additional data for hooks
  • gatingServiceSignature: Signature from the deposit’s gating service
  • signatureExpiration: Expiration timestamp for the signature
Events Emitted:
  • IntentSignaled(intentHash, escrow, depositId, paymentMethod, owner, to, amount, fiatCurrency, conversionRate, timestamp)
Example:

cancelIntent

Cancels an outstanding intent. Only callable by the intent owner.
bytes32
Hash of intent being cancelled
Events Emitted:
  • IntentPruned(intentHash)

fulfillIntent

Fulfills an intent by verifying the off-chain payment proof.
FulfillIntentParams
Struct containing all fulfillment parameters:
  • intentHash: The intent hash to fulfill
  • paymentProof: Proof of the off-chain payment
  • verificationData: Additional data for payment verification
  • postIntentHookData: Data to pass to the post-intent hook
Events Emitted:
  • IntentFulfilled(intentHash, to, netAmount, isManualRelease)
  • IntentPruned(intentHash)
Example:

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
Events Emitted:
  • 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%)
Note: Fee must be less than or equal to 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

Paused Functionalities:
  • Intent creation (signalIntent)
  • Intent fulfillment (fulfillIntent)
Unpaused Functionalities (for fund recovery):
  • 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 calculations
uint256
21888242871839275222246405745257275088548364400416034343698204186575808495617 - Prime field for intent hash calculations
uint256
5e17 - Maximum referrer fee (50%)
uint256
1e17 - Maximum protocol fee (10%)

Fee Structure

Fees are deducted from the release amount in the following order:
  1. Protocol Fee: Taken from the release amount and sent to protocolFeeRecipient
  2. Referrer Fee: Taken from the release amount and sent to referrer
  3. Net Amount: Remaining amount sent to the intent recipient or post-intent hook