Skip to main content

Order Lifecycle

Overview​

The Bungee Auto Mode is a order based execution with off-chain signatures designed to execute same chain and cross-chain swaps. When you want to swap tokens across chains, the protocol breaks down this intent into a series of steps, each optimized for security, efficiency, and best execution.

For same chain swaps, the protocol executes the swap directly on the source chain. The steps for same chain swaps are much simpler as the swap is performed directly on the source chain atomically.

For cross-chain swaps, the protocol performs the following steps:

  1. Quote Generation
  2. Order Creation
  3. Auction
  4. Asset Extraction
  5. Fulfillment
  6. Settlement

Order Lifecycle

Stage Details​

1. Quote Generation​

PurposeBefore committing to a swap, get an estimate of the output amount
How it Works• Uses the Quoting Engine to check prices and liquidity
• Returns a quote with execution details
• Final execution price is determined during the auction phase, where off-chain agents compete to execute your order

2. Order Creation​

PurposeSubmit your swap request in a secure and cost-effective way
How it Works• Specify source token, destination token, and parameters
• Create order either offchain (ERC20) or onchain (any token)
• Uses Permit2 for gasless ERC20 approvals
• Includes protection parameters like slippage

Creating Orders​

For ERC20 tokens, you have two options:

  • Offchain: Create orders by signing messages using Permit2. This is gasless and only requires a one-time on-chain approval.
  • Onchain: Place orders directly through smart contracts, which requires gas fees.

For native tokens, orders must be created onchain through smart contract transactions, which always require gas fees and are secured by blockchain consensus.

3. Auction​

PurposeSelect the best executor based on price and reliability
How it Works• Order enters Bungee's auction house
• off-chain agents analyze and bid on the order
• Best bid wins

4. Asset Extraction​

PurposeLock the source tokens for the swap, guaranteeing the order's execution
How it Works• Winning Transmitter uses your Permit2 approval
• Extracts exact amount from order and may swap to an intermediate token if needed and permitted by user order
• Assets locked in smart contract for the duration of the swap

5. Fulfillment​

PurposeComplete the token swap on the destination chain
How it Works• Transmitter executes on destination chain
• Performs swaps if needed
• Must meet requirements set by user's order

6. Settlement​

PurposeSettle the order and unlock payment to the winning/executing off-chain agent
How it Works• Verify successful token transfer on destination chain
• Release locked token/stake
• Emit settlement event and update relevant contract states

Protection Mechanisms​

Protection TypeConditionsActions
Deadline ProtectionIf the order isn't executed by the deadline• The order expires automatically
• Extracted assets become refundable
• Refunds can be triggered by anyone, but our backend handles this automatically
Slippage ProtectionIf market conditions change• Execution reverts if it falls below the minimum threshold
• Assets are returned to the smart contract
• The order can be refunded and retried
Failed ExecutionIf execution fails• Assets remain secure in the smart contract
• A 3-hour settlement window begins
• Refunds occur automatically after the window
• Manual refunds are also supported

Error Handling​

Error StageConditionsConsequences
Before Asset ExtractionIf error occurs• Order remains valid
• No assets at risk
• Can be picked up by another transmitter
• Expires at deadline if not executed
After Asset ExtractionIf error occurs• Assets locked in contract
• 3-hour settlement window
• Automatic refund system by our backend or anyone can trigger a refund