Next Article in Journal
Implementation of Remote Control for the AM 524 Antenna Amplifier Unit System in SAC Chambers
Previous Article in Journal
Tikhonov-Tuned Sliding Neural Network Decoupling Control for an Inverted Pendulum
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Study on Blockchain Sandwich Attack Strategies Based on Mechanism Design Game Theory

1
Leicester International Institute, Dalian University of Technology, Dalian 116024, China
2
Sage IT Consulting Group, Shanghai 200000, China
3
School of Law, University of Washington, Seattle, WA 98195, USA
4
Khoury College of Computer Sciences, Northeastern University, Boston, MA 02115, USA
5
School of Computer Science, University of Bristol, Bristol BS8 1QU, UK
*
Authors to whom correspondence should be addressed.
Electronics 2023, 12(21), 4417; https://doi.org/10.3390/electronics12214417
Submission received: 6 September 2023 / Revised: 26 September 2023 / Accepted: 20 October 2023 / Published: 26 October 2023

Abstract

:
The rapid progression of Decentralized Finance (DeFi) has established Decentralized Exchanges (DEX) as critical elements in the financial landscape. Nevertheless, the open and transparent nature of DEX makes them susceptible to strategic manipulations, especially the sandwich attack. During such maneuvers, ill-intentioned actors exploit price slippage by positioning their transactions strategically around a target’s order to reap unfair profits. This paper introduces a ground-breaking framework rooted in mechanism design game theory to lessen the impact of sandwich attacks. The framework delineates the precise strategy of the sandwich attack and its repercussions, shedding light on the tactical aspects and utility functions pertinent to both the attackers and the ordinary traders, subsequently referred to as workers. The discussion extends to defining utility functions for both the market and the workers, emphasizing the benefits of liquidity provision for the market and the potential profits and losses for the workers. The proposal encourages adopting a market-centric mechanism design grounded in game theory, wherein the market, operating as the designer, creates rules to maximize its utility while considering the workers’ utility. Through a meticulous analysis of this game-theoretic approach, the study identifies optimum strategies for all the involved parties, demonstrating that these strategies can reach a balanced state. Further, this study presents a comparative view against existing research, highlighting the limitations of contemporary solutions and asserting the effectiveness of the proposed model in protecting the interests of both the market and the workers. Ultimately, this research furnishes stakeholders with new perspectives and instruments to thwart sandwich attacks and lays a foundation for creating resilient and fair decentralized trading infrastructures.

1. Introduction

Decentralized Finance (DeFi) represents a transformative shift in contemporary finance, leveraging blockchain technology to furnish a decentralized, transparent platform for financial transactions. Within this domain, Decentralized Exchanges (DEX) emerge as notable entities, offering users an economical trading platform free from intermediaries. While the decentralized paradigm brings advantages such as increased transaction autonomy, heightened privacy, and reduced costs, it simultaneously unveils unique security challenges. A paramount concern is the ‘sandwich attack’, wherein attackers place their transactions around a victim’s order, capitalizing on price slippage. As the DeFi sector flourishes, reaching a market capitalization in the billions and attracting diverse investors and traders, the complexities of trading on DEXs have increased. This enhances opportunities for malefactors, compromising ordinary traders’ interests and undermining the foundational trust and fairness intrinsic to DEX. If traders perceive a risk of manipulation, they may shy away from DEX, impeding the robust and sustained evolution of the DeFi landscape.
The prevalence of sandwich attacks critically jeopardizes the fairness and transparency of DEX. If trader confidence erodes, it could trigger an exodus, reducing DEX liquidity and affecting its market efficiency and stability. Consequently, formulating a mechanism that effectively mitigates sandwich attacks and concurrently safeguards the interests of both the market and the traders has become an urgent research imperative. Moreover, it is vital that this mechanism addresses the attacks and does so without unduly impeding or delaying routine transactions. This calls for a comprehensive examination of DEX trading mechanisms, pinpointing potential vulnerabilities and formulating robust defensive strategies.
To address the outlined challenges, we advocate for an investigative approach grounded in mechanism design—a prominent subfield of economics that focuses on creating mechanisms to ensure that, despite private information, each participant’s strategic decisions converge to a socially optimal objective. Our methodology begins with a comprehensive examination of DEX trading mechanisms, highlighting susceptible areas. Building upon mechanism design theory, we then introduce an innovative trading mechanism adept at countering sandwich attacks while preserving market liquidity and efficiency. Our methodology comprises several distinct phases: 1. Data Collection and Analysis: We initiate by amassing a substantial dataset of DEX trading activities, followed by a rigorous statistical scrutiny to discern potential attack vectors and vulnerabilities. 2. Model Establishment: Using insights from the preliminary data analysis, we construct a trading model that meticulously captures the nuances of DEX transactions and potential malicious tactics. 3. Mechanism Design: Drawing from mechanism design theory, we devise a novel trading mechanism that encourages traders to disclose their authentic trading intentions transparently, effectively neutralizing malicious maneuvers. 4. Simulation and Validation: A series of comprehensive simulation experiments validate our mechanism’s robustness across diverse scenarios. Our experimental findings underscore that our proposed mechanism notably augments market fairness and transparency, ensuring optimal trading liquidity and efficiency.
The salient contributions of this work encompass the following key areas: 1. In-depth Examination of DEX Trading Mechanisms: We thoroughly investigated the DEX trading mechanisms and the associated attack strategies, which offered a rich data repository and deep insights for future research. 2. Debut of an Innovative Trading Mechanism: Our proposed mechanism, rooted in mechanism design theory, addressed the sandwich attacks while safeguarding market liquidity and efficiency—a marked breakthrough in the DEX sphere. 3. Pragmatic Implementation Guidance: Beyond theoretical discourse, our work provided actionable insights for real-world deployment. DEX operators can leverage our findings to refine their trading structures, enhancing market transparency and fairness. 4. Augmenting Mechanism Design’s Role in Finance: Furthermore, our study heralded an expanded role for mechanism design within the financial sector, especially in financial investigations.

