100% found this document useful (1 vote)
282 views15 pages

Flashloans

The document discusses flash loan-based wash trading in decentralized finance. Flash loans allow borrowing virtual assets without collateral, which some abuse to simultaneously buy and sell the same cryptocurrency on an exchange to mislead the market, known as wash trading. The paper analyzes properties of flash loan-based wash trading and proposes a detection method, finding over 6,000 wash transactions. It also analyzes the relationship between wash trades and price/volume fluctuations and compares costs of traditional vs. flash loan-based wash trading.

Uploaded by

Perpetual God
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
282 views15 pages

Flashloans

The document discusses flash loan-based wash trading in decentralized finance. Flash loans allow borrowing virtual assets without collateral, which some abuse to simultaneously buy and sell the same cryptocurrency on an exchange to mislead the market, known as wash trading. The paper analyzes properties of flash loan-based wash trading and proposes a detection method, finding over 6,000 wash transactions. It also analyzes the relationship between wash trades and price/volume fluctuations and compares costs of traditional vs. flash loan-based wash trading.

Uploaded by

Perpetual God
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Understanding Flash-Loan-based Wash Trading

Rundong Gan, Le Wang, Xiangyu Ruan, Xiaodong Lin∗


School of Computer Science, University of Guelph
Guelph, Canada
{rgan,lwang20,ruanx,xlin08}@uoguelph.ca

ABSTRACT KEYWORDS
Flash Loan, a popular lending service in the decentralized finance Wash Trading, Flash Loan, Market Manipulation, DeFi Security
(DeFi) ecosystem, allows users to borrow a large number of virtual ACM Reference Format:
assets without any collateral. It can be leveraged to support many fi- Rundong Gan, Le Wang, Xiangyu Ruan, Xiaodong Lin. 2022. Understanding
nancial activities (such as arbitrage, collateral swap, self-liquidation, Flash-Loan-based Wash Trading. In 4th ACM Conference on Advances in
etc. ), but unfortunately, it is often abused for malicious intent. One Financial Technologies (AFT ’22), September 19–21, 2022, San Francisco, CA,
example of abusing flash loan servicing is to simultaneously sell USA. ACM, New York, NY, USA, 15 pages. https://doi.org/10.1145/3558535.
and buy the same cryptocurrency on the same exchange to mislead 3559793
the market, aka wash trading. It can manipulate the cryptocurrency
market at a very low cost (anecdotally average around 0.033 ETH 1 INTRODUCTION
gas fee for each transaction on Ethereum mainnet), thereby dra-

matically damaging the stability and fairness of the market. More
seriously, attackers can amplify the market impact by borrowing 







more assets from Flash Loan platforms. Until now, there has been lit- 
 











 

tle attention paid to Flash-Loan-based wash trading, but meanwhile, 
 

we have started to witness significant wash trading activities using



Flash Loan. In this research, we analyze the properties of Flash-  
      

Loan-based wash trading in detail and propose a heuristic-based


detection method. The real-world Flash Loan transaction data from
Ethereum is used to verify our proposed detection method and more Figure 1: The process of Flash-Loan-based wash trading.
than 6,000 wash transactions were found. Moreover, we analyze
the relationship between wash transactions and fluctuations in the
price and volume of targeted assets. Finally, we evaluate the cost 1.1 Decentralized Finance and Manipulation
difference between traditional wash trading and Flash-Loan-based Decentralized Finance (DeFi)[20] is a new developing area at the
wash trading to reveal the attackers’ motivation. intersection of peer-to-peer networks, cryptography, digital assets,
Our work reveals that some metrics, like trading volume, widely and financial services. Different from Centralized Finance (CeFi),
used by investors when buying assets in traditional finance, be- DeFi keeps the business reputation with smart contracts and DeFi
come less believable in today’s DeFi market largely since there exist protocols on blockchains instead of central institutions (e.g., banks
low-risk ways of amplifying the effects of market manipulation or centralized exchanges) or a middleman. The revolutionary de-
activities. This research has shed light on the urgency of regulat- sign has attracted more and more investors and developers, and
ing the emerging DeFi market and provides insight into how to over 17,000 DeFi protocols and applications have been deployed
formulate more effective regulations for the DeFi market. on blockchains [7]. According to DeFi Plus’ report [10], the total
amount of value locked (TVL) inside DeFi protocols has reached
CCS CONCEPTS $110 billion in November 2021.
• Security and privacy → Economics of security and privacy; However, it is no secret that the DeFi system on permission-
Distributed systems security. less blockchains is a wild ‘dark forest’ [13]. There are plenty of
market manipulators who use artificial actions to influence the
price of financial products [11]. In CeFi, manipulators enter crafted
∗ Corresponding author buy/sell orders to control the stock price. In DeFi, cryptocurrencies
can be manipulated in the same way. Compared with the former,
DeFi market manipulation is more complex and diverse, and the
Permission to make digital or hard copies of all or part of this work for personal or manipulators can be traders, market makers, or exchange man-
classroom use is granted without fee provided that copies are not made or distributed
for profit or commercial advantage and that copies bear this notice and the full citation agers. The most popular manipulation methods in DeFi include
on the first page. Copyrights for components of this work owned by others than the Pump&Dump[22], Wash Trading[16], Sandwich Attack[25] and
author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or
republish, to post on servers or to redistribute to lists, requires prior specific permission
Oracle manipulation [12].
and/or a fee. Request permissions from [email protected].
AFT ’22, September 19–21, 2022, San Francisco, CA, USA 1.2 Flash-Loan-based Wash Trading
© 2022 Copyright held by the owner/author(s). Publication rights licensed to ACM.
ACM ISBN 978-1-4503-9861-9/22/09. . . $15.00 Some DeFi manipulations often require large amounts of assets
https://doi.org/10.1145/3558535.3559793 as input, such as Oracle manipulation. If an attacker uses his or

74
AFT ’22, September 19–21, 2022, San Francisco, CA, USA Rundong Gan and Le Wang et al.

Detection Financial Analysis


Data Collection
Graph Construction

Application Addresses
Validation & Analysis
Position Calculation
Transaction Information Market Impact
Event Logs Edge Deletion
Market Information Detection Results
Judgement Cost Analysis

Figure 2: The workflow of our paper.

her own assets for attacking, there will be two problems: 1) the 1.3 Motivation of this Paper
required input is large, so the attacker needs to have enough cryp- Flash Loan is an emerging financial technology in DeFi, but its
tocurrencies; and 2) if the attack transaction fails, the attacker may regulation is lacking. Our findings enable a better understanding
lose all assets. Thus, there are high risks associated with these of how Flash Loan is being abused for wash trading and provide
manipulations from the attackers’ perspective. potential avenues for regulators to disrupt these illegal activities.
However, there is an innovative and popular service called Flash
Loan [19] in DeFi systems, which clears the way for DeFi attacks.
1.4 Our Contributions
Flash Loan does not exist in traditional finance and allows users to
borrow a large amount of cryptocurrency in the same transaction In previous studies, most of the research [2, 3, 8] focuses on tradi-
without any collateral. Flash Loan offers users a fast way to get tional wash trading which is frequent in centralized exchanges. To
massive investments to participate in various financial activities, the best of our knowledge, no detection method and comprehensive
which could improve the market’s liquidity. To some extent, Flash analysis have been proposed for Flash-Loan-based wash trading,
Loan can increase the efficiency of the DeFi market and maintain the except for a small case being briefly mentioned [14]. In this paper,
balance of the entire ecosystem[14, 19]. Moreover, the cost of Flash our contributions can be summarized as follows:
Loan is low: borrowers just need to repay small gas fees (average • This paper is the first systematic study to understand Flash-
0.061 ETH on Ethereum mainnet) and loan interest (usually less Loan-based wash trading. In previous studies, wash trading
than 0.3%). In order to attract users, some flash loan lenders (e.g., using Flash Loan is only a possible attack and there is not
dYdX ) even charge only 1 W ei ( 1W ei = 10−18 ET H ) interest. enough sample evidence and principle analysis to prove the
Unfortunately, for tricky attackers, Flash Loan is like an attack possibility of such attacks. Our work confirms the possibility
booster, which finances illegal activities, amplifies the impact of and widespread existence of such attacks.
attacks, and maximizes attack profits. Attackers can destroy a fi- • A heuristic-based algorithm is proposed to detect wash trans-
nancial system at a low cost without any financial risk. Many Flash- actions using Flash Loan. Flash-Loan-based wash trading
Loan-based attacks have been reported, such as Oracle manipula- is only briefly mentioned in previous papers, and no detec-
tion, Pump&Arbitrage, and Reentrancy[4]. tion scheme has been proposed yet. We design a detection
Wash trading is one of Flash Loan’s widespread exploits but scheme based on detailed analysis of Flash Loan and the final
has been paid little attention so far. In wash transactions, trading results confirm the effectiveness of our method.
volume indicating one asset’s popularity is usually the major object • We analyze the market impact and attack cost to reveal
to be manipulated. Manipulators use a series of buy/sell actions to manipulators’ motivations. Existing research mainly focuses
increase the transaction volume for giving a false impression of on the detection of abnormal behaviours, but ignores the
high trading volume on the market [3]. In traditional wash trading, process of wash trading, for example, the market impact and
attackers may only have a small amount of start-up capital. To cost of wash transactions. Our analysis shows that Flash-
greatly increase the trading volume, the limited money will be Loan-based wash trading can amplify the market impact
reused many times and these wash trades form a closed cycle [8]. compared to traditional wash trading.
However, in Flash-Loan-based wash trading ( as shown in Figure 1),
The whole process of this paper is shown in Figure 2. Firstly, we
attackers can borrow large assets from Flash Loan applications and
filter trading data related to lending applications to get Flash Loan
use the loan to amplify the effect of manipulation. After the wash,
transactions. Then, we build a graph for each loan transaction based
all assets will be returned to the Flash Loan application. Compared
on asset transfers to detect wash transactions. Thirdly, we validate
with those traditional volume manipulations, Flash-Loan-based
the detection results and analyze the basic characteristics of these
wash trading has a bigger impact on the stability and fairness of
wash transactions. In addition, we conduct a financial analysis to
the cryptocurrency market.
determine the impact and cost of such attacks.

