Grant Application 2 - PolySwap

Grant Application 2 : PolySwap

(2nd post with updated grant proposal and technical details)

PolySwap: Automated DeFi Swaps Powered by Predictive Markets


Author:

This project will be developed by :

In this github organisation where there is already the code done during the hackathon : EthGlobalBangkok repositories · GitHub


About You:

Baptiste is a blockchain engineer and entrepreneur formerly cofounder and CTO of Nefture a web3 security startup. He has extensive experience in launching web3 projects and has won multiple hackathon prizes.

Lucas is a computer science student at EPITECH, passionate about web3, building blockchain projects beside school. He’s doing an internship at Kiln, leading player in the staking ecosystem. He’s motivated to build a significant project to build up his experience.


Additional Links:

ETHGlobal project page with some pictures of the telegram mini app : PolySwap | ETHGlobal


Grant Category:

Other: new use case using CoW Swap Smart orders


Grant Description:

PolySwap allows for the automatic trigger of DeFi swaps based on predictive markets like Polymarket. The project was awarded during ETH Global Bangkok 2024 and its team is pushing for its development and release.

The value proposition is simple:

  1. the user selects a prediction market. For example, the winner of a presidential election or the performance of a new “state of the art” AI model,
  2. they then create a PolySwap order through CoW to trigger a swap in the conditions where the selected market’s odds reach a certain threshold,
  3. once the condition is achieved on-chain, solvers can execute the swap autonomously without the need for the user’s input

PolySwap enables web3 users to seamlessly automate trading execution based on real world predictions.

For the first version, we plan to deploy the protocol on Polygon POS to have native compatibility with Polymarket.

In upcoming versions, we plan on expanding deployments to all CoW compatible chains using cross-chain messaging technologies like LayerZero read for example in order to connect a swap on any chain with any prediction market.

We also plan on creating a widget that could directly be integrated in various apps frontend like Polymarket or wallets.


Grant Goals and Impact:

This project bridges DeFi automation with real-world predictive markets, offering users a powerful tool to manage risk and make smarter market decisions. With a simple frontend interface, it’s accessible to anyone.

This DeFi tool will allow CoW users to access a whole new way to automate their trading workflows with trustless prediction market triggers. PolySwap is a very good way to demonstrate the power of the CoW Swap modular intent based architecture, potentially drawing new eyes to the CoW ecosystem.


Milestones:

This grant aims at reaching a first functioning proof of concept version of the product deployed on Polygon. The goal is to test the use case, get feedback on the UX and gauge initial market traction. The learnings from this first iteration will allow us to plan a second iteration that would also include a security audit.

Milestone Due Date payment
PolySwap IConditionalOrder contracts development and deployment 2 weeks 2k xDAI + 750 CoW
Frontend dapp design 3 weeks 500 xDAI + 500 CoW
Dapp development and deployment 6 weeks 3.5k xDAI + 1.5k CoW

Contracts Development and Deployment

Implement an IConditionalOrderGenerator smart contract capable of interpreting the staticInput of a ComposableCow order and verifying whether the prediction market trigger has been met.
The prediction market trigger is defined by a target price for a specific outcome token. However, this price is not stored on-chain. Instead, we can simulate this behavior by creating a Polymarket order at the target price and checking on-chain whether it has been fulfilled.
This allows us to determine whether the market price has reached the specified threshold.
The getTradeableOrder(…) function will accept the Polymarket order hash as part of the staticInput, and the verify(…) function will call getOrderStatus(orderHash) from the Polymarket CTFExchange contract.

It will check that:

  • isFilledOrCancelled is true
  • remaining is 0

This ensures the order was filled and not just cancelled.
Finally, the contract will be deployed on Polygon.

Stack: Foundry

dApp Development

Design

Design a user experience that clearly communicates how to create, track, and modify swap intents based on prediction market triggers.

  • the user will be able to select any polymarket prediction market
  • the user will be able to set market price as condition
  • the user will be able to set an already created Polymarket order that is waiting to be filled as a condition.
  • The user will be able to set a max price at which their order will execute with (of the token they want to buy - this will limit the risk of buying at an unfavorable price once the condition is met)
  • the user will be able to see all waiting orders and can cancel them at any time.

Pages:

  • Home: Display popular Polymarket markets and allow users to search or select a market by name (using the Polymarket API).
  • Polyswap Order Creation: Interface for setting all required parameters, inspired by the TWAP creation flow.
  • My Orders: List all orders associated with the connected wallet. Provide the ability to inspect or cancel orders.

Stack: Figma

Development

Convert the Figma design into a fully functional Next.js application. Use Wagmi.sh for wallet connection, and implement a backend service with a database to index and serve relevant on-chain data.
When a Polyswap order is created:

  • The backend will first create a Polymarket order using their API/SDK with the user-defined target price.
  • The resulting Polymarket orderHash is then passed as a parameter in the smart contract when creating the Polyswap order.

Stack: Next.js, Wagmi.sh, Node.js, PostgreSQL


Funding Request:

We propose that milestone payments be released upon each milestone’s approval.


Budget Breakdown:

This funding would allow us to support the necessary development time to achieve completion of this project’s first proof of concept version. Reaching this first milestone would then open us to many other grant opportunities with different chains, prediction market solutions and other compatible web3 projects.


Gnosis Chain Address (to receive the grant):

gno:0x20D3Ab73226A5121Da6F2a33C8F78538f4F8D30a


Other Information:

  • All the code will be open sourced and is already
  • we’ll provide a biweekly update about our progress here in the forum thread
  • Feel free to provide any other trigger for the swap or something else that you think about and that can be added in the grant
  • We’re happy to answer any questions and are open to feedback about this proposal

Referral:

Alex Viñas


Terms and Conditions:

By submitting this grant application, I acknowledge and agree to be bound by the CoW DAO Participation Agreement and the CoW Grant Terms and Conditions.

5 Likes

Hi, This looks much nicer and quite well scoped / defined, showing increased understanding of the complexities associated with conditional orders and the ComposableCoW framework. It is a little disappointing that it would be deployed / available only on one chain - nonetheless I think this would be a cool demonstrator / use case and it would be great to get more developers building with ComposableCoW.

I’d happily take this on as a review, and simultaneously signal my support of this grant.

5 Likes

I’d also like to signal my support and propose myself as steward for this grant.

I think that starting with Polygon as the first deployment makes sense especially since Polymarket is the most popular prediction market and this order type could create synergies with Polymarket.

@intermarch3 can you please specifically mention in proposal that the grant will be developed as open source project and you’ll provide a biweekly update about your progress here in the forum thread? :folded_hands:

If there’s no other comments I think it’s ready to move to snapshot

5 Likes

Happy to share the the grant was approved by the grants committee.

@intermarch3 @Pybast good luck!
Please post here once you have a working repo, you want to provide a development update, or you have any questions!

5 Likes