# Divigent — treasury layer for x402 agent wallets > Divigent is the treasury layer for x402 agent wallets on Base. It helps agent wallets keep USDC ready for payments, recall liquidity before spend, and route idle USDC into supported Base yield venues. Live on Base mainnet and audited by Oak Security. ## Where Divigent sits ```text Agent wallet -> x402 payment lifecycle -> Divigent treasury hooks -> Base yield venues ``` Divigent is not an x402-paid endpoint. It is the treasury and liquidity layer around x402 agent wallets. The wallet remains the execution layer. Divigent does not hold private keys, does not sign transactions, and does not authorize payments. The SDK and contracts manage idle USDC around the payment lifecycle. ## Install ```bash npm install @divigent/sdk viem ``` Current public SDK package: `@divigent/sdk@1.0.5` ## Core SDK pattern ```ts import { Divigent, parseUsdc } from "@divigent/sdk"; const divigent = Divigent.create({ publicClient, walletClient, chain: "base", }); await divigent.ensureInitializedAndWait(); await divigent.depositWithApprovalAndWait({ amount: parseUsdc("10"), }); ``` ## x402 buyer-side integration Use `attachTo` to connect Divigent to an existing x402 client. Divigent can recall before payment if liquid USDC is short, and redeploy unused USDC above the idle buffer after settlement. ```ts import { Divigent, parseUsdc } from "@divigent/sdk"; import { x402HTTPClient, type x402Client } from "@x402/core/client"; import { wrapFetchWithPayment } from "@x402/fetch"; declare const client: x402Client; declare const merchantPayTo: `0x${string}`; const divigent = Divigent.create({ publicClient, walletClient, chain: "base", }); const handle = divigent.attachTo(client, { minIdleThreshold: parseUsdc("0.25"), maxPaymentAmount: parseUsdc("5"), maxSessionPaymentAmount: parseUsdc("25"), allowedPayTo: [merchantPayTo], requireAllowedPayTo: true, allowedOrigins: ["https://api.example.com"], allowedResources: ["https://api.example.com/paid"], }); const http = new x402HTTPClient(client); const fetchWithPayment = wrapFetchWithPayment(fetch, http); const fetchWithDivigent = handle.wrapFetchWithYield(fetchWithPayment, http); await fetchWithDivigent("https://api.example.com/paid"); handle.detach(); ``` ## Seller-side integration Seller integrations can use `attachToResourceServer(resourceServer, config)` to sweep merchant income into Divigent after x402 settlement while keeping an operating buffer liquid. ## Wallet analysis helpers These read public Base USDC transfer history. They do not require backend auth, do not sign, and do not move funds. ```ts const behavior = await divigent.analyzeWalletBehavior({ wallet: "0x...", lookbackDays: 30, }); const missedYield = await divigent.analyzeMissedYield({ wallet: "0x...", lookbackDays: 30, assumedApy: 0.045, minOperatingBalance: "0.25", }); ``` `analyzeWalletBehavior` returns current and average USDC balance, transfer counts, payment distribution stats, cadence, inferred buyer/seller/both role, and an EIP-3009/x402 signal when USDC moves while nonce remains zero. `analyzeMissedYield` replays deterministic reserve logic over historical USDC transfers and returns deployable USDC-days, estimated missed yield, capital-efficiency estimates, and short headline strings. ## Protocol metrics helper `getProtocolMetrics()` returns protocol-level traction metrics from on-chain Divigent router events and live accounting reads. ```ts const metrics = await divigent.getProtocolMetrics(); console.log(metrics.wallets.uniqueWalletsUsingDivigent); console.log(metrics.volume.cumulativeDepositedUsdc); console.log(metrics.tvl.currentTvlUsdc); console.log(metrics.transactions.totalTreasuryOperations); ``` Notes: - `transactions.totalDivigentTransactions` counts unique authorization, deposit, and withdrawal transactions. - `transactions.totalTreasuryOperations` counts unique deposit and withdrawal transactions. - `transactions.recallProxyTransactions` uses Divigent withdrawals as an on-chain recall proxy. - Exact x402-settled-via-Divigent attribution requires SDK/backend telemetry that correlates recalls with x402 settlement. ## Base mainnet contracts - DivigentVaultRouter: `0xE958A89c2CCa697d4896990685800cc1D5AF2A01` - DivigentYieldOracle: `0x3Ba775E8fAE60E72c99dE10C720fC44ab38BF71A` - dvUSDC receipt token: `0x1497f7F3b156e110b1d90BC7F1759F40fb48Ea4F` - DivigentFeeCollector: `0x1a2eF76E6E323D95f836917f812f6D159c3A0960` ## Supported venues - Aave V3 Pool on Base - Steakhouse USDC Prime MetaMorpho V1 on Base ## Documentation - Main site: https://divigent.ai/ - GitBook docs: https://divigent.gitbook.io/divigent-docs - SDK quickstart: https://divigent.gitbook.io/divigent-docs/quick-start/sdk - x402 SDK guide: https://divigent.gitbook.io/divigent-docs/quick-start/x402-with-sdk - Payment lifecycle: https://divigent.gitbook.io/divigent-docs/quick-start/payment-lifecycle - Architecture overview: https://divigent.gitbook.io/divigent-docs/architecture/overview - Contract addresses: https://divigent.gitbook.io/divigent-docs/protocol/address-registry - SDK API reference: https://divigent.gitbook.io/divigent-docs/sdk/api-reference - MCP overview: https://divigent.gitbook.io/divigent-docs/mcp/overview - Oak Security audit: https://divigent.gitbook.io/divigent-docs/audit-report/oak-security-audit-report ## Repositories - SDK: https://github.com/Divigent/divigent-sdk - MCP server: https://github.com/Divigent/divigent-mcp - Protocol contracts: https://github.com/Divigent/divigent-protocol ## Contact - Email: hello@divigent.ai - X: https://x.com/DivigentAI