Grant Application: 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.

6 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.

1 Like

Thanks @Pybast for the update and transparency.
I personally really want to see this grant come to fruition.
I think it’s a great showcase of CoW Protocol’s capabilities with a twist on prediction markets which are obviously trending recently.

I’d be willing to extend the deadline according to the proposed timeline.
I think this should be the very last date for completion including all deliverables ready to be reviewed by @mfw78 though :folded_hands:

2 Likes

Hello everyone,

Quick update to close the loop on this first PolySwap grant :rocket:
We’ve now completed the remaining items discussed previously, and PolySwap is live in beta production.

The full end-to-end flow is functional and ready to be reviewed.

You can test the application here:
:backhand_index_pointing_right: https://polyswap.lucasl.dev

Repositories:

This version includes the finalized core contracts and dApp logic, along with the necessary UX and safety adjustments to support real usage. As mentioned before, this is a beta release, but the product is fully operational and showcases the intended composability between prediction markets and CoW Protocol infrastructure.

We’re happy to provide any additional context, walkthroughs, or clarifications if needed for the review.

Thanks again for the patience and support in getting this over the line — we’re excited to finally share a live version with the community.

Looking forward to your feedback :raising_hands:

2 Likes

Grant Review: PolySwap Deliverables Assessment

Hi @intermarch3 @Pybast,

Thanks for the update and congratulations on getting the beta live. I have conducted a review of the repositories and on-chain activity. Whilst the code quality looks reasonable and the UI is functional, I have a couple of concerns before we can consider the grant complete.

1. Mock vs Real Polymarket Integration

Looking at the .env.sample in the dApp repository, the live deployment appears to be configured to use the mock Polymarket handler rather than the real integration:

# NEXT_PUBLIC_POLYSWAP_HANDLER=0xE930639F0EbE2A7309f214e48e9F5ae3C5306Ff7
NEXT_PUBLIC_POLYSWAP_HANDLER=0x65a5B712F34d8219A4c70451353D2F6A80e6703c # with mock polymarket

Can you confirm which handler the production deployment at polyswap.lucasl.dev is actually using?

2. No Evidence of Real End-to-End Transaction

Both the real Polymarket handler (0xE930639F0EbE2A7309f214e48e9F5ae3C5306Ff7) and mock handler (0x65a5B712F34d8219A4c70451353D2F6A80e6703c) show zero transactions on Polygonscan. The demo video mentioned using a mock to ‘simulate a resolved condition instantly’.

The grant proposal stated the goal was ‘a first functioning proof of concept version of the product deployed on Polygon’ to ‘test the use case’. Before we can sign off on the final milestone, we would need to see at least one successful end-to-end transaction demonstrating:

  • A conditional order created against a real Polymarket market
  • The order triggering and executing when the Polymarket condition is met
  • On-chain evidence of the completed swap

Even a small test amount (e.g. 1 USDC) would suffice to demonstrate the system works as intended with real infrastructure.

Could you provide links to on-chain transactions showing this flow, or conduct a test and share the results?

Hello :waving_hand:

Thanks for the review and for taking the time to look through the repositories and on-chain setup. Here are clarifications on the points you raised.

1. Mock vs Real Polymarket Integration

You’re right that the .env.sample references the mock Polymarket handler by default. This is intentional for local development and demos.

To clarify, the production deployment uses the real Polymarket handler (0xE930639F0EbE2A7309f214e48e9F5ae3C5306Ff7). The mock handler is not used in production.
For information, we have changed the beta link so here is the correct link now : https://polyswap-beta.lucasl.dev

2. Use of the Mock in the Demo Video

The demo video shared earlier was recorded using the mock handler to allow instant condition resolution during a live demo. This was purely for demonstration purposes.

The current beta deployment uses the real Polymarket integration and does not rely on the mock.

We will send an updated demo video in the coming weeks.

3. On-chain Activity and End-to-End Transactions

The Polymarket handler contract we developed contains only view functions. These functions are used to check market conditions and therefore do not generate on-chain transactions or Polygonscan activity.

The flow works as follows:

  • Watchtowers call the handler’s view functions off-chain to verify whether a Polymarket condition is met.

  • Once verified, the condition is forwarded to the CoW Protocol order book.

  • During execution, solvers independently re-check the condition on-chain before settling the swap.

This is why there is no direct on-chain activity on the handler contract itself.

That said, we understand the need for a concrete end-to-end proof using real infrastructure. Below is a transaction that demonstrates the full flow with a real Polymarket market and on-chain execution:

:backhand_index_pointing_right: Transaction link: Polygon Transaction Hash: 0x72ffd71a40... | PolygonScan

:backhand_index_pointing_right: CoW Explorer link : CoW Explorer

Let us know if you need additional context or a walkthrough of the transaction.

1 Like

Hi,
Thanks for this and the persistence. I can confirm that this grant meets its stated objectives and consider it suitable for disbursement of all milestones.

mfw

3 Likes

Hi @intermarch3, thanks again for your work, the grant has now been fully paid.

Please note that if you plan to sell the $COW tokens received as part of this grant, liquidity on Gnosis Chain is currently quite limited, which may result in significant price impact. For this reason, we would recommend bridging the tokens to Ethereum, where liquidity is deeper, using the Gnosis bridge.

There are no bridge fees for this transfer; you would only need to cover a small claim transaction fee on Ethereum once the bridge transfer has been confirmed.

1 Like