Peregrine

Build custom flows that turn any signal into an automated, risk-controlled trade

Peregrine

Created At

ETHGlobal Lisbon 2026

Winner of

Uniswap

Uniswap Foundation - Best Uniswap API Integration 2nd place

Project Description

Peregrine is a visual automation builder for trading. A user creates a custom flow, chooses where information comes from - an X handle, webhook, scheduled API check, manual input, or onchain event - and decides what should happen next. The flow can add market and portfolio context, ask an AI model to buy, sell, swap, reduce a position, or hold, or skip AI and follow deterministic rules. Before execution, Peregrine applies balance and position limits, venue and asset allowlists, slippage controls, and a global kill switch. Saved flows run in the background, so they can react and trade even while the user is away. Every run keeps a record of the original signal, data used, decision, applied limits, and execution result.

How it's Made

Peregrine is a Bun and TypeScript monorepo. The interface is built with Next.js 16, React 19, Tailwind CSS 4, and React Flow 12. The canvas is not just a diagram: nodes and edges are saved as executable configuration. An Elysia API validates the graph and compiles the connected nodes into an execution plan, while a separate Bun worker handles background triggers. PostgreSQL and Drizzle store users, wallets, flows, runs, individual node outputs, execution attempts, and receipts.

Signals can enter through a public webhook endpoint, a manual or pasted payload, or the X polling worker. The X source watches the handles referenced by active flows using server-side session cookies; users never need to connect their own X account. New posts are deduplicated in PostgreSQL and delivered to every matching flow. The same runner is designed to support scheduled requests and onchain triggers without changing the rest of the flow.

AI decisions are requested through OpenRouter and must match strict Zod schemas. The model receives only the sources connected to its node and may choose only markets, tokens, and venues supplied by the backend. Invalid output is rejected or converted into a safe hold. AI is optional: a flow can also pass a deterministic trade instruction directly to the risk and execution nodes.

For Polymarket, Gamma provides market metadata and @polymarket/clob-client-v2 places signed orders. Peregrine uses a server-controlled owner key, a type-3 deposit wallet, and Polymarket’s builder relayer for deployment and approvals. The Graph supplies indexed Polymarket position and PnL data, while Polygon RPC reads actual spendable balances so portfolio value is never mistaken for available cash.

We also built a Uniswap Classic execution client around the Uniswap Trading API. It validates quotes, token addresses, amounts, balances, gas, slippage, price impact, approvals, and Permit2 data before signing with viem. Broadcast checkpoints and receipt verification make retries safer. World AgentKit provides the trust layer for integrations that Peregrine explicitly marks as human-only: the backend verifies CAIP-122 proofs, checks AgentBook, prevents nonce replay, and blocks restricted execution before any venue request is made. Core Polymarket and Uniswap flows remain available without World verification.

background image mobile

Join the mailing list

Get the latest news and updates