lidofinance / core

Lido DAO smart contracts
https://lido.fi
GNU General Public License v3.0
382 stars 193 forks source link

Slippage control upon withdrawals #694

Closed Rassska closed 1 year ago

Rassska commented 1 year ago

Hey there, hope you're doing fine!

Do I get it right, that the current version of the feature/shapella-upgrade doesn't provide any opportunity for users to set the desired slippage on-chain upon withdrawals?

Thanks!

Rassska commented 1 year ago

Actually, I got it, in the context of the Lido withdrawals it doesn't make any sense.

Rassska commented 1 year ago

But wait, what if the following sequence of actions happens?

In case of the following sequence of txs, nothing weird happens. But what if the Bob's withdrawal request comes right after AccountingOracle's report(which will report negative rebase) in the same block? In this case, the bunker mode is not activated yet, but it seems Bob loses some funds due to the negative rebase.

Rassska commented 1 year ago

Anyways, I think it's better to have some slippage control mechanism for unexpected cases like that.

TheDZhon commented 1 year ago

Hey, @Rassska Thank you for bringing up this issue :+1:

The current architecture presumes strict FIFO ordering of finalization, and requests aren't cancellable. Based on this, 'virtual slippage' control isn't feasible for implementation on the protocol's level.

To overcome the issue, one might want to exchange stETH for ETH on secondary markets or sell the already placed request position represented as an ERC721-compatible token (NFT).

Rassska commented 1 year ago

Of course, the probability for such case is pretty low, but as I got it correctly it makes some sense: I'm talking about the following txs order:

As a result, after 36 days or when bunker mode is de-ativated and the batch which contains Bob's withdrawal is finalized, Bob receives less amount of ETH compared to the case where he simply could front-run tx2 which causes the negative rebase.

I mean, the whole concept here is to explore some withdrawal requests passed right after negative rebase happens.

Anyways, thanks a lot, I'm just exploring the Lido for fun!

TheDZhon commented 1 year ago

I see your point, yet the bunker mode activates retroactively, practically excluding the probability of the bunker mode front-running (by means of the associated frame definition of the withdrawal request)

see the second rule for the 'Withdrawal requests finalization' section https://docs.google.com/document/d/1NoJ3rbVZ1OJfByjibHPA91Ghqk487tT0djAf6PFu8s8/edit

image

Nevertheless, maybe you see any additional weaknesses? :eyes:

Rassska commented 1 year ago

Thanks a lot, gotcha!