75
Understanding Flash-Loan-based Wash Trading AFT ’22, September 19–21, 2022, San Francisco, CA, USA

2 FLASH-LOAN-BASED WASH TRADING Flash Loan is non-collateralized, and the smart contract will guar-
antee that the lender is paid back. Therefore, the lender can issue
2.1 Flash Loan
credit without upfront collateral from the borrower. 2) Loan Size.
Borrowers can lend out all the funds in the capital pool which is
governed by smart contracts. The lending of largest Flash Loan
transaction in 2021 exceeds $20 billion1 . 3) Liquidation Risk. In
Lending Application Trader
T d Other Applications traditional lending, if the market price of collateral changes dramat-
ically, the borrower may be exposed to the risk of liquidation with
 Call Loan Function
Action Sequence the loss of collateral. For Flash Loan borrowers, they have no such
 Provide Flash Loan Swaping
risk because collateral is not required in their transactions. 4) Loan
Borrowing
Cycle. In traditional lending, the loan ends when all borrowings
 Interact with other Applications

Minting
are repaid or collateral is forced to be liquidated. For Flash loan, the
 Return the Loan Burning
successful validation of this transaction including borrowing and
……
repaying means the end of the lending.
 Repay the Loan and Interest

2.2 Wash Trading


Figure 3: The workflow of a Flash Loan transaction. Wash trading is a popular market manipulation method and it is de-
fined as “Entering into, or purporting to enter into, transactions to
give the appearance that purchases and sales have been made, with-
Flash Loan is a new form of uncollateralized lending which
out incurring market risk or changing the trader’s market position
is available to traders on some decentralized finance protocols
” [5] by the Commodity Futures Trading Commission (CFTC). From
based on blockchain networks (e.g., Ethereum). This type of loan
the definition, we can know that wash trading does not change
allows users to borrow unsecured loans from lenders without any
actors’ market positions (the number of assets held by a trader)
intermediaries. It gives users the ability to trade in ways that weren’t
after a series of selling/buying actions, so they do not incur any
possible before. Users can use Flash Loan to raise large amounts of
market risk. The trading volume of an asset indicates its popularity,
money in a short time for legal financial activities ( e.g., arbitrage,
and the purpose of wash trading is to manipulate trading volume
self-liquidation, and collateral swap[19]). More importantly, while
through selling/buying an asset[3]. By wash trading, misleading
Flash Loan helps traders make a profit, those traders don’t take any
information will be fed to the market. When uninformed investors
capital risk.
see false market information, they will make wrong judgments
Workflow. Figure 3 illustrates the workflow of a standard Flash
and buy financial products that seem popular. Finally, investors’
Loan transaction, which consists of 5 stages: loan function call,
misguided buying leads to price spikes of target products.
loan providing, interaction with other applications, return of funds,
and loan repayment. Firstly, the trader uses smart contracts to call
relevant functions of the lending application and sets the type and 2.3 Flash-Loan-based Wash Trading
number of cryptocurrencies to be lent (–). When there are enough In the exchange of CeFi, system administrators can easily and
assets, the lending application will transfer the requested assets freely create fake transactions in the backend, e.g., Mt. Gox market
to the trader (—). The trader uses borrowed assets to interact with manipulation[6]. In DeFi, due to the immutability and transparency
other applications and performs a series of actions, such as swap- of blockchains, wash traders need to hold and use real assets for
ping, borrowing, minting, burning, etc (˜). After using the loan, selling and buying to improve the trading volume. When the target
the trader gets the money back (™). Due to flash loan rules, the trading volume is too large, it may be difficult for manipulators to
trader must repay the loan with extra interest in the same transac- raise enough start-up capital and they can only rely on multiple
tion, then smart contracts of the lending application will check the closed capital cycles [16]. Flash Loan can help attackers to remove
amount returned (š). If non-sufficient assets including the loan and this “obstacle” and they just need to pay loan interest, trading fees,
interest are returned by the trader, the entire transaction will fail and gas fees without any risks. When an attacker borrows an asset,
and the blockchain state will be rolled back. Note that all stages the asset will be used to perform some actions that increase trading
are finished in one transaction. Because of the atomicity of DeFi, volume but do not change the position of any asset. After wash
actions in Figure 3 can be combined into financial behaviours (e.g., trading actions are completed, the asset will be returned to the loan
arbitrage) with high-level semantics. provider. It should be noted that the target of flash loan-based wash
Cost. In this paper, we divide the cost of a Flash Loan transaction trading can not only be assets, but also some DeFi applications
into three parts: 1) Gas fee. In Ethereum-like systems, users need which also need fake transactions to lure investors.
to pay gas fees to miners to have their transactions included in the Figure 4 shows a Flash-Loan-based wash trading2 on Ethereum.
block. 2) Loan interest. In stage š, loan services usually require Firstly, the attacker takes a 44.74 WETH (wrapped ETH) loan from a
users to pay a small amount of interest. 3) Trading fee. In stage
˜, users need to pay fees for these financial services. We treat this
1 Cream Finance Attack, https://etherscan.io/tx/0x0fe2542079644e107cbf13690eb9c2c6
part of the cost as trading fees to distinguish loan interest.
5963ccb79089ff96bfaf8dced2331c92
Differences. As a novel DeFi application, Flash Loan has many 2 An example of Flash-Loan-based wash trading, https://etherscan.io/tx/0xd367e56c18
properties that are different from traditional lending. 1) Collateral. 3b727ef1c0670213ccd62a2d2b0275459d0ff5e7dd9d320c0a8e30

76
AFT ’22, September 19–21, 2022, San Francisco, CA, USA Rundong Gan and Le Wang et al.

Table 1: Main Differences between traditional wash trading and Flash-Loan-based wash trading on blockchains

Properties Traditional Wash Trading Flash-Loan-based Wash Trading

Attack Form Multiple transactions form a closed capital cycle to Due to the limitation of Flash Loan, each transaction has a
keep the net position unchanged. full capital circle to keep the net position unchanged.

Wash Size Depends on initial funds. If the attacker has enough funds to pay gas fees and trading
fees, there is no size limit.

Capital Risk 1) If the time interval is too long, the value of hold- Failed transactions will only result in loss of gas fees.
ing assets may decrease; 2) wrong operations on
the blockchain can lead to the loss of all assets.

Attack Cost Gas fees and trading fees. Gas fees, trading fees, and loan interest.

From dYdX (Flash Loan Provider) To 0x08cb95bb8e2afa7013342a7dcbaab8e1b57f2a77 For 44.7400 WETH Take Flash Loan from dYdX

From 0x08cb95bb8e2afa7013342a7dcbaab8e1b57f2a77 To Uniswap V2 : ZCX 3 (Exchange ) For 44.7400 WETH


Swap WETH for ZCX using
Asset transfer order

Uniswap V2 pool
From Uniswap V2 : ZCX 3 (Exchange) To 0x08cb95bb8e2afa7013342a7dcbaab8e1b57f2a77 For 46,646.5402 ZCX

From 0x08cb95bb8e2afa7013342a7dcbaab8e1b57f2a77 To Uniswap V2 : ZCX 3 (Exchange) For 46,436.7424 ZCX


Swap ZCX for WETH using
Uniswap V2 pool
From Uniswap V2 : ZCX 3 (Exchange) To 0x08cb95bb8e2afa7013342a7dcbaab8e1b57f2a77 For 44.3069 WETH

From 0x08cb95bb8e2afa7013342a7dcbaab8e1b57f2a77 To dYdX (Flash Loan Provider) For 44.7400 WETH Repay the loan to dYdX

Figure 4: Asset transfer in a wash trading transaction.

