7

A concrete example would be flash loans, where you could borrow some value from a lending script, do something interesting with it, and return the borrowed amount to the script with a fee, all in one transaction.

Intuitively this feels like it would need to be multiple transactions with separate outputs, but the lending script needs to verify that it is receiving sufficient value in return before it will ever lend anything.

How might this be modeled in Plutus to work?

2 Answers 2

2

Transactions on Cardano can be made up of many state changes. The transaction as a whole is atomic and a state change in the transaction will only be performed if all the changes can be performed.

For something like flash loans, as @Marek-Mahut points out, instead of having multiple transactions imperatively executed, each transaction just includes the before and after state. Flash loans are no longer needed in Cardano's model.

You could have a contract that allows you to redeem some ADA as long as you replace it with some interest in the same transaction--which is the equivalent of a flash-loan--but why would you ever do that? Plutus validators don't check that they're getting paid, they check that the state after redemption will be valid. The flash loan no longer serve the purpose of unlocking liquidity inside contracts. That comes for free with the EUTxO model.

tl;dr: All transactions on Cardano are made up of atomic state changes. This allows for what would be atomic sets of transactions on other blockchains.

1

Flash loans are not possible within the eUTXO model as each transaction is a single state transition, where a typical flash loan consist of two state transitions within a single transaction.

In my opinion, this is one of the most interesting security/safety features of the eUTXO model.

2
  • That "two state transitions within a single transaction" is what I mean by "atomic." Yeah. The safety here sounds comforting, but in describing the EUTxO model, Lars suggested that anything on Ethereum would be theoretically possible on Cardano--maybe I read too much into it. I'm far from understanding the limitations of the EUTxO model, but Haskell has ways of modelling this safely with the STM monad. I'd hope in the future Plutus could be extented to allow it. May 31, 2021 at 19:06
  • Yes, it was mentioned already that Lars called it a flash loan by mistake in one of the presentations, but he meant smart contract composability - similar, but a different concept. May 31, 2021 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.