2. Related Work

In the domain of game-theoretic mechanism design, numerous studies have addressed the challenges inherent to sandwich attacks. Heimbach and Wattenhofer provided a highly effective algorithm for traders to set the slippage tolerance. [1]. Modern game theory applications predominantly scrutinized terrorist targeting strategies encompassing entities like businesses, officials, and civilians [2,3]. Within these paradigms, targets often employ divergent tactics to thwart potential threats [4,5]. Noteworthy contributions by Sandler et al. and Zhuang et al. utilized game theory to elucidate equilibrium strategies for both attackers and defenders, focusing on optimal resource allocation against terrorism and natural disasters [6,7]. Similarly, Liang et al. presented an exhaustive survey of game-theoretic solutions targeting network security, bifurcating the strategies into attack–defense analyses and security metrics [8]. Zonouz et al. pioneered the Response and Recovery Engine as an innovative response mechanism [9]. Shamshirband et al. invoked a cooperative game-theoretic approach, enhanced with fuzzy q-learning, to detect and mitigate intrusions in wireless sensor networks [10]. Yuan et al. further postulated optimal criteria for cyber defenders and DoS attackers, leveraging optimal control paradigms [11]. This Special Issue spotlighted the cyber–physical security facets of Networked Control Systems and encapsulated state-of-the-art developments within system theory and decision sciences applied to this rapidly evolving domain [12].
Transitioning to the blockchain domain, Cai et al. critically evaluated blockchain-driven reputation systems, emphasizing vulnerabilities like ballot-stuffing and bad-mouthing [13]. Tosh et al. contextualized block withholding attacks within blockchain cloud architectures, accounting for disparate pool reward dynamics [14]. A novel threat vector, termed the balance attack, was introduced by Natoli et al., targeting forkable blockchain infrastructures [15]. Subsequent contributions by Budish et al. and Dey et al. delved into the economic constraints of Bitcoin and proffered machine learning frameworks to starve off a majority of blockchain-centric threats [16,17]. For bolstered security, Rathore et al. advocated for an integrated architecture merging Software Defined Networking with blockchain. This approach amplified the prowess for detecting threats within IoT ecosystems [18].
Based on previous research, this paper enhances the result of the extant literature [2,4,5,19,20,21,22,23] by introducing a bespoke game-theoretic mechanism, specifically crafted to neutralize sandwich attacks within market-centric environments.

3. Preliminary Work

In the context of the swift evolution of blockchain technology and DeFi, DEX have emerged as a focal component, attracting considerable attention. Nevertheless, the inherent openness and transparency of DEX inadvertently provide avenues for malevolent actors, with sandwich attacks standing out as the most prevalent one. In this section, we elucidate the intricacies of the sandwich attack, review the existing literature, and emphasize the significance of mechanism design in DEX.

3.1. Principles of the Sandwich Attack

At its core, the sandwich attack involves an attacker strategically positioning their transactions around a victim’s transaction to capitalize on price variances. The attacker initially inflates the asset’s price with the transaction (1), waits for the victim’s transaction to materialize and subsequently deflates the asset’s price with the transaction (3), thereby securing a profit.
(1)
Scenario without an Attack:
s 0 T r a n s a c t X F o r Y δ x V x * , y * ,   δ y V = y 0 y *
x * = x 0 + δ x V , y * = x 0 y 0 x 0 + δ x V c x s 0 , δ x V + c y s 0 , δ y V
The victim sent a transaction (2) using δ x V of x transformation of δ y V of y; the underlying Automated Market Maker (AMM) market starts from s 0 = ( x 0 , y 0 ) ; the market becomes a x * , y * state without any unexpected price sliding points caused by the attack.
(2)
Scenario with an Attack: The attacker’s initial state is ( θ δ x A 1 , 0 ) . They initiate the front-running transaction (1) and the subsequent transaction (3) to launch a sandwich attack. Let δ x A 1 be defined as the attack cost just sufficient for a single sandwich attack.
s 0   T r a n s a c t X F o r Y   θ δ x A 1 s 1 = x 1 , y 1 , δ y A 1 = y 0 y 1 x 1 = x 0 + θ δ x A 1 , y 1 = x 0 y 0 x 1 c x s 0 , θ δ x A 1 + c y s 0 , θ δ x A 1
The attacker exchanges θ δ x A 1 of x for δ y A 1 of y. Starting from the underlying AMM market state s 0 = ( x 0 , y 0 ) , the market transitions to state s 1 = ( x 1 , y 1 ) .
s 1   T r a n s a c t X F o r Y   δ x V s 2 = x 2 , y 2 , δ y V = y 1 y 2
x 2 = x 1 + δ x V , y 2 = x 1 y 1 x 2 c x s 1 , δ x V + c y s 1 , δ x V
Due to the front-running transaction, when executing the (2) transaction, the market state is no longer the initially assumed s 0 , but s 1 = ( x 1 , y 1 ) . Modifying the original (2) transaction formula by replacing s 0 with s 1 , we obtain the new market state s 2 = ( x 2 , y 2 ) .
s 2   T r a n s a c t Y F o r X   δ y A 2 s 3 = x 3 , y 3 , δ x A 2 = x 2 x 3 x 3 = x 2 y 2 y 3 c y s 2 , δ y A 2 + c x s 0 , δ y A 2 , y 3 = y 2 + δ y A 2
After the victim’s transaction is executed, the attacker’s subsequent transaction (3) is executed. The attacker exchanges δ y A 2 of Y for X. Starting from the market state s 2 = ( x 2 , y 2 ) , the market transitions to state s 3 = ( x 3 , y 3 ) . Ultimately, the attacker obtains a profit of δ y A 2 in X. The attacker’s profit is calculated by subtracting the attack cost from the X currency amount obtained after the attack, which is written as follows:
p r o f i t = δ x A 2 θ δ x A 1 .