Flash Loan provider dYdX and the receiver address is 0x08cb95bb8e- reasons to confirm that these transactions are only possible for
2afa7013342a7dcbaab8e1b57f2a77. Then, the borrowed ETH is trans- wash trading.
ferred to Uniswap V2: ZCX 3 (an exchange pool) for swapping Compared with traditional wash trading, Flash-Loan-based wash
and the attacker gets 46,646.5402 ZCX back. Thirdly, ZCX is ex- trading has the following characteristics: 1) Assets used for wash
changed back before the loan is repaid. In this transaction, ETH is trading are borrowed from Flash Loan providers and the loan needs
swapped in and out in the same pool and finally repaid to dYdX, to be repaid in the same transaction, so each transaction must have
so the positions of all assets hardly change. According to the Au- a full capital circle to keep the net position unchanged. 2) Attackers
tomated Market Maker(AMM) protocols [23] of decentralized ex- can borrow a large amount of money just by paying gas fees, trading
changes, it is impossible for the attacker to arbitrage in the same fees, and a small amount of loan interest, so the wash size can be
capital pool. On the contrary, the attacker needs to pay trading fees much larger than traditional wash trading. 3) When a wash trading
(rateswap × amountswap ) in each swapping, so the borrowed ETH transaction fails due to a mistake, the state of the blockchain will
changes from 44.74 ETH to 44.30 ETH. To make up the difference roll back, so the attacker only loses a small number of gas fees. For
for repaying, the attacker needs to transfer a small number of his manipulators, these characteristics can help them effectively reduce
assets ( 44.7400 ET H − 44.3069 ET H = 0.4331 ET H ). The attack cost costs and amplify the impact of wash trading. Table 1 shows the
is about 0.4471 ETH including 0.0140 ETH gas fee and 0.4331 ETH main differences between traditional wash trading and Flash-Loan-
trading fee when loan interest is just 1 Wei for dYdX. We treat this based wash trading on blockchains.
transaction as wash trading for three reasons: 1) The net position
of each participating address is almost unchanged. 2) A sequence of
actions costs high gas fees and trading fees but makes no financial 3 PRELIMINARIES
sense (e.g., arbitrage or asset swap). 3) There are dozens of similar 3.1 Attack Model
transactions related to the smart contracts. It is unreasonable for
We assume that there is a rational adversary A, who wants to
traders to repeatedly execute meaningless transactions at a high
achieve the ultimate volume goal Vдoal and mislead innocent traders
cost unless there is a special purpose. Therefore, we have enough
to invest some tokens or applications. A has a small amount of
start-up capital, which can only cover the basic loan interest, gas

77
Understanding Flash-Loan-based Wash Trading AFT ’22, September 19–21, 2022, San Francisco, CA, USA

 orrow   orrow   orrow 


 orrow 
  

Flash Flash Flash Flash
Loan Loan  Trader Loan  Trader Loan  Trader
 Trader
Provider Provider Provider Provider
 Repay   Repay   Repay 
 Repay 









 









 


 Swap 



  
for   Swap   Swap  

  Repay  
 Swap   Swap   for   for 
 and remove
  Swap   Repay 
for  for  collateral   Mortgage
for  and remove  and
collateral  borrow 

Lending Lending
Exchange 1 Exchange 2 Exchange Exchange
Exchange app app

(a) Wash Trading (b) Arbitrage (c) Self-liquidation (d) Collateral Swap

Figure 5: Common patterns of Flash Loan transactions

fees, and trading fees, but is not enough to manipulate the trading RQ1 How to detect Flash-Loan-based wash transactions?
volume and produce misleading information directly. However, due RQ2 What are the characteristics of these wash transactions?
to the openness of DeFi systems, A can use Flash Loan to complete RQ3 What impact does these transactions have on the market?
the manipulation. To avoid unnecessary costs including gas fees RQ4 Why do attackers choose Flash Loan for manipulation?
and trading fees, A will only perform actions related to wash trad-
ing. In our model, no matter what strategy A adopts, the victims 4 DETECTION SCHEME
V are always these innocent traders kept in the dark. This section targets RQ1.

3.2 Notation 4.1 Modeling Trade Graphs


We use the following notations to describe different concepts in In this paper, we construct a trade graph G(V , E,W ) for each Flash
DeFi transactions. Loan transaction, and construction rules are shown below.
Flash Loan transaction: T X i denotes a flash loan transaction. • Node. V is the set of blockchain addresses that have partici-
Application. app is the DeFi application traders interact with. pated in asset transfers. In a Flash Loan transaction, multiple
Address. address represents the blockchain address that partic- addresses are involved. We only care about financial activi-
ipates in the transfer of a transaction. ties in these transactions, so receiving and sending addresses
Asset and Transfer. asset is the cryptocurrency asset used as are taken into our consideration.
input for trading actions in a Flash Loan transaction. In a Flash • Edge. E is the set of asset transfers. Firstly, edges are di-
Loan transaction, assets are transferred between different addresses. rected, and the direction of each edge depends on the money
asset A asset B flow — from the sender to the receiver. Secondly, edges are
For example, a transfer path is address 0 → address 1 →
assetC heterogeneous because multiple assets may be transferred
address 2 → address 3 . For each transfer, the amount of the between two addresses.
input asset is amount. • Weight. W is the set of the transfer amount. The weight of
Action. action is the trading action which can be used to im- an edge is the transfer amount of one asset in this transaction.
plement high-semantic financial activities. An action consists of
multiple transfers. For example, a swap action can be represented as 4.2 Transaction Patterns of Flash Loan
asset A asset B
{ addresst r ader → addressexchanдe , addressexchanдe → Figure 5 lists several common patterns of Flash Loan transactions.
addresst r ader }. In DeFi systems, a transaction consists of multiple actions, and
Loan Interest. rateloan donates the loan rate. The total interest these actions are completed by different asset transfers [21]. These
paid by the trader is loan amount × rateloan . patterns are described as follows.
Gas Fee. We assume that the gas fee is the same when executing • Wash trading. Traders use the borrowed loan to sell and
the same type of action. Gas fees for Flash Loan and swap actions buy the same cryptocurrency on the same exchange to mis-
are дas f l ash_loan and дasswap respectively. Generally, the more lead the market (details can be reviewed in Section 2.3).
actions involved in a transaction, the more gas fees are required. • Arbitrage. A simplest Flash Loan arbitrage (as shown in
Trading Fee. ratet r adinд_f ee donates the trading fee rate. The Figure 5(b) ) usually has four actions: borrowing, first swap,
total trading fee paid by the trader is tradinд amount×ratet r adinд_f ee . second swap, and repayment. Two asset A transfers between
the loan provider and the trader represent borrowing and
3.3 Research Questions repayment respectively. The swap action is composed of
asset A asset B
Flash-Loan-based wash trading is an activity that does not exist in two transfers: trader → exchanдe and exchanдe →
traditional finance, so we conduct a qualitative study of this new trader . In the first transfer, the trader calls the smart contract
attack. Our study seeks to answer the following research questions. and transfers his assets to the exchange, then another type

78
AFT ’22, September 19–21, 2022, San Francisco, CA, USA Rundong Gan and Le Wang et al.

of asset is returned in the second transfer. By buying at a • Heuristic 2: Just like traditional wash trading, there is also
low price and selling at a high price in different exchanges, a closed transaction cycle. The funding for wash trading
the trader completes the financial activity of arbitrage. mainly comes from Flash Loan, and once the loan ends, all
• Self-liquidation. In the self-liquidation of Figure 5(c), the the assets will be returned with unchanged positions for
trader does not have enough assets to redeem the collateral each address. To maintain the unchanged position, there
from a collateral-based lending application. In order to avoid must be a closed capital cycle. Due to the limitation of Flash
the risk of being liquidated, the trader borrows a flash loan Loan, traders can only use the loan in the same transaction,
to pay the debt. After taking out the collateral, the trader so this circle only exists in one transaction rather than being
sells the collateral in exchange and repays the loan to the distributed among multiple transactions like traditional wash
provider. trading.
• Collateral swap. In the collateral swap of Figure 5(d), the • Heuristic 3: When an asset is exchanged, the asset will be
trader decides to change the collateral for more profit. When exchanged back in the same path before the loan ends. As
the trader has redeemed the collateral, he/her exchanges shown in Figure 5(a), when A swaps assets on the exchange,
a new asset and re-pledges the new asset into the lending there will be an opposite transaction to get the original as-
application. To repay the flash loan, the trader borrows one sets back with close volume. A chooses such a path for two
asset again from the lending application. reasons: 1) The way users influence prices is by sending
From the above transaction patterns, we can find that there is false information to the market, not by manipulating the
an asset return path in wash trading, and the type and quantity of exchange’s price formula. When traders swap large amounts
assets held by each address remain almost unchanged. For (b)(c)(d), of assets on AMM-based exchanges, there will be large slip-
there will always be some applications that have their net asset page [24] and traders may suffer asset losses, which will be
positions changed. This is because (b)(c)(d) have a practical financial acquired by arbitrageurs and sandwich attackers [25] later.
significance which is based on valid asset transfers. Therefore, for Therefore, A needs to exchange the asset back to maintain
any meaningful transaction, there will always be a net position the state of the exchange. 2) Trading volume in finance is
change. usually the sum of the quantities sold and bought, so a return
It should be noted that these figures have been simplified and path will double the volume of wash trading.
some special actions are not shown. For example, when a trader • Heuristic 4: In order to reduce costs, the manipulator will
provides liquidity for a DeFi application, some credential tokens only focus on actions related to wash trading. Although
will be created and transferred to the trader from zero address unrelated complex actions can be used to confuse investors,
3 (zero address assetcr→ ed e nt i al
trader , which is called minting). they also result in higher gas fees, additional trading fees,
When the trader removes liquidity from the DeFi application, these and unknown risks. We assume A is rational enough and
assetcr ed e nt i al he/she always achieves the wash goal with the least cost
tokens will be destroyed (trader → zero address, which and risk. In this paper, if a transaction increases the trading
is called burning). volume, but has real financial significance (no return path),
we do not treat it as wash trading.
4.3 Heuristic-based Detection Method
Some flash loan services (e.g., Flash Swaps[15]) allow users to
4.3.1 Analysis of Flash-Loan-based Wash Trading. repay the loan with another asset. When manipulators use such
In fact, all of the patterns in Figure 5 can increase the wash tar- services to complete their transactions, there will be real financial
get’s trading volume. The reason we treat Figure 5(a) as a wash significance and the state of the exchange will change. To maintain
trading transaction is that there is a very small change in the net the state, they need to construct two opposite transactions, which
position of assets for each address and the trader does not take any will increase the cost and risk. Therefore, in this paper, we assume
risk, such as a drop in the price. In other words, such transactions that manipulators borrow and repay the same asset to reduce risks
do not make any real financial sense. This fits the description of and costs.
wash trading by Yi Cao et al.[3]: wash trading is merely fraudu-
lent activities rather than true trading actions, so each participated 4.3.2 Algorithm Description.
trader tends to maintain his own positions unchanged or minimize
the unnecessary financial loss. At the same time, gas fees for trans- Our detection method is shown in Figure 6. Asset transfer records
actions in Ethereum are expensive, and no one wants to execute between different addresses are used as input data. There are four
such a meaningless transaction except for price manipulation. main steps for detection: graph construction, position calculation,
According to the characteristics of Flash Loan and wash trading, edge deletion, and judgment. They are described as follows:
we apply the following heuristics to identify wash transactions: Graph Construction. Let’s assume there is a Flash Loan trans-
• Heuristic 1: When A uses Flash Loan services for wash action T X i that includes some actions, and these actions involve
trading, his/her own limited funds are mainly used for gas different addresses and transfers. We have already known that Flash-
fees and trading fees, rather than directly participating in Loan-based wash trading only exists in one transaction, so we build
the wash. The assets used for wash trading mainly come a graph G i (V , E,W ) for T X i to detect wash trading. One edge can be
from Flash Loan. represented as (addresssender , addressr eceiver , asset_type, amount),
where addresssender is the sender, addressr eceiver is the receiver,
3 zero address, 0x0000000000000000000000000000000000000000 asset_type is the type of asset transferred, and amount is the weight

