4 ms·
EDIT: The article linked by qqii [1] is much better and actually answers all these questions. In short, the smart contracts to allow the loan and to allow the 5
by zaroth 6y ago
EDIT: The article linked by qqii [1] is much better and actually answers all these questions. In short, the smart contracts to allow the loan and to allow the 5x leverage position were totally buggy.
[1] - https://news.ycombinator.com/item?id=25806183 https://news.ycombinator.com/item?id=25806183
I used to do some work on Bitcoin, but this all reads like some Cirque du Soleil fever dream.
These market making smart contracts will trade at 50% swings within a single block?
> The core of this trade utilises a margin trade on a DEX (bZx) to increase the price of WBTC/ETH on another DEX (Uniswap) and thus creates an arbitrage opportunity. The trader then borrows WBTC using ETH as collateral (on Compound), and then purchases ETH at a “cheaper” price on the distorted (Uniswap) DEX market. To maximise the profit, the adversary then converts the “cheap” ETH to purchase WBTC at a non-manipulated market price over a period of two days after the flash loan.
So we start with a flash loan of ETH, go through two smart contracts to end up holding 112 “WBTC” against their borrowed 5,500 ETH.
> In steps 4 , the trader opens a short position for ETH against WBTC (on bZx), with a 5× leverage.
I’m having trouble parsing this sentence. What exactly does this mean?
> Upon receiving this request, bZx transacts 5,637.62 ETH on an exchange (Uniswap) for only 51.35 WBTC (at 109.79 ETH/WBTC).
What does ‘transacts’ mean in this sentence? And bZx is offering an anonymous trader 5x leverage... based on what?
I think they are selling ETH to buy WBTC which blows out the order book and ends up crashing the price of ETH from 30ETH/WBTC to 100ETH/WBTC?
> Note that at the start of block 9484688, Uniswap has a total supply of 2,817.77 ETH and 77.09 WBTC (at 36.55 ETH/WBTC).
I’m not sure why the total supply on Uniswap of each token is expressed as a price?
The trader then converts 112.00 WBTC to 6,871.41 ETH at 61.35 ETH/WBTC on Uniswap. Recall they started off by getting 112 WBTC for 5,500 ETH.
> In step 6 the trader pays back the loan, paying a 1×10^11 Wei fee. Note that dYdX only requires a fee of 1 Wei.
No idea what Wei are or what the significance is of why they would pay 100 billion of them instead of 1, where they come from or how they are accounted for in the profitability.
> After the flash loan transaction (i.e. the first part of this pump and arbitrage trade), the trader gained 71.41 ETH...
Wait, I thought they had netted ~1,209 ETH, where does this 71.41 come from?
> ...and has an over-collateralized loan of 5,500 ETH for 112 WBTC (49.10 ETH/WBTC).
What happened to the 5x leveraged short position?
And how in the world did they coordinate all of these separate and interlinked orders to execute in multiple transactions all in the same block in an atomic fashion?
Anyway, in the end they need to give back the WBTC by buying WBTC with the ETH they netted;
> In total, the adversarial trader exchanged 4, 377.72 ETH for 112 WBTC (at 39.08 ETH/WBTC) to redeem 5, 500.00 ETH. (over the following two days)
Look... whatever people are out there building on these networks, this is just bizarre.
- qqii 6y agoYeah the paper is surprisingly difficult to follow. I had a muncher easier time with this article (https://www.palkeo.com/en/projets/ethereum/bzx.html https://www.palkeo.com/en/projets/ethereum/bzx.html) and just following the call stack for details.
- dang 6y agoOk, we've changed the URL from https://arxiv.org/abs/2003.03810 https://arxiv.org/abs/2003.03810 to that article. Thanks!
- barnabee 6y agoFull disclosure: we're building a protocol for better decentralised markets, which is not susceptible to this kind of exploitation [1]. The thing where the “market” smart contract will just take the money and blindly trade at ever more ridiculous prices (because it’s just two pools of assets and a dumb formula) is crazy. I don’t expect it to last too long in the wild (at least at any scale, obviously some smart contracts that exist now will technically be around forever) or make it into many real world uses of the tech. Well functioning markets have protection against extreme price moves, including flash crashes, whether caused by flash loans or other algorithms. It might even turn out that good decentralised markets end up being resistant to atomically chaining trading transactions with other actions generally. [1] An example of this in action can be seen here: https://twitter.com/RudolphTamlyn/status/1349719025933291520 https://twitter.com/RudolphTamlyn/status/1349719025933291520
- literallycancer 6y agoI find it helpful to look up the definitions of terms I'm not familiar with. Anyhow, wei are a unit of gas, since you usually pay for gas in ETH you can just think of it as paying small amounts of ETH. For the Uniswap price question, just look up the formula. Leverage is provided presumably against some collateral. You chain contract calls to make them execute in the same block. It's more of a side effect of how time works when dealing with blocks rather than something you have to try hard to do.