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