79
Understanding Flash-Loan-based Wash Trading AFT ’22, September 19–21, 2022, San Francisco, CA, USA

Input data Graph Construction Position Calculation Edge Deletion Judgement


  
Flash Flash Flash
Loan  Trader Loan  Trader Loan  Trader
Provider Provider Provider


   























Delete this type of edge when
the condition is met

Null Graph Wash Trading


Transfer records
between different addresses
Exchange Exchange Exchange

Figure 6: The process of our detection method.

representing transfer amount. If two edges have the same partici- Algorithm 1 Flash-Loan-based Wash Trading Detection
pating addresses and asset_type, we classify them as the same type Input: N Transactions of Flash Loan, the threshold θ
Output: Wash trading set W T .
edge edдe_type_k. W T ← {}
Position Calculation. Unlike previous studies, we calculate posi- GRAP H ← { }
// Graph construction for each transaction
tion changes based on edges rather than addresses. Calculating edge for i = 1 to N do
net positions allows us to discover those transfers that have a return G i (V , E, W ) = Gr aph _Const r uct ion(T X i )
GRAP H _S ET ← G i (V , E, W )
path. We assume a pair of trading addresses addressX and addressY EDG E _T Y P E _S ET ← edдes , nodes
from T X i , and there are M transfers of assetn between them. There end for
for G i (V , E, W ) in GRAP H _S ET do
are l transfers with the direction of addressX → addressY and for edдe _type _k in EDG E _T Y P E _S ET do
(M −l) transfers with the direction of addressY → addressX . Then // Position Calculation
Posit ion Chanдe edдe _t ype _k = P osit ion _Calcul at ion(edдes , asset n )
we can calculate the position change Position Chanдeedдe_type_k P os i t ion Chanдe edдe _t ype _k
if M AX (amount _t r ans f e r ,amount _t r ans f e r as s e t n )
≤ θ
for the edge type k by the following formula: as s e tn
X → Y Y → X
then
Position Chanдeedдe_type_k (addressX , addressY , assetn ) // Edge Deletion
G i (V , E, W ) ← Edдe _Del et ion(G i (V , E, W ), edдes)
= |amount_trans f er ass e tn − amount_trans f er as s e tn | end if
 X → Y Y → X end for
= | m=l
m=1 amount_trans f er addr ess X ,addr essY ,asset n ,m
m=M // Judgement
if G i (V , E, W ) = ∅ then
− m=l +1 amount_trans f er addr essY ,addr ess X ,assetn ,m | W T ← T Xi
end if
where amount_trans f er is the amount of assetn transferred be- end for
tween two addresses. In this step, we calculate the net position Return W T

change for each type of edge.


Edge Deletion. For the position change of each type of edge, we
allow it to be within a certain range. We think a type of edge same detection algorithm to detect wash transactions for different
has a return path when the position change meets the following targets in this paper.
condition: 4.3.4 Filtering Invalid Flash Loan Transactions.
P osit ion Chanдe edдe _t ype _k In Flash Loan transactions, there are two types of invalid trans-
M AX (amount _t r ans f er ass e tn ,amount _t r ans f er ≤θ
ass e t n ) actions: 1) The borrower repays the loan immediately after getting
X → Y Y → X

where θ is the threshold that we set to filter out meaningless transfer the loan without any other actions. 2) The loan amount is 0. These
edges. When a set of edges satisfies the above condition, we remove two types of transactions do not use loans for any operations, so we
the set of edges from G i (V , E,W ). treat these transactions as invalid transactions and remove them
Judgement. After the edge deletion in the previous step, only edges from the detection results.
with real financial significance are left. From the previous analysis,
we can know that wash trading has almost constant positions and 5 EXPERIMENTS AND ANALYSIS
does not make any financial sense, which means there are no edges 5.1 Data Collection
left here. Therefore, when the final asset transfer graph is a null dYdX 4 , Aave 5 and Uniswap V2 6 are the most popular Flash Loan
graph (G i (V , E,W ) = ∅), we consider T X i to be a wash transac- providers on Ethereum, which hold the majority of the market
tion. The description of the whole detection process is shown in share [19]. In this paper, we will analyze Flash Loan transactions
Algorithm 1. using any of the three services. In order to detect Flash-Loan-based
4.3.3 Application-targeted Flash-Loan-based Wash Trading. wash trading, we first need to get Flash Loan transactions. However,
In DeFi, the target of wash trading can be not only an asset but using the Ethereum client to sync an archive node and parse related
also an application. Similar to the mechanism of asset-targeted transactions requires more storage resources (fast SSD drive with
wash trading, application manipulators can mislead investors by 4 dYdX,https://dydx.exchange/
increasing the trading volume of an application so there will also 5 Aave,https://aave.com/
be a closed capital cycle in the transaction. Therefore, we use the 6 Uniswap V2, https://uniswap.org/

80
AFT ’22, September 19–21, 2022, San Francisco, CA, USA Rundong Gan and Le Wang et al.

at least 6TB+ of space) and time, so it is a high-cost method for 5.2 Detection Results with Different
researchers who only want to study small-scale transactions. In Parameters
this paper, we provide a method for collecting Flash Loan transac-
Figure 7 shows the detection results under different θ . In order to
tions through third-party platforms (more details can be found in
determine the θ , we analyze these detection results.
Appendix: Data Collection). This method mainly has the following
steps:
6750
(1) Download coarse transaction data. When a transaction

Number of Detection Results


6500
uses Flash Loan, the provider’s smart contract will be called
through the blockchain address. We can download these 6250
transactions that have called Flash Loan smart contracts 6000
from Dune’s online database 7 to get coarse data. However,
5750
only Aave has an obvious Flash Loan feature, so we need to
filter out irrelevant transactions for dYdX and Uniswap V2 in 5500
later steps. It should be noted that Uniswap V2’s Flash Loan 5250
comes from different capital pools, so we need to collect
5000
related transactions from multiple smart contracts in the 0.0 0.2 0.4 0.6 0.8 1.0
Uniswap V2 project. Different Values of θ
(2) Get transaction details. To be able to filter transactions in
the next step, we need to get more transaction details from
Bloxy 8 , and these details include transaction information, Figure 7: Detection results under different θ .
execution traces, event logs, and internal asset transfers.
These transaction details will be used to discover Flash loan (1) When θ = 0, the detection rule is strict and only those trans-
transactions in the next step. We do not use Etherscan to actions that keep the position completely unchanged will
collect data because many details of internal transactions be found. After removing invalid transactions, we find 4956
are not available on this platform. highly similar transactions (e.g., an asset wrapping transac-
(3) Filter transaction data. Different Flash Loan smart con- tions 9 ) and the pattern of these transactions is shown in
tracts have different core functions and execution logic, so Figure 8(a) : some WETHs are loaned out and these WETHs
it is difficult to use a unified approach to filter these transac- are transferred to the Wrapped Ether contract 10 in exchange
tions. A feasible idea is to find key characteristics of Flash for native ETHs. Then, ETHs are transferred to the WETH
Loan transactions by analyzing the smart contracts of dif- contract again and WETHs are returned to the trader for the
ferent projects. Fortunately, Wang et al.[19] have a detailed loan repayment. These transactions repeatedly transform
discussion on how to identify Flash Loan Transactions using WETH and ETH but do not make any financial sense. We sus-
execution traces and event logs. In this paper, we use their pect the purpose of such transactions is to create fake usage
summarized features to filter these coarse data. records of the WETH contract. We also found 26 transactions
with another pattern (as shown in Figure 8(c)): loans are used
to provide liquidity or invoke application services. When all
Table 2: Flash Loan transactions from different platforms operations are completed, the asset is returned on the same
path. A typical transaction 11 is the liquidity providing of
Providers Time Number Compound 12 . In this transaction, 94,549 ETH is borrowed
Aave V1 Feb-16-2020 ∼ Jan-18-2022 23,874 to provide liquidity for Compound. Then, 1,605.8 WBTC is
Aave V2 Nov-30-2020 ∼ Jan-18-2022 24,180 borrowed and returned in Compound. Finally, liquidity is
dYdX May-25-2019 ∼ Jan-18-2022 43,208 removed and the loan is repaid. In these transactions, the
Uniswap V2 May-05-2020 ∼ Jan-18-2022 143,433 loan amount is huge but no application state is changed.
Total — 234,695 (2) When θ changes from 0 to 0.2, the number of detected trans-
actions increases from 5176 to 6547. After removing invalid
transactions, we found 1306 new transactions with the pat-
tern of 8(b). In these transactions, the loan is used repeatedly
We start collecting data from the time each app was created, and to buy the target asset even though there is no profit op-
the end time for data collection is January 18, 2022. Through the portunity. For example, there is a smart contract 13 and 62
above steps, we collected a total of 234,695 Flash Loan transactions 9 An asset wrapping transaction, https://bloxy.info/tx/0xf5f6a23c1e81dda566086ff157
(as shown in Table 2). Uniswap V2 has the most Flash Loan trans- 780afb68da028e1ca2df0488e2cb5475fbb65f
actions because it has a variety of capital assets and supports flash 10 Wrapped Ether, https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083

