5 ms·
Details of this "complex transaction" [0]. 1. Using account A, Flash Borrow 500m DAI 2. Deposit 500m dai into yDAI 3. Deposit ~500m yDAI into yUSD 4. D
by gzer0 5y ago
Details of this "complex transaction" [0].
1. Using account A, Flash Borrow 500m DAI
2. Deposit 500m dai into yDAI
3. Deposit ~500m yDAI into yUSD
4. Deposit ~500m yUSD into yUSDVault
5. Mint ~$500m crYUSD (it used yUSDVault as underlying)
6. Account A now has $500m crYUSD
7. Using account B, flash borrow $2b ETH
8. Mint cETHER
9. Borrow 500m yUSDVault
10. Mint $500m crYUSD
11. Transfer $500m crYUSD to account A
12. Borrow 500m yUSDVault
13. Mint $500m crYUSD
14. Transfer $500m crYUSD to account A
15. Borrow 500m yUSDVault
16. Transfer 500m yUSDVault to account A
17. Account A now has $1.5b crYUSD and $500m yUSDVault
18. Using account A, Redeem $500m yUSDVault
19. Transfer 8m yUSD to yUSDVault to ~double its’ share value
20. Since yUSDVault is now worth double, cream now thinks that the account A’s $1.5b crYUSD is worth $3b
21. Borrow $2b ETH
22. Account A now has $2 ETH, $500m yUSD, and $1b in Cream collateral.
23. The ETH and yUSD can be used to pay back the flash loans while the $1b collateral can be used to drain Cream.
[0] https://twitter.com/Mudit__Gupta/status/1453401698563596293 https://twitter.com/Mudit__Gupta/status/1453401698563596293
- elliekelly 5y agoAm I understanding correctly that all of this happens in one single transaction? The flash loan is borrowed, deployed, and repaid in one fell swoop? I’m trying to think of the most complicated single transaction item I’ve ever seen booked. I wish I wasn’t so rusty because trying to figure out the journal entries for this would be a fun little nerd puzzle.
- gzer0 5y agoThe attack was executed over multiple transactions due to block gas limits, but the bulk of it happened in this transaction [0]. Edit: These sort of financial engineering, whether one believes it to be an inherent flaw or not, are the exact reason why banks and financial regulation were eventually adopted. Crypto becomes the wild west, we have these "flaws / glitches / financial engineering" -> many people lose money -> regulation by lawmakers -> the circle repeats itself. [0] https://etherscan.io/tx/0x0fe2542079644e107cbf13690eb9c2c65963ccb79089ff96bfaf8dced2331c92 https://etherscan.io/tx/0x0fe2542079644e107cbf13690eb9c2c659...
- lawn 5y agoMight be a nitpick, but banks predates computers by several centuries, so these kinds of vulnerabilities are not the reason why banks were "eventually adopted".
- elliekelly 5y agoThanks for the link! Your edit reflects my thoughts exactly. I posted an old Law Review comment[1] describing (at a very high level) the market conditions in the early 1900s that gave rise to federal securities regulation. It’s a bit surprising how many of those mistakes we’re “relearning” with crypto. I wonder whether perhaps the crypto craze might have come about, in part, because of the regulatory inaction following the Great Recession. [1]https://news.ycombinator.com/item?id=29041167 https://news.ycombinator.com/item?id=29041167
- smoovb 5y agoThis is the post I was expecting under the HN article today with the title "Financial innovation is actually happening"
- mNovak 5y agoAs a crypto noob, can anyone point me to info on what this crYUSD and yUSDVault business is?
- ericlewis 5y agonot sure about crYUSD.. but there is an article about yUSDVault here: https://medium.com/talking-crypto/introduction-to-yearn-vaults-and-how-the-yusd-vault-works-c8ffda0d951f https://medium.com/talking-crypto/introduction-to-yearn-vaul...
- deleted 5y ago[deleted]
- qeternity 5y agoThese are all tokens that wrap other tokens, in this case, USD stablecoins. 1. You take a stablecoin like DAI or USDC and deposit with Yearn, who in turn lend it out and earn interest. You receive yDAI or yUSDC tokens in return which can be redeemed for the original deposit plus accrued interest. 2. You take your yDAI and deposit that into a Curve pool which is a decentralized exchange specializing in stablecoins. There is a pool that allows swapping between yDAI and yUSDC (and two others). If you deposit in this pool, you get a generic yUSD token that represents your claim to the pool’s assets and fees. 3. You look at your yUSD not content with the financial alchemy you’ve performed so far and think “what can I do with this securitized certificate of deposit?” Fear not, Yearn has a “vault” (lending strategy) specifically for yUSD. You praise the degenerate ape overlords and deposit to earn even more interest on your boring dollars. In return you receive yUSDVault tokens. 4. Not content, you begin to wonder why stop with yUSDVault. Are there any other strangers you can lend your rehypothecated certificate of deposit to? Yes! Cream finance will happily issue you their version of yUSD called cryUSD against your yUSDVault collateral…party on Wayne! 5. Now, Cream aren’t your typical boring bank that incinerate their money on synthetic CDOs and the like. These cryUSD tokens that they issue, can also be used as collateral to borrow other things! Hooray! But in order to value cryUSD, Cream needs to figure out how much the underlying yUSDVault tokens are worth. To do this, they need to figure out how much yUSD each yUSDVault token has claim to, and then multiply by the yUSD price. 6. It just so turns out that if you borrow a bunch of yUSDVault in a flash loan, and then redeem it for yUSD, you can get the balance of the yUSDVault very low. Let’s say you did this and left the yUSDVault balance very low (say, $8m). This is not a problem in itself, as these tokens are designed to be redeemed. 7. Well, knowing what we know from step 5, a clever trader realizes that if they do all of the above, and then borrow some yUSD (say $8m) and just donate it to the yUSDVault, when Cream goes to calculate how much cryUSDVault is worth, it will have immediately doubled in value, because some generous donor has just doubled the balance of yUSD owned by yUSDVault (and doubling the borrowing power of cryUSDVault in the process). So if you had flash borrowed a bunch of cryUSDVault (say $1.5b) against flash borrowed collateral (say $2b of ETH), you just now managed to double the value of your loaned assets to $3b but you’ve only posted $2b of collateral. 8. Normally a borrower’s collateral would be liquidated well before being underwater, but in this case everything is happening atomically inside a single transaction. 9. So the smart trader takes her $3b of cryUSDVault, borrows a bunch of other stuff to repay the $2b flash loan, which leaves her with $1b of collateral to borrow a bunch of other stuff (and ultimately default on).
- ndesaulniers 5y agoMore info from the tweet author on their blog: https://mudit.blog/cream-hack-analysis/ https://mudit.blog/cream-hack-analysis/.