You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reviewing the Gelato issues, I was thinking about the claiming process, and an improvement that we might want to take into account for v2.
Example: 1 batch swap market order
So, there’s situations we want to create an order, and create "Withdraw requests" ahead of time, for example on a 1-batch-swap market order.
Since we don’t know ahead of time the price we will get, or even if we will trade, we don’t know how much of the tokens we will be withdrawing. So the overall timeline looks like this:
[batch 1]
Create Order: Trade 100 WETH for 0 DAI, for 1 batch
Create future withdraw requests: Withdraw 100 WETH and ∞ DAI in batch 3
Note:
100 WETH --> we account for the possibility of the trade not happening
∞ DAI --> We really don't know how much DAI we will get. So we say, I want to withdraw it all.
[batch 2]
Order is active. Solvers work on their solution
A Trade happen: 80 WETH for 16.000 DAI
[bath 3]
Execute the matured withdraws: Withdraw 80 WETH + 16.000 DAI
The issues
One issue with the above setup is that, because of the Withdraw Request of ∞ DAI in batch 3:
If the user has ANY order with DAI as a sell token, no solver will consider my orders for batch 3
If the user has ANY deposit of DAI for full-filling other order, it will be automatically withdrew
Possible improvements
3 possible improvements are:
Account for received tokens: Accumulate the received tokens in the order information. This way we know the exact amount of tokens we should actually withdraw. A nice thing that comes also from this change, is that we can get the actual price of the order (that can be superior to the limit price)
Allow to withdraw before the batch starts: For the example above, we could allow the user to execute the withdraw BEFORE batch 3 (1) (in the last minute of batch 2 all trades are final). This would prevent the issue with solvers/contract ignoring orders that sell DAI in batch 3.
Request and withdraw right away: 🚨🚨 (same as above, but to the NEXT leve) In the last minute of the batch 2 (1), we can in theory safely withdraw tokens without waiting for the request to mature.
(1) NOTE: In the above proposal, for not making it more complex, I abused the language a bit. When I wrote "in the last minute of batch 2" I meant "in the last minute of the batch that solves batch 2 that it's in fact minute 4 of batch 3 since we always are solving the previous batch, instead of the current one.
The text was updated successfully, but these errors were encountered:
Reviewing the Gelato issues, I was thinking about the claiming process, and an improvement that we might want to take into account for v2.
Example: 1 batch swap market order
So, there’s situations we want to create an order, and create "Withdraw requests" ahead of time, for example on a 1-batch-swap market order.
Since we don’t know ahead of time the price we will get, or even if we will trade, we don’t know how much of the tokens we will be withdrawing. So the overall timeline looks like this:
[batch 1]
100 WETH
for0 DAI
, for 1 batch100 WETH
and∞ DAI
in batch 3[batch 2]
[bath 3]
The issues
One issue with the above setup is that, because of the
Withdraw Request of ∞ DAI in batch 3
:Possible improvements
3 possible improvements are:
(1)
(in the last minute ofbatch 2
all trades are final). This would prevent the issue with solvers/contract ignoring orders that sell DAI in batch 3.(1)
, we can in theory safely withdraw tokens without waiting for the request to mature.The text was updated successfully, but these errors were encountered: