Skip to main content

The Router

Status: Partially implemented. Solana settlement via Jupiter is live. Cross-chain settlement (Circle CCTP V2) and gasless transactions (Kora) are planned.
AGG (Aggregator) is the payment router for the 402 (Payment Required) economy. It abstracts away the complexity of blockchain payments, allowing users to pay with any token on any chain.

Routing Architecture

AGG functions like a DEX aggregator (Jupiter) but for payments, not just swaps. It solves the “n-to-1” problem: Users have n tokens on m chains, but the Merchant wants 1 specific token on 1 chain.

1. The 402 Handshake

The protocol begins when a client hits a gated resource. Server Response (402 Payment Required)
HTTP/1.1 402 Payment Required
WWW-Authenticate: 555x402 realm="sector-13",
  amount="5.00",
  token="USDC",
  chain="solana",
  recipient="HuW...9zP"

2. Pathfinding

The AGG Client (SDK) calculates the optimal route based on the user’s wallet state. Factors:
  • Gas Cost: Solana (less than $0.001) vs Base vs Polygon.
  • Swap Slippage: If paying with SOL to settle in USDC (routed via Jupiter).
  • Bridge Time: If paying from Base to settle on Solana (via CCTP V2).
Example Route: User (Base/ETH) -> Uniswap (USDC) -> CCTP V2 Bridge -> Solana (USDC) -> Merchant

3. Solana Settlement (v0 + LUTs)

On Solana, AGG uses Versioned Transactions (v0) and Address Lookup Tables (LUTs) to pack complex logic into a single atomic transaction with sub-2-second finality. Transaction Structure:
  1. Swap Instruction: Jupiter CPI to convert User Token -> USDC.
  2. Fee Instruction: Transfer platform fee to Treasury.
  3. Payment Instruction: Transfer remaining amount to Merchant.
  4. Memo Instruction: Attach orderId for reconciliation.
pub fn settle_payment(ctx: Context<Settle>, amount: u64) -> Result<()> {
    token::transfer(ctx.accounts.user, ctx.accounts.merchant, amount)?;
    emit!(PaymentSettled { id: ctx.accounts.order.id });
}

Fee Structure

AGG enforces a transparent fee model:
Fee TypeRatePayerDescription
Platform Fee0.5–1.0%MerchantDeducted from the settlement amount.
Gas FeeVariableUserNetwork costs (gasless via Kora where supported).

Cross-Chain Settlement

For cross-chain payments (e.g., Base -> Solana), AGG utilizes Circle CCTP V2 (Cross-Chain Transfer Protocol).
  1. Burn (Source): User burns USDC on source chain.
  2. Attest (Circle): Circle verifies the burn.
  3. Mint (Destination): USDC minted on destination chain and forwarded to Merchant.

Integrations

  • Jupiter: Optimal swap routing on Solana.
  • Kora: Gasless transaction sponsorship — users don’t need SOL for gas.
  • Circle CCTP V2: Non-custodial cross-chain USDC transfers.