cowprotocol / cow-sdk

CoW protocol SDK
https://docs.cow.fi/cow-protocol/reference/sdks/cow-sdk
Other
31 stars 9 forks source link

Poll conditional orders + Allow custom logic to delay checks to a given date, block, or forever #149

Closed anxolin closed 1 year ago

anxolin commented 1 year ago

Implement some basic Polling Also, applies some follow-ups from: comments in https://github.com/cowprotocol/cow-sdk/pull/147

Implement a Polling (as a Template Method in ComposableCow)

This generic polling logic will check the following:

isAuthorised

Method in ComposableCow to check if the order is authorised.

Exposed as public method, but also convenient for the polling logic.

image

Removed validation from constructor

I thought it was best to not do a validation in the constructor of the order, so we can programmatically call to isValid

Also the method isValid doesn't throw any more, instead returns the reason. This reasons are convenient for other methods like poll to give a good description of why the order is not yet ready.

Now polling can instruct to never poll again that smart order, and return a good reason why:

image

Generics for ConditionalOrders

Changed back to T and P as suggested in https://github.com/cowprotocol/cow-sdk/pull/147

Not implemented in this PR (follow up coming)

Custom logic in Twap conditional order to postpone some checks for the future (instead of checking on each block)

I left some TODOs:

image
github-actions[bot] commented 1 year ago

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

coveralls commented 1 year ago

Coverage Status

coverage: 77.586% (-3.8%) from 81.422% when pulling e7f2ae07262792838a417d620ac4cccc2ef2dd19 on poll-conditional-orders into a4c398c21f8431469f9f67b9e097def78481525a on small-nit-suggestions.

alfetopito commented 1 year ago

Unit tests are not happy

alfetopito commented 1 year ago

@anxolin unit tests were still broken