cowprotocol / cow-sdk

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

Check existence of the order in the orderbook, and add polledOrderInOrderbook #166

Closed anxolin closed 1 year ago

anxolin commented 1 year ago

This PR adds a 2 things:

1) A new check, after we get the order that "should" be created, we double-check if it was already created or not by quering the orderbook.

2) After we verify the existence of the order, the polling will return by default TRY_NEXT_BLOCK, but at the same time it will give the concrete order to give a different result. This will allow orders like Twap to say: "Ok, so if current part is already created, next part should be starting by this exact time, therefore it will return a TRY_AT_EPOCH overriding TRY_NEXT_BLOCK default).

This will allow orders to be polled much more efficiently, for example, DCA that trades once a month, you will not need to check every block between two months.

Also, another efficiency, is that watch towers will not need to post the orders if someone else already posted it, reducing drastically the errors of DuplicatedOrder.

Not included

Next PRs I plan to add:

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: 75.063% (-0.8%) from 75.813% when pulling dcfd3acab019e35a441ca1ce7a4c1fd116708ae8 on check-order-existance into c0cb55f68efd73202a5d0c3f1b5c669064962cdb on main.

alfetopito commented 1 year ago

The unit tests are broken :/

alfetopito commented 1 year ago

Unit tests are still failing. Seems like something with the dependencies?

image
anxolin commented 1 year ago

@alfetopito worked for me. will review šŸ‘€

image
anxolin commented 1 year ago

Test are āœ… GREEN!

anxolin commented 1 year ago

@alfetopito merging, let me know if you have any other comments