3.2. Introduction to Mechanism Design Game Theory

Mechanism design game theory, a prominent subfield of economics, investigates the formulation of mechanisms that ensure that the participants’ optimal strategies coincide with the designer’s objectives. Within the sphere of DeFi, such designs are indispensable. This is primarily due to the information asymmetry between the market and its participants, which holds the potential for engendering malicious actions. Ideally, if the market possessed complete knowledge of a participant’s intentions—including potential malevolent plans—it could proactively design deterrent strategies. Yet, participants frequently withhold full disclosure, fearing privacy breaches or strategic exposure. This discrepancy presents a critical challenge: how can one construct a mechanism that safeguards participant privacy and mitigates malevolent actions? The answer lies in mechanism design game theory, particularly in its revelation principle. This principle asserts that, for every Bayesian Nash equilibrium, a corresponding direct mechanism exists wherein participants genuinely reveal their information. Consequently, one can effectively thwart malevolent endeavors by crafting a direct mechanism that incentivizes participants to disclose their intentions honestly. This study conceptualizes the market as the principal and the participants as the players. The principal’s mandate is to curate a mechanism encouraging the players to transparently convey their data, enabling the market to strategize and optimize its returns.

3.3. Introduction to the Problem

To describe this problem more concretely, we introduce some mathematical notations. We use R to represent the market and W to represent the set of workers. Each worker wi has a type z i = c i , T i , where Ci is the worker’s total assets, and Ti is his intention to attack. The types of all the workers form a type of space Z = i W Z i . The information that worker wi reports to the market is represented as g i G i , where g i is the worker’s strategy, a function of the worker’s true type zi. The strategies of all the workers form a strategy space G = i W G i . The market produces an output yi based on these strategies, and all the outputs form an output space Y = i W y i . In this framework, our goal is to design a mechanism, a mapping from strategy space G to output space Y. The devised mechanism ought to meet two essential criteria: firstly, it must optimize the market’s utility, and, secondly, it must ensure that the most strategic approach for the participants is to relay their information truthfully. Specifically, h i g i is the requester’s strategy, and h i H is the mechanism strategy space. u R ( h i g i ) : Y R   is seen as the utility of the market, while u w i ( h i g i ) : Y R is seen as the utility of the workers.

3.4. General Framework to Counteract Sandwich Attacks

Given the escalating occurrence of sandwich attacks in the DeFi landscape, there is an imperative need for a holistic and robust strategy to neutralize them. A proficient strategy should not only detect and preempt these assaults but also guarantee that the DeFi environment retains its transparency, decentralization, and user-centricity.
Our proposed holistic strategy addresses the technical nuances and behavioral dynamics of sandwich attacks. Technologically, we incorporate sophisticated surveillance tools harnessing machine learning methodologies to discern anomalous trading activities instantaneously. These instruments are adept at pinpointing impending sandwich attacks, and facilitating swift counteractions.
Moreover, we champion the incorporation of transaction latency protocols. The attacker’s anticipated trajectory can be unsettled by instating a minor, randomized latency to every transaction. Even a slight delay could dissuade potential attackers while posing minimal disruption to regular traders.
Behaviorally, our strategy underscores the importance of trader education. By equipping traders with comprehensive insights into sandwich attacks, through resources and tools, they can be empowered to make judicious choices and adopt prudent trading habits. This encompasses instructive guides, illustrative case studies of sandwich attacks, and trading safety protocols.
Lastly, we advocate a communal approach to tackling these onslaughts. Envisioning a platform where users can flag dubious activities, recount their encounters, and brainstorm solutions can cultivate a communal front against adversarial elements. Harnessing the shared expertise and alertness of the DeFi populace can usher in a fortified, resilient ecosystem.

3.5. The Rise of DeFi

