Skip to main content

A block of credit starting with flash loans

· 6 min read
NEST Protocol


The flash loan is an on-chain advancement. A successful call of assets within the contract gives more assets returned for that call, while a failed call of the contract means no change in assets. And within that transaction, you have the assets within the contract at your disposal, as long as they are repaid within that transaction. This process does not place any restrictions on the use of assets and has a great degree of freedom, similar to real-world liquidity financing. It can be argued that this structure enables a single transaction to be credited. Since the transaction is done in one block, we can call this credit "one block of credit". Some people may think that a "one block credit" has no advantage in terms of time and will have little value. Indeed, this "one block of credit" is unattractive when you consider the many credit assets we have in the real world, but there is one situation that becomes very important, and that situation is arbitrage!

How does flash loans work?

Flash Loans, utilizing the transactional characteristics of a trade (ACID: Atomicity, Isolation, Consistency, Duration), has a callback design for the loan model, as follows.

  1. In addition to specifying the amount of the loan, the loan function entry needs to specify a receiving contract address

  2. The receiving contract needs to meet the requirements given by the loan specification

  3. The loan interface calls the specified callback function of the receiving contract and transfers the money, while recording the status of the balance before the transfer

  4. The receiving contract receives the loan transfer at the same time, the callback function is called, and can use the received assets to execute custom contract logic, or call other contract functions

  5. After the execution of the receiving contract function is completed, it returns to the callback point of the substitute repayment function, at which time it is able to get the third part of the pre-transfer balance status, at which time a check is made to check whether the repayment is received, and if not, it enters an exception state and the whole transaction is revoked.

As explained above, the callback mechanism is designed to take advantage of the transactional nature of the trade to complete a supervised "credit lending process".

Credit on the blockchain

The anonymity of the blockchain makes the concept of "credit" redundant. All on-chain lending and leverage requires full collateral. Even if someone were to go the other way and try to create a weak credit through some kind of "identity" asset, that would essentially be another type of collateral (notice the word asset, you know it's a collateral). In the world of blockchain, you can't have credit if you can't guarantee the performance. And the only way to guarantee performance is generally collateral. Various types of the decentralized lending and on-chain stablecoin solutions, all conform to this logic.

A risk-free arbitrage opportunity have never completely disappeared in the real world

Unlike the traditional commodity economy, in the financial world, once a risk-free arbitrage opportunity arises, the demand will no longer be a sloping downward curve, but a straight line perpendicular to the horizontal axis (arbitrage yield), i.e. the demand will be infinite! Any participant, who has the capital or the ability to finance, will try to participate in this opportunity in any way possible. This is the ideal situation. In the real world, where real arbitrage opportunities arise, there is often an important constraint: "borrowing constraints". That is, the person who finds the opportunity does not have the capital and cannot finance it to complete the arbitrage, resulting in an opportunity that may only be exploited by a few, or even not exploited for a long time. This inefficient allocation of resources is not tolerated by most financiers, so there is an unrelenting critique of lending restrictions. Since in the real world there are difficulties in determining whether an arbitrage opportunity is truly risk-free and whether the lent liquidity can be returned in a timely manner, lending restrictions and partial "market inefficiencies" have never completely disappeared.

Flash loans have solved "market inefficiencies"

But the existence of flash loans on the blockchain could make the lending restrictions and resulting "market inefficiencies" of the traditional financial world disappear altogether! This is because on the chain, this flash loan solves both of the aforementioned problems: 1. whether the arbitrage opportunity is real; and 2. whether the loan can be repaid in a timely manner. For example, if there is a contract A that exposes an arbitrage opportunity, any pool O in the blockchain world that supports the lightning loan, and a participant s who finds the opportunity, s does the following arbitrage contract B for the opportunity: call the asset X in O and interact with the contract A. If the arbitrage is successful, the asset X in O is returned. If the arbitrage is successful, the asset X within O is returned, and if the arbitrage fails, i.e., the asset returned to O is lower than X, contract B is revoked. In such a contractual process, the authenticity of the arbitrage opportunity is verified by whether the borrowed assets can be effectively returned, thus satisfying both conditions 1 and 2. Noting that here O and s can be any pool of funds and individuals, meaning that the whole process is free of obstacles and selectivity, thus fully reflecting the homogeneity of participants and financial needs, and perfectly solving the problem of inefficient resource allocation.


Of course, the perfect implementation of Flash Lending is also guaranteed by certain basic conditions: a large pool of assets supporting the Flash Lending interface and allowing contracts to call each other. These two conditions, if met, will build a perfect decentralized financial system. Its efficiency would far exceed that of traditional finance, not just because of code execution, but because of the perfect resolution of arbitrage risk and the credit required for arbitrage. But it's worth noting that if contract calls create new arbitrage opportunities, this is not the behavior we would expect to drive market effectiveness. This is a completely new type of financial attack, because if the transactional nature of the contract is exploited and restructured externally to create a new transaction, it is not really an arbitrage that is ineffective for the market, but rather undermines market effectiveness. But in any case, the creation of a new type of credit, which helps overcome the "lending constraint", is an important discovery in the blockchain space and provides much help for subsequent development.