swap services compared to other Flash Loan providers. c756cc2


11 A liquidity providing transaction, https://etherscan.io/tx/0x965f50184d11a200698e77
f23ce02cd2b606a07b20e2d5dcd62d1c01ba25c13a
12 Compound, https://compound.finance/
7 Dune, https://dune.com/ 13 A wash smart contract, https://etherscan.io/address/0x6c48f0b2fa06d7f04003b90b6
8 Bloxy, https://bloxy.info/ 45db7767099b6ea

81
Understanding Flash-Loan-based Wash Trading AFT ’22, September 19–21, 2022, San Francisco, CA, USA

 orrow the loan  orrow the loan  orrow the loan


Flash Flash Flash
Loan Trader Loan Trader Loan Trader
Provider Provider Provider  Repay the loan
 Repay the loan  Repay the loan

 Liquidity providing
 Restore the asset  Get the wrapped  Swap assets  Swap assets  Use the service
asset back back
 Liquidity removing

Application Application Application

(a) Asset Wrapping (b) Asset Swapping (c) Liquidity Providing

Figure 8: The most frequent patterns in detection results

transactions are related to it. Among them, 57 transactions 6331


6000
are used to buy and sell the same token on the same exchange.
In addition, the targets of this contract mainly contain two 5000

Number of Transactions
tokens: ODDZ and SAITO.
4000
(3) When θ changes from 0.2 to 1, the number of detection
results has hardly changed. This means that when the asset 3000

return path exists, most wash transactions do not have a 2000


position change ratio of more than 20%. If θ is set to 1, all
1000
Flash loan transactions will be treated as wash trading and
the algorithm cannot detect wash transactions. 0
8 1
Uni V2 Aave dYdX
Different Flash Loan Providers

Table 3: Detection results when θ = 0.2


Figure 9: Transaction numbers of different Flash Loan ser-
Patterns Number vices used by manipulators.
Asset Wrapping 4956
Liquidity Providing 78 they choose a loan application with a lower interest rate to reduce
Asset Swapping 1306 the attack cost.

5.3 Validation
Through the above analysis, we found that when θ = 0, those
transactions without trading fees will be detected and the target of
these wash transactions is usually some applications. When θ is set Table 4: W ashr at io distributions for different wash targets.
to 0.20, some token-targeted transactions are found. To be able to
discover all transactions that meet the detection condition, we set W ashr at io
the value of θ to 0.20. Table 3 shows the final detection results for Percentage (%)
(Wash Volume/ Total Volume)
different patterns. For the pattern of asset wrapping, all transaction ≥ 10% 70.49
types are the same, there is only one wash target (WETH contract). ≥ 20% 49.18
For the pattern of liquidity providing, Compound, Aave, and iUSDC
≥ 30% 36.07
are the main wash targets. For the pattern of asset swapping, there
≥ 40% 22.95
are 67 different target tokens.
≥ 50% 16.39
We also counted the usage of Flash Loan services in our detected
results (as shown in Figure 9). It can be found that 6331 wash transac-
tions used the dYdX service and only 9 transactions used other Flash For each wash target tarдet j , we calculate the W ashr at io (=
W ash V olume
Loan services. This is not surprising since dYdX has almost free in-  T ot al Mar ket V olume ) which represents the ratio of wash volume
terest on borrowing: dYdX loan int er est = 1W ei 1W ei = 10−18 ET H . to total market volume (trading on decentralized exchanges) during
For Aave and Uniswap V2, the cost is more expensive: Aaveloan r at e = the attack. In Table 4, we show distributions of W ashr at io for differ-
0.09%, U niswap V 2loan r at e = 0.3%. Although Uniswap V2 is the ent wash targets. As can be seen from the figure, over 70% of wash
most popular Flash Loan provider, most traders just use it to ar- targets have a 10% W ashr at io , about 50% of wash targets have a 20%
bitrage in the form of flash swaps. For arbitrageurs, Uniswap V2 W ashr at io , and about 36% of wash targets have a 30% W ashr at io .
provides a wider variety of loan assets, so they can accept a loan This shows that the transactions we detected have greatly improved
rate of 0.3%. For manipulators, there is usually no asset gain, so the trading volume of targets.

82
AFT ’22, September 19–21, 2022, San Francisco, CA, USA Rundong Gan and Le Wang et al.

Manual analysis. In a wash trade, users are involved in frequent


sales. Therefore, we randomly selected 100 transactions from the
600000
detection results for manual analysis, and checked whether the
500000
following two conditions holds: 1) the smart contracts in these

Loan Amount (USD)


transactions are always called to complete similar transactions 400000

(times ≥ 10) which do not have any financial significance but cost 300000
gas fees. and 2) the on-chain funding source that financed one 200000
transaction also financed other similar transactions(times ≥ 10).
100000
Finally, 97% of transactions meet both of the above conditions, so
0
we consider the detection results to be reliable.
Wash Transactions Other Flash Loan Transactions
5.4 Characteristics of Wash Transactions
This section targets RQ2. Through statistics and analysis of these
Figure 11: Loan amount distributions for different types of
detected results, we find these wash transactions have some basic
transactions.
characteristics, which are shown below.
Gas Cost. Figure 10 shows the difference in gas cost for wash trans-
actions and other Flash Loan transactions. Compared with other for other transactions are at lower levels ($3,000∼$20,000). This
Flash Loan transactions, the gas fees of wash transactions are gen- shows that a large loan amount is not necessary for real Flash Loan
erally distributed in a lower range (average 0.033 ETH gas fee for traders and they just need the right amount of assets.
each transaction). This is because wash transactions don’t need
to compete for priority with other transactions and manipulators
only need to set appropriate gas fees for transaction execution. For
1400
manipulators, they will reduce the cost as much as possible when Datef irst wash − Datetarget creation (Days)
1200
completing the target transaction volume. In contrast, there are
1000
many competing transactions (e.g., arbitrage) and complex trans-
actions in other Flash Loan transactions, so the gas cost is higher 800

(average 0.061 ETH gas fee for each transaction). In detection results, 600

we also observed 7 transactions that have high gas fees (average 400
0.267 ETH) because they performed multiple wash actions in a 200
single transaction. 0

Wash Transactions

1.0

0.8
Figure 12: Time interval distributions of wash transactions.
Gas Cost (ETH)

0.6
Time Interval. To analyze the time feature, we calculate the wash
0.4 time interval which equals the first wash trading time Date f ir st wash
minus the target creation time Datet ar дet cr eat ion . From Figure 12,
0.2
we can find that most wash transactions start within a year of the
0.0
target creation and many wash transactions were initiated within
Wash Transactions Other Flash Loan Transactions
three months of target creation. This means wash trading usually
targets recently released assets or applications, and fake trading
volumes are created to attract traders’ attention.
Figure 10: Gas cost distributions for different types of trans- Activities of Wash Smart Contracts. In detection results, a total
actions. of 205 smart contracts were created to complete the 6340 wash
transactions. By manual inspection, we find that 65 of these smart
Loan Amount. Since different assets can be borrowed from Flash contracts have a similar activity pattern (as shown in Figure 13):
Loan applications, we convert loans to USD using the real-time 1) Manipulators control accounts to create wash smart contracts
price of each asset for comparison. Figure 11 shows loan amount and transfer ETH to them. 2) Created smart contracts are called
distributions for different types of transactions. We find that the to complete wash actions and ETH is converted into the target
loan amounts of wash transactions are distributed in a higher range asset to pay trading fees. 3) After completing all wash actions, the
($70,000∼$130,000), which is because wash trading needs more remaining ETH will be exchanged back. 4) The remaining ETH is
assets to increase the total market volume. Even though the loan is eventually withdrawn to an account controlled by the manipulator.
free, the loan amount for most wash transactions is still not very We also found that these smart contracts were never used again
high. We guess this is because cunning manipulators always avoid after completing the wash trading. This suggests these contracts
being discovered by careful investors. In contrast, the loan amounts were built specifically for creating fake transactions.

83
Understanding Flash-Loan-based Wash Trading AFT ’22, September 19–21, 2022, San Francisco, CA, USA

