Settlement Console
Execute x402 payment-gated settlement workflows
📋 What is a Settlement?
A settlement is a payment-gated workflow that uses AI agents to analyze vault state and recommend safe withdrawal limits before executing multi-step settlement operations. This implements the x402 Payment Required protocol, where settlements must be paid for before execution.
🔑 What is a Job ID?
A Job ID is a unique identifier for your settlement request (e.g., "job-001", "settlement-abc"). It tracks the payment status and links the payment (Step 1) to the execution (Step 2). You can use any string, but it must be the same in both steps.
job-001- Simple numeric IDsettlement-2024-001- Date-based IDuser-alice-batch-1- User-specific ID
⚙️ Parameters Explained
- Job ID (required) - Unique identifier for this settlement
- User Address (required) - The wallet address to analyze (0x...)
- Agent (required) - Which AI agent to use for analysis
- Requested Amount (optional) - Amount you want to withdraw in CRO. If provided, the agent will validate if it's safe. If omitted, the agent will recommend an optimal limit based on your vault balance.
🔄 Two-Step Workflow
Payment (x402)
Purpose: Pay for the settlement service before execution.
What happens: You submit a Job ID and pay 1.0 TCRO via MetaMask. The payment is sent to the SettlementPayment smart contract on Cronos Testnet, which marks this Job ID as "paid" on-chain and allows you to proceed to Step 2.
Why it's needed: The x402 protocol ensures settlements are paid for before consuming computational resources (AI analysis, blockchain transactions).
Run Settlement
Purpose: Execute the AI-powered settlement analysis and on-chain transaction.
What happens:
- System verifies the Job ID was paid (from Step 1)
- Reads your current vault balance and withdrawal limit from the blockchain
- Selected AI agent analyzes your vault state and recommends a safe withdrawal limit
- System applies safety clamps (max 50% of balance by default)
- If you provided a requested amount, validates it doesn't exceed the recommended limit
- Writes the new recommended limit to the blockchain via
agentSetWithdrawLimit() - Executes settlement pipeline (validate, calculate fees, route payouts, finalize)
🤖 Agent Selection
Different agents use different strategies to recommend withdrawal limits:
- Portfolio Rebalancer AI - Uses GPT-4 for intelligent analysis (if AI enabled), falls back to 20% of balance
- Settlement Batch Optimizer - Recommends 40% of balance, optimized for batch operations
- Withdrawal Risk Sentinel - Conservative approach, starts at 50% and tightens by 5% on subsequent calls
- Emergency Brake - Crisis mode, recommends only 10% for high-risk situations
Step 1: Payment (x402)
Step 2: Run Settlement
Complete the steps to execute a settlement