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 (CTF Exchange): 0xEa8FA1438785b9464f988e3AFa1E464Ba3A110B1
View on Polygonscan
Contract Address (Neg Risk CTF Exchange): 0x04a7745Ee5c5cCE28aD0A2c956e789415a90EA7D
View on Polygonscan
![]() Lucas Leclerc |
![]() Baptiste Florentin |
|---|

