ditto-lab / ditto

NFT Future protocol
MIT License
60 stars 3 forks source link

Block refund #51

Closed calvbore closed 2 years ago

calvbore commented 2 years ago

In the current implementation multiple bids in the same block incentivize front running. The first successful bid effectively cancels any subsequent bids although they may be a higher offer.

This pr will implement a kind of internal block auction. The first bid in a block will behave normally as before, however any subsequent offers in the block will check if the offer amount is higher than the clone's worth at the last successful bid, if so then the offer succeeds and the last bidder is refunded the clone's worth and any fees (excluding gas) they had paid.

The goal of this change is to reduce MEV causing gas wars and instead redirect the rising prices within the protocol itself.

calvbore commented 2 years ago

I was considering another design where fees are refunded completely within the block, which I think is more desirable, but was slightly more complex to implement.

calvbore commented 2 years ago
calvbore commented 2 years ago

Still finding a couple edge cases that I'm working out

calvbore commented 2 years ago

So, i noticed that in the else block of duplicate() fees were being calculated according to the clone's worth or auction price instead of the total amount transferred to the contract. So I fixed that in this pr and reconfigured the math in getMinAmountForCloneTransfer() to accurately reflect the calculation.