DeFi has emerged as a transformative paradigm within the financial landscape, heralding a transparent, permissionless, open-source financial service ecosystem. Operating devoid of central authority, this model ensures global inclusivity in accessing financial services. The catalyst propelling DeFi’s meteoric ascent is the Ethereum blockchain, which facilitates the deployment of smart contracts—self-executing contracts with predetermined conditions. These contracts have enabled many novel, transparent, and censorship-resistant financial offerings.

3.6. The Role of DEX in DeFi

DEX within the DeFi spectrum signify a profound evolution in finance. Capitalizing on blockchain technology, DeFi platforms provide financial services, bypassing conventional intermediaries such as banks. This democratization broadens the accessibility of financial instruments to an expansive global audience.
Several dynamics underpin DeFi’s ascendancy. Primarily, the innate transparency and robust security features of blockchain render it a compelling alternative to established financial architectures. Activities are cataloged on a public ledger ensuring transparency, while cryptographic methodologies undergird its security and integrity.
Furthermore, DeFi introduces groundbreaking financial instruments and services absent in classical financial systems. Mechanisms from yield farming to liquidity mining permit users’ novel avenues for asset appreciation, a departure from conventional modalities. Compounded by the automation capabilities of smart contracts, operational costs diminish while efficiency soars.
Nevertheless, DeFi’s exponential growth is not devoid of hurdles. Given its emergent phase, many platforms have yet to weather real-world exigencies, leading to vulnerabilities—with sandwich attacks epitomizing such pitfalls. As the DeFi domain advances, it is imperative to confront these challenges robustly, maintaining the integrity and trustworthiness of the ecosystem.
The prospects of DeFi are vast, heralding a more inclusive, agile, and lucid financial framework. However, the risks stemming from malicious exploits and system vulnerabilities must be preemptively addressed to harness their full potential.

3.7. Sandwich Attacks: A Growing Concern

Sandwich attacks, an emergent form of market manipulation, have raised substantial concerns within the DeFi realm. These attacks capitalize on the transparent sequencing of blockchain transactions, enabling malicious entities to leverage other traders’ actions preemptively. At its core, an attacker identifies an impending significant transaction, strategically positioning their trades before and after the target, thereby “sandwiching” it. This strategy facilitates price manipulation in favor of the attacker, potentially yielding substantial profits.
For example, attackers would buy the asset that users are exchanging, e.g., using Chainlink to exchange for Ether (ETH), knowing that the price of ETH is increasing. The criminals then purchase ETH at a lower price so that the victim can purchase it at a higher price. The attacker then sells the ETH at a higher price. This affects the amount of ETH the initial user will receive. Since the attackers managed to execute the order at the price they wanted, the cost of the following trade would be higher. This causes the price of ETH to increase, allowing attackers to profit by trading traders back and forth and artificially creating a price increase.
The underpinnings of sandwich attacks are intricately linked to blockchain transaction processing. Given that transactions are appended to the blockchain in aggregated “blocks”, a temporal window emerges wherein attackers discern pending transactions and strategize. Herein, the deterministic transparency of blockchain, typically its forte, is paradoxically a vulnerability.
As the DeFi ecosystem amplifies in traction and valuation, the lucrative allure of successful sandwich attacks intensifies, magnetizing malicious entities keen on exploiting such weak points. This trajectory not only imperils individual traders financially but also erodes trust in decentralized frameworks. For DeFi to fully manifest its promise, it is essential to confront and neutralize such challenges proactively.

3.8. The Need for Mechanism Design in DeFi

The inherent decentralization of DeFi platforms demands avant-garde strategies to safeguard security and equity. Colloquially termed “reverse game theory”, mechanism design involves sculpting a game with meticulous rules tailored to yield specific outcomes, even amidst participants pursuing self-centered objectives. Within DeFi, this translates to architecting infrastructures such that overarching system equity and integrity prevail irrespective of participants’ potentially self-serving or malevolent actions.
DeFi’s decentralized framework implies the absence of a centralized arbitrator to instate rules or penalize ill-intentioned players. This void in centralized governance renders traditional fairness and security safeguards, such as regulations or supervisory entities, impotent. Consequently, the inherent system protocols must be resilient to counteract malevolent conduct.
By harnessing mechanism design, we can cultivate DeFi platforms where optimal strategies for individual actors (traders, liquidity contributors, or prospective adversaries) synchronize with the platform’s collective optimum. This might encompass architecting fee models that dissuade sandwich attacks, incentivizing user-driven suspicious activity reporting, or pioneering trading algorithms impervious to recognized threats.
Moreover, as the value managed by DeFi platforms escalates, so do the stakes. An isolated vulnerability or systemic design oversight can trigger monumental fiscal setbacks and reputational dents. Ergo, integrating mechanism design within DeFi transcends mere academic contemplation—it crystallizes as a pragmatic imperative, anchoring the enduring credibility and reliability of decentralized finance constructs.

4. In-Depth Discussion on Utility Functions

4.1. Market Utility

