← Back to home

4DLimitOrder

4-dimensional limit orders, are an extremely novel, simple, and powerful new order type. They are intuitive, and can replace many other order types, as well as do things previously impossible.

Screenshots

4DLimitOrder screenshot 1
4DLimitOrder screenshot 2
4DLimitOrder screenshot 3
4DLimitOrder screenshot 4
4DLimitOrder screenshot 5
4DLimitOrder screenshot 6

Problem Statement

In this project, I used CoWSwap Programmatic Orders Framework, to develop a totally new type of limit order. Normal limit orders take:amount to tradea time windowa fixed price target4-dimensional limit orders take:amount to tradea time windowa target price which can change over timeThis simple addition means that you can more accurately model your trading intents. 4D Limit orders are flexible enough that they are a superset of many other order types, including: normal limit orders, market orders, dutch auctions, normal auctions. With a single 4D Limit order you can even model more complex preferences, such as an increasing time-preference. If we open up to 2+ 4D Limit orders, you can automatically trade an ascending channel pattern (buying low and selling high). Previously this would require coding skills to build a bot.

Solution

The code for the order type itself is in my fork of the CowSwap/composable-cow github repo (for easier development setup). there are unit tests for it, as well as a deployment script to test it out and run orders.The order is deployed on Gnosis Mainnet, at: 0x1989fd64aa8883c221f5c09ef58d673347a4c3cf (https://gnosisscan.io/address/0x1989fd64aa8883c221f5c09ef58d673347a4c3cf)Below, I've linked the order execution script, which creates a simple 4D Limit order (acting as a delayed market sell), to show how to set one up. But there are a few other files in the repo as well (see the commit log).Setup script: https://github.com/earlyxyz/composable-cow/blob/main/script/submit_SingleLimit4D.s.solOrder type code: https://github.com/earlyxyz/composable-cow/blob/main/src/types/Limit4D.solFuture Work: I had started to build a small frontend visual order-building tool, but ran out of time, so I'd love to continue that, and finish it.

Hackathon

ETHGlobal Istanbul

2024

Prizes

  • 🏆

    CoW Programmatic Framework2nd Place

    CoW Protocol

Contributors