Mercury
import { Aside } from ‘@astrojs/starlight/components’;
DPX integrates directly with Mercury — connecting Mercury’s banking layer to DPX’s settlement and oracle layer. When a Mercury payment is tagged for DPX routing, it flows automatically through oracle verification, Claude reasoning, and on-chain settlement.
How it works
Section titled “How it works”Mercury payment.sent → DPX /mercury-webhook → HMAC signature verified → Oracle check + Claude reasoning → router.settle() on Base mainnet → Settlement receipt loggedMercury handles the banking side (ACH, wires, balances). DPX handles the stablecoin settlement side (oracle intelligence, ESG scoring, on-chain execution).
1. Install Mercury CLI
Section titled “1. Install Mercury CLI”curl -sSf https://cli.mercury.com/install.sh | shmercury login2. Register the DPX webhook
Section titled “2. Register the DPX webhook”mercury webhook create \ --url https://agent.untitledfinancial.com/mercury-webhook \ --events payment.sentCopy the signing secret from the output.
3. Add secrets to the Settlement Agent
Section titled “3. Add secrets to the Settlement Agent”cd dpx-agents/settlement-agent
wrangler secret put MERCURY_WEBHOOK_SECRET# Paste the signing secret from step 2
wrangler secret put MERCURY_DEFAULT_RECIPIENT# Paste the on-chain wallet address for unspecified recipients4. Tag payments for DPX routing
Section titled “4. Tag payments for DPX routing”Include a DPX tag in the Mercury payment note or metadata:
| Method | Example |
|---|---|
| Note / memo | "Intercompany Q2 dpx:0xYourWalletAddress" |
| Payment metadata | dpx_recipient = 0xYourWalletAddress |
| Metadata flag | dpx_route = true (uses MERCURY_DEFAULT_RECIPIENT) |
Payments without a DPX tag are acknowledged but not routed — Mercury receives a 200 OK with action: ignored.
Payment routing
Section titled “Payment routing”The /mercury-webhook endpoint on the Settlement Agent:
- Verifies the
Mercury-SignatureHMAC-SHA256 header - Filters to
payment.sentevents only - Converts Mercury cents → USD
- Extracts the on-chain recipient from metadata, note, or default
- Routes to the standard DPX settlement flow — oracle check, Claude decision, on-chain execution
Cross-currency settlements
Section titled “Cross-currency settlements”To route a Mercury USD payment to a EUR settlement, add destination_currency to the payment metadata:
destination_currency = EURDPX will apply FX fee (0.40%) and route through EURC on Base.
Polling (alternative to webhook)
Section titled “Polling (alternative to webhook)”For environments where webhooks aren’t available, the Mercury watcher polls for new transactions every 10 seconds:
export MERCURY_API_KEY=your_keyexport DPX_AGENT_URL=https://agent.untitledfinancial.comexport DPX_DEFAULT_RECIPIENT=0xYourAddress
npm run watch# from dpx-agents/mercury/The watcher picks up payments containing dpx:0x... in the note field and routes them identically to the webhook flow.
Mercury CLI reference
Section titled “Mercury CLI reference”mercury account list # Check balancesmercury payment create # Initiate a paymentmercury transaction list # Recent transactionsmercury webhook list # View registered webhooksmercury webhook delete <id> # Remove a webhookEnvironment variables
Section titled “Environment variables”| Variable | Required | Description |
|---|---|---|
MERCURY_WEBHOOK_SECRET | Yes (webhook) | Signing secret from Mercury webhook registration |
MERCURY_DEFAULT_RECIPIENT | Recommended | Fallback on-chain address for dpx_route=true payments |
MERCURY_API_KEY | Yes (watcher) | Mercury API key for polling mode |
What happens on HOLD
Section titled “What happens on HOLD”If the oracle is in CAUTION or UNSTABLE, Claude will HOLD the settlement:
{ "settlementId": "dpx_abc123", "status": "held", "reasoning": "CAUTION conditions with $500,000 exceeds $100K threshold. Flagging for review.", "oracleScore": 81}The Mercury payment is already sent — DPX logs the hold. Resubmit when oracle returns STABLE, using the same referenceId.