by dcolkitt · 5y ago · 0 comments
Right now, the only real way to front run is to take liquidity ahead of a large order. Since swapping costs fees, this restricts front running to trades larger than 0.3% of the liquidity in the pair.
In V3, it will now be possible for liquidity providers to “jump the queue”, by adding liquidity in a narrow range. If an arbitrage bot is monitoring the pending block, it’ll be able to predict exactly how much the price will move on the next block. It can then add liquidity at exactly that range, collect the lion shares of the LP rewards, then instantly remove the liquidity at the end of the block. The only remaining hurdle is the gas cost to add->remove liquidity (which on L2 will be virtually zero).
I really hope they beta test this, because it could potentially be disastrous. Right now, front running really only costs money from large traders. Liquidity providers actually benefit from collecting fees on the extra swaps. But this has the potential to destroy the incentives to LPs, and drain all the liquidity out of the market.
Alice, wanting to transact, writes down two opposing orders, say buy 1 share of A for $10 and sell 1 share of A $10, plus a signed secret stating which order it actually is.
Other players subscribe to one of the two opposite orders.
Next thing (whatever that means in these blockchains, but after other players have subscribed to one of the two opposite orders), Alice reveals the secret using her private key. This reveals which order it was (buy or sell). Alice then makes a deal automatically with whoever subscribed to that order. The other opposite order is cancelled.
For the above scheme to work, Alice's reveal would have to occur at a later block than her initial commit. Otherwise an arbitrage bot could simply peek at the reveal before the commit is mined. Also Alice's commit has to lock the chain until its reveal. Otherwise when her reveal is propagated on the P2P network, the arbitrage bot could jump the queue in front of her commit and still exploit her.
You're now talking about the market freezing for 12-seconds (the block time) on every single trade. That's completely infeasible for any sort of liquid pair like ETH/USDT. Not to mention a single malicious player could DDoS the entire market. Or use it as a free option during periods of high volatility: lock the market then "reveal" in whatever direction the centralized exchanges moved in the lock-up period.
Maybe you could only lock "big trades", but that in itself reveals a lot of information. You don't necessarily know the direction, but you can likely infer it with high certainty. For example if Alice doesn't own much of a token, then it's nearly certain she's buying not selling.
SCRT (Hardware TEE, functional on Cosmos)
Partisia (MPC, no working product)
Other theoretical methods include homomorphic encryption and indistinguishable obfuscation.
Edit: of course, Optimism "Chain Organizers" can front-run, but if they will be run by Uniswap themselves, then they have no incentive to ruin their own product.
It's true that miners always have "right of first refusal", in that whoever mines the block can choose to prioritize his own transactions over anyone else. But if miners don't exercise that option, then any third party can front-run the target by outbidding them. Getting rid of miners, does not in anyway remove the issue of front-running. Currently, less than 5% of front-running activity is performed by miners.
As long as transactions are propagated over a P2P network, then front running is still possible. So Optimism only fixes this problem, if Uniswap LLC is hosting the entire side chain and participants are directly submitting their transactions to Uniswap's servers instead of the block chain. However if that's the case, then they almost certainly will be legally obligated to perform KYC/AML on all clients, at which point they are essentially a centralized exchange.
For reference, even Binance Smart Chain, which is heavily criticized for being a centralized exchange in disguise, does not take this approach. Centralize validators are used, but the network itself is still P2P instead of centrally hosted.
When you say you simply need to run a full node, thats incorrect. It is a prerequisite yes, but much less than half the battle. You also need now to ensure correct order placement (on any opportunity there are upwards of 5-15 competing bots), a friendly relay network/mining pools, efficiently node peering (e.g. 2-400 peers per node, managed on a custom routing table), a network of nodes to broadcast/listen for mem pool messages across the entire network instantaneously without waiting for P2P propagation (1-2 hops may introduce enough latency to lose out on the arb) (& some nodes are malicious - who fail to propagate arb'ble tx's), patched/custom GETH instances running on nodes (I am not at liberty to reveal what optimizations make one competitive). And then above all of that you need to be able to absorb, identify profitable transactions and then compute/simulate optimal transaction parameters in a very constrained amount of time.
So its not at all simple, in fact I have wound down most of my operations as the costs vs. rewards are extremely marginal now vs. what they were mid last year.
With Optimism, there can be multiple L2 chains, by different "Chain Organizers". When you submit a transaction, you get a receipt from Organizer, a cryptographic promise that it will be included in future rollup.
It means only Organizers can attempt to front-run, by adding a transaction before giving out your receipt. And users can always choose to use different Organizers, those that don't front-run. Since Organizers gain a small amount of fees, it doesn't make sense to be a bad, front-running Organizer.
How do we know this number? It seems like it would be possible for miners to front run without any identifying characteristics.
Also, there's https://libsubmarine.org/
How so? Now rather than colluding with miners and/or mining pools they'll collude with stakers and/or staking pools.
This doesn't harm the person doing the swap, per se. It harms the Liquidity Providers that hold their capital in the pool for longer term.
That would make the estimates worse though.