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

Hello guys :waving_hand:

Quick update, we’ve just finished building a functional prototype of the contract.
We’ve tested it with a mock version of Polymarket, and everything is working as expected.

A quick note on the development phase: we initially spent a lot of time debugging why the contract wasn’t working. The breakthrough came when we ran a local watchtower and were finally able to identify the issue through its logs. That’s why I’d suggest making watchtower logs publicly available. It would really help developers during integration and debugging. Just a small improvement idea.

:triangular_flag: Our current objectives are to finalize the contract, test it directly with Polymarket, write proper documentation, and search for potential vulnerabilities.
As you’ve probably noticed, we’ve gone past the initial deadline for delivering the contract. We’re extending this milestone a bit longer to ensure everything is solid.

Have a good day

2 Likes

Hello everyone :waving_hand:

Just a quick update from our side! Summer’s been quite packed for both of us, but development is moving forward and we’re confident we’ll be able to wrap up the project within the next two months.

We’ve just finished building the first functional version of the smart contract.
You can find the repo here:

Let us know if you have any early feedback or questions!

2 Likes

Hi, quick update on our side.

I’m currently working on the dApp and almost have a complete end-to-end user flow. From exploring Polymarket markets, placing a Polymarket limit order, to placing a conditional order on-chain.

On the contracts side, @Pybast is still adding more tests and improving the documentation as requested.

2 Likes

Hello guys :waving_hand:

I am sharing with you a video demo of the functional v1 of Polyswap, showcasing an end-to-end user experience with the app. :rocket:

:backhand_index_pointing_right: Demo video download link

In this demo, I used a Polymarket mock to simulate a resolved condition instantly, but the system works in the same way without the mock.

Here is the project repositories:

As requested, you will also find a diagram showing the overall architecture of the application and the flow of funds. This diagram is also included in the README of the dApp repository.

:backhand_index_pointing_right: diagram png download link

@mfw78 could you confirm if this diagram is sufficient for you to begin the contract audit?

There is still some work needed to make the application more stable and maintainable, but the core functionality is already implemented.

I look forward to your feedback :eyes:

3 Likes

Hello everyone,

We synced up to have a concrete plan to wrap up this first grant and version of PolySwap. The core contracts and dApp logic are already functional, what’s left mainly focuses on polish and production readiness. To achieve a fully working product, we need to integrate the following features and improvements:

  1. Funds Management: Add liquidity deposit/redeem system to fund Polymarket limit orders (contracts + dApp),
  2. Safe Integration: clean up WalletConnect flow, disable sponsored TXs, limit swap volume (POC),
  3. Conditional Orders: during first usage, setup domain delegation for ComposableCoW (dApp) and add swap validation checks,
  4. Code & UX: review dApp structure, fix TX batching issues, simplify backend logic, add beta disclaimers.

Once these are done, we’ll be ready to deploy our beta to production.

We’re aware the timeline has shifted compared to what was initially planned. I personally started a new position as CTO at Cork Protocol in September, which made the past couple of months quite busy. @intermarch3 has also been in a busy period.

That said, we’ve synced up and, given how close we are to completion, we’re confident we can deliver a working production version by December 31st.

Would that work for this current grant?

We’re fully committed to pushing this forward, PolySwap is a great showcase of DeFi composability and how prediction market transparency can be leveraged by Composable CoW. We’re excited to finalize this milestone and share the live version with the community.

Happy to get feedback or to provide further details.