MA Florian Gronde Flashloans-Ohne Appendix
MA Florian Gronde Flashloans-Ohne Appendix
MA Florian Gronde Flashloans-Ohne Appendix
Supervised by:
Prof. Dr. Fabian Schär
Credit Suisse Asset Management (Schweiz) Professor for
Distributed Ledger Technologies and Fintech
Center for Innovative Finance, University of Basel
Abstract
This paper deals with the concept of Flash Loans on the Ethereum
Flash Swaps on Uniswap and Flash minting. It also describes the two
largest ashloan attacks that have brought the concept into the public
were analyzed and their applications were worked out. It is shown how
which tokens are in focus. It is pointed out that the most common ap-
for arbitrage and Aave for closing of collateral debt positions, whereas
1
Keywords: Aave, bZx, Flash loans, Flash minting, Flash swaps,
2 Decentralized loans 6
2.1 Classic P2P lending . . . . . . . . . . . . . . . . . . . . . 6
2.2 Flash loans . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.1 Applications . . . . . . . . . . . . . . . . . . . . . 9
4 Empirical research 26
4.1 Data acquisition and preparation . . . . . . . . . . . . . 26
4.2 Categorization . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3 Findings . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.3.1 Utilization numbers of Flash Loans . . . . . . . . 37
4.3.2 Distribution of txns over time . . . . . . . . . . . 39
4.3.3 Applications . . . . . . . . . . . . . . . . . . . . . 41
4.4 Token on protocols . . . . . . . . . . . . . . . . . . . . . 50
4.5 USD volumes . . . . . . . . . . . . . . . . . . . . . . . . 53
5 Conclusion 59
5.1 Limitations and further research . . . . . . . . . . . . . . 60
References i
Appendix
I
List of Figures
mio USD . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
II
List of Tables
III
List of abbreviations
API Application Programming Interface
ETH Ether
P2P Peer-to-Peer
SC Smart Contract
txn transaction
USD US Dollar
XRP Ripple
IV
Plagiatserklärung
Ich bezeuge mit meiner Unterschrift, dass meine Angaben über die bei
der Abfassung meiner Arbeit benutzten Hilfsmittel sowie über die mir
zuteil gewordene Hilfe in jeder Hinsicht der Wahrheit entsprechen und
vollständig sind. Ich habe das Merkblatt zu Plagiat und Betrug vom
22. Februar 2011 gelesen und bin mir der Konsequenzen eines solchen
Handelns bewusst.
Florian Gronde
2012-065-694
V
Acknowledgements
Many thanks to Prof. Dr. Fabian Schär for the opportunity to work on
and considerations. Huge thanks to Susanne Halimi for all the technical
explanations and thoughts during the data acquisition and the push to
dive deeper into the topic by the overwhelming interest in my work and
1
1 Introduction
news went viral quickly (e.g. Trustnodes (2020b)) and drew public atten-
First, a ashloan of 10,000 Ether (ETH) from the dYdX trading plat-
form was invested half on the Compound platform for conversion into
Wrapped Bitcoin (WBTC) and half on the bZx platform for shortening
the same amount WBTC. Subsequently, the price of WBTC was lowered
in a prot from the settlement. The ashloan and the protocol fee were
probably Aave and dYdX. Aave developers (2020b) describe Flash Loans
serve [...] a certain amount of liquidity, that must be returned within the
same transaction. Besides a relatively low protocol fee, there are no fur-
ther costs for the borrower. The only condition is that the loan must be
returned within the same transaction, within one block on the Ethereum
Blockchain. Although the very short time between taking out a loan
has now been eliminated for the described procedure, the basic concept
1 transaction
(txn):
0xb5c8bd9430b6cc87a0e2fe110ece6bf527fa4f170a4bc8cd032f768fc5219838
2
of risk-free loans nevertheless opens up a wide range of investment op-
require collateral that exceeds the value of the loan. Collateralized loans
are probably the most common form of lending in the traditional nan-
eralized loans. Here, the repayment of the loan in the same transaction
is a condition for the actual disbursement. This means that the user only
are required, the repayment can be limited on using the actual credit. In
this way, the user has hardly any investment risks. Apart from the rela-
tively small protocol fee, no own funds have to be used. This guarantees
that the user will only receive a loan if he can achieve a positive return on
cannot be repaid and the actual payout is not possible. In this way, no
investment risk arises for the lender either. He never has to provide funds
which are not paid back. On decentralised platforms, this enables almost
unique investment opportunity. But above all, the high prots that have
nipulating prices, provide the basis for exciting news. Nevertheless, there
ject of Flash Loans. This may be mainly due to the very young concept.
News on the topic is mostly limited to the analysis of the attacks. The
3
the functionality of the involved smart contracts of the lending platforms
on the one hand, and detailed data analysis of the purposes of Flash
Loans on the other hand are often not in focus. Reliable sources are thus
1.3 Objective
The central question of the present study can be derived from the ob-
servation of the increased interest in the topic of Flash Loans and the
tions are the focus of the analysis: It will be elaborated how Flash Loans
basically work and why they are a unique form of credit. This is con-
nected with the description of the used smart contracts of the lending
often reported attacks and the exploitation of large capital gains could
come about. Furthermore, the present work focuses on dierent use cases
and shows in an empirical analysis the extent of the current use of Flash
Loans.
1.4 Methodology
Since there is hardly any scientic research on Flash Loans, the collec-
tion of the relevant data was done from scratch. For the acquisition of
used. Data about dYdX (2020) could be collected by querying the cor-
the relevant txns for ash swaps on Uniswap (2020a) was done using
Dune Analytics (2020). Further txns for ash minting could be acquired
be found in the section Empirical research and the appendix. After iden-
4
tifying the relevant txns, the respective token transfers were drawn from
2020a) and Qin et al. (2020) with the addresses of the token transfers
and destinations of the transfers was created. This serves as a basis for
rectly. Furthermore txns which were not successful were checked for their
data cleansing and the identication of applications took the major part
of the work.
jectives of the work. Subsequently, in chapter two Flash Loans are dis-
ash minting and ash swaps are explained. Chapter three deepens the
dYdX, bZx, Uniswap and an example of ash minting. First the func-
tionalities of the protocols which are key for the usage of Flash Loans
evaluation of the results builds up the conclusion of the paper. Note that
have been put into footnotes. All direct links have been marked in blue
5
for better visibility.
2 Decentralized loans
The concept ashloan (or Flash lending) was rst introduced by Max
Wol (2018). However, the project around the open-source bank Marble
has not yet seen a user-ready release. But even protocols for uncollat-
eralized lending which are available live on the Ethereum main-net are
Truong, 2020) or ashmint (2020) try to ll this gap and oer a sim-
Flash loans like on Aave, dYdX or ash swaps on Uniswap are aimed at
developers and technically experienced users. But not only the currently
dicult interaction with ashloan protocols, but also the unique concept
users in understanding them. For this reason, the following chapter rst
of Flash Loans is given. Chapter three goes into more detail about the
(2020a) oers a good starting point. The platform, which rst started
in 2017 under the name Ethlend, was launched in 2018. The lending
protocol oers the possibility for decentralized pool lending and borrow-
Smart Contract (SC). Deposits are paid into a pool contract. From this
6
pool contract, lenders can then borrow loans. The LendingPoolCore
2
contract stores the states of all reserves, i.e. the deposits of individual
loans require users to lock a collateral with greater value than the loan
in their reserves. Reserves represent the core of the pools. They hold the
of the collateral in ETH. The amount a user can borrow depends on the
old value is set for every reserve. The threshold for a user is a weighted
lateral drops in price, causing the healthfactor to drop below one, then
from the liquidation are then used to repay the loan untill a maximum
factor rises above 1 again. The role of liquidator can be taken over by any
user and thus acquire a part of the collaterals relatively cheaply. Users
can take out loans at a xed or variable interest rate and repay them
functionality is similar in its basic features for many other crypto lending
7
2.2 Flash loans
The Ethereum Virtual Machine (EVM) contains the possibility to revert
throws away all changes that happened since that checkpoint. The EVM
tract are not fullled (Ethereum Foundation, 2020). This makes ashloan
does not need a credit balance in his cryptowallet or even in the interact-
ing SC, except for a small amount of the ashloan currency to pay the
protocol fee (which also could be acquired through arbitrage gains). Note
that network fees for initiating the txn are not taken into consideration
here since they are accounted for every txn on Ethereum. When a user
user can then use the loan for various actions within the duration of the
platform with a lower interest rate, one can use Flash Loans to clear
the rst debt and switch to another platform. The Applications section
After the execution of the SC actions, the user repays the ashloan plus a
network fee. This is only possible if the user has made a prot through his
SC. As there must not previously be a credit balance in the user's wallet,
no other funds other than the actual loan can be used for repayment.
However, if a User makes a loss on his investments, he can not pay back
the loan. In this case the revert function mentioned above will be used.
The transaction is put back into the state in which the loan has not yet
been paid out. Since this all happens within one transaction, the actions
This eliminates the risk of making a loss for both the user and the issuer
of the ashloan.
8
2.2.1 Applications
notice without having or being able to invest his own funds. The following
section introduces them and gives examples for txns and projects for a
specic application.
the price of the currency is lower than the price on another platform, the
currency can be sold there and an arbitrage prot can be made. An ex-
the rst ever Flash Loan on the blockchain, were able to make a small
prot on the transaction (Julien Bouteloup for Flash Boys, 2020). Figure
To carry out the arbitrage trade, rst a ashloan of 3, 137.4070 DAI was
made on Aave. After taken out the ashloan, DAI was converted into
3 txnhash:
0x4555a69b40fa465b60406c4d23e2eb98d8aee51def21faa28bb7d2b4a73ab1a9
9
the same amount of Single-Collateral DAI (SAI) through MakerDAO's
Migration contract by rst burning the amount of DAI and then minting
the same amount of SAI. Then SAI was converted into DAI using the
now higher than before the conversion. One can conclude here that there
was a better conversion price of SAI to DAI on Uniswap than the one
through the ashloan and the amount of 3, 148.3879 DAI repaid to Aave
was 10.9809 DAI. After repayment of the loan to Aave and deduction of
the protocol fee of ∼ 7.6867 DAI, a prot of 3.2942 DAI was achieved
(Qin et al., 2020). Despite the relatively small prot, this example of the
be deposited. The deposited collateral is then locked until the loan can
is possible that the currency of the loan may fall sharply in value against
repay the loan, because the value of the currency is lower than the value
when the loan has been taken, and his collateral remains locked. Flash
loans oer the possibility to pay back the loan and thus release the col-
lateral. For example, a borrower who has deposited ETH as collateral for
a loan in the form of DAI can take out a ashloan in DAI in the amount
of the CDP. With the ashloan he pays back the CDP and can release
change and the ashloan is repaid. Finally, the remaining ETH that was
4
deposited as collateral is taken back . An example is found in Figure 2:
4 txnhash:
0x79644cd1bf45b196eb3aad9b96c1892568adc5ee830e746ed2d48d8a4081b2f2
10
Figure 2: Token transfers of CCDP example
Source: txn:
0x79644cd1bf45b196eb3aad9b96c1892568adc5ee830e746ed2d48d8a4081b2f2
on Etherscan
In the example txn, a ashloan from Aave, equal to the outstanding dept
position of ∼ 262.1786 DAI on the plattform Maker is taken out. Next the
CDP is paid back. For Maker this works by burning the amount (sending
5
it to the origin address ). Then the collateral of ∼ 2.0951 Wrapped
Ether (WETH) is freed and withdrawn. For paying back the ashloan,
the user rst converts the corresponding amount from the withdraw from
WETH to DAI using the Kyber reserve. In the txn one can observe the
dierence between the required amount for repaying the ashloan and
deposit that is not important for the process of CCDP. Following this,
the ashloan of ∼ 262.4145 DAI, including a fee (read more in: 3.1
Aave Lending Protocol) is paid back and a small surplus is sent to the
of the collateral might have been withdrawn in another txn and is not
DeFi Saver (2020) provides a dashboard with the same functions as de-
loans and release locked collaterals without the need for additional own
5 address:
0x0000000000000000000000000000000000000000
11
A similar principle as for closing CDP is also applied to the renance
high interest rates on his debt to a platform with lower interest rates, the
amount of the loan. The loan is then redeemed and the position closed.
At the same time, the collateral deposited is released. Now the collateral
interest rate. The ashloan is then repaid including the transaction fee.
This makes it possible to change the interest rate of a loan without having
to repay the loan from one's own funds. The costs incurred are only the
are issued, a currency swap can be made and changed into the preferred
currency by using swap platforms such as Uniswap (Marc Zeller for Aave
Blog, 2020).
observing the value of the collateral and noticing a sharp drop, a user
can interact and buy back own collaterals. The procedure then follows
cies. Aave, for example, oers a variety of currencies for this purpose. It
The amount of the loan depends largely on the performance and value of
the entire loan and then take it up again with a new collateral. In order
to avoid having to raise further own funds to repay the loan, a ashloan
the protocol fee are then repaid. Kevin Truong (2020) already is work-
ing on this concept under the name Collateralswap for the platform
12
6
MakerDAO . An example is provided in Figure 3 below:
0.5 WETH using the ashloan. Then converts WETH for ∼ 380.64 Basic
Attention token (BAT) using Uniswap (read more in: 3.4.1 FlashSwaps).
surplus of ∼ 0.02625 DAI is sent to the user. This way the user swapped
the collateral from WETH to BAT in only one txn without using own
funds.
Wash trading The following use case briey presents a deliberate way
volume of certain assets than would actually be traded on the open mar-
articially aects the price and harms the development of the cryptocur-
rency market in the long run (Cong et al., 2019). Alongside with this
6 txnhash:
0xf0c72b0e64612ba607d7499acc3dbf7dfcedc2a63901d38ec742eb64f1456ae4
13
statement, Cong et al. (2019) nd evidence that a large proportion of
estimates that the wash trading rates of the major cryptocurrencies range
from 50% to 75%7 . According to Qin et al. (2020) the biggest hurdle to
DeFi exchanges, which settle all transactions on-chain and can not use
is binding. With the help of Flash Loans it is possible to reach very high
In this txn a ashloan on dYdX is carried out (read more about dYdX in:
3.2 dYdX). Then 0.01 WETH was converted into ∼ 122.18978 LOOM
and back into ∼ 0.0099 WETH. Afterwards the ashloan was paid back
(Qin et al., 2020). What distinguishes this txn from other applications,
such as arbitrage, is that the txn has been carried out although there was
a loss when swapping tokens. This indicates that the user wanted the txn
to complete to push up trading volumes and did not try to make a prot
from it in the rst place. Qin et al. (2020) state that the 24-hour trading
7 Bitcoin:
50%, Ethereum: 75%, Ripple (XRP): 55%, and Litecoin: 74%
8 txnhash:
0xf65b384ebe2b7bf1e7bd06adf0daac0413defeed42fd2cc72a75385a200e1544
14
3 Flash loans in detail
The following chapter goes into detail about the smart contracts of the
minting and the interaction with them. Based on this, the attacks are
described which have brought Flash Loans into the focus of the public
and media. It is explained how the attackers were able to achieve such
contracts.
the call of the function flashloan(). It is set up to only let the owner
important to notice that 1 ether refers to 10 000 tri WEI worth of 1 DAI.
The argument _params lets one dene additional parameters. The re-
15
flashloan function. _amount is the borrowed amount of the loan with
a _fee of 0.09% to be paid back. Next any application specied within
the contract is carried out and the ashloan is transferred back to the
of the loan plus the _fee. After compiling and deploying the contract
transferred to the contract. If this is not done, the txn is reverted and
3.2 dYdX
The logic of Flash Loans on dYdX follows in principle the same as on
borrowing, and lending (dYdX, 2020). It is account based and all state
actions into operations. The most important feature here is that collat-
This means that multiple actions can be performed without the need for
collateralization per se. For example, loans can be taken out, used for
ation. The logic of Flash Loans on dYdX follows the same as on Aave
16
11
WEI. Despite this statement, fees of 1 WEI could be observed , and a
12
statement of dYdX founder Antonio Juliano in a personal discussion
3.3 bZx
The protocol bZx also contains an explicit ashloan feature through the
that call the function and then perform actions the functionality will
be pointed out here for the sake of completeness. The only executed
ashloan on bZx is the second famous ashloan attack, which will be pre-
sented later. BZx is a decentralized protocol that enables lending and
borrowing for margin trading (bZeroX, LLC, 2018). For this purpose,
bZx uses global liquidity pools which are shared between many dierent
exchanges (Hussey and Tran, 2020). When users deposit liquidity they
held by each lender. They are minted by the contract mentioned before
When borrowing assets (to trade with margin), users borrow from an iTo-
ken lending pool and receive the corresponding underlying asset. When
tial contract again and calling the function before it has been completed
(fravoll, 2019). A pausing check validates that the function has not been
the asset to the address of the borrower and then might send it to the
target address by an ArbitraryCaller.sendCall within the contract
ArbitraryCaller. The target can be an external address or contract
11 txn: 0xc9c1d6563f2db590c8786ad98ce07daddf9bd1e753b57ed695fe9475d234a5
12 On Discord 11.07.2020
13 https://github.com/bZxNetwork/.../LoanToken/LoanTokenLogicV4.sol
14 txn:
0x762881b07feb63c436dee38edd41f7a74c33091e534af56c9f7d49b5ecac15
17
which then performs some applications with the ashloan. Afterwards,
the remaining asset balance is transferred back and a check on the asset
balance is made.
require (
address ( this ) . balance >= beforeEtherBalance &&
ERC -20( loanTokenAddress ). balanceOf ( address ( this ))
. add ( totalAssetBorrow ) >= beforeAssetsBalance ,
" 40 "
);
LoanTokenLogicV4
The check requires the ETH balance before the loan not to be less than
after and the ERC-20 token balance of the asset of the loan added up by
which follow the idea of Flash Loans. Although they are not explicitly
assigned to the term Flash Loans because ash swaps technically only
involve the exchange of two tokens and ash minting does not request
a loan, the possible applications are the same. The general functioning
3.4.1 FlashSwaps
With the launch of version 2 of Uniswap (2020b) the feature ash swaps
changed for another, ash swaps allow the withdrawal of the token with-
Flash Loans. A user can dispose of the amount of the received tokens
18
within a transaction as long as he repays or exchanges them at the end
swap of ERC-20 token pairs and the swap of ERC-20 and ETH. The
two main SCs involved are a Factory contract and a Pair contract. The
ployed. In order not to create Pair contracts for tokens that already
the respective address linked to the token. Routers are helper contracts
that perform the safety checks needed for safely swapping, adding, and
tract contains a liquidity pool for exactly one ERC-20 token and ETH
or two specic ERC-20 tokens (in the following the term token will be
used representative for any ERC-20 token or ETH). The exchange price
kept constant during swaps and changes only when liquidity is added
receives the amount of tokens needed to keep the relation constant after
a certain amount of tokens has been deposited. Because the ratio of to-
kens changes, the exchange rate changes as well and gives incentives to
swap in the opposite direction. When liquidity is added to a pool for the
rst time, the user has to decide which rate between tokens is considered
ratio at the time of deposit. If the ratio is dierent from the general
market price, arbitrage possibilities arise through swaps, driving the ex-
change rate back to a level near the market price. To incentivize users
19
ETH and ERC-20 tokens are withdrawn at the current exchange rate,
not the initial rate at the deposit, which facilitate arbitrage possibilities
required for a user to deposit the amount of one token or ETH needed
as it is deposited within the same txn (which does not necessarily mean
that users more often do not deposit before they take out swaps). To
included in the token pair that msg.sender wants to send to the to ad-
to the Pair contract before calling the swap function. To determine be-
tween a usual swap and a ash swap the parameter data is used. For
has already been made and the tokens are transferred directly to the
and 3 fetch the addresses of the tokens included in the pair while line 4
20
call of uniswapV2Call the respective amount of tokens including a fee of
must be transferred back. The fee of withdrawing tokens on Uniswap is
3%, whereas the amount in the reserve after the return must be greater
3.4.2 Flash-minting
ERC20 token generator (2020) and added to the total supply. They dier
from standard ERC-20 tokens which have a xed total quantity (token-
certain tokens like the stablecoin DAI must be deposited with collaterals
before minting, which correspond to the equivalent value of the new to-
kens in USD. In this way, DAI can maintain its coverage with the USD.
The concept ash-minting uses the described creation of new tokens. Qin
all new tokens are destroyed within the transaction in which they were
created. Economically, this only makes sense when minting asset backed
tokens can represent an economic value. One WETH can also be trans-
ferred and traded at any time and always retains the equivalent value of
underlying asset and anyone can mint arbitrarily many unbacked tokens
and spend them at full face value, so long as they destroy all the un-
backed tokens (and therefore restore the backing) before the end of the
asset. The logic is the same as for Flash Loans. All applications men-
21
tioned above are conceivable here. The dierence with ash minting is
that the source of funds is not a lending platform like Aave. However, the
import " @openzeppelin / contracts / token / ERC -20/ ERC -20. sol ";
interface IBorrower {
function executeOnFlashMint ( uint256 amount ) external ;
}
contract FlashMintableToken is ERC -20 {
function flashMint ( uint256 amount ) public {
// mint tokens
_mint ( msg . sender , amount );
// hand control to borrower
IBorrower ( msg . sender ). executeOnFlashMint ( amount );
// burn tokens
_burn ( msg . sender , amount );
}
}
Williams (2020))
is explained how the attackers could make ∼ 350k USD and ∼ 650k
USD prot. The mechanics of the attacks have been shown quite well in
would exceed the scope of the present work and would not provide added
value for the economic analysis of Flash Loans. Therefore, the following
15
The rst attack took place on 2020-02-15 01:38:57 and diers from the
15 txn:
0xb5c8bd9430b6cc87a0e2fe110ece6bf527fa4f170a4bc8cd032f768fc5219838
22
attack described later because no oracle manipulation was performed,
2020). After taking up a ashloan on dYdX for 10,000 ETH, 5500 ETH
liquidity pools and borrowing assets (Leshner and Hayes, 2019). When
users deposit assets they receive cTokens representing the Asset. In the
borrow, they lock their deposits as collateral and receive a specic share
factor of the pool from which is borrowed. Next, the attacker opened up
a deposit of ETH for 5x WBTC and called for a swap of ETH to WBTC.
for a token pair, Kyber searches reserves to nd the best price for the
for the trade. The only pool which had enough liquidity to provide such a
large amount was Uniswap, so the margin trading function leveraged Ky-
enough liquidity to service the entire amount. Because the ratio of to-
kens within the Uniswap liquidity pool of the token pair ETH/WBTC
changed (see 3.4.1 FlashSwaps), the exchange rate changed from ∼ 38.5
WETH/WBTC to ∼ 109.8 WETH/WBTC. This part of the transaction
was only executed to manipulate the conversion rate on Uniswap. WBTC
holding of WBTC which is worth less than the swaped WETH under
16 https://github.com/bZxNetwork/.../iTokens_loanOpeningFunctions.sol
23
pool from ending up with less liquidity than is covered by collaterals.
1 require ((
2 loanDataBytes . length == 0 && // Kyber only
3 sentAmounts [6] == sentAmounts [1]) || // newLoanAmount
4 ! OracleInterface ( oracle ). shouldLiquidate (
5 loanOrder ,
6 loanPosition
7 ),
8 " unhealthy position "
9 );
amount to withdraw, the oracle was never consulted and there was no
check for liquidation (Livnev, 2020). This kind of strategy, raising the
margin over the rate which could be realized when market prices would
wards the pump, the attacker sold his 112 WBTC from Compound to
Uniswap using a regular swap. The price realized in the swap was 61.4
WBTC/ETH, leading to a return of 6871.4127388702245 WETH. The
ashloan was paid back, using the remaining 3200 ETH from the initial
loan and ∼ 6800 ETH of the swap return (plus a small fee), leading to a
02-18 03:13:58, was using the same idea of manipulating prices but with
bZx was made by the attack. The reasons can be found in the found in
the pause of the protocol and because the functionality is poorly doc-
again uses Kyber to manipulate prices. For this purpose, the ashloan
minted against the value of USD by the platform Synthetix (2020). Syn-
17 txn:
0x762881b07feb63c436dee38edd41f7a74c33091e534af56c9f7d49b5ecac15
24
one of the reserves for Kyber. Kyber selects the reserve of the plat-
form with the best available price or the ability to service the requested
amount. For this purpose, 540 ETH were rst converted on Uniswap
Kyber reserve and then 20 ETH on sUSD Kyber reserve were converted
to sUSD. This was done 18 times and each time the conversion price
Due to the manipulated prices of the Kyber Reserves, the Oracle re-
ports a price which diers from the actual market price. The attacker
Synthetix did not seem to have enough liquidity at that time. The re-
maining ETH was transferred back. The price of ∼ 268, 2989 ETH/USD
is signicantly above the manipulated price reported by the Kyber oracle.
Next, sUSD on bZx is exchanged for ETH. The sum of ∼ 1, 099, 841.3921
sUSD is composed of all swaps on Kyber reserves and the exchange on
Synthetix. The attacker can thus obtain∼ 6796, 0128 ETH at a price of
∼ 161, 8362 ETH/sUSD. This is nearly 100 USD less than the price called
at the beginning of the attack. Since sUSD follows the value of the USD,
bZx sUSD worth ∼ 1, 099, 841, 3921 USD, while it returns ETH worth
1, 780, 889, 52138 (calculated at the price at the beginning of the attack)
USD. This represents a loss of∼ 681, 048, 1293 USD. After the exchange,
the attacker repays the ashloan consisting of ∼ 6796, 0128 ETH plus re-
maining ∼ 3082, 1409 ETH from the initial ashloan, leading to a prot
While the rst attack exploited a bug in a function of the bZx protocol
that did not contact the oracle, the second attack was aimed at getting
They both took advantage of the opportunity to take out very high loans
fact that with Flash Loans, there now is theoretically a possibility for all
DeFi users to execute txn with high sums. Further more precautions in
25
preventing oracle manipulation must be taken.
4 Empirical research
The following chapter analyses the use of Flash Loans. The analysis
protocols on which they are executed and the amount of the loans. The
main interest lies in the categorization of use cases. Criteria are dened
how Flash Loans and the associated transactions can be categorized into
use cases. The aim is to nd out which of the above mentioned possible
Flash Loans on the presented protocols is and which volumes in USD are
observable.
The chapter rst describes the methodology of data collection and prepa-
ration, then goes into the categorization of use cases and concludes with
The data collection for Flash Loans on dYdX turned out to be more com-
plex, since no subgraph exists for dYdX Flash Loans and the denition
18 txnhashes:
0xf65b384ebe2b7bf1e7bd06adf0daac0413defeed42fd2cc72a75385a200e1544
0xb5c8bd9430b6cc87a0e2fe110ece6bf527fa4f170a4bc8cd032f768fc5219838
26
tion, applications of Flash Loans, i.e. various token transfers, are always
dYdX. To obtain the relevant txns to be considered Flash Loans, all txns
during the data analysis it was found that txns which include the simul-
taneous deposit and withdraw, but not in the form of a ashloan, also
meet the conditions stated before. This is the case, for example, when a
and the amount deposited do not correspond were removed. This is also
true for the two events when two dierent tokens are involved. The dif-
Pair contract has previously been paid with the appropriate amount of
one token in the token pair before the swap is executed to equalize the
pair. All returns >0 are ash swaps because the swap took place before
query on Dune Analytics (2020) returns the hashes of the matching txn.
23
SELECT call_tx_hash
FROM uniswap_v2 ." Pair_call_swap "
WHERE octet_length ( DATA ) > 0
LIMIT XYZ ;
27
of the respective txn hashes, "uniswap_v2."Pair_call_swap"" refers
The identication of ash minting txn has been done by the two contracts
AM) and block 10464540 (Jul-15-2020 02:11:21 PM). After data cleansing
the time frame was reduced to block 9142247 (Dec-21-19 08:04:25 PM)
The initial amounts of the Flash Loans on Aave could be taken directly
from TheGraph call. For dYdX the transaction action pairs Borrow and
Repay have been compared and the Flash Loan amount taken was set to
those ones with the same amount (plus a fee tollerance of upt to 2 WEI)
and the same token. This has been done with all possible care to avoid
that actions that represent a borrow and repay within the Flash Loan txn
are included in the analysis. If there were multiple candidates, the pair
that brackets other pairs was considered. For Uniswap the amounts of
the transaction action Swap amount token on Uniswap has been taken
available in V2.
identied as Flash Loans, ash swaps or ash minting were loaded from
pendix API Calls. After the collection of all data, as many known
addresses as possible were assigned to the token transfers that take place
within the txn. For this purpose the addresses labelled by Etherscan's
2020a) and Qin et al. (2020) were used. These were mapped with the ad-
24 contract: 0xf7705C1413CCE6CfC0fcEfe3F3A12F38CB29dA
25 contract: 0x09b4c8200f0cb51e6d44a1974a1bc07336b9f47f
28
applications.
4.2 Categorization
After the data acquisition, the same or similar transfers and txns were
grouped. The following chapter presents the methods used for the iden-
txns and the contracts deployed by the owner address have been checked
of the application. If this was the case, all txn which were included in
short explanation is given. Examples can be found within the data set
under the respective subcat tag. When more than one use cases within
Arbitrage
that several contracts deployed by the owneraddress work the same way.
The contracts basically take out a ashloan and try to make prot by
26 https://0xtracker.com/traders/0x1d92ed2c7cb9bb19c654dcec059d043856b601e4
29
Arbitrage_swaps The DEX 1inch reported an arbitrage trade of
27
Chi Gastoken on Twitter . Said contract swapped Gastoken minted by
form Hex (2018 -2020) in combination with Flash Swaps. The platform
allows earning and staking of the token HEX by depositing ETH. Addi-
sion from HEX to the hex.win platform. Although some sources assume
strategy takes advantage of the minting of 1 HXY per 1000 HEX trans-
29
ferred to hex.win and is structured as follows: :
A ash swap over a high sum of 31337 HEX is taken. HEX is trans-
30
ferred to Hex.win and converted to HXY. The origin address mints the
the user. The user pays the ash swap by the tokenpair HXY/HEX and
keeps the amount of additionaly minted HXY. Again, multiple txns of the
vision of liquidity loan to the protocol Compound Labs, Inc. (2020) and
27 https://twitter.com/1inchexchange/status/1265198816619266048
28 https://uniswap.info/token/0x2b591e99afe9f32eaa6214f7b7629768c40eeb39
29 txn:
0x0a070096bd56a8aaab31370f1f3afeaad0e8ace4b755f206983ddcbc24d772e1
30 address:
0x0000000000000000000000000000000000000000
30
called COMPfarming and can be observed in varoius ashloan txns via a
and carry out as many of the above interactions with Compound as pos-
sible. The resulting COMP tokens can then be sold and an arbitrage
the amount of the collateral to be liquidated is taken out and then the
at a lower price, which results in a higher return of the same token. The
dierence between the ashloan and the received amount of the token is
spective owner addresses were manually checked for other SCs and, if a
similar scheme was available, they were assigned to the same application.
31 e.g.: 0x475adbbc7226b121077e4bae696c526a83750c55eed408a391c5a951b0d5c2b4
31
Arbitrage_hammerbots On the famous Black Friday on March 12.
and 13. 2020, a collapse of the price of ETH caused many CDPs to be
counter act against zero bids (bids for liquidations around zero). Block-
spam nodes with txns and hindering keeper bots to successfully place
bids and keep zero bids from happening. 22 addresses of potential ham-
mer bots have been identied in the report. These addresses could be
identied within the data set of the present work. It is noticeable that
these txn do not include any transfers other than taking out a ashloan
the mentioned addresses and when there are only two transfers involved
in dYdX Flash Loans folowing the same scheme. Hence they do not seem
bots it is not yet clear to which extend the found relation holds, but it
day. Although the purpose of these txns could not be fully claried as a
deeper analysis would exceed the scope of the work, it seems reasonable
Txns which are initiated by addresses that have been identied as po-
tential hammer bots, because they also inititiated txns which follow the
found previously. Again it has to be stated that one should take care in
beforehand.
32 e.g. txn of address: 0x03ebd0748aa4d1457cf479cce56309641e0a98f5 on Etherscan
32
Arbitrage protocols The following protocols are known to be proto-
the dierence that it is not limited to token pairs but can contain
kens when they are o market price and keep arbitrage prots. Txns
Collateral_swap
eralswap directly.
CCDP
33
MCDOpenFlashLoan, MCDOpenProxyActions, MCDSaverFlashLoan and
CompoundImportFlashLoan33
Wash trading
lowing the example in 2.2.1 Wash trading, all txns which do not con-
tain any other transfers besides the ashloan, the back-and-forth trans-
fer and a maximum of one other transfer to another address, were in-
in the same currency should take place to distinguish the txns from ar-
cannot be classied as wash trading. Here it must be made clear that the
identied txns must be treated as potential and not denitive wash trad-
can be established.
No_application
conceivable. Nevertheless, the observed txns seem to have been used for
test purposes only because there rarely transfers other than minting and
case.
33 contracts: https://github.com/DecenterApps/[...]/contracts
34
NAPP
or because manual checks of all txns would not have been meaningful in
35
4.3 Findings
The nal data set consists of 6857 txns and 64660 token transfers. Table
1 provides an overview over the attributes used in the data set "Master-
data.xlsx". For calculating USD values of tokens, the prices of the most
frequent tokens used were collected. This was done because unfortu-
of the unfrequent tokens involved in the data set. This is especially true
for the large amount of tokens found in FlashSwaps. This approach re-
Attribute Description
36
The headers in the "Exchange_rates.csv" data set correspond to the
value of the loan. date was used for mapping exchange rates (the same
The following section shows the distribution of txns over protocols and
shows which applications and subcategories have been used the most
and in which months they could be observed. It then presents the usage
tant to note that the focus has been deliberately placed on a qualitative
vided. This is therefore appropriate for the present work, which aims to
explain the hitherto very unilluminated topic of Flash Loans and to give
a description of the applications and the monetary use to date. All visu-
(2012-2020) in Python.
It was found that Aave covers half of all Flash Loans taken out in the ob-
mainly used for CCDP because Desaver makes use of Aave Flash Loans
and is therefore only used here. Uniswap only covers a small amount
37
(10.40%) which is due to the possibility of ash swaps became available
only in May 2020. Further it can be observed that the concept of Flash
minting is hardly ever used. This is due to the very new and unknown
concept which is almost not covered in any reports. On bZx, the only
loan attacks. No denitive statement can be made here on the low level
apart from audit reports (see: CertiK (2020a)) in conjunction with the
further calls of the function. Table 2 and Figure 5 vizualize the distribu-
tion of txns and transfers over protocols. Flash loans on Aave and dYdX
average of 3.31 transfers per txn. This corresonds to a lot of failed txns on
Uniswap as shown later. The same is true for Flashminting. The average
38
3500
3000
2500
2000
txns
1500
1000
500
0
dydx aave mint uni
protocol
The following part describes the distribution of txns over time on proto-
cols and tries to reason the observed occurrences by showing the distri-
Table 3 show the monthly usage of ashloan txns. While numbers started
to rise since the launch of the feature on Aave in February, the usage is
39
Table 3: monthly usage of Flash Loans
Month txns
Dec-19 25
Jan-20 9
Feb-20 157
Mar-20 1574
Apr-20 1726
May-20 1055
Jun-20 1683
Jul-20 628
Total 6857
The average number of txns per month from February to June 2020
is 1509.5 which shows the very moderate use. December 2019 and Jan-
uary 2020 where excluded in calculating the average because Flash Loans
where ocially only available from February on. July was excluded be-
Figure 6 and table 4 show the distribution of number of txns on the dif-
ferent protocols on a monthly base and supports the hypothesis that the
observed dierences in the quantity of Flash Loans executed are partly re-
lated to the time when the ashloan feature of Aave and Uniswap became
average share of ∼ 21% in May, June and July. It has to be noted that
data for July is scarce, since data collection was done until 15.07.20.
40
Table 4: txn count over time
December-19 25 0 0
January-20 3 6 0
February-20 26 114 0
March-20 375 1197 0
April-20 1054 653 0
May-20 149 773 126
June-20 957 423 303
July-20 98 246 284
dYdX
1200 Aave
Uniswap
1000
800
txns
600
400
200
0
Dec-19 Jan-20 Feb-20 Mar-20 Apr-20 May-20 Jun-20 Jul-20
time
4.3.3 Applications
The following part illustrates the distribution of applications over all pro-
subcategories on a certain protocol. Over the whole data set, 5724 txns
41
could be assigned to an application, which corresponds to ∼ 83%. There-
fore 1151 txns remain unassigned (NAPP). Table 5 and gure 7 provide
is found that the most frequent use cases are Arbitrage (43.21%) and
error because the initial purpose of said txns could not be determined.
All these txns were observed on Uniswap. Being aware that Uniswap only
have been requested for Flash swaps with the purpose of dierent arbi-
trage strategies, it seems reasonable that these txns may have followed a
swaps only make up a share of under 1% of all txn applications. There are
trading purpose or not. bZx and ash minting were excluded here since
they are not representative for the analysis of the applications. Therefore
the data set for the following analysis reduces to 6812 txns.
application txns %
Total 6812
42
3000
2500
2000
txns
1500
1000
500
0
NAPP Arbitrage Collateral_swap Wash_trading CCDP No_application
application
43
Table 6: Distribution of subcategories over protocols
6812
34.72% of all txns and almost 70% of txns on Aave. As said before,
Aave is mainly used for CCDP because Desaver is making use of Aave
Flash Loans. Nearly all other identied txns on Aave are initiated by
and potential hammer bots, making up almost 65% of the protocol usage
and one fourth of all txns. Further, a lot of Arbitrage swaps (12.43%)
can be observed. The split up in usage between Aave and dYdX may be
explained by the dierence in fees for taking up Flash Loans. When exe-
fee for keeping collaterals from being liquidated. This seems also to be
44
true for Collateral swaps whose only being executed using Aave as well.
Uniswap show high share of 45.72% of failed txns. Table 7 shows that
most errors have been caused by a revert. It remains yet unclear if the
errDescription txns %
Total 326
45
2000
1500
txns
1000
500
nt ge Ba ror
Ar ollat rag bot
din _a n
Ar mm PP
ge sw o
No ge_s t
pp p
as bi uid 0
CC g_po tack
Ar efis al
Ar itra ver
Ar on r
Ar itrag ract
ge Y
p
o
d_ rbc ce
ra al_ da
ra HX
tra ge tio
_a wa
om
W Ar _Liq ap_
_D nti
ra _b
a A
h_ tra a
t
bit e_
t
bit ge
DP te
_c
b
ge
ra
bit
Ar
Ar
subcategory
January. The only ones occurring are on dYdX. It is assumed that these
were not carried out with the intention of initiating a ashloan, as the
concept of Flash Loans was not known at that time, but it is worth not-
ing that it was already possible to borrow and repay the same amount
within one txn on dYdX. Txns on February 2020 consist of a large share
txns are noticeable high for following dates: On March 12 2020, the so
24 hours (PULSE, 2020), leading to black friday one day later. Many
46
bitrage_hammerbots). A comparable price drop happened on May 10
(−10.38%)(Cointelegraph, 2020).
Arbitrage_hammerbot
Arbitrage_dao
800
Collateral_swap_0
Arbitrage_liquidation
Arbitrage_attack
700 NAPP
Wash_trading_potential
CCDP_Defisaver
600 Arbitrage_bot
Arbitrage_swap
No_app_error
500 Arb_Balancer
Arbitrage_Arbcontract
txns
Identified_Arbitrage_HXY
400 Arbitrage_comp
300
200
100
0
Dec-19 Jan-20 Feb-20 Mar-20 Apr-20 May-20 Jun-20 Jul-20
time
txns date
Table 8 shows the three most frequent occurrences of CCDP txns per
day. It is noticeable that the presented txns happen on dates when great
for a general relation between the price of ETH and the number of CCDP
txns could be found. Figure 10 shows the relationship between the price
47
of ETH (taken from investing.com (2020)) and observed CCDP txns by a
linear regression line on a 95% condence interval. The light blue bands
around the line represent the standard error of the regression line. It
illustrates that CCDP txns can not be observed relatively often when
between the price of ETH and the usage of CCDP, but standard errors
are wider spread for high occurrences. Three points on the left-hand side
stick out the most (marked in red) which are related to the three dates
line on the left, which is partly visible in the increase in standard errors.
48
occurrence of price drops could be determined, it seems reasonable to say
that specic dates of price drops caused users to try to save collaterals
from getting liquidated. The share of nearly 70% of all txns by CCDP
exclusively been executed on dYdX from April 1, 2020 (with one excep-
tion on April 24, 2020). Figure 11 shows this change by displaying the
The large arbitrage bot txns in April of about 79% on dYdX explains the
relatively high increase in txn observed on dYdX in gure 6.
140
Aave
dYdX
120
100
80
txns
60
40
20
0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/0 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/ 0
/0 0
20
18 03/2
19 03/2
20 03/2
21 03/2
22 03/2
23 03/2
24 03/2
25 03/2
26 03/2
27 03/2
28 03/2
29 03/2
30 03/2
31 03/2
01 03/2
02 04/2
03 04/2
04 4/2
05 04/2
06 04/2
07 04/2
08 04/2
09 04/2
10 04/2
11 04/2
12 04/2
13 04/2
14 04/2
15 04/2
16 04/2
17 04/2
18 04/2
19 04/2
20 04/2
21 04/2
22 04/2
23 04/2
24 04/2
26 04/2
27 04/2
28 04/2
29 04/2
4/
/
17
time
49
A noticeable large amount of potential hammer bot txns happens in June
2020. Table 9 presents the ve most observations per day of potential
hammer bot txns. It shows a tight concentration of txns in the time be-
tween June 22 and June 27. Despite the observation of frequent common
purpose the transaction serves, but it seems quite possible that by con-
suming node resources they are doing preparation for further arbitrage
txns date
Aave Table 10 shows the distribution over tokens of Aave Flash Loans,
the number of txns a Flash Loan in a specic token was taken out, the
percentage share over all txns and the average amount of one Flash Loan
of a token. Again it must be noted that the conversion rate of the tokens
DAI (55.10%), ETH (34.61%) and USDC (6.89%) are most frequently
used.
50
Table 10: Flash Loan amounts and distribution of tokens on Aave
Total 3412
Loans. ETH (42.24%), DAI (36.70%) and USDC (21.06%) are exclu-
sively used. Without taking into account USD values of the observed
token transfers, it can already be observed that dYdX volumes are well
above those on Aave. DAI Flash Loans on dYdX are about 30%, ETH
about 17220% and USDC about 756% above Flash Loans on Aave. Al-
though there are less Flash Loans taken out on dYdX, the average amount
count that dYdX is mainly used for arbitrage purposes and Aave for
CCDP.
Total 2687
FlashSwaps. HEX (33.52%) and WETH (6.45%) are used the most.
51
Table 12: Flash Loan amounts and distribution of tokens on Uniswap
iserr 0 0.00 0 0
HEX 239 33.52 12520186.5674295 52385.7178553535
WETH 46 6.45 274.629507614833 5.97020668727898
SLP 16 2.24 25048 1565.5
UBT 8 1.12 5762.74387153 720.34298394125
DAI 7 0.98 5000.00102243845 714.28586034835
BAT 5 0.70 33944.8159269802 6788.96318539603
COMP 5 0.70 1053.171 210.6342
ISLA 4 0.56 1047.76218132451 261.940545331128
XIO 4 0.56 16980.0176925845 4245.00442314613
KNC 3 0.42 2144.47440080784 714.82480026928
SNX 3 0.42 1529.51386040405 509.837953468017
AMPL 2 0.28 4645.82576914 2322.91288457
AUC 2 0.28 1866.2566711331 933.128335566552
BUIDL 2 0.28 406.306027279666 203.153013639833
CEL 2 0.28 555.8335 277.91675
DATA 2 0.28 13212.3511596386 6606.1755798193
ESH 2 0.28 330.044992105303 165.022496052652
JRT 2 0.28 5397.17218807722 2698.58609403861
LINK 2 0.28 747.11708571948 373.55854285974
MKR 2 0.28 5.76443003453046 2.88221501726523
NEXO 2 0.28 1998.8867129342 999.443356467098
SHIP 2 0.28 5831.73432078942 2915.86716039471
USDC 2 0.28 14871.492006 7435.746003
ANT 1 0.14 403.465023090514 403.465023090514
BAND 1 0.14 98.6562935008362 98.6562935008362
BLT 1 0.14 1612.19043858256 1612.19043858256
BNT 1 0.14 224.655563758628 224.655563758628
DONUT 1 0.14 3639.0268454507 3639.0268454507
DZAR 1 0.14 20522.392116 20522.392116
GRID 1 0.14 175.504960223652 175.504960223652
GST2 1 0.14 8.61 8.61
LRC 1 0.14 363.717615226304 363.717615226304
MCX 1 0.14 7941.32268774983 7941.32268774983
MINDS 1 0.14 106.324926180489 106.324926180489
OXT 1 0.14 301.403861505878 301.403861505878
QNT 1 0.14 2.8749153140519 2.8749153140519
REN 1 0.14 1976.90332630488 1976.90332630488
RLC 1 0.14 607.287036635 607.287036635
RPL 1 0.14 894.24341207903 894.24341207903
STAC 1 0.14 57267.4033322954 57267.4033322954
STAKE 1 0.14 2.37401091799079 2.37401091799079
UP 1 0.14 5822.64377510077 5822.64377510077
VXV 1 0.14 38.5603547551341 38.5603547551341
WBTC 1 0.14 0.23748504 0.23748504
ZRX 1 0.14 146.130895378452 146.130895378452
cDAI 1 0.14 2751.0697203 2751.0697203
Total 3412
52
all (iserr). The many dierent tokens is made up by the fact that
FlashSwaps allow the swapping of any token pair available. This makes
of certain tokens. The stated amounts from the token which was given
to the user in a txn has been used, not the token which was paid back.
showed hardly any relevant results for the task of this study. Around 18%
of txns failed (4 out of gas and 4 reverted). A sum of 11.300442018246
fmETH and 11.122 fWETH were used in txns. Only one txn showed
is because the concept is rarely used and the present txns seem to have
34
been initiated for test and proof-of-concept purposes only . The conclu-
sion is based on the fact that almost no transfers other than the minting
itself can be observed and the amounts are very low. Although there
are concepts in the making which try to use the concept, such as ash-
35
mint.app for the easy use of ashminting , a new token ADEX with
36
inherent ash minting feature or a request to make DAI on Maker-
37
DAO ash mintable , these concepts do not show observable data for
over all and over specic protocols and applications. From the previous
share of 91.88% of all tokens used. As a result, only historical prices for
this tokens were acquired since the expense of collecting prices of other
Table 14 and gure 12 show the value of Flash Loans taken out per
53
month in mio USD. After relatively low volumes in December 2019 until
February 2020, volumes raise quickly im March when Flash Loans be-
came more popular and Black Thursday and Friday made it necessary
for users to save collaterals through Desaver. After relatively low vol-
umes compared to the following months, June and July show high USD
Dec-19 0.060188488682491
Jan-20 0.018009891791302
Feb-20 9.99398983251672
Mar-20 41.8248923026221
Apr-20 4.94490782522818
May-20 9.1571141102114
Jun-20 510.02652879264
Jul-20 384.753773424701
Total 960.779404668394
54
500
400
value USD in mio
300
200
100
0
Dec-19 Jan-20 Feb-20 Mar-20 Apr-20 May-20 Jun-20 Jul-20
time
protocols by month. It is quite clear that dYdX shows by far the most
at in comparison. It should be noted that the results for Uniswap are
not very meaningful as the available USD values of the tokens are not
55
protocol
3500000 dYdX
Aave
3000000 Uniswap
2500000
value USD
2000000
1500000
1000000
500000
0
Dec-19 Jan-20 Feb-20 Mar-20 Apr-20 May-20 Jun-20 Jul-20
time
Table 14 shows the aggregated Flash Loan values in USD on dYdX and
tion, the results appear to be consistent. Since dYdX is mainly used for
dydx 927,014,127.795046
aave 33,745,408.0583357
total 960,759,535.853382
The volume in mio USD of Flash Loans taken out for a specic appli-
accounts for the majority of observed USD values. Another large part is
56
made up of undened applications. Potential washtrading txns, CCDP
and collateral swap, on the other hand, do not show high values.
400
USD value in mio
300
200
100
ing
PP
ge
DP
wa
NA
ra
CC
ad
l_s
bit
tr
ra
Ar
h_
te
as
lla
W
Co
subcategory
The volume in USD of Flash Loans taken out for a specic applications
hammer bots. The relatively high proportion of the latter might be due
to the very large number. Surprisingly, arbitrage bots do not account for
ETH in the data set) worth more than 42 million USD was borrowed on
38
dYdX in a Flash Loan . This is also true for potential wash trading txns
where a few outliers tend to drive up the bar (for the txn hashes see data
38 txn:
0x63a99ac8b812ee1c80bf9f0ca5809a48ca54e88fc3f38b1cca94bec99536
57
set "Exchange_rates.csv"). Also noticeable are arbitrage attacks which
only show four txns but an average of 18, 291, 253.58 USD per txn. The
same seems to be true for Arb_Balancer, where the average value per
350
300
USD value in mio
250
200
150
100
50
0
Ar mm PP
DP ote k
Ar efis ial
Ar co r
Ar ollat trag bot
Ar age l_sw ao
ra iqu p_0
as b ui n
din e_a n
Ar itra aver
bit e t
ge XY
p
g o
Ar itrag trac
d_ rb nce
CC g_p ttac
W Ar _liq atio
tra g tio
om
ra _b
_D nt
ha NA
r a d
ra _H
C bi er
bit _L a
bit er e_
h_ itra da
bit ge
ifie _A la
_c
b n
ge id
b
_
A
ge
ra
bit
b
Ar
Ar
subcategory
58
5 Conclusion
The aim of this paper was to explain the novel concept of Flash Loans
data set has been created and a descriptive analysis shows its content
plications occupy only a small part. Potential wash trading txns make
on-chain wash trading is easy to identify and known DEX would not be
the txns must remain unanswered here. Due to the strong involvement
arbitrage swaps and HXY arbitrage strategies. Concerning the use of the
dYdX. Uniswap shows little share, probably due to the short availability
of Flash Loans taken out in token and the respective USD amount. It
became clear that dYdX shows by far the highest amounts. Aave shows
only a small share and Uniswap showed too much dierent coins for an
it remains to be seen how Flash Loans on bZx will develop once the
59
it could be observed in arbitrage strategies (Arbitrage_HXY and Arbi-
It has been made clear that Flash Loans oer a wide range of possible
use cased and that the usage in sheer number of txns is not very high yet.
Loans in USD of 960.78 mio and the average volume per Flash Loan of
around USD 141, 042 show that users make use of high values for their
purposes.
concepts on the presented platforms and analyzes for this purpose the
for the individual use cases. Furthermore, the present work is lacking
the time following the txn should be checked to examine if there was an
eect on trading volumes. The paper presents the current state of the art
Around the concept of Flash Loans the emergence of new platforms like
39
the user friendly use of ash minting , new token with inherent ash
40 41
minting feature or aggregation of dierent Flash Loan protocols can
It must also be noted that a large part of the time and eort involved
in the present work was caused by data acquisition. Especially for the
39 https://ashmint.app
40 https://www.adex.network/blog/token-upgrade-de-features
41 https://www.kollateral.co
60
identication of Flash Loans on dYdX, a time consuming data cleansing
the ndings of this work, data should be relatively much easier to obtain
useful to nd out the reasons for the failure of so many txns on Uniswap
61
References
Aave (2020a), `Aave Protocol Whitepaper V1.0', https://whitepaper.
io/document/533/aave-whitepaper. Accessed: 08.05.2020.
https://docs.
Aave developers (2020a), `Performing a Flash loan',
aave.com/developers/tutorials/performing-a-flash-loan. Ac-
cessed: 08.05.2020.
cessed: 08.05.2020.
i
https://bzx.network/pdfs/CertiK%
CertiK (2020a), `Audit Report',
Certik (2020b), `Little Pains, Great Gains: How the Balancer DeFi
little-pains-great-gains-balancer-defi-contract-was-drained.
Accessed: 25.07.2020.
tocol https://coinmarketcal.com/en/event/
Relaunch',
currencies/multi-collateral-dai/historical-data/?start=
20190820&end=20200820. Accessed: 20.08.2020.
currencies/ethereum/historical-data/?start=20190820&end=
20200820. Accessed: 20.08.2020.
Cong, L. W., Li, X., Tang, K. and Yang, Y. (2019), `Crypto Wash Trad-
ii
introducing-1-transaction-cdp-closing-powered-by-flash-
loans-8a83456226f4
Accessed: 20.06.2020.
0.3.0-alpha.14', https://readthedocs.org/projects/py-evm/
downloads/pdf/latest. Accessed: 08.05.2020.
https://etherscan.
tract addresses with an OpenSource license)',
io/exportData?type=open-source-contract-codes. Accessed:
01.08.2020.
16.07.2020.
16.07.2020.
https://medium.
Frangella, E. (2020), `Flash Loans, one month in',
com/aave/flash-loans-one-month-in-73bde954a239. Accessed:
14.08.2020.
https://fravoll.github.
fravoll (2019), `Checks Eects Interactions',
io/solidity-patterns/checks_effects_interactions.html. Ac-
cessed: 21.07.2020.
iii
Gudgeon, L., Perez, D., Harz, D., Gervais, A., Livshits, B. et al. (2020),
is bZx?', https://decrypt.co/resources/
bzx-ethereum-defi-decentralized-finance-explained-guide.
Accessed: 20.07.2020.
| Arbitrage https://medium.com/@bneiluj/
DAO',
https://www.theblockcrypto.com/linked/56134/
of ETH lost' ',
defi-lending-protocol-bzx-exploited-a-portion-of-eth-lost.
Accessed: 14.08.2020.
ketProtocol', https://compound.finance/documents/Compound.
Whitepaper.pdf. Accessed: 21.07.2020.
iv
https:
Marc Zeller for Aave Blog (2020), `Sneak peek at Flash Loans',
//medium.com/aave/sneak-peek-at-flash-loans-f2b28a394d62.
Accessed: 08.05.2020.
Nikolaev, I. (2019), `HEX HEX und die Kohle ist weg? Was
https://cryptomonday.de/
steckt hinter dem besseren Bitcoin?'.
hex-hex-und-die-kohle-ist-weg-was-steckt-hinter-dem-
besseren-bitcoin
Accessed: 16.07.2020.
bzx-hack-full-disclosure-with-detailed-profit-analysis-
e6b1fa9b18fc
Accessed: 16.07.2020.
https://
PULSE, D. (2020), `DeFi Status Report Post-Black Thursday',
defipulse.com/blog/defi-status-report-black-thursday. Ac-
cessed: 14.08.2020.
Qin, K., Zhou, L., Livshits, B., Gervais, A. et al. (2020), `Attacking the
DeFi Ecosystem with Flash Loans for Fun and Prot', arXiv e-prints
p. arXiv:2003.03810.
v
Synthetix (2020), `Litepaper', https://docs.synthetix.io/
litepaper. Accessed: 12.08.2020.
guy-flashloan-borrows-30-million-eth-for-just-100. Ac-
cessed: 25.07.2020.
https://uniswap.org/docs/
Uniswap (2020c), `How Uniswap works',
https://uniswap.org/docs/v2/smart-contract-integration/
using-flash-swaps. Accessed: 16.07.2020.
vi
Uniswap (2020e), `Smart Contract Integration - Providing Liquidity',
https://uniswap.org/docs/v2/smart-contract-integration/
providing-liquidity. Accessed: 16.07.2020.
vii