Smart contracts for wash trading

250000
Suspicious Trading Volume
Normal Trading Volume
200000



Volume (USD)


  150000
 



100000

Manipulator-controlled addresses Application 50000

0
Figure 13: The most frequent activity of wash smart con-

2021-03-08

2021-03-09

2021-03-10

2021-03-11

2021-03-12

2021-03-13

2021-03-14

2021-03-15

2021-03-16

2021-03-17

2021-03-18

2021-03-19

2021-03-20

2021-03-21
tracts.

Time (Year-Month-Day)
6 FINANCIAL ANALYSIS
This section targets RQ3 and RQ4. In this section, we analyze the
market impact and attack cost to explore why manipulators are will- Figure 14: Trading volume of token 0x3383c5 on Uniswap V2.
ing to use Flash-Loan-based wash trading for volume manipulation.
Detailed results are shown in Appendix: Financial Analysis.
It should be pointed out that in some special cases (e.g., small wash
volume goal), traditional wash trading are more cost-effective.
6.1 Correlation Analysis
Figure 14 shows a case that the fake trading volume caused an 7 DISCUSSION
increase in the normal trading volume of token 0x3383c5 (part of Due to the anonymity and decentralization of blockchains, this
the hash code). From March 8th to March 14th, the normal trad- study has multiple limitations:
ing volume is always less than $10,000 while Flash-Loan-based Ground-truth based validation. First and foremost, it should be
transactions dominate the market. From March 15th, the normal made clear that how to obtain reliable labeled data is a challenging
trading volume began to increase, and the manipulators stopped task in wash-trading-related research. As far as we know, there is
the behavior of wash trading. We searched Twitter, Discord and still no conclusive evidence here to validate such criminal activity.
other social networking sites for relevant information about the Cao et al. [3] were the first team to systematically study wash trad-
token and found that a lot of promotional information was released ing, but in their study, only manually reproduced samples based on
during the period. These promotions touted the token’s bright fu- abnormal trading patterns were used to evaluate the effectiveness
ture and good performance on Uniswap V2 to attract innocent users. of their algorithm. In these studies [9, 16, 17] focusing on DeFi
Although we know there were some fake transactions, those inno- wash trading, there is still no clear ground-truth validation. It is
cent users still chose the token and it eventually led to an increase not surprising, as there are always limitations to linking abnormal
in the price (over 30%). This shows Flash-Loan-based transactions trading patterns to specific criminal activity. However, this does
can affect the trading volume and prices of target tokens. not mean that the detection and evaluation of these studies are
In the Appendix to Correlation Analysis we did some rough unreliable. In the regulation of traditional finance, wash trading has
calculations and came to some conclusions: 1) By calculating the a clear definition, and any transaction that meets the definition can
Pearson correlation coefficient, we can find the market trading be regarded as an abnormal transaction. Most traders are for profit
volume of target assets is highly related to these wash transactions, and they have no incentive to make such illegal transactions with-
which indicates that wash trading directly led to an increase in out direct profit. Therefore, transactions that conform to anomalous
market trading volume. This is not surprising as the direct purpose trading patterns can serve as evidence for legal penalties in many
of Flash-Loan-based wash trading is to increase the market volume scenarios. Of course, the research would be more convincing if we
of target assets; and 2) we also find the prices of some target assets could have more evidence (e.g. audio recordings, social network
can be affected by wash transactions within a week (other tokens chat logs, IP addresses, etc.) to validate those transactions. In the
may take longer) and this shows that fake transactions can affect future, mining more conclusive evidence for price manipulation on
the market performance of assets. the blockchain is an area worth exploring.
Prevention of wash trading. The detection algorithm in this pa-
6.2 Cost Analysis per is run “after the fact”, which means that unless miners are
Through simulation experiments of Cost Analysis, we find that willing to deploy it to reject those transactions, our algorithm can-
under certain conditions (e.g., the loan interest is less than 0.1% not defend against wash trading in real-time. In fact, the main
and the target trading volume is large enough), Flash-Loan-based purpose of our paper is to analyze and prove the abuse of Flash
wash trading can have a lower cost than traditional wash trading. Loan in wash trading, thereby drawing the attention of regulators
Under the same cost, the maximum wash volume of traditional and investors to such transactions. Although the business of wash
wash trading is much smaller than Flash Loan-based wash trading, trading has existed for a long time [1], there are few concrete so-
which means the latter can effectively amplify the impact of attacks. lutions to this problem. Decentralized exchanges haven’t shown

84
AFT ’22, September 19–21, 2022, San Francisco, CA, USA Rundong Gan and Le Wang et al.

enough enthusiasm to prevent it because wash trading can bring REFERENCES


them more transaction fees. In a wash trading manipulation, victims [1] Anna Baydakova. 2019. For $15K, He’ll Fake Your Exchange Volume – You’ll Get on
are those uninformed traders who buy bubbling assets at irrational CoinMarketCap. https://www.coindesk.com/markets/2019/07/18/for-15k-hell-
fake-your-exchange-volume-youll-get-on-coinmarketcap/
prices. To protect these innocent traders, there are two possible [2] Yi Cao, Yuhua Li, Sonya Coleman, Ammar Belatreche, and Thomas Martin McGin-
solutions in the future: 1) design more reliable market metrics (e.g. nity. 2014. Detecting wash trade in the financial market. In 2014 IEEE Conference
on Computational Intelligence for Financial Engineering & Economics (CIFEr). IEEE,
taking TVL into account) instead of using trading volume directly; 85–91.
and 2) develop trade monitoring tools like Chain Analysis based on [3] Yi Cao, Yuhua Li, Sonya Coleman, Ammar Belatreche, and Thomas Martin McGin-
our research to catch bad actors after the fact (with the help of side nity. 2015. Detecting wash trade in financial market using digraphs and dynamic
programming. IEEE transactions on neural networks and learning systems 27, 11
information to uncover their identity). (2015), 2351–2363.
[4] Yixin Cao, Chuanwei Zou, and Xianfeng Cheng. 2021. Flashot: A Snapshot of
Flash Loan Attack on DeFi Ecosystem. arXiv preprint arXiv:2102.00626 (2021).
[5] Commodity Futures Trading Commission (CFTC). 2022. CFTC Glossary Wash
8 RELATED WORKS Trading. https://www.cftc.gov/LearnAndProtect/EducationCenter/CFTCGlossar
y/glossary_wxyz.html#washtrading
Flash Loan. Research on Flash Loan can be traced back to the work [6] Weili Chen, Jun Wu, Zibin Zheng, Chuan Chen, and Yuren Zhou. 2019. Market
of Wang et al. [18], and then many Flash-Loan-based attacks [4, 14] manipulation of bitcoin: Evidence from mining the Mt. Gox transaction network.
began to be analyzed and explored. Although Flash-Loan-based In IEEE INFOCOM 2019-IEEE conference on computer communications. IEEE, 964–
972.
wash trading has been mentioned in these papers, only a small case [7] James Chung. 2022. DeFi Market Commentary. https://consensys.net/blog/crypt
is briefly introduced. The specific principles and detection methods oeconomic-research/defi-market-commentary-january-2022/
[8] Lin William Cong, Xi Li, Ke Tang, and Yang Yang. 2021. Crypto wash trading.
of Flash-Loan-based wash trading have never been discussed so far. arXiv preprint arXiv:2108.10984 (2021).
Wash Trading. Yi Cao et al. [3] are the first to propose a systematic [9] Dipanjan Das, Priyanka Bose, Nicola Ruaro, Christopher Kruegel, and Giovanni
method for the detection of wash trading. They use digraphs and Vigna. 2021. Understanding security Issues in the NFT Ecosystem. arXiv preprint
arXiv:2111.08893 (2021).
dynamic programming to find wash trading of stocks in centralized [10] DeFi-Plus. 2021. The TVL of DeFi Projects . https://defipulse.com/
exchanges. With the development of blockchain and the prosperity [11] Felix Eigelshoven, André Ullrich, and Douglas Parry. 2021. Cryptocurrency
of DeFi, wash trading began to appear in decentralized exchanges. Market Manipulation: A Systematic Literature Review. (2021).
[12] Shayan Eskandari, Mehdi Salehi, Wanyun Catherine Gu, and Jeremy Clark. 2021.
Some studies [16, 17] start to focus on wash trading in decentralized Sok: Oracles from the ground truth to market manipulation. In Proceedings of the
financial systems. The above studies mainly focus on the detection 3rd ACM Conference on Advances in Financial Technologies. 127–141.
[13] Kaihua Qin, Liyi Zhou, and Arthur Gervais. 2021. Quantifying Blockchain Ex-
of abnormal behaviors but ignore the understanding and analysis tractable Value: How dark is the forest? arXiv preprint arXiv:2101.05511 (2021).
of wash trading (e.g., the cost and the impact of wash trading on the [14] Kaihua Qin, Liyi Zhou, Benjamin Livshits, and Arthur Gervais. 2021. Attacking
market). At the same time, some advanced DeFi applications (such the defi ecosystem with flash loans for fun and profit. In International Conference
on Financial Cryptography and Data Security. Springer, 3–32.
as Flash Loan) in the financial market are not taken into account in [15] Uniswap. 2022. Flash Swaps. https://docs.uniswap.org/protocol/V2/guides/smart-
time. contract-integration/using-flash-swaps
In this paper, we explain the background and principle of Flash- [16] Friedhelm Victor and Andrea Marie Weintraud. 2021. Detecting and quantifying
wash trading on decentralized cryptocurrency exchanges. In Proceedings of the
Loan-based wash trading in detail and analyze the basic character- Web Conference 2021. 23–32.
istics of this type of attack. Based on these analyses, we designed [17] Victor von Wachter, Johannes Rude Jensen, Ferdinand Regner, and Omri Ross.
2021. NFT Wash Trading: Quantifying suspicious behaviour in NFT markets. In
a reliable detection scheme to find wash transactions using Flash Financial Cryptography and Data Security. FC 2022 International Workshops.
Loan. Further, we also explore the cost and market impact of such [18] Dabao Wang, Siwei Wu, Ziling Lin, Lei Wu, Xingliang Yuan, Yajin Zhou, Haoyu
attacks to elucidate manipulators’ motivation. Wang, and Kui Ren. 2020. Towards understanding flash loan and its applications
in defi ecosystem. arXiv preprint arXiv:2010.12252 (2020).
[19] Dabao Wang, Siwei Wu, Ziling Lin, Lei Wu, Xingliang Yuan, Yajin Zhou, Haoyu
Wang, and Kui Ren. 2021. Towards a first step to understand flash loan and its
applications in DeFi ecosystem. In Proceedings of the Ninth International Workshop
9 CONCLUSION on Security in Blockchain and Cloud Computing. 23–28.
We propose a heuristic-based detection method after thoroughly [20] Sam M Werner, Daniel Perez, Lewis Gudgeon, Ariah Klages-Mundt, Dominik
Harz, and William J Knottenbelt. 2021. Sok: Decentralized finance (defi). arXiv
studying the attack principle of Flash-Loan-based wash trading. Our preprint arXiv:2101.08778 (2021).
detection results demonstrate that Flash-Loan-based wash trading [21] Siwei Wu, Dabao Wang, Jianting He, Yajin Zhou, Lei Wu, Xingliang Yuan, Qin-
is widespread. Through further analysis of the results, we find ming He, and Kui Ren. 2021. Defiranger: Detecting price manipulation attacks
on defi applications. arXiv preprint arXiv:2104.15068 (2021).
that most wash transactions can significantly increase the market [22] Jiahua Xu and Benjamin Livshits. 2019. The anatomy of a cryptocurrency pump-
volume of targets. These wash transactions have lower gas fees and and-dump scheme. In 28th {USENIX } Security Symposium ( {USENIX } Security
19). 1609–1625.
higher lending amounts than other Flash Loan transactions. We [23] Jiahua Xu, Nazariy Vavryk, Krzysztof Paruch, and Simon Cousaert. 2021. SoK:
also found that these wash transactions can significantly increase Decentralized Exchanges (DEX) with Automated Market Maker (AMM) protocols.
market volume, but may not immediately increase the price of target arXiv preprint arXiv:2103.12732 (2021).
[24] Liyi Zhou, Kaihua Qin, and Arthur Gervais. 2021. A2mm: Mitigating frontrunning,
assets. Even so, Flash-Loan-based wash trading is still favored by transaction reordering and consensus instability in decentralized exchanges.
manipulators because it can amplify the attack while reducing the arXiv preprint arXiv:2106.07371 (2021).
cost as much as possible compared to traditional wash trading. [25] Liyi Zhou, Kaihua Qin, Christof Ferreira Torres, Duc V Le, and Arthur Gervais.
2021. High-frequency trading on decentralized on-chain exchanges. In 2021 IEEE
Symposium on Security and Privacy (SP). IEEE, 428–445.

