ZenithPay iconZenithPay
Concepts

Auto-Swap

OKB -> USDG funding after policy gate

Auto-swap lets an agent pay USDG-settled x402 services when wallet balance is in OKB.

The swap is strictly a funding step: ZenithPay never swaps before SpendPolicy.sol approves the payment.

Auto-swap (funding mechanism)

Auto-swap exists to help agents pay services that require USDG when the agent has insufficient USDG but enough OKB.

Key rule: policy first, never swap first

ZenithPay always checks SpendPolicy.sol for the settlement-token-denominated maxAmount before any swap happens.

If policy fails, the payment is rejected immediately (status: "blocked"). If the payment is above the human review threshold, it is paused for approval (status: "pending"). No swap occurs in either case.

When swap happens

Swap is only attempted if USDG is insufficient to cover the requested payment amount.

Correct execution order (pay service)

  1. SpendPolicy check (settlement token amount)
  2. USDG balance check
  3. If needed: swap_quote -> swap_approve -> swap_swap for the exact required USDG
  4. x402 /verify -> /settle

Why exact amount matters

ZenithPay approves only what it needs for the payment, so slippage cannot accidentally push spending above the policy-gated cap.

On this page