Inspiration
Hackathon Project Submission
Project name
xSepia
Elevator pitch
Set your investment strategy once, xSepia watches Polymarket odds in real time and repositions your tokenized stock portfolio before the market reacts.
About the project
Inspiration
We wanted to bring portfolio management onchain and let investors benefit from blockchain's core fundamentals: decentralization, transparency, and self-custody. Traditional brokerages hold your assets, execute on their timeline, and operate as black boxes. We believed there was a better way: vaults governed by immutable onchain rules, where the user is always the owner and the strategy is always verifiable.
The missing piece was intelligence. A vault that just rebalances on a timer is a robo-advisor clone. But Polymarket, where participants put real money behind their predictions, provides a live, incentive-aligned signal layer that consistently outperforms analyst consensus. We asked: what if onchain vaults holding xStocks could listen to prediction market odds and reposition automatically, before the price moves?
That's how xSepia was born.
What it does
xSepia allows people to create automated investment vaults that hold xStocks tokenized equities with custom, immutable onchain rules. Users configure their vault through 4 steps:
- Select xStocks - pick from available tokenized equities (AAPL, MSFT, NVDA, etc.)
- Set allocations - define the percentage weight for each xStock asset
- Choose a strategy - DCA (dollar-cost averaging) or manual
- Attach a signal - link a Polymarket probability to the vault with a threshold; when that threshold is reached, the vault triggers an action: Change Allocation, Buy Asset, Exit to Cash, or Pause Buying
Users fund with USDC, the vault buys xStocks according to the allocation, and the strategy runs on its own. No manual trading, no constant monitoring.
How we built it
xStocks as the asset layer. Every vault in xSepia holds xStocks tokenized equities as its core assets. When a user defines an allocation like 50% AAPL / 30% MSFT / 20% USDC, the vault calls xStocks' buy action to acquire tokenized stock positions. When a signal triggers a rebalance, the vault sells xStocks back through the same protocol. xStocks are not an add-on; they are the only equity asset type the system supports. Without xStocks, there is no product.
EIP-1271 vault contracts. The core architectural decision was to define each vault as a smart contract implementing EIP-1271 (signature validation for contracts). This was a deliberate choice: it's exactly how CoW Swap and 1inch Fusion process their swaps. An operator signs and sends orders on behalf of the vault while strictly respecting its onchain rules, including xStocks-specific constraints like supported tickers and allocation bounds.
The flow works as follows:
- Factory Vault creates a new ERC-1271 vault contract and sets the user as owner
- The offchain backend constructs and hash-signs orders based on the vault's strategy rules and xStocks asset mappings
- The GPv2 Vault Relayer (CoW Swap) proceeds with the order; the vault's
isValidSignaturecheck ensures every order complies with the onchain rules before any xStocks trade executes
Tech Stack:
| Layer | Technology |
|---|---|
| Frontend | Next.js, wagmi.sh, TypeScript, Bun |
| Backend | Elysia.js API framework, viem, Squid indexer, TypeScript, Bun |
| Database | PostgreSQL |
| Blockchain | Foundry (smart contract factory + customized ERC-1271) |
| Protocols | xStocks, CoW Swap, 1inch Fusion |
| Chains | Ink (primary), Ethereum |
| Infrastructure | Server managed by Coolify, Pangolin for domains & tunneling |
Polymarket Signal Service - A standalone TypeScript microservice that runs a pipeline to fetch, filter, score, and monitor Polymarket markets. It narrows 10,000+ markets down to financially relevant signals, maps them to xStocks tickers (e.g., "Will Apple beat Q3 earnings?" maps to xStocks AAPL), and monitors user-defined probability thresholds every 5 minutes. When a threshold is breached, it fires a webhook to the backend which triggers the vault's configured action on its xStocks holdings.
Challenges we faced
Gasless user experience. We challenged ourselves to provide a smooth experience where the user doesn't even need gas for almost the entire investment flow. We create the vault and set them as owner, and for orders the CoW Swap resolver handles the gas. The user just funds with USDC, the vault acquires xStocks, and everything else happens behind the scenes.
EIP-1271 customization. The biggest technical challenge was the implementation and customization of EIP-1271: how to encode the vault's rules onchain and verify that every order coming through CoW Swap follows them. Each vault has unique allocation rules, supported xStocks tickers, strategy parameters, and signal-triggered actions, all of which must be enforced at the signature validation level.
Signal-to-xStocks mapping. Polymarket hosts thousands of markets, and we needed to extract only the financially actionable ones and map them to the correct xStocks tickers. A question like "Will the Fed cut rates in November?" doesn't map to a single stock: it affects rate-sensitive equities across multiple xStocks. We built a layered filtering and mapping approach to handle both direct (single-company earnings to one xStock) and indirect (macro event to multiple xStocks) relationships.
Threshold idempotency. A probability can oscillate around a threshold repeatedly. Without careful state management, the system would fire duplicate rebalance actions on the same xStocks positions. We implemented a breach-once-then-reset model: the monitor fires on the first crossing, marks the subscription as breached, and only resets when the probability recovers in the opposite direction.
What we learned
We learned how to integrate xStocks' buy action into a real investment strategy that is both highly accessible and fully customizable. xStocks' tokenized equities gave us the composability that traditional brokerages can't offer: programmable portfolio logic executing onchain, triggered by off-chain prediction market intelligence, settled through battle-tested protocols like CoW Swap and 1Inch Fusion, all without the user ever touching gas or managing keys. The simplicity of xStocks' interface made it possible to build a full automation layer on top within the hackathon timeframe.
What's next
We want to give users the opportunity to build the closest strategy to what they envision. That means adding more xStocks assets, more strategy options, and integrating more signal sources beyond Polymarket: broader market data, social sentiment, and onchain analytics.
We also need to continue developing our indexer to power most of the app's data and make it scalable and resilient as we onboard more users and support more vaults holding xStocks.
With more time, we would love to integrate Chainlink CRE into our infrastructure to trigger signals in real time. CRE would listen for onchain events and call our API to execute strategy actions on xStocks positions, removing the need for polling and enabling truly event-driven vault automation.
Built With
- 1inch
- bun
- cowswap
- eip-1271
- elysia.js
- erc-4337
- ethereum
- foundry
- ink
- next.js
- polymarket
- postgresql
- solidity
- squidindexer
- typescript
- wagmi.sh
- xstocks
Log in or sign up for Devpost to join the conversation.