Skip to main content
Attach runtime conditions to any composable transaction. Transactions wait until conditions are met before execution - enabling limit orders, price-based triggers, and safe conditional operations.

Why Use Conditional Execution?

Traditional approach: Execute immediately and hope conditions are met, or build complex smart contracts
With conditions: Transactions wait intelligently until requirements are satisfied, then execute automatically

Key Benefits

  • Smart waiting - Transactions stay PENDING until conditions are met (limit orders, price triggers, etc.)
  • User protection - Only execute when safe (sufficient balance, healthy positions, etc.)
  • MEV protection - Check price slippage before swaps execute
  • Gas efficient - Avoid failed transactions by verifying conditions first
  • Works everywhere - Compatible with ALL instruction types (transfer, approve, default, etc.)
  • Type-safe - Full TypeScript support with ABI inference

Common Use Cases

  • Limit orders - Wait for price to reach target level before executing
  • Balance-triggered actions - Execute when funds arrive from bridges or swaps
  • Safety checks - Verify contract state (not paused) before execution
  • DeFi safeguards - Ensure healthy positions before borrowing or withdrawing
  • Slippage protection - Only execute swaps at acceptable prices

Quick Start

1

Install the SDK

2

Create a Condition

3

Add to Any Instruction

4

Execute

How It Works

Conditions leverage the composability system’s STATIC_CALL mechanism with intelligent waiting:
Two execution paths:
  1. Immediate execution - All conditions pass → Transaction executes immediately
  2. Waiting mode - Conditions not met → Transaction stays PENDING, MEE periodically rechecks until conditions pass or timeout expires
Under the hood: Each condition becomes an InputParam that calls a view/pure function and validates the result against your constraint (GTE, LTE, or EQ). MEE simulates execution periodically, and once simulation succeeds (all conditions pass), the transaction executes onchain.

API Reference

createCondition

Create a condition that must be satisfied for execution.

ConditionType

Examples:

Common Patterns

Minimum Balance Check

Contract Not Paused

Multiple Conditions (AND Logic)

All conditions must pass for execution.
All conditions must pass - The transaction waits (PENDING) until all conditions are satisfied, or fails if timeout expires.
Create a limit order that waits for a price target.
Check current price before executing swaps.

Waiting for Conditions

When conditions aren’t immediately met, MEE keeps the transaction in PENDING state and periodically checks until conditions pass.
Lifecycle:
  1. Submit transaction with conditions
  2. PENDING - MEE periodically checks conditions
  3. Condition satisfied - Transaction executes automatically
  4. MINED_SUCCESS - Complete
If conditions aren’t met within the timeout period, the transaction will eventually FAIL.

Best Practices

1. Always Add Descriptions

2. Use Type-Safe ABIs

3. Limit Number of Conditions

Each condition adds ~5,000-10,000 gas:
  • ✅ 1-3 conditions - Optimal
  • ⚠️ 4-5 conditions - Acceptable if necessary
  • ❌ 6+ conditions - Consider refactoring

4. Order by Likelihood of Failure

Place most likely to fail conditions first:

5. Handle Decimal Precision

6. Use Appropriate Constraint Types

Troubleshooting

Condition Always Fails

Problem: Condition consistently reverts. Solutions:
  • Verify decimal precision matches token (USDC = 6, WETH = 18)
  • Check constraint type is correct (GTE vs LTE vs EQ)
  • Test the view function directly to see actual return value
  • Ensure target contract address is correct

Transaction Stuck in PENDING

Problem: Transaction never executes. Solutions:
  • Check if condition can realistically be met
  • Verify correct contract address
  • Set reasonable upperBoundTimestamp
  • Test condition function returns expected value

Type Errors with ABI

Problem: TypeScript complains about function name or args. Solutions:
  • Ensure ABI is defined with as const
  • Check function exists in ABI
  • Verify args match function signature

Gas Estimation Fails

Problem: Transaction simulation fails. Solutions:
  • Simplify conditions or reduce count
  • Verify view functions can be called successfully
  • Check contract addresses are correct
  • Ensure function is truly view/pure (no state changes)

Summary

Conditional execution adds powerful runtime validation to your transactions:
  • ✅ Use createCondition() to define conditions
  • ✅ Add to any buildComposable call via conditions array
  • ✅ All conditions must pass for execution
  • ✅ Transactions wait intelligently until conditions are met
  • ✅ Perfect for limit orders, price triggers, and safe execution
  • ✅ Works with all instruction types
Start with simple balance checks, then expand to limit orders and complex validations.