cowprotocol / services

Off-chain services for CoW Protocol
https://cow.fi/
Other
187 stars 73 forks source link

feat: Surplus capturing JIT orders to be shown on cow explorer #2825

Closed sunce86 closed 1 month ago

sunce86 commented 3 months ago

Problem

Surplus capturing JIT orders are expected to be shown in cow explorer, or better said, to return valid data on api calls:

https://api.cow.fi/docs/#/default/get_api_v1_orders__UID_ https://api.cow.fi/docs/#/default/get_api_v1_transactions__txHash__orders https://api.cow.fi/docs/#/default/get_api_v1_trades https://api.cow.fi/docs/#/default/get_api_v1_account__owner__orders

The reason this is not case at the moment is because surplus capturing JIT orders are visible only once the order is settled onchain. They are not part of the orders database table.

Suggested solution

Create a new database table surplus_capturing_jit_orders. This table is supposed to contain settled SC-JIT orders data. Since it would be saved from the OnSettlementEventUpdater, only subset of order data is visible onchain and saved to the database.

surplus_capturing_jit_orders table needs to be reorg resistant and save data (order_uid, owner, sell_token, buy_token etc).

Then, 4 api calls need to be updated to search for order in surplus_capturing_jit_orders, and not just in orders table.

fleupold commented 3 months ago

What are your thoughts on creating this table for all jit orders (not just surplus capturing). Is there anything about surplus capturing jit orders that makes them particular for the explorer?

sunce86 commented 3 months ago

What are your thoughts on creating this table for all jit orders

I don't see any reason to not save all jit orders if we want. Based on the suggested solution ☝️, anything we show on cow explorer for JIT orders is already visible onchain so...