titania-research-labs / suave-fbadex

Proof of concept for a Frequent Batch Auction on Suave.
https://collective.flashbots.net/t/implementing-frequent-batch-auction-on-suave/3415
14 stars 1 forks source link

Question: Amount is not filled on a pro rata basis in some cases #1

Open massun-onibakuchi opened 3 months ago

massun-onibakuchi commented 3 months ago

Hi, Titania Research Labs team. I'm new to this field. So, please kindly correct me if I'm wrong. I'm wondering what I found is a bug or not.

Description

According to this link, amount is filled on a pro rata basis. It's not like CLOB. Or originally is this orderbook-style DEX?

https://collective.flashbots.net/t/frequent-batch-auction-on-suave/3104/1#:~:text=When%20the%20supply%20and%20demand%20curves%20intersect%2C%20orders%20are%20executed%20according%20to%20the%20amount%20of%20tokens%20bought%20and%20sold.%20If%20the%20trading%20volumes%20of%20the%20tokens%20do%20not%20balance%2C%20they%20take%20a%20pro%2Drata%20approach.

In the following test, two sell orders should fill 50 amount each but actually they fill 90 and 10 amount in order.

https://github.com/titania-research-labs/suave-fbadex/blob/fed696105d543434f855d02d453c6fb3a1d143f7/test/FBA.t.sol#L93-L113

banr1 commented 3 months ago

Thank you for your question.

That's right. When it comes to executing FBA orders, there are two possible approaches: the pro-rata method and prioritizing orders that arrive earlier within the batch period. For the sake of simplicity in this PoC, we implemented the latter approach.

massun-onibakuchi commented 3 months ago

Thank you for your question.

That's right. When it comes to executing FBA orders, there are two possible approaches: the pro-rata method and prioritizing orders that arrive earlier within the batch period. For the sake of simplicity in this PoC, we implemented the latter approach.

Got it. Thanks for the comment

massun-onibakuchi commented 3 months ago

Also, just curious, why do these lines return encoded function data and emit an event on callback? Is that implemented incompletely for upcoming feature?

https://github.com/titania-research-labs/suave-fbadex/blob/fed696105d543434f855d02d453c6fb3a1d143f7/src/FBA.sol#L163

https://github.com/titania-research-labs/suave-fbadex/blob/fed696105d543434f855d02d453c6fb3a1d143f7/src/FBA.sol#L193-L195