-
Notifications
You must be signed in to change notification settings - Fork 157
bug: Legit token is not tradeable due to minimum transfer check #3286
Description
Problem
USDL is a rebasing token which internally converts shares to user balances. It can currently not be traded due to a token implementation detail that clashes with the checks we run before adding a new order to the order book.
Before accepting an order the backend runs a simulation to verify that some minimum amount of tokens can be transferred into the settlement contract. This verifies that the user has at least that minimum amount and that the approvals are either already set or will be set just in time to make the trade possible.
The minimum amount we currently try to transfer is exactly 1. Due to USDL's internal math this triggers an exception since it effectively considers 1 equal to 0 which is guarded by an assertion.
This simulation shows what happens during our transfer check and fails when the tested amount is 1. If you resimulate but try to transfer 2 instead it works which would make the token tradeable in cow swap.
Impact
The token is not tradeable.
To reproduce
Try selling some USDL using cowswap.
Expected behaviour
The token is tradeable.
Proposed solution
Transferring 1 is not an option with this token but there are also tokens where even a single atom of the token is worth significant money. To not cause any issues for those tokens we could try to do multiple transfer checks with different sizes. If one of them works we could consider the token supported.
You could for example try the transfer with 1, 10, and 100 atoms. This is hopefully enough to cover the majority of edge cases.
Since the issue with transferring 1 is pretty exotic and the simulations are fast we could probably just do these multiple simulations serially after another to stay as fast for the majority of the cases without always simulating more than we have to.