Automated DeFi swaps triggered by on-chain prediction market outcomes.
This repository contains the core smart contracts of PolySwap, a protocol that allows users to create conditional swap intents based on prediction markets like Polymarket.
PolySwap lets users define CoW Swap orders that become valid only when a specific prediction market condition is met. The contract checks the status of a Polymarket order and activates the swap only if that order has been fully filled (indicating the prediction condition was reached).
BaseConditionalOrder: Abstract contract to inherit for compatibility with ComposableCoW.Polyswap: Main contract that inherits fromBaseConditionalOrderand verifies if the Polymarket order is filled.PolySwapOrder: Verifies if the Polyswap order parameters are correct and defines the order struct.
The Polyswap contract uses the Polymarket CTFExchange contract to check, via the getOrderStatus() function, whether:
- the order is filled or cancelled, and
- the remaining amount is
0.
If both conditions are met, the swap is executed using the Composable CoW Swap protocol. Both conditions being met means that the limit order has been filled and that the price of the limit order has been achieved.
- Solidity
- Foundry for development and testing
- Polygon PoS as the initial deployment network
All contracts are deployed on Polygon for compatibility with Polymarket's on-chain infrastructure.
Contract Address: 0xE930639F0EbE2A7309f214e48e9F5ae3C5306Ff7
View on Sourcify
![]() Lucas Leclerc |
![]() Baptiste Florentin |
|---|

