rndlabs / cowswap-twap-orders Goto Github PK
View Code? Open in Web Editor NEW๐๐ฎ Time-weighted average price orders for CoW Protocol
License: GNU General Public License v3.0
๐๐ฎ Time-weighted average price orders for CoW Protocol
License: GNU General Public License v3.0
Problem
Naively polling every block for a tradeable order is not required with ConditionalOrders
that have some defined payload. This is because the payload itself relates to the order and can be used to determine beforehand if there should be some tradeability (unless specific on-chain state is checked by the respective ConditionalOrder
).
Solution
When watching for orders, we take advantage of custom error
s passed on reversion:
OrderCancelled
, delete it from storage.OrderExpired
, delete it from storage.OrderNotValid
, skip processing in this block (likely a result of a span
).Tasks
You build command goes like this:
"build": "forge buid && yarn build:actions && yarn build:cli",
Shouldn't it be:
"build": "forge build && yarn build:actions && yarn build:cli",
Problem
Naively watching for orders and sending these to the API will result in multiple submissions of the same order. As CoW Protocol protects against this by monitoring the fill of each orderUid
, this doesn't cause multiple executions, however it consumes resources for API submissions.
Solution
Remember the orderUid
s that are submitted. If an order has been previously submitted, don't submit it again. Implement a fill watch action that purges filled orderUid
s from the storage.
Tasks
Registry
layout to include status
a Map with key
of keccak256(getTradeableOrder(payload))
and value
corresponding to an enum of either SUBMITTED
or FILLED
.SUBMITTED
, don't attempt to submit again to CoW Protocol.Problem
It is a little difficult to monitor all the parts of an order (TWAP) to see see what the fill rate was like.
Solution
Using the status
from #2 if the order becomes OrderCancelled
or OrderExpired
, we can generate a report.
Tasks
OrderCancelled
or OrderExpired
, generate a report of the number of parts that were filled / not filled.I really like the changes that were made compared to the framework in https://github.com/cowprotocol/conditional-smart-orders as they allow more effective creation of smart orders and also make it easier to leave the Safe functional!
One decision I find difficult however, for general purpose smart orders is to require fixed length signatures. There are definitely use cases (e.g. dynamic price checkers for milkman style orders) where the same order type may have different lengths signatures.
Maybe we can define a magic value that indicates "arbitrary length" to avoid failing this check:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.