ACKNOWLEDGEMENT
This research was partially supported by NSERC (Natural Sciences
and Engineering Research Council of Canada), Canada.

85
Understanding Flash-Loan-based Wash Trading AFT ’22, September 19–21, 2022, San Francisco, CA, USA

0xc52c32 0.85 0.051 0.054 0.049 0.049 0.049 0.053 0.057 0.063
0.8
Wash volume time series for different assets

0xf74134 0.97 0.12 0.6 0.49 0.21 -0.29 -0.58 -0.73 -0.76
0.6
0x1453db 0.59 -0.12 -0.12 -0.12 -0.12 -0.12 -0.11 -0.11 -0.11

0x1fe24f 0.28 -0.2 -0.27 -0.26 -0.22 -0.18 -0.16 -0.22 -0.23 0.4

0xdece0f 0.94 -0.32 0.051 0.33 0.28 0.47 0.7 0.57 0.032 0.2

0xaef4f0 0.73 -0.23 -0.21 -0.2 -0.18 -0.19 -0.2 -0.19 -0.19 0.0

0x62786e 0.92 -0.26 -0.28 -0.31 -0.35 -0.21 -0.028 0.023 0.082
−0.2
0x2edf09 0.15 -0.38 -0.4 -0.4 -0.42 -0.45 -0.46 -0.42 -0.35
−0.4
0xa2881f 0.64 -0.75 -0.43 -0.082 0.51 0.36 -0.22 -0.4 0.026
−0.6
0xf9fbe8 0.47 -0.26 -0.027 0.1 0.014 -0.13 -0.2 0.32 0.35

M arket V olume timedelay =0 day timedelay =1 day timedelay =2 days timedelay =3 days timedelay =4 days timedelay =5 days timedelay =6 days timedelay =7 days
Different Time Series

Figure 15: Pearson correlation coefficients for different time series pairs.

A APPENDIX: FINANCIAL ANALYSIS market trading volume. This is not surprising, as the direct purpose
In this section, we analyze the market impact and cost to explore of Flash-Loan-based wash trading is to increase the market volume
why manipulators are willing to use Flash-Loan-based wash trading of the target asset. This improvement is immediate, as Flash Loan
for volume manipulation. It should be noted that all the market makes wash trading without capital restrictions.
data in this paper is obtained from Dune and Ethplore14 . By setting different timedel ay , we find that only four assets
(0x f 74134, 0xdece0f , 0xa2881f , 0x f 9f be8) have a significant cor-
A.1 Correlation Analysis relation between prices and wash volume within a week. The prices
of most assets were not significantly affected. For most assets, there
For the convenience of calculation and comparison, we mainly ana-
is no clear positive correlation between wash volume and prices,
lyze the market impact of Flash-Loan-based wash trading on target
and 0x2ed f 09 even shows a high negative correlation. On the one
assets. Firstly, we selected 10 assets with the most wash transac-
hand, the price is usually determined by multiple market factors,
tions and collected three types of time series for them: wash volume
and not every Flash-Loan-based wash trading will be successful.
Twash_volume , market volume Tmar ket _volume , and asset prices
For manipulators, they may need more actions to get investors’
Tasset _pr ice (the basic unit of time series is the day). The effect
attention, such as posting attractive news on social networking
of trading volume on prices is delayed rather than immediate, so
sites. On the other hand, the effect of trading volume on price is
we set up sliding windows Slidinд_W indow t ime with different de-
not immediate, and there may be a longer time delay.
lays timedel ay ( timedel ay ∈ {1 day, 2 days, 3 days, 4 days, 5 days,
6 days, 7 days}). The width of the Slidinд_W indow t ime is equal to
the time span of wash trading. For example, for one asset, the wash A.2 Cost Analysis
time lasts for 30 days from April 18, 2021 to May 17, 2021, so we take In this section, we discuss the attack cost of wash trading with-
three time series Twash_volume , Tmar ket _volume ,Tasset _pr ice of /without Flash Loan. Because Flash-Loan-based wash trading for
the asset during this period. When timedel ay = 2 days, We set the different targets has a similar cost structure, we just chose one
time range for Tasset _pr ice from April 20, 2021 to May 19, 2021. In scenario for discussion.
this way, we have a total of 90 pairs of time series.
In economics, the Pearson correlation coefficient is often used A.2.1 Description.
to measure the correlation between two variables. In this paper, we Flash Loan. We assume there is a flash loan platform F with
use the Pearson correlation coefficient to evaluate the impact of amount f l ash_loan of asset f l ash_loan , which the adversary A can
wash transactions on market volume and prices. Figure 15 shows borrow. The interest rate of asset f l ash_loan is rate f l ash_loan .
the correlation coefficients between different time series pairs. The Decentralized Exchange. There is a decentralized exchange
Y-axis represents Twash_volume of different assets, and the X-axis pool PX /Y , which is based on the simplest AMM mechanism (x ×y =
represents Tmar ket _volume and Tasset _pr ice with different time k). The pool includes amount X of asset X and amountY of asset Y.
delays. We use the first eight digits of the address hash to distinguish X is the popular currency (e.g., ETH or USDC) that can be borrowed
different assets. from Flash Loan services, and Y is the currency created by A. For
From the first column of Figure 15 , we can find that the market PX /Y , the trading fee of a swap action is rateswap × amountswap .
trading volume of almost all target assets is related to wash trans- We assume that the trading fee of PX /Y is not earned by A. Note
actions. Especially for asset 0x f 74134, the correlation reaches 0.97, that the slippage is ignored.
which indicates that wash trading directly led to an increase in Adversary. Adversary A has a certain amount of initial funds
C 0 and some ETHs for gas fees. His purpose is to create fake trading
14 Ethplor, https://ethplorer.io/zh/ volume V olume дoal (V olume дoal > C 0 ) in pool PX /Y .

86
AFT ’22, September 19–21, 2022, San Francisco, CA, USA Rundong Gan and Le Wang et al.