Within the blockchain ecosystem, the market functions as a liquidity provider. Such liquidity is realized through a series of transactions and operations, with the fee revenue, v t , being paramount. This revenue represents the gains the market accrues from liquidity over time, t. In the majority of DEX, the fee revenue v t is predominantly derived from the following three components:
  • Market value l ( t ) : This part mainly relates to the fluctuation of the coin price. It is determined using Formula (1) p 1 × p 2 = k . For stablecoins, since their value is relatively stable, this part is not considered.
  • Governance token value z ( t ) : This part is time-dependent, reflecting the value of the governance token over time.
  • Transaction-related part g ( t ) : This part is the product of transaction volume, coin price, and fee sharing divided by the total value locked.
Given the above, the fee revenue is calculated according to the following function:
v t = l t + z t + g t
Given the market’s inherent unpredictability and persistent volatility concerning coin prices, we adopt the Geometric Brownian Motion model. This model, a widely recognized stochastic differential equation within stochastic processes, aptly characterizes such volatility.
Obviously, a market’s currency price continuously fluctuates and has a certain degree of randomness. Therefore, we introduce the Geometric Brownian Motion model, a commonly used stochastic differential equation in stochastic processes.
d S t S t = μ t + σ d B t
In the above equation, S   ( t ) is the currency price at time t ; μ is the return on asset S; σ denotes the volatility of asset S , and B   ( t ) is a standard Brownian Motion that follows the normal distribution of N (0,1). The solution of this differential equation is as follows:
S t = S 0 e μ σ 2 2 t + σ B t
After that, we will modify the formula for handling fee income. If S   ( t ) is defined as the token price at time t , then l   ( t ) , z   ( t ) , g   ( t ) can be rewritten as l t = α · S 1 t + β · S 2 t , where α · β =   k , and z t = λ · S ( t ) represents the quantity of two types of tokens separately, and λ governs the number of tokens. g t = ρ · S t · c / t v l , where ρ is the trading volume, and ρ , c , and (2) are the constants.
As a simplification, the fee revenue v(t) can be obtained through the following equation:
v t = ρ · c t v l + λ + α + β · S t
For the market, whenever an attack occurs, it will cause damage. We view the impact of the attack on the market as an impact on the health of the market, including liquidity conditions and so on. We use k   ( t ) to describe this indicator, which can be calculated using the following equation:
k t = ω 1 b t + ω 2 a t + ω 3 m t
where b   ( t ) denotes (2); a ( t ) denotes the number of active addresses, and m   ( t ) is the 24 h trading volume; ω i is the weight coefficient toward each component, which can be determined using common methods such as the Analytic Hierarchy Process. Because short selling is also a type of trading, which can be both long and short, it is not possible to directly relate a   ( t ) and m   ( t ) to the prices. Considering that volatility is usually described using variance in statistics, we denote a   ( t ) and m   ( t ) with variance V a r [ S 1 t ] of S 1 t multiplied by different coefficients as shown below.
a t = δ · V a r S 1 t ,   m t = η · V a r S 1 t
Then, k   ( t ) can be expressed as
k t = ω 1 · t v l + ω 2 · δ + ω 3 · η · V a r S 1 t
The variance of S 1 t can be obtained with the following equation:
V a r S 1 t = S 1 0 2 e 2 μ t e σ 2 t 1
Based on the physical meanings of two sandwich attack strategies, h i g i is abbreviated as h   ( t ) . Canceling an order will have an impact on both the commission income v   ( t ) and the health level p   ( t ) . We construct a function n   ( t ) to describe the impact of canceling orders on the market. The more cancellations, the more negative the impact, where n is the given parameter.
n t = n 1 θ h t + h 0
Until now, the market utility can be written as
U R = 0 T x _ x ¯ v t + k t · d · n t · f x d x d t
where d is the given parameter showing the difference caused by the impact of canceling the order on the two variables. f ( x ) is the probability density function of w i ’s attack intention calculated based on historical data. Without historical information, the statistical data of all the workers providing services to requesters can be used to approximate f   ( x ) and normalize the value of x to between [0, 1]. All the workers x of w i have a maximum and minimum value.

4.2. Worker Utility

In this section, “workers” predominantly denotes traders. We operate under the assumption that all the workers act rationally. Thus, they will determine whether to initiate an attack and the amount of tokens to allocate based on maximizing their interests. We delineate this behavior using the profit function during the sandwich attack process, denoted as p(θ), which has been mentioned previously. Grounded in these assumptions, the subsequent equation encapsulates the utility of the workers:
U w = 0 T ( p θ · μ θ h ( t ) · o ) d t
where h ( t ) is the market’s strategy, and μ ( θ ) is a sigmoid function measuring the attack intention of the worker.
μ θ = 1 1 + e α θ θ 0
where o is a parameter representing the loss from canceling a single order.

5. Market-Led Mechanism Design Game Theory

In this section, we integrate the previously discussed utility functions, applying mechanism design game theory to derive the optimal strategies for both the market and the workers. Subsequently, we examine the equilibrium conditions of these strategies.

5.1. Market’s Optimal Strategy

