Hacker News new | ask | show | jobs
by UncleMeat 1523 days ago
But then how are the funds used? Why is somebody able to transact with funds that they will receive in a block that hasn’t yet been added to the chain?
1 comments

The transaction is basically a function call like this:

flash_loan(int amount_borrowed, func arbitrary_trades)

1. give LOANEE_ADDRESS amount_borrowed

2. call arbitrary_trades()

3. give LOANER_ADDRESS (amount_borrowed + interest)

When 2. is executed, the loanee has the money. When 3. is complete, the loaner has the money back. If the loanee doesn't have the money to give, 3rd step fails. And since its atomic, the whole transaction fails.