rateswap = 0.1%, V olumegoal = 800 ET H ratef lash loan = 0%, V olumegoal = 800 ET H ratef lash loan = 0%, rateswap = 1%
12
Wash Trading without Flash Loan Wash Trading without Flash Loan Wash Trading without Flash Loan
9.4 Wash Trading with Flash Loan (M=20) 12 Wash Trading with Flash Loan (M=20) Wash Trading with Flash Loan (M=20)
Wash Trading with Flash Loan (M=40) Wash Trading with Flash Loan (M=40) Wash Trading with Flash Loan (M=40)
10
9.2 Wash Trading with Flash Loan (M=60) 11 Wash Trading with Flash Loan (M=60) Wash Trading with Flash Loan (M=60)
Wash Trading with Flash Loan (M=80) Wash Trading with Flash Loan (M=80) Wash Trading with Flash Loan (M=80)

9.0 10 8
Cost (ETH)

Cost (ETH)

Cost (ETH)
8.8 9
6

8.6 8
4
7
8.4
6 2
8.2
5 0
0.0 0.1 0.2 0.3 0.4 0.5 0.5 0.6 0.7 0.8 0.9 1.0 0 200 400 600 800 1000
Flash Loan Interest (ratef lash loan ) (%) Trading Rate (rateswap ) (%) Washing Goal (V olumegoal ) (ETH)

(a) Wash trading with different r at e f l ash_l oan (b) Wash trading with different r at e sw ap (c) Wash trading with different V olume дoal

Figure 16: The cost of wash trading with different parameters

Then, there are two strategies for wash trading.


Cost t x i = дas f ee + tradinд f ee + interest f l ash_loan
A.2.2 A creates wash trading transactions without Flash Loan.
Since A’s funds are limited, in order to achieve V olume дoal , he = 2 × дas swap + дas f l ash_loan + Ci ×
must reuse C 0 in multiple transactions. After each transaction tx i ,   (7)
rate swap + Ci × 1 − rate swap × rate swap
the initial fund Ci will be reduced due to the trading fee:
+ Ci × rate f l ash_loan
 
C i = C i−1 × 1 − rate swap (1) then, the total cost is:
so, for the fund C 0 , the maximum washing capacity is 
i=M
Cost f l ash_loan = Cost t x i (8)

i→∞
 i i=1
V olume M AX = C 0 × 1 − rate swap (2)
i=1 A.2.4 Simulation Experiments.
The cost of each transaction is: To simplify the calculation, we specify X as ETH and Y as the
target asset for wash trading. In the pool PX /Y , amount X = 100,
amountY
Cost t x i = дas f ee + tradinд f ee and amountY = 100,000 ( price X /Y = amount X
). Common values
(3) of rateswap are 0.05%, 0.3% and 1%, so we consider rateswap in the
= дas swap + Ci × rate swap
range of 0.05%∼1%. We take the average gas fee of each action, so
Assuming there are a total of N transactions, дas f l ash_loan =0.004 ETH and дasswap =0.004 ETH. A has 10 ETH
for wash trading, and he can borrow ETH from F. Because common

i=N
 i values of rate f l ash_loan are 0%, 0.09% and 0.3%, we consider the
V olume goal = C 0 × 1 − rate swap (4)
i=1
range of rate f l ash_loan to be 0%∼0.5%. Figure 16 shows the cost of
wash trading with different parameters.
and the total cost is:
In Figure 16(a), we set rateswap = 0.1%, V olumeдoal = 800 ETH.
To complete V olumeдoal , if A repeatedly uses C 0 without Flash

i=N
Cost wit hout _f l ash_loan = Cost t x i (5) Loan, the all cost is 8.67 ETH, which is not affected by rate f l ash_loan .
i=1 If A uses Flash Loan, the final cost depends on the interest of Flash
Loan. When rate f l ash_loan is more than 0.3%, using Flash Loan
A.2.3 A creates wash trading transactions with Flash Loan. for wash trading is not a cost-effective strategy. This can explain
Because flash loan providers usually have a large number of why DyDx’s Flash Loan service is often used to create wash trad-
funds, we assume there is no upper limit for Flash-loan-based wash ing transactions. We also find that if A creates too many Flash
trading. In order not to arouse suspicion, we also assume that A Loan transactions with high rate f l ash_loan , it will cost more than
completes wash trading in M transactions, and each flash loan traditional wash trading. Therefore, for A, he should choose a
transaction has two swap actions (swap in/out): reasonable M and rate f l ash_loan .
As can be seen from Figure 16(b), rateswap is also an important

i=M
   2 factor that affects the final cost. If rateswap is lower, A can use C 0
V olume goal = Ci × 1 − rate swap +Ci × 1 − rate swap (6) repeatedly with less loss, and the cost of the two strategies is not
i=1 much different. However, when rateswap is high (1%), traditional
where Ci can be randomly selected and is not limited by the wash trading requires more cost. This is because a high rateswap
initial capital. The cost of each transaction is: means more losses when using C 0 repeatedly. For those assets with

87
Understanding Flash-Loan-based Wash Trading AFT ’22, September 19–21, 2022, San Francisco, CA, USA

low liquidity in the market, some DEXs (e.g., Uniswap) usually


set higher trading fees (1%). Therefore, for those assets with high AND a.call_success = true
trading fees, using Flash Loan will save more money. AND (
We also from Figure 16(c) find that when rate f l ash_loan = a."amount0Out" = 0
0%, rateswap = 0.1%, if not using Flash Loan, Volume M AX = or a."amount1Out" = 0
i→∞ )
i=1 10 × (1 − 1%) ≈ 990 ETH, which means that traditional wash
i
trading can only create limited fake volume when rateswap is too
high. Within the limited wash volume, the larger the V olume дoal , Note: In the Dune database, not all fields have clear explanations.
the more obvious the advantage of using Flash Loan. When V olume дoal Therefore, when users make customized queries, they need to un-
is too small, it is irrational for A to use Flash Loan to create wash derstand the whitepaper of the relevant project and be familiar
transactions. enough with the contract code.

B APPENDIX: DATA COLLECTION B.2 Get transaction details


In this section, we show how to collect targeted transaction data We use Bloxy to collect detailed execution traces and event logs (in
based on third-party platforms. fact, Dune also provides relevant data, you can choose it according
to your needs). In this step, we use the official API of Bloxy to collect
B.1 Download coarse transaction data the following data:
Dune gives us customizable tools to query, extract, and visualize Transfer Records. In this paper, transfer records are used to detect
vast amounts of data from the blockchain. For some services with abnormal flash loan transactions. Therefore, for Flash Loan trans-
the direct Flash Loan feature, we can use the SQL to query relevant actions that have been identified in the previous step, we collect all
transactions directly. For example, Aave’s Flash Loan service always token transfer records (both internal and external) directly.
calls the function flashLoan, and it emits a unique event called Execution Traces and Event Logs. In the Execution Trace mod-
FlashLoan. Therefore, we can query Aave’s Flash Loan transactions ule of Bloxy, related functions and inputs are shown in detail. We
in Dune according to the following SQL code: use this information to determine the final Flash Loan transactions
according to the rules in the next step.
Code 1 : Query Flash Loan Data from Dune for Aave B.3 Filter transaction data
SELECT
In this subsection, we describe how to identify Flash Loan trans-
evt_tx_hash,
actions through the execution traces and event logs. Note that our
DATE_TRUNC ('hour', evt_block_time) AS time,
experience is learned from the work of Wang et al.[19].
"target" AS target,
Identify flash loan transactions from dYdX. Unlike Aave, there
asset AS token,
is no obvious function for us to directly identify transactions, but we
amount AS amt,
can still achieve Flash Loan service in dYdX by analyzing the execu-
premium AS fee_amt,
tion process of the smart contract. There are two check conditions
(premium) / NULLIF(amount, 0) AS fee,
for identifying:
'Aave V2' AS source,
evt_block_number • Condition 1: In a Flash Loan transaction, there are a series
FROM of actions (Operate, Withdraw, callFunction, Deposit) and
aave_v2."LendingPool_evt_FlashLoan" all actions have corresponding event logs ( LogOperate,
LogWithdraw, LogCall, and LogDeposit );
• Condition 2: All event logs follow a particular order:
However, for some services ( e.g. Uniswap V2 and dYdX ) that LogOperate → LogWithdraw → LogCall → LogDeposit.
do not directly provide Flash Loan features, we can’t get the re- Identify flash loan transactions from Uniswap V2. Since part
quired transactions directly from Dune, so additional identification of the identification is already done in B.1, we just need to do the
is necessary. Before the next step, we can use Dune to get coarse rest of the checks at this step. There are two check conditions for
transactions related to the target project. For example, for Uniswap identifying:
V2 which has multiple capital pools, the query code is as follows:
• Condition 1: For a Flash Loan transaction , the internal
transaction triggered by uniswapV2Call must include the
Code 2 : Query Coarse Data from Dune for Uniswap V2 invocation of transfer or transferFrom function;
SELECT * • Condition 2: The receiver address of transfer function or
From transferFrom function must be the pair contract which can
uniswap_v2."Pair_call_swap" a be identified in Dune.
LEFT JOIN uniswap_v2."Factory_evt_PairCreated" b When there is a new Flash Loan service, we can collect new data
ON a.contract_address = b."pair" by adding SQL code and modifying identification rules. Note that,
where this data collection approach can be used not only for Flash Loan
LENGTH(a.data) > 1 services but also for other similar DeFi services.

88

You might also like