To optimize the market’s benefits, it is essential first to define its utility function, which is a function of both the market’s and the workers’ strategies. Specifically, we utilize the following formulation to maximize the market’s benefits:
m a x U R = 0 T x ¯ x ¯ [ ( v t + k ( t ) * d ) · n ( t ) · f ( x ) ] d x d t = 0 T R h t d t
where R h t = x _ x ¯ [ ( v t + k t · d ) · n t · f x ] d x . In order to cause U R to maximize, we use the Euler–Lagrange equation for the solution.
R h d d t R h = 0
Due to the absence of a first derivative for h t , the Euler–Lagrange equation degenerates into R h = 0 and, hence, we have
h * g = n 1 g x ¯ x ¯ v t + d · k t 2 h 0
After substituting v   ( t ) and k   ( t ) into the union simplification, we obtain the optimal strategy for the market as
h * g = n 1 g x ¯ x ¯ ρ · c t v l + λ + α + β · S t + d · ω 1 · t v l + ω 2 · δ + ω 3 · η · V a r S t 2 h 0

5.2. Worker’s Optimal Strategy

In parallel with the market’s strategy, it is imperative to define the worker’s utility function, which is contingent upon both the worker’s and the market’s strategies. We propose the following optimization problem for workers:
max U w = 0 T ( p θ · μ θ h t ) * o d t
By substituting the optimal strategy h * ( g ) of the market, we obtain the optimal strategy for the workers denoted using
g = g * .  
Due to the complexity of the analytical solution for g , which is limited by its length and overall appearance, we use   g * instead.

5.3. Equilibrium Analysis

To prove that the solutions above are the optimal choices for the market and the workers, it is crucial to verify that our solution outputs the largest utility for each stakeholder. Equivalently, the following inequalities holds
R h     0 ,   2 R h 2     0
Due to space limitations, we will not present the full proof on the main page. The central idea is solving the Hessian matrix of R for h , corresponding to this Hessian matrix being semi-positive definite or using the definition of a convex function directly. Thus, R is a convex function of h ; hence, its second-order partial derivative is less than or equal to zero.

6. Evaluation

The ascent of DeFi has marked DEX as being pivotal in finance. However, the inherent openness of DEX exposes them to manipulations like sandwich attacks, where malicious actors exploit price slippage for unfair gains. Building upon existing research, Liu et al. have applied the Stackelberg game and presented efficient mechanisms to analyze the pricing and workload allocation optimization for malicious behavior in crowdsourcing cases [24,25]. However, the research on the interactions between the market and the players in the adversarial sandwich attack setting is under-explored. Heimbach et al. proposed an algorithm for traders to circumvent most sandwich attacks, but it fails to consider the market’s profit [1]. This paper presented the utility functions of both the market and the workers and solved their utility optimization problems through a cooperative mechanism design. The closed-form optimal strategies are provided, which ensure truthful behavior in the equilibrium and creates a safer and more efficient trading environment within the DeFi sector.

6.1. Effectiveness Analysis

The game-theoretic model of mechanism design developed in the paper employs foundational principles from empirical economics and game theory [26,27] to allow the organizer to set up a mechanism (game rules) between the market and the workers which is predicated on the maximization of the market’s benefit, a function that is obtained using the variational method of solving the general function of the market’s benefit function defined on a generalized function space. The principles underlying cryptocurrencies and blockchain technology [28,29] further inform this model, ensuring that the market’s strategy will always be optimal, regardless of how a worker implements it. With this generalization in mind, the worker substitutes this mechanism into his benefit function and then solves it for his optimal strategy. In fact, the optimal solution obtained by the market is an optimal strategy space, and, no matter how the worker changes his strategy, he is in the optimal strategy space of the market. Both optimal strategies are obtained by taking derivatives. In particular, since the market’s benefit function is generalized, it is variationally differentiated and solved according to the Euler–Lagrange equation. By proving that the second-order derivative is less than zero, it can be introduced that both strategies maximize benefits, i.e., Nash equilibrium.

6.2. Security Analysis

The market is the rule maker of the game; this is based on the reality that workers who want to trade in the market have to abide by the rules set by the market, therefore ensuring that the rules of the game will be implemented correctly [30]. In establishing the workers’ benefit function, we have assumed that all the workers are rational—i.e., they will all maximize their benefits as their strategy. Under such a premise, the workers will choose their optimal strategy under the mechanism developed by the market. Based on the effectiveness analysis from the previous section, the workers choose the optimal strategy, meaning that the market can obtain the corresponding optimal strategy in the optimal strategy space and reach the Nash equilibrium, which maximizes the benefits for both.

6.3. Practical Application

When no mechanism is used to design a game theory model, a worker who finds a profitable order put forward by a user will launch a sandwich attack to take advantage of it. This causes the user to experience higher unexpected price slippage, resulting in severe financial losses, and also negatively damages the trading market by lowering the market’s fee earnings and corrupting the market’s reputation, which is negative for the market’s health [31]. That is why it is said that the market will act through some means, such as canceling the user’s orders to limit the attacks on the workers. However, this will also reduce the benefits of the market. Neither the market nor the workers will maximize their benefits in this blind confrontation.
The difference is that by applying mechanism design game theory, when the workers find a profitable order placed by a user, they formulate their strategies based on the benefit function. The market will then obtain the corresponding optimal strategy in the optimal strategy space so that both the market and the workers can have their optimal strategy. Each of them will reach their relative maximum benefit. Overall, this model achieves the following: it ensures that the market’s interests are not compromised; it thwarts some sandwich attacks; and it prevents users from over-experiencing unexpected price slippage, which would otherwise result in severe economic losses.

7. Conclusions

The inherent openness and decentralization of DeFi streamline transactions on DEX. However, these qualities also render it vulnerable to malicious sandwich attacks, which hinder the advancement of blockchain finance and smart contracts.
In response to this challenge, we introduce a method grounded in mechanism design game theory where the market serves as the rule-setter by optimizing its utility. Under this mechanism, the market can induce the workers to choose its optimal solution, maximizing the market’s profit. We calculated the closed form solution for the market and the workers through a convex optimization.
Our method not only seeks to enhance market returns but also addresses the interests of the workers, thus striking a harmonious balance. Collectively, our study presents a novel and efficacious approach for mitigating sandwich attacks in the DeFi sector, potentially fostering the evolution of blockchain finance and smart contracts.

Author Contributions

Conceptualization, Y.L. and X.W.; methodology, X.W.; formal analysis, Y.C.W. and M.Z.; writing—original draft preparation, Y.L.; writing—review and editing, Y.C.W. and M.Z.; supervision, X.W. and H.F.; project administration, H.F. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The data that support the findings of this study are available from the corresponding author upon reasonable request.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Heimbach, L.; Wattenhofer, R. Eliminating sandwich attacks with the help of game theory. In Proceedings of the 2022 ACM on Asia Conference on Computer and Communications Security, Nagasaki, Japan, 30 May–2 June 2022; pp. 153–167. [Google Scholar]
  2. Saad, M.; Spaulding, J.; Njilla, L.; Kamhoua, C.; Shetty, S.; Nyang, D.; Mohaisen, D. Exploring the Attack Surface of Blockchain: A Comprehensive Survey. IEEE Commun. Surv. Tutor. 2020, 6, 3451–3463. [Google Scholar] [CrossRef]
  3. Tang, B.; Fu, H.; Wu, Y.C. On reservation prices in the all-pay contest with correlated information. Manag. Decis. Econ. 2023, 44, 3932–3943. [Google Scholar] [CrossRef]
  4. Saad, M.; Spaulding, J.; Njilla, L.; Kamhoua, C.; Shetty, S.; Nyang, D.; Mohaisen, A. Exploring the Attack Surface of Blockchain: A Systematic Overview. arXiv 2019, arXiv:1904.03487. [Google Scholar]
  5. Liu, Z.; Li, Z. A Blockchain-based Framework of Cross-border E-commerce Supply Chain. Int. J. Inf. Manag. 2019, 52, 128–139. [Google Scholar] [CrossRef]
  6. Sandler, T.; Arce, M.D.G. Terrorism & Game Theory. Simul. Gaming 2003, 34, 319–337. [Google Scholar]
  7. Zhuang, J.; Bier, V.M. Balancing Terrorism and Natural Disasters Defensive Strategy with Endogenous Attacker Effort. Oper. Res. 2007, 55, 976–991. [Google Scholar] [CrossRef]
  8. Liang, X.; Xiao, Y. Game Theory for Network Security. IEEE Commun. Surv. Tutor. 2013, 1, 256–263. [Google Scholar] [CrossRef]
  9. Zonouz, S.; Khurana, H.; Sanders, W.H.; Yardley, T. RRE: A Game-Theoretic Intrusion Response and Recovery Engine. IEEE Trans. Parallel Distrib. Syst. 2014, 1, 341–353. [Google Scholar] [CrossRef]
  10. Shamshirband, S.; Patel, A.; Anuar, N.B.; Kiah, M.L.M.; Abraham, A. Cooperative Game Theoretic Approach Using Fuzzy Q-learning for Detecting and Preventing Intrusions in Wireless Sensor Networks. Eng. Appl. Artif. Intell. 2014, 32, 228–241. [Google Scholar] [CrossRef]
  11. Yuan, Y.; Yuan, H.; Guo, L.; Yang, H.; Sun, S. Resilient Control of Networked Control System Under DoS Attacks: A Unified Game Approach. IEEE Trans. Ind. Inform. 2016, 12, 1786 –1794. [Google Scholar] [CrossRef]
  12. Sandberg, H.; Amin, S.; Johansson, K.H. Cyberphysical Security in Networked Control Systems: An Introduction to the Issue. IEEE Control. Syst. Mag. 2015, 35, 20–23. [Google Scholar]
  13. Cai, Y.; Zhu, D. Fraud Detections for Online Businesses: A Perspective from Blockchain Technology. Financ. Innov. 2016, 2, 20. [Google Scholar] [CrossRef]
  14. Tosh, D.K.; Shetty, S.; Liang, X.; Kamhoua, C.A.; Kwiat, K.A.; Njilla, L. Security Implications of Blockchain Cloud with Analysis of Block Withholding Attack. In Proceedings of the 17th IEEE/ACM International Symposium on Cluster, Madrid, Spain, 14–17 May 2017; pp. 1–8. [Google Scholar]
  15. Natoli, C.; Gramoli, V. The Balance Attack or Why Forkable Blockchains Are Ill-Suited for Consortium. In Proceedings of the 2017 47th Annual IEEE/IFIP International Conference on Dependable Systems and Networks (DSN), Denver, CO, USA, 26–29 June 2017; pp. 128–136. [Google Scholar]
  16. Budish, E. The Economic Limits of Bitcoin and the Blockchain. Int. Political Econ. Glob. J. 2018, 1–9. [Google Scholar] [CrossRef]
  17. Dey, S. Securing Majority-Attack in Blockchain Using Machine Learning and Algorithmic Game Theory: A Proof of Work. In Proceedings of the 2018 10th Computer Science and Electronic Engineering (CEEC), Colchesterm, UK, 19–21 September 2018. [Google Scholar] [CrossRef]
  18. Rathore, S.; Kwon, B.W.; Park, J.H. BlockSecIoTNet: Blockchain-based Decentralized Security Architecture for IoT Network. J. Netw. Comput. Appl. 2019, 143, 167–177. [Google Scholar] [CrossRef]
  19. Zhou, L.; Qin, K.; Torres, C.F.; Le, D.V.; Gervais, A. High-Frequency Trading on Decentralized On-Chain Exchanges. In Proceedings of the 2021 IEEE Symposium on Security and Privacy (SP), San Francisco, CA, USA, 24–27 May 2020. [Google Scholar]
  20. Wang, Y.; Zuest, P.; Yao, Y.; Lu, Z.; Wattenhofer, R. Impact and user perception of sandwich attacks in the defi ecosystem. In Proceedings of the 2022 CHI Conference on Human Factors in Computing Systems, New Orleans, LA, USA, 29 April–5 May 2022; pp. 1–15. [Google Scholar]
  21. Züst, P.; Nadahalli, T.; Wattenhofer, Y.W.R. Analyzing and Preventing Sandwich Attacks in Ethereum. ETH Zürich 2021. Available online: https://pub.tik.ee.ethz.ch/students/2021-FS/BA-2021-07.pdf (accessed on 20 August 2023).
  22. Yuan, S.; Li, J.; Liang, J.; Zhu, Y.; Yu, X.; Chen, J.; Wu, C. Sharding for blockchain based mobile edge computing system: A deep reinforcement learning approach. In Proceedings of the 2021 IEEE Global Communications Conference (GLOBECOM), Madrid, Spain, 7–11 December 2021; pp. 1–6. [Google Scholar]
  23. Yuan, S.; Li, J.; Wu, C. Jora: Blockchain-based efficient joint computing offloading and resource allocation for edge video streaming systems. J. Syst. Archit. 2022, 133, 102740. [Google Scholar] [CrossRef]
  24. Liu, C.; Wang, S.; Ma, L.; Cheng, X.; Bie, R.; Yu, J. Mechanism design games for thwarting malicious behavior in crowdsourcing applications. In Proceedings of the IEEE Infocom 2017-IEEE Conference on Computer Communications, Atlanta, GA, USA, 1–4 May 2017; pp. 1–9. [Google Scholar]
  25. Liu, C.; Wang, S.; Wang, C.; Bie, R.; Shin, D. Stackelberg game based optimal workload allocation and pricing mechanism in crowdsourcing. In Proceedings of the 2016 IEEE International Conferences on Big Data and Cloud Computing (BDCloud), SocialComputing and Networking (SocialCom), Sustainable Comput-ing and Communications (SustainCom)(BDCloud-SocialCom-SustainCom), Atlanta, GA, USA, 8–10 October 2016; pp. 193–200. [Google Scholar]
  26. Catalini, C.; Gans, S. Some Simple Economics of the Blockchain. J. Econ. Perspect. 2018, 32, 79–102. [Google Scholar]
  27. Roth, A.E. Game Theory as a Part of Empirical Economics. Econ. J. 2013, 123, 25–40. [Google Scholar] [CrossRef]
  28. Nakamoto, S. Bitcoin: A Peer-to-Peer Electronic Cash System. 2008. Available online: https://bitcoin.org/bitcoin.pdf (accessed on 20 August 2023).
  29. Buterin, V. A Next-Generation Smart Contract and Decentralized Application Platform. White Paper, 2013. Available online: https://ethereum.org/en/whitepaper/ (accessed on 20 August 2023).
  30. Wu, X.; Xie, X.; Zhang, H.; Wang, Y.; Tao, X. DeFiRanger: Detecting Price Manipulation Attacks on DeFi Applications. J. Blockchain Secur. Appl. 2021, 4, 45–60. [Google Scholar]
  31. Amini, M. A Game Theory Method to Cyber-Threat Information Sharing in Cloud Computing Technology. Int. J. Comput. Sci. Eng. Res. 2023, 11, 45–60. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Liang, Y.; Wang, X.; Wu, Y.C.; Fu, H.; Zhou, M. A Study on Blockchain Sandwich Attack Strategies Based on Mechanism Design Game Theory. Electronics 2023, 12, 4417. https://doi.org/10.3390/electronics12214417

AMA Style

Liang Y, Wang X, Wu YC, Fu H, Zhou M. A Study on Blockchain Sandwich Attack Strategies Based on Mechanism Design Game Theory. Electronics. 2023; 12(21):4417. https://doi.org/10.3390/electronics12214417

Chicago/Turabian Style

Liang, Yuxuan, Xukang Wang, Ying Cheng Wu, Hongpeng Fu, and Mengjie Zhou. 2023. "A Study on Blockchain Sandwich Attack Strategies Based on Mechanism Design Game Theory" Electronics 12, no. 21: 4417. https://doi.org/10.3390/electronics12214417

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop