{
  "openapi": "3.1.0",
  "info": {
    "title": "AMLIL API",
    "version": "0.3.0",
    "summary": "Hook aggregator for Uniswap v4 on Robinhood Chain, paid per call with x402.",
    "description": "Registry of every Uniswap v4 hook on Robinhood Chain with Aggregator Hooks detected by behaviour; quotes across native, hooked and external liquidity plus Hookline's aggregated route, each leg with a ready Universal Router transaction; compute jobs signed by the node. Paid endpoints use x402 v2 with USDG on Robinhood Chain (chain id 4663). Free endpoints need nothing.",
    "x-chain": {
      "registry": "eip155:4663",
      "payments": "eip155:4663"
    },
    "x-x402": {
      "scheme": "exact",
      "network": "eip155:4663",
      "asset": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
      "assetSymbol": "USDG",
      "decimals": 6,
      "payTo": "0xcbEb870973D4b022D035d828906A8B91364Fc300",
      "eip712": {
        "name": "Global Dollar",
        "version": "1"
      },
      "facilitator": "https://amlil.app/api/facilitator",
      "flow": "Unpaid request -> 402 with PAYMENT-REQUIRED header (base64 JSON, x402 v2). Sign an EIP-3009 TransferWithAuthorization for the amount, retry with PAYMENT-SIGNATURE. Response carries PAYMENT-RESPONSE with the settlement tx."
    }
  },
  "servers": [
    {
      "url": "https://amlil.app"
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "summary": "Node, chain and payment details",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/stats": {
      "get": {
        "summary": "Index stats: hooks, pools, aggregator hooks, external pools, head block, settled calls",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/hooks": {
      "get": {
        "summary": "Hook registry",
        "description": "Every v4 hook indexed from PoolManager.Initialize: address, kind (aggregator|fee|order|guard|oracle|liquidity|full), flags decoded from the address, pools, pairs, score, price, and for aggregator hooks the detection evidence. Unpaid requests get a 6-hook preview in the 402 body.\n\nPaid with x402: 0.001 USDG per call.",
        "x-x402": {
          "price": "0.001",
          "scheme": "exact",
          "network": "eip155:4663",
          "asset": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
          "assetSymbol": "USDG",
          "decimals": 6,
          "payTo": "0xcbEb870973D4b022D035d828906A8B91364Fc300",
          "eip712": {
            "name": "Global Dollar",
            "version": "1"
          },
          "facilitator": "https://amlil.app/api/facilitator",
          "flow": "Unpaid request -> 402 with PAYMENT-REQUIRED header (base64 JSON, x402 v2). Sign an EIP-3009 TransferWithAuthorization for the amount, retry with PAYMENT-SIGNATURE. Response carries PAYMENT-RESPONSE with the settlement tx."
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "402": {
            "description": "Payment required. Header PAYMENT-REQUIRED carries the requirements.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                },
                "description": "base64 JSON: {x402Version, accepts:[{scheme,network,amount,asset,payTo,maxTimeoutSeconds,extra}]}"
              }
            }
          }
        }
      }
    },
    "/api/route": {
      "post": {
        "summary": "Quote and swap transactions for a pair",
        "description": "Quotes every candidate pool for the pair through the v4 Quoter, ranks by output, labels each leg native|hooked|external and attaches a Universal Router transaction (to, data, value, minOut, deadline, needsApproval). Also returns Hookline's aggregated route when available. Body: {sell, buy, amount, pin?: address[], taker?: address}. Tokens are symbols (ETH, USDG) or 0x addresses.\n\nPaid with x402: 0.002 USDG per call.",
        "x-x402": {
          "price": "0.002",
          "scheme": "exact",
          "network": "eip155:4663",
          "asset": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
          "assetSymbol": "USDG",
          "decimals": 6,
          "payTo": "0xcbEb870973D4b022D035d828906A8B91364Fc300",
          "eip712": {
            "name": "Global Dollar",
            "version": "1"
          },
          "facilitator": "https://amlil.app/api/facilitator",
          "flow": "Unpaid request -> 402 with PAYMENT-REQUIRED header (base64 JSON, x402 v2). Sign an EIP-3009 TransferWithAuthorization for the amount, retry with PAYMENT-SIGNATURE. Response carries PAYMENT-RESPONSE with the settlement tx."
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "402": {
            "description": "Payment required. Header PAYMENT-REQUIRED carries the requirements.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                },
                "description": "base64 JSON: {x402Version, accepts:[{scheme,network,amount,asset,payTo,maxTimeoutSeconds,extra}]}"
              }
            }
          }
        }
      }
    },
    "/api/jobs": {
      "post": {
        "summary": "Compute job signed by the node",
        "description": "Body: {kind: impact-sim|vol-surface|fee-model, params?}. Returns input, output, resultHash and the node's signature over the hash; verify with any EIP-191 library against `signer`.\n\nPaid with x402: 0.005 USDG per call.",
        "x-x402": {
          "price": "0.005",
          "scheme": "exact",
          "network": "eip155:4663",
          "asset": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
          "assetSymbol": "USDG",
          "decimals": 6,
          "payTo": "0xcbEb870973D4b022D035d828906A8B91364Fc300",
          "eip712": {
            "name": "Global Dollar",
            "version": "1"
          },
          "facilitator": "https://amlil.app/api/facilitator",
          "flow": "Unpaid request -> 402 with PAYMENT-REQUIRED header (base64 JSON, x402 v2). Sign an EIP-3009 TransferWithAuthorization for the amount, retry with PAYMENT-SIGNATURE. Response carries PAYMENT-RESPONSE with the settlement tx."
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "402": {
            "description": "Payment required. Header PAYMENT-REQUIRED carries the requirements.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                },
                "description": "base64 JSON: {x402Version, accepts:[{scheme,network,amount,asset,payTo,maxTimeoutSeconds,extra}]}"
              }
            }
          }
        }
      }
    },
    "/api/allowance": {
      "get": {
        "summary": "ERC-20 -> Permit2 and Permit2 -> Universal Router allowances for an owner",
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "owner",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/tx/{hash}": {
      "get": {
        "summary": "Transaction receipt on the registry chain",
        "parameters": [
          {
            "name": "hash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "status success|reverted|pending"
          }
        }
      }
    },
    "/api/balance/{address}": {
      "get": {
        "summary": "Payment asset and native balances",
        "parameters": [
          {
            "name": "address",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/ledger": {
      "get": {
        "summary": "Recent x402 settlements on this node",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/facilitator": {
      "get": {
        "summary": "Self-hosted x402 facilitator status (gas readiness)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/facilitator/supported": {
      "get": {
        "summary": "x402 facilitator: supported kinds",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/facilitator/verify": {
      "post": {
        "summary": "x402 facilitator: verify {paymentPayload, paymentRequirements}",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/facilitator/settle": {
      "post": {
        "summary": "x402 facilitator: settle {paymentPayload, paymentRequirements}",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/hookline/quote": {
      "post": {
        "summary": "Fresh Hookline quote for a taker (free, 60s validity)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/hookline/swap": {
      "post": {
        "summary": "Build the Hookline transaction {quoteId, permitSignature?}",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/hookline/track": {
      "post": {
        "summary": "Track a sent Hookline swap {quoteId, txHash}",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/hookline/status/{hash}": {
      "get": {
        "summary": "Hookline swap status",
        "parameters": [
          {
            "name": "hash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/burns": {
      "get": {
        "summary": "Fee buyback and burn: policy, total $AMLIL burned by the node, pending USDG, and every burn transaction (rebuilt from on-chain Transfer logs)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/burn/run": {
      "post": {
        "summary": "Run a buyback now (operator or Vercel cron only; x-burn-secret or Authorization: Bearer CRON_SECRET)",
        "responses": {
          "200": {
            "description": "burn executed"
          },
          "401": {
            "description": "unauthorized"
          },
          "409": {
            "description": "not run: below threshold, gas below reserve, or already running"
          }
        }
      }
    }
  }
}
