Incentive Mechanism Design for Mitigating Frontrunning and Transaction Reordering in Decentralized Exchanges

Decentralized exchanges (DEXes) provide effective price discovery and fair trading while dealing with the drawbacks of centralized exchanges, e.g., lack of transaction transparency and exclusive control of user assets and transaction fees. However, many DEXes suffer from frontrunning and transaction reordering, which fundamentally flaw their design. In this paper, we present a novel incentive mechanism design for mitigating frontrunning and transaction reordering even if frontrunners pay high transaction fees in DEXes. We utilize a weighted counting sort algorithm to order transactions based on the users’ multi-dimensional private information (e.g., transaction delay and confidentiality). To elicit users’ private information, we consider a multi-dimensional contract-theoretic design based on the users’ willingness to share their private information. We show that the miner can always maximize its utility under the complete and incomplete information scenarios. We implement solutions to our multi-dimensional contract and sorting algorithm on a decentralized oracle network to create a decentralized system and design a web application to extensively evaluate the performance of our proposed incentive mechanism. We further show that ordering transactions based on users’ private information increases the miner’s utility by $78.42\%-84.57\%$ and reduces the users’ cost by 64.47% compared with the state-of-the-art fair sequencing services, automated arbitrage market maker, and miner extractable value auctions.


I. INTRODUCTION A. BACKGROUND AND MOTIVATIONS
Blockchains have gained significant traction in diverse areas over the few years. Many users have rushed to build innovative solutions on blockchains, such as bitcoin and ethereum. In particular, blockchains feature the key benefits of transaction decentralization, transparency, tokenization, and anonymity for a more reliable exchange of value among participants [1]. Blockchains also provide the essential platform for decentralized exchanges (DEXes), which enable users to buy and sell cryptocurrencies without the need The associate editor coordinating the review of this manuscript and approving it for publication was Abderrezak Rachedi .
for brokers [2]. While these are the marks of blockchain's tremendous success, certain behaviors of miners, such as reordering transactions to maximize their block utilization and profits, lead to higher transaction costs and longer mining delay for users. Also, transactions become more vulnerable to frontrunning as they languish in the mempool.
Furthermore, Daian et al. neologized the term miner extractable value (MEV) to express the various possibilities of using adversarial ordering optimization (AOO) to extract money from a blockchain smart contract system [3]. Recent investigations have determined that at least 28.8M USD was taken from MEV over the past decade [4]. Usually, the term MEV is closely associated with miners because they hold unlimited power to order transactions in a block. At the 1 Sandwiching involves placing orders before and after a transaction. The attacker front-runs and back-runs concurrently, sandwiching the original pending transaction. 2 A DON is a collection of autonomous blockchain oracles that supply data to a blockchain and eliminates single points of failure in smart contracts. preferences are characterized by how long they can wait in a queue until their transactions are mined, which is often unknown to the miner, especially when there are several heterogeneous users. The confidentiality of users' transactions is also users' private information and will not be easily accessed by the miner due to privacy concerns. Although the miner may not know each user's private information, it may obtain certain statistics of such information from market research and transaction histories [15]. For instance, the miner may know the user type distributions (which is referred to as an incomplete information in this paper). Different levels of information asymmetry require the miner to design different optimal strategies to achieve the highest possible utility. Therefore, motivated by the preceding discussion, we ask and attempt to answer the following questions in this paper: 1) How could transactions be ordered on the blockchain network to avoid MEV centralization and extraction? 2) How should users with multi-dimensional private information be incentivized to encourage honest behaviors? 3) How could transaction ordering and multi-dimensional contracts be implemented on the blockchain platform?

B. CONTRIBUTIONS
Contract theory is considered to be an effective approach for designing incentive mechanisms under asymmetric information scenarios [16]. Therefore, we leverage contract theoretic techniques to design an incentive mechanism with the users' multi-dimensional private information to encourage ethical behaviors in the blockchain network. Firstly, we characterize the user types based on their multi-dimensional private information (transaction delay and confidentiality), which can help the miner make effective decisions to maximize its utility. Secondly, we provide a contract design under the complete information scenario and incomplete information scenario to users based on the willingness to share their private information with the miner. 3 This contract design extracts the users' private information necessary for an efficient transaction ordering stage. Next, we deploy a weighted counting sort algorithm to order transactions on the blockchain network based on the users' private information. Expressly, our multidimensional contracting and transaction sorting algorithm are jointly achieved via a DON to prevent MEV centralization and extraction. The DON forwards transactions to a mempool after ingesting them and reaching a consensus on the transaction order based on users' private information. We term this integrated system as weighted sequencing service (WSS) in the subsequent literature for simplicity.
To the best of our knowledge, this work is the first attempt to investigate the relationships between miners and users with multi-dimensional private information and related transaction ordering problems resulting from MEV. Compared to previous recent works, our contributions can be summarized as follows: • Transaction ordering mechanism design: We apply a weighted counting sort algorithm with very low computational complexity to order transactions based on user preferences from our multi-dimensional contract.
• Multi-dimensional contract design with users' private information: We design a multi-dimensional contract that elicits users' private information and overcomes the information asymmetry between the miner and users.
• Implementation of multi-dimensional contract and transaction ordering algorithm: We deploy the solutions to our optimal contract design and transaction ordering algorithm on a DON to demonstrate the feasibility of the real deployment of our proposed scheme.
• Experiment and results discussion: We develop a web application platform to experiment and evaluate the performance of our proposed mechanism gains compared with existing approaches.
The rest of the paper is organized as follows. Section III presents the system model and the preliminaries for our incentive mechanism design. We present our multidimensional contract formulations and closed-form solutions in Section IV. Section V introduces the transaction sorting algorithm for our proposed mechanism and overall system architecture. In Section VI, we illustrate the experiment results and analysis of our proposed mechanism, and finally, Section VII concludes our discussion.

II. RELATED WORKS
Blockchains have gained significant traction in diverse areas over the past few years. As such, several kinds of research have been centered on incentive mechanism designs in the blockchain aspect of this field of study. In [18], the authors proposed a data-sharing incentive model based on an evolutionary game theory using blockchain with a smart contract. The smart contract mechanism can control the excitation parameters in real time and encourage users to share data. The authors in [19] addressed a need for more understanding of the strategic behavior of rational processors within committees in shard-based consensus protocols by analyzing the behavior of processors using a game-theoretic model. In [20], the authors presented a reputation system called RTChain, which is integrated into the e-commerce blockchain to achieve a distributed consensus and transaction incentives.
Furthermore, in close relation to our work, the authors in [7] introduced fair sequencing service (FSS), a decentralized oracle network for fair user transaction sequencing based on the time of arrival, which improves the users' transaction latency. However, this transaction-ordering-based technique typically leads to poor income for miners and redundant MEV on the network (e.g., [7]). Secondly, the works in [8] and [9] presented an auction theoretic approach to mitigate MEV via auctioning the right to order transactions on the blockchain network. Nonetheless, these approaches result in ''managed centralization,'' where a single sophisticated party always wins the auction and captures all of the MEV (e.g., [8], [10], [11]). In [12] and [13], regulated transaction fees to lower user expenses. In [12] and [14], the authors presented an automated market maker (AMM) to reduce users' costs by leveraging smart contracts (SCs) to alter gas fees upon incoming transaction requests autonomously. The authors of [13] introduced an automated arbitrage market maker (A2MM) that selects the best-effort two-point arbitrage among various AMMs based on transaction costs. Generally, in feesoptimization-based systems, fees cannot be forecasted with 100% accuracy before submitting an order since requests may be executed on bridge reserves with higher fees without the user's knowledge [14].
Our work differs from [7], [8], [9], [12], [13], and [14] in that we consider a multi-dimensional contract-theoretic design based on the users' willingness to share their private information, which is used for sorting transactions to optimize the users' and miners' utilities. In principle, our proposed mechanism is a more practical approach to transaction reordering and frontrunning on blockchain networks. The authors in [21] proposed a consensus scheme called PoRF, which is based on a reputation-based consensus that allows for fair and random transaction selection. It aims to address the problem of dishonest nodes colluding with other nodes to prioritize their transactions over others, reducing their latency and improving their QoS. However, the authors fail to consider the existential users' and miners' information asymmetry levels.

III. SYSTEM MODEL
Consider a blockchain network with DON, users, and miners interacting via DEX contracts. We propose a contract-based incentive system to characterize the miners' and users' honest conduct under various information asymmetries. Users can choose from a range of contract items offered by the DON on behalf of the miners. Section III-A presents a modeling of the interaction between the DON, miners, and blockchain users. As our network model, we present the user types and contract preliminaries in Section III-B. In Section III-C, we provide the utility model, which specifies the users' payoffs and the miners' utility.

A. SYSTEM ARCHITECTURE
Consider an ethereum proof-of-work (PoW) network, which is composed of immutable ledgers protected by a decentralized network of computers, known as ''miners'' [22]. We can also apply the concepts from this work to other blockchain networks, such as proof of stake, as long as they support DEXes. These miners are responsible for cumulating pending transactions into blocks, which are subsequently validated by the entire network and added to a global ledger. New blocks of transactions are continuously generated, while the blockchain network ensures that all transactions are valid, e.g., no double-spending attacks. 4 Consequently, the blockchain network has a limited network downtime, which makes it challenging to guarantee that transactions will be ordered exactly as submitted on the blockchain [23]. Each block in the blockchain can only hold a certain number of transactions. Conventionally, miners have complete control over which pending transactions from the mempool they include in their blocks (an off-chain location for unconfirmed transactions). However, this autonomy brings with it the inherent issues associated with MEV.
In this work, we deploy the DON, which comprises a committee of blockchain responsible for handling any interaction between the miners and users. By severing the ability to order transactions from the ability to produce blocks with our DON, we can avoid malicious value extraction by miners or transaction frontrunning by users through predefined ordering policies. The DON provides real-world data to a blockchain through middleware and is also capable of simple computation on such data. To achieve our DON implementation, we adopt a chainlink platform that gives blockchain developers an easy-to-use framework for writing hybrid SCs that connect to external resources by combining on-chain and off-chain computation [24]. We refer to the implementation from [25] and [26] to construct our DON. For simplicity, we show a list of major symbols and their definitions in Table 1. Fig. 1 illustrates the typical DON, miner and users interaction on a blockchain network. 5 Users submit transactions to the mempool, and miners decide from the mempool on which transactions to include in their block of transactions and the transaction order. In Fig. 1, the variable T $ 1 represents a user transaction that arrives first with a gas fee $, where 4 Other methods can be employed in blockchains to prevent doublespending attacks. However, this problem is not the focus of this paper. 5 For simplicity, we consider multiple users and a miner in Fig. 1. However, all deductions extend to multiple miners. See Section VI-A for more on this extension. $ < $$ < $$$. This concept also holds for the subsequent transactions T $$ 2 , and T $$$ 3 . Generally, users send these transactions to the mempool for mining. With chainlink keeper functions, the DON orders unconfirmed transactions from mempool storage to the contract scheme contractedout number (SCON) for the miner [27]. The DON chainlink keeper functions provide a mechanism for executing basic blockchain network tasks [26]. Typically, a miner will select transactions solely based on the highest gas fees (the transaction fee), e.g., T $$$ 3 , T $$ 2 , and T $ 1 . As a result, a miner can extract extra profits from users by capitalizing on its ability to arbitrarily reorder transactions, creating what is generally referred to as MEV [4], [28]. The subsequent subsections provide the significant preliminaries required for our mechanism design.

B. NETWORK MODEL 1) USER'S TYPES
We consider a group of N users on the blockchain network, which are characterized by two-dimensional private information: the transaction confidentiality θ and the delay tolerance t. Different applications, e.g., stock trading, financial transactions, NFT, etc., require different confidentiality and delay tolerance levels. In this work, θ represents private information such as the transaction revenue or arbitrage opportunity observed by the user. For the convenience of presentation, we denote a user with multi-dimensional data µ i as µ i ≜ (θ i , t i ) as a type-i user for all users belonging to a set I = {1, · · · , I } of I types, 6 where θ i and t i represent the typei user's confidentiality and delay tolerance, respectively. Each user type i ∈ I comprises n i users, such that i∈I n i = N . Practically, users evolve with time and, therefore, will have 6 We refer to multi-dimensional contracts by P. Bolton for more on user types descriptions [16]. VOLUME 11, 2023 96017 Authorized licensed use limited to the terms of the applicable license agreement with IEEE. Restrictions apply. different individual preferences. However, we assume the user's type does not change for simplicity.
Due to the existence of diverse user private information, it is challenging for a miner to predict user behaviors without the information about each user's type. 7 To address this information asymmetry challenge, we propose a contract-theoretic approach that elicits private information from users.

2) CONTRACT FORMULATION
Contract theory is a promising and extensively used theoretic tool for addressing problems with private information. Hence, we introduce our contract formulation in this subsection.

3) MINER'S CONTRACT
The miner will offer a contract that stipulates the relationship among users' delay tolerance, transaction workload and cost. Concretely, contract C = (t max , ϕ) includes a maximum delay t max (for all user types) and I contract items ϕ for each user type, such that ϕ = {ϕ i } i∈I . Notation t max represents the maximum delay acceptable by users on the blockchain network, which can be achieved by setting verifiable delay functions (VDFs) on transactions [29], i.e., miners with t i ≤ t max can finish mining and propagating transactions in time. We specify the relationship between each type-i user's transaction workload and cost in each contract item ϕ i ≜ (ω i , r i ), where ω i and r i represent the transaction workload and the reward (e.g., money) for mining each type-i user's transaction, respectively, if the miner completes a transaction workload within the required time. We mention that the values of ω i and r i are functions of the mining resource demands, e.g., block size of user i's transaction denoted as s i , such that ω i = ω(s i ) and r i = r(s i ) [30]. The miner with t i > t max proposes a zero contract item for any type-i.

4) USERS' CHOICES
Before establishing the contract, each user decides on a delay tolerance level and an amount that it is willing to pay for its transaction, based on the transaction's confidentiality, e.g., how much revenue it can obtain from that transaction. Next, the user proceeds to choose a contract item that best describes its type or maximizes its payoff. If a user chooses the contract item ϕ i , the miner needs to ensure that ω ( s i ) is mined and propagated within time t max . 8 In return, the miner receives a reward r(s i ) that determines the user's transaction cost. Usually, the miner and users will not participate if their respective payoffs are negative (defined in Section III-C1 and Section 4d, respectively). Consequently, we specify the miner's and the users' payoffs in the following.

C. UTILITY MODEL 1) MINER'S UTILITY
The miner's utility is defined as the difference between its reward obtained from the blockchain transaction and transaction mining cost. Consider a miner with an available resource x, a transaction workload ω, and the miner's hash power γ can be expressed as γ (ω(s i ), x) [31]. We denote the miner's block size by s, which comprises the total transactional and metadata size. The token reward for miners constitutes a fixed bonus β ≥ 0 for mining a new block and a variable transaction fee λs i defined by the occupied transaction block size s i of a user i and a predefined transaction fee rate λ [32]. Therefore, the i-th miner's token reward r(s i ) can be expressed as follows: 9 (1) where P(γ (ω(s i ), x), s i ) represents the probability that the miner obtains the reward for contributing a block to the blockchain [31]. The miner's utility U can be calculated as where θ i ω(s i ) is the miner's cost for type-i user's transaction and 1 t i ≤t max can be expressed as which means that only miners with t i ≤ t max are likely to take a transaction. A miner with t i > t max gets a deduction to discourage the possibility of MEV extraction once contracting.

2) USERS' PAYOFF
Each user's payoff in each trading is based on its utility and payment. Specifically, a type-i user's utility can be expressed in terms of its confidentiality and valuation for transaction workload, which are usually its private information. The user payment generally comprises the cost for mining its transaction, depending on how much reward the miner obtains from the mining. If a type-i user selects a contract item ϕ i , the respective payoff W can then be calculated as: where V (θ i , t i ) 10 is the type-i user's evaluation function regarding θ i and t i , which is a strictly increasing concave The term c i r(s i ) represents the transaction cost from the miner, where c i is an additional fee imposed by the miner based on its valuation on the reward from providing the required service to users. However, for simplicity, we set c i = 1 to fundamentally not change the nature of our solution.

IV. MULTI-DIMENSIONAL CONTRACT DESIGN FOR USERS
In this section, we analyze the miner's optimal incentive mechanism for users with different information asymmetry levels. To investigate the impact of these information asymmetry levels between the miner and users, we consider the following contract designs: 1) Complete information scenario: The miner is aware of each user's type, which provides an upper bound of its reward compared with the incomplete information scenario [16]. 2) Incomplete information scenario: In this case, the miner does not know the user type but only knows the distribution of user types. This scenario leads to the second-best outcome with a non-linear price discrimination for user transactions [16]. For each design, we first present the contract feasibility condition and then solve for the optimal contract. The contract feasibility and optimality are defined as follows [16]:

Definition 1 (Contract Feasibility): A contract is feasible if each user obtains the maximal payoff by choosing the contract item designed for its type. Definition 2 (Contract Optimality): A contract is optimal if it maximizes the miner's payoff among all feasible contracts.
The rest of this section includes the optimal contract design under the complete information and incomplete information scenario in Section IV-A and IV-B, respectively.

A. COMPLETE INFORMATION SCENARIO
In this subsection, we investigate the miner's optimal contract under the complete information scenario where the miner knows each user type. This design makes it feasible for the miner to observe and ensure that each user type accepts the contract items designed for that type and will not accept any contract item not designed for it. Also, the miner can obtain a first-best outcome, which leads to perfect price discrimination [16]. Nonetheless, the miner is still required to guarantee that each user obtains a non-negative payoff, which incentivizes users to accept their corresponding contract item. Expressly, a contract is feasible if and only if it satisfies Individual Rationality (IR) constraints: Definition 3 (Individual Rationality): A contract is individually rational if it provides a non-negative payoff to each type-i that accepts the contract item ϕ i designed for its type, i.e., (5) Therefore, the optimal contract C * complete = (t * max , ϕ * ) under the complete information scenario is the solution to the optimization problem: Problem 1 (Contracting Under Complete Information Scenario Problem): which aims to maximize the miner's utility as shown in (6a) under the IR constraint presented in (6b). To solve this problem, we first calculate the miner's reward r(s i ) for any given s i from (1). Next, we substitute r(s i ) into the miner's objective function to obtain the optimal transaction workload ω * (s i ) as well as the optimal transaction delay time t * max (see Theorem 1).
Lemma 1: For any given transaction workload ω(s i ) even if ω(s i ) ̸ = ω * (s i ), it is optimal for the miner to choose its reward as r( We provide the proof of Lemma 1 in Appendix, which establishes that the miner will offer zero payoffs to all users contracting under the complete information scenario. Subsequently, we can determine the optimal transaction workload for each user type that minimizes the miner's cost based on Lemma 1. Next, we present another observation based on Lemma 2, showing the impact of choosing each user type-i on the miner's cost.
Lemma 2: The miner's payoff for only choosing type-i is expressed as We provide the of Lemma 2 in Appendix. Lemma 2 describes the miner's trade-off towards different users' private information, i.e., θ and t. As a result, we can transform users' two-dimensional private information into a onedimensional model, which shows the miner's preference for different user types: Definition 4 (Miner's Preference List): The miner has a higher preference for a user type-i than type-j (expressed by i ≻ j) if and only if (θ i , t i ) > (θ j , t j ). Fig. 2 shows how the miner's preference changes for each user type over (θ, t) parameter spectrum. Each axis represents the users' sensitivity towards (θ, t). Expressly, the miner's preference on users' types is higher for users with high confidentiality and low transaction delay than low confidentiality and high delay users. We express the set of user types that have the same high miner preference as follows: For instance, suppose that there are five user types A, B, C, D, and E characterized with (θ, t) as shown in Fig. 2.
In Theorem 1, we provide the optimal contract for the miner under the complete information scenario considering different cases of the set µ * i : Theorem 1: Under complete information scenario, the miner's preference order for users' transactions can be derived as: , offering only positive contract to one type i ∈ µ * i results in the same miner's maximal utility. Proof of Theorem 1 is provided in Appendix. Theorem 1 illustrates that the miner only provides a positive contract item to the most desired user type and offers zero contract to all other users. Additionally, due to the non-uniqueness of the most preferred user type, the optimal contact may not be unique but will always exist. Conversely, it is not optimal to choose (offer a positive contract item) to several user types within or outside the set µ * i , as this would reduce the miner's reward.
Logically, having less user information would result in different behavior of the miners. As a result, we present in the subsequent subsection that the miner's optimal contract under an incomplete information scenario is more complicated than the complete information scenario.

B. INCOMPLETE INFORMATION SCENARIO
In this subsection, we present the miner's optimal contract under the incomplete information scenario, where it does not know which type each user belongs to but is aware of the probabilistic distribution of users' types, i.e., a probability P i that a user belongs to a type-i. The user type-i probability P i for this case can be expressed as Moreover, this user type probability in our contract design applies to any distribution that best characterizes the user behavior.
In this design, the miner needs to account for any expected reduction in its payoff for incorrectly proposing contract items not precise for a specific user. Hence, the miner's utility for user type-i in this case is Suppose the miner adopts the previously derived optimal contract design from the complete information scenario for the incomplete information scenario. In that case, the miner will have a higher payoff for offering a higher contract item to user type-i instead of user type-j, where V (θ j , t j ) > V (θ i , t i ), and vice versa. The miner will likely receive a low utility when user type-j and N are not sufficiently large. Usually, this type of contract design leads to a second-best outcome, where the miner needs to adopt a non-linear pricing model [16]. Motivated by the structure of the complete information scenario, where miners only select the most preferred user type, we construct a simplified contract where the miner only offers two types of contract items; one is positive payoff for a group χ ⊆ I of user types, and the other is zero payoff for the rest user types in I\χ. This contract structure provides a tractable approach to characterize the incomplete information scenario efficiently.
Also, the miner cannot force a user to accept a specific contract item, but it can design the contract to ensure each user accepts their corresponding contract item. Hence, the miner needs to further guarantee the Incentive Compatibility (IC) constraints: Definition 5 (Incentive Compatibility): A contract is incentive compatible if it provides the maximal payoff for each type-i user when he chooses the contract item ϕ i designed for its type, i.e., We can find the optimal contract C * incomplete = (t * max , ϕ * ), which is a solution to the optimization problem: Problem 2 (Contracting Under Incomplete Information Scenario Problem): In this problem, we also maximize the miner's utility as presented in (12a) under the IR and IC constraints shown in (12b) and (12c), respectively. Let χ i represent any subset of user types in I, and χ * represent the set of user types resulting in the maximal miner utility in the optimal incomplete information scenario. In the following subsection, we provide how to solve the optimal contract, establish the optimal contract for any arbitrary type set χ i , and give the guideline for finding the optimal type set χ * .
From (12), the complexity of our problem increases since the number of IR and IC constraints become I 2 . As presented in Lemma 3, we first reconstruct IR and IC into an equivalently small set of equations to solve this problem. Second, we present the optimal solution considering a set of users χ i , i.e., C * incomplete , and evaluate the The probability of having n χ i 96020 VOLUME 11, 2023 Authorized licensed use limited to the terms of the applicable license agreement with IEEE. Restrictions apply. users belonging to the types in χ i as: where P χ i = i∈χ i P i as the probability of having i users in set χ i . Let T max and θ max represent the maximum delay tolerance and confidentiality of user types in χ, such that T max = max{t i } i∈χ i and θ max = max{θ i } i∈χ i , respectively. Then C * incomplete (χ i ) can be characterized by Lemma 3. Lemma 3: For any arbitrary set of types under incomplete information scenario, the optimal contract is given as follows: 1) t * max = T max , 2) for all user types in χ i : 3) for any user type i / ∈ χ i , φ * = 0. Next, we obtain the optimal user type set χ * . We show the insight concerning the user types composed in the optimal type set χ * for any value of N . Generally, we expect the miner to choose user types with higher preference. Nonetheless, the following counter-intuitive results demonstrate that choosing certain user types with lower preferences (excluding others with higher preferences) may increase the miner's utility.
Proposition 1: For the optimal contract under incomplete information scenario C incomplete , there exist user types i and j such that i ∈ χ * , j / ∈ χ * , and (θ i , t i ) > (θ j , t j ). Proof of Proposition 1 is provided in Appendix. The insights behind Proposition 1 are: 1) choosing a user type with higher preference may not be optimal when the probability that this user type exists is small, 2) the miner's cost is decided by the user types' maximum computational time t i and the maximum workload ω(s i ) in the type set. Consequently, the combination of multiple high-preference types may not have an excellent overall performance.

V. MULTI-DIMENSIONAL CONTRACT AND TRANSACTION ORDERING MECHANISM
After contracting in Section IV, the miner must sequence transactions strategically to obtain maximal payoff. However, this step is challenging to achieve without MEV extraction or the miner's utility trade-offs for user satisfaction. In this section, we present our transaction ordering algorithm with our multi-dimensional contract in Section V-A and the overall system architecture design in Section V-B. Concretely, this approach can help resolve the ordering problems in MEV extractions and decentralized finance (DeFi). It simultaneously aims to address the problems of high gas costs for diverse user transactions types.

A. TRANSACTION ORDERING MECHANISM DESIGN
As mentioned in the Section IV, blockchain users reach a service-level agreement (SLA) with a miner to include its transaction to the current block [33]. In this case, the SLA document comprises the multi-dimensional contract designed for each user type. This contract design specifies the acceptable delay and confidentiality constraints of user transactions. The miner has to consider its block size and user requirements before ordering transactions. Let the set Q = {Q 1 , Q 2 , · · · , Q z , · · · , Q Z } represent Z number of transactions in the mempool and the set A = {1, 2, · · · , m, · · · , M } denote M number of miner's blocks. The miner's ordering solution Q * can be presented as Q * = {Q 1,1 , Q 2,2 , · · · , Q z,m, , · · · , Q Z ,M }, where Q z,m denotes a transaction z located at the block m. Expressly, we formulate the WSS transaction ordering and contracting problem as an optimization problem shown below:

Problem 3 (WSS Transaction Ordering and Contracting Problem Formulation):
In this problem formulation, (15a) presents the objective function for maximizing the miner's utility. This objective function is formulated similar to the multi-dimensional contract design from Problem 2, which captures Problems 1 and 2 if the probabilities are known, e.g., P i = 1. The constraints in (15b) and (15c) represent the IR and IC constraints, respectively. The IC constraint is dropped if the user type falls under the complete information scenario. The constraint in (15d) ensures that the sum of each block size and transaction match the total available block size and transactions.
We divide this problem into two parts, with the first part comprising the solutions provided in Section IV. Essentially, the solutions from Section IV, which comprises (15a)-(15c), reveal each user types' private information needed for our transaction ordering stage. Under the complete information scenario, we offer the contract items from the solution in Theorem 1 under the incomplete information scenario, and under the incomplete information scenario, we offer the contract items from Lemma 3. The second part provides a weighted transaction ordering algorithm to handle subsequent constraints. This weighted transaction sorting algorithm ensures the optimal ordering of transactions to meet the miner's block size requirements and total available transactions on the network.
To understand the modeling preliminaries of our transaction ordering algorithm, we introduce the classification groups of transactions. Without loss of generality, transactions are grouped into four main categories based on the users' desired confidentiality and delay. These categories include very high priority (VHP), high priority (HP), mid priority (MP), and low priority (LP) transactions [34]. A VHP transaction requires high confidentiality and a short delay compared with an LP transaction with low confidentiality and long delay. HP transactions demand high confidentiality but long delay, and MP transactions require low confidentiality and a short delay. We classify transactions into these categories to determine the maximum delay for each transaction, which can be represented as 1 4 t max , 2 4 t max , 3 4 t max , and t max for VHP, HP, MP, and LP transactions, respectively. The transaction categories can be calculated as follows where P 1 , P 2 .P 3 and P 4 represent VHP, HP, MP, and LP transactions, respectively. In the WSS design, we apply a weight σ i to each transaction expressed as where σ i is the weight of Q i computed as a product of the delay tolerance specified by the user, the transaction confidentiality, and the transaction workload, this weight determines the position and cost of a particular transaction. In this case, the total number of transactions Z is used instead of the number of particular transaction types to make this approach agnostic and generic for satisfying all three designs in Section IV. We employ the counting sort algorithm to order the weights, which determines the position of each transaction in the mempool based on the weights of each transaction. We use counting sort because it is fast, efficient, and suitable for the nature of our problem [35]. Counting sort also excels at sorting out values that have repeating occurrences in a given set. Additionally, the time complexity of counting sort algorithm is O(N w +K w ), where N w is the number of elements in the input weights and K w is the range of weights [36]. The time complexity for our multi-dimensional contract can be computed as O(N ) [37]. Therefore, the overall system's time complexity can be evaluated as O(N ) + O(N w + K w ). WSS applies a second phase check by timestamp for repeated similar transactions to ensure fairness in terms of the time of arrival. We present algorithm 1 and Section V-B to explain the WSS mechanism design.

B. OVERALL MODEL ARCHITECTURE
In our model, users can submit their transactions directly to the DON. To ensure a transparent ordering is available

Algorithm 1 The Proposed Weighted Sequencing Service (WSS) Mechanism Algorithm
Data: θ = confidentiality, t = delay, W = user payoffs σ = transaction weights, N = total transaction, ω = transaction workload input : t, θ, ω, N output: Q * = getSolution(arr) / * sorts transaction weights * / void countSort(arr): max = *maxElem(arr.begin(), arr.end()); min = *minElem(arr.begin(), arr.end()); range = max -min + 1; count(range), output(arr.size()); to all miners on the blockchain, the users must simultaneously submit transactions to these multiple nodes. However, we explore an alternative in which the DON monitors the mempool of a target blockchain and selects transactions from it on behalf of a relying SCON [27]. Typically, the DON utilizes web services as its data source and considers the mempool as a data source to produce reports corresponding to the user transactions. We show the flow of our proposed WSS implementation in Fig. 3 and the detailed description in Appendix.
In Fig. 3, users submit their transactions to the mempool in step 1. The DON in step 2 executes the miner's 96022 VOLUME 11, 2023 Authorized licensed use limited to the terms of the applicable license agreement with IEEE. Restrictions apply. contract to reveal each user's type and obtain the various parameters (e.g., confidentiality and delay) needed for the transaction ordering stage. 11 These optimal contract solutions from Theorem 1 and Lemma 3 are coded directly into the chainlink SCs to enhance the latency performance of our mechanism. Next, the DON sequences 12 user transactions sent to the mempool using Alg. 1 in in step 3 of Fig. 3 The DON ingests transactions and then reaches a consensus on their ordering, rather than letting a single node dictate. Both WSS multi-dimensional contracting and transaction ordering algorithm are available through an application programming interface (API) calls to ensure that all nodes obtain the same results [38]. The DON comprises chainlink keepers that employ WSS to sequence these transactions and then forwards the transactions to the mempool for the miners. The miners interact with the newly-ordered user transactions through the blockchain SCON, as shown in step 4 of Fig. 3. To validate the mining sequence, we check the transaction order against the miner's block id (e.g., α i denotes the miner's transaction order). Peer-to-peer networks are complicated, and a miner can take advantage of these complications to launch MEV extractions. Also, an adversary with several peers and a fast network connection can frontrun others. However, we can significantly raise the bar for MEV extraction and front-running attempts with our type-revealing contract design and transaction ordering algorithm. Additionally, this incentive mechanism ensures the miner's utility is maximized, offers a good 11 We use the executeContract() function from Alg. 1, which computes the contract items for each user using solutions from Theorem 1 and Lemma 3. 12 We execute the weight computation and countSort() function in Alg. 1 to sort the user transactions. quality of service to each user type, and reduces unethical behaviors on the network.

VI. EXPERIMENT RESULTS AND ANALYSIS
In this section, we first present the system configuration for our experiments in Section VI-A. Secondly, we introduce the performance metrics and experiment benchmarks for the basis of our experiment in Section VI-B. Finally, we perform extensive experiments to evaluate the performance gains of the proposed mechanism and validate our results in Section VI-C.

A. SYSTEM CONFIGURATION
In this section, we present the configuration design for our proposed scheme's pervasive experiments and analysis. All experiments are conducted regarding blockchain system architecture and standards [1]. We execute the experiments utilizing Python 3.6 environment and solidity v0.8.0 on a Core i7 CPU computer capacitated with 3.8 GHz and 32GB RAM processor speed and memory. In our evaluation, we employ the blockchain states of Uni and Sushiswap [39], two of the largest on-chain DEXes obtaining 73.27% of the market volume. Consequently, our proposed scheme implementation performs as expected on these two platforms. We use Uniswap as a pricing oracle to fetch the 2, 000 USD/ETH prices for any arbitrary transaction [40]. We assume that the 2, 000 USD/ETH transaction price is zero when none is available, thus neglecting the corresponding transaction. We utilize a price of 2, 500 USD/ETH as of Dec 2021.
To deploy the multi-dimensional contract and sorting algorithm in this system, we execute a chainlink keeper from the chainlink platform with SCs on Ubuntu 18.04 LTS OS. We use solidity programming languages for scripting and writing our SCs. The solutions to our multi-dimensional contract design are directly written into SCs that execute on the selected batch of transactions to extract the user types for transaction ordering. We select a batch of 25 transactions per transaction execution round by default. We also built a web interface with ReactJS [41] to manage adding transactions, chainlink oracle node initialization, and experiment results (see appendix). In this experiment, we initialize 10 chainlink oracle nodes for decentralizing the execution of our contract and sorting algorithms. However, due to the cost involved in deploying transactions on-chain, we limit the majority of transaction executions to off-chain to reduce the cost. Additionally, our mechanism ensures legacy compatibility with the existing blockchain and lower gas costs when implemented using chainlink technologies. Other predefined parameters include: t max = 10min, β = 12.5, λ = 15, s = 10kb, and Q = 1, 000.
We set the user confidentiality θ and delay preferences t to [None, LP, MP, HP, VHP], which maps to θ and t to [2,4,6,8,10] in the menu options to determine the weights for each transactions, as shown Fig. 5b in Appendix. In the experiment, we consider 300 different user types and 10 different miners on the blockchain network.

B. PERFORMANCE METRICS AND EXPERIMENT BENCHMARKS
In this section, we introduce the preliminaries, such as experiment criteria and benchmarks, for Section VI-C. The experiment criteria explain how the different results for this discussion were chosen, and the benchmarks explain the measurement metrics that were used to get these results.

1) EXPERIMENT CRITERIA
To analyze our proposed incentive mechanism, we offer the following outcomes in this experiment: contract analysis, miner's utility analysis, users' payoff analysis, fraction of users served, user participation rate analysis, and security analysis. Based on contract evaluation, the contract analysis expands the miner's utility and the user's payoff, providing a comprehensive overview of contracts in our proposed incentive mechanism. To investigate the analysis of our contract design, we present the benchmarks in Section VI-B2. In addition, as stated in Section VI-C1, our contract analysis goes into greater depth regarding how different contract designs affect the miner's utility and the users' payoff.
Based on the benchmark in Section VI-B3, our system performance results indicate the miner's utility and user's payoff as transactions increase, the fraction of users served, the user participation rate, and security analysis. To begin, the miner's utility and the user's payoff as transactions on the blockchain increase indicate the performance of our proposed strategy as transactions on the blockchain increase. We observe and record the effects on the miner's utility and the user's reward to obtain these results, as discussed in Sections 4c and VI-C3, respectively. Second, based on the proportion of user transactions processed and the number of user types on the blockchain platform, the fraction of users served and the user participation rate reflect the performance of our proposed scheme. We actively compute the total number of mined user transactions and user types using the experiment setup from Section VI-A. Finally, the security analysis demonstrates our proposed incentive scheme's unique weaknesses and mitigating mechanisms, as discussed in Section VI-C6.

2) BENCHMARK 1
This benchmark includes the miner and users' evaluation towards complete information, incomplete information, uniform, and no contract. The complete information contract comprises the solution from Section IV-A, and the incomplete information contract describes the results from Section IV-B. To expand the depth of contract analysis studies, we present Appendix's uniform contract, which has a single contract item applicable to all users. In addition, we propose a no contract scenario in which users are not offered any contracts, which essentially characterizes the existing system. This metric provides a framework for evaluating the miner's utility and the users' payoff preferences in relation to the various contract design situations.

3) BENCHMARK 2
This benchmark comprises FSS, A2MM, and MEV auction. Firstly, the authors in [7] introduced an FSS, which orders transactions based on a first-come-first-served approach in the mempool but did not consider the miner's utility optimization and user preferences. Secondly, the authors in [13] presented an A2MM, which performs optimal transaction routing based on transaction fees but fails to consider the user preferences introduced in our work. Lastly, the work in [9] presented MEV auctions to mitigate MEV via auctioning the right to order transactions but failed to consider the users' payoff optimization and preferences. We utilize these metrics to evaluate our system's performance concerning the miner's utility and user's payoff as transactions increase, the fraction of users served, the user participation rate, and security analysis. Figs. 4a and 4b, the contract analysis such as miner's utility and users' payoff contrasted with contract evaluation will be discussed.
In this experiment, we investigate the contract preferences based on user type evaluations. Specifically, we analyze the miner's utility and users' payoff considering the various contracts as shown in Figs. 4a and 4b. 13 In Fig. 4a, we can observe that the miner's utility is an increasing function of the users' evaluation, which results from a higher willingness to pay. Users with high confidentiality and tolerance are more likely to pay since they value the mining service, which directly increases the miner's income when the transaction cost is fixed or minimal. Furthermore, as a user's evaluation increases, it becomes more profitable to serve users with higher evaluation than lower evaluation.
Miner's utility achieves the highest under the complete information scenario contract and the lowest under no contract. From Fig. 4b, the users' payoff is high under complete information scenario contract followed by incomplete information scenario contract and uniform contract. 14 This trend's deduction can be attributed to the suitable contract design for each user type under the complete information scenario to produce maximal utility and vice versa. Also, users can capitalize on misrepresentation of its type probability to reduce their cost, as observed in Figs. 4a and 4b. Hence, we can conclude from the results that a miner will prefer a complete information contract design at all times while users gravitate towards incomplete information scenario contract.
However, our multi-dimensional contract design significantly improves the miner's utility and users' payoff. Fig. 4c shows the performance of our proposed mechanism design based on the miner's utility. In Fig. 4c, we evaluate the miner's utility from (1) considering our proposed WSS with FSS, A2MM, and MEV auction. 15 First, the miner's utility is an increasing function of the number of transactions and user evaluations but a decreasing function of the transaction cost, which is intuitive since a high transaction cost reduces the miner's utility. Our proposed WSS achieves approximately 78.42% − 84.57% increase in the miner's utility compared with FSS, A2MM, and MEV auction in blockchain networks.

2) MINER'S UTILITY ANALYSIS
As shown in Fig. 4c, offering a multi-dimensional contract in addition to the sorting algorithm delivers higher miner's utility. The reasons for this trend in results constitute: (i) as shown in WSS's multi-dimensional contract, we illustrate the optimal strategies for the miner to help maximize its utility, (ii) as we have shown from Fig. 4c, our contract design extracts the various user types for appropriate pricing, which improves the miner's utility, (iii) WSS weighs transactions based on user evaluations for transactions after contracting to increase the miner's utility. As the miner has an increased utility from our proposed mechanism, we can conclude that WSS is a promising approach to enhancing miners' utility on blockchain networks.

3) USERS' PAYOFF ANALYSIS
This part of the experiment compares the users' payoff under WSS, FSS, A2MM, and MEV auction as shown in Fig. 4d. The users' payoff increases as transactions increase with WSS achieving up to 64.47% cost reduction compared with FSS, A2MM, and MEV auctions. From (4), the users' payoff is a function of workload evaluation and transaction cost. That is, a highly evaluated transaction presumably yields a higher revenue to users, and the more costly resources a miner will use, the higher the price users will be charged. Highly evaluated transactions often attract high transaction fees and vice versa. This approach provides a more efficient way of identifying and extracting profits for miners from users without indiscriminately increasing transaction fees or encouraging any gas price bidding wars among users. The users' payoff is high under WSS, followed by FSS, A2MM, and MEV auction, which suggests a superior performance for our proposed mechanism.
Similarly, in Fig. 4d, the better results from our proposed mechanism can be attributed to the following reasons: accurate representation of each user type for proper pricing via contracting and decisive transaction ordering based on the representation of each user type. Also, users do not need to worry about mining speed since getting a transaction into the mempool is guaranteed upon accepting contract items designed for each type. Therefore, users with low evaluation can send transactions with low gas prices, which are eventually mined with auditable records showing that transactions were not censored. Additionally, users will have a low evaluation of transactions if transaction fees exceed a threshold, requiring miners to process low-priority transactions. As a result, users' payoff increases based on reduced transaction fees. The DON also re-transmits scheduled user transactions to a relying contract with a high gas price, providing timely processing, and by using batching, the network keeps pertransaction gas costs low.

4) FRACTION OF USERS SERVED
This part of the experiment illustrates the fraction of users served as one of the system performance metrics of our proposed mechanism (WSS). In Figs. 4e and 4f, we compare the fraction of users served in WSS compared with FSS, A2MM, and MEV auction. The fraction of users served determines two main criteria: how many successful transactions are mined per sampled group of transactions and how many transaction types (e.g., VHP, HP, MP, and LP) are served per sampled number of users on the blockchain network. Figs. 4e and 4f describe the fraction of users served based on number of transactions and transaction types, respectively. From Fig. 4e, the fraction of users served increases as the number of transactions increase. This trend indicates that increasing transactions does not overload the blockchain network, which results from a relatively large block size and relatively small transaction processing time.
Also, our proposed mechanism achieves 72% more fraction of users served than FSS, A2MM, and MEV auctions. This trend can be attributed to the various user type characterization from contracting. Our contract designs ensure that any user type is well represented, which enhances the chance of processing more transactions. As deduced in Theorem 1, offering a positive contract to a particular user type yields the same payoff as many user types, making it more reasonable to serve more users instead of specific user types. Also, Proposition 1 can infer that the miner is not fixated on serving high-priority users since this approach does not always yield a higher utility the probability of that user type is low. As a result, the miner is motivated to accept various user types that optimize its utility. Finally, accepting the contract items designed for each user type guarantees that transactions will be mined within specified delay preferences. Failure to process transactions within the specified time duration leads to a negative payoff to the miner's utility. Hence miners are incentivized to execute transactions promptly and as scheduled. Therefore, we can conclude that our proposed mechanism offers a better fraction of user satisfaction than other proposed MEV mitigation schemes.

5) USER PARTICIPATION RATE ANALYSIS
In this experiment, we evaluate the user participation rate based on the duration and number of users engaged on the platform using WSS, FSS, A2MM, and MEV auction. User participation is an essential system performance metric for the sustainability of blockchain networks. Figs. 4g and 4h illustrate the user participation rate based on the experiment duration and number of transactions. From Figs. 4g and 4h, the user participation rate for our proposed system increases as the experiment time and number of transactions increase. WSS achieves up to 68% more user participation than FSS, A2MM, and MEV auction.
Based on the results obtained from Sections VI-C2 and VI-C3, we can conclude that the high user participation rate observed in our proposed mechanism is due to the enhanced miner's utility and user's payoff. The results also point to the potential of individual rationality and incentive compatibility, which provides users a non-negative payoff for any contract and a high payoff for choosing a contract designed for its type. As a result, users are more motivated to participate in blockchain transaction mining than other proposed MEV mitigation strategies.

6) SECURITY ANALYSIS
In this part of the experiment evaluation, we present the security analysis of our proposed mechanism to support the results from Sections VI-C2 to Sections VI-C5. We consider two main concerns: 1) the possibility of miners disregarding the transaction mining order submitted by the chainlink nodes, and 2) MEV centralization and 51% attacks by chainlink nodes when sequencing transactions. Firstly, the miners risk obtaining a negative reward, which prevents them from defaulting in mining transactions beyond the required delay tolerance. Next, miners have minimal arbitrage opportunity ideas of the transactions before executing the mining because the private user information about any transactions is hidden. This concept of obfuscating transactions ensures that miners will not reorder transactions, which will cause penalties in future mining activities. Secondly, our proposed mechanism reduces the risk of MEV centralization and 51% attacks with decentralized transaction ordering by the chainlink nodes. Expressly, no miner or DON has exclusive access to WSS, which prevents the possibility of collusion on the network.
By mitigating these security challenges, WSS obtains a better fraction of users served and participation rate, as shown in Sections VI-C4 and VI-C5.

VII. CONCLUSION
In this paper, we have studied an essential issue of incentive mechanism design for mitigating frontrunning and transaction reordering in DEXes. To the best of our knowledge, this is one of the first papers to address multi-dimensional private information considering different levels of information asymmetry and transaction ordering mechanisms for blockchain networks. We have introduced a weighted counting sort algorithm for ordering transactions on the blockchain network to avoid MEV centralization and extraction. To incentivize and encourage ethical behaviors, we have presented a multi-dimensional contract design for users with multi-dimensional private information. Moreover, we have implemented a DON to execute our transaction ordering and multi-dimensional contracts on the blockchain platform. We have revealed the effects of the various contract types on the miner's optimal strategies. One of our key contributions is to investigate how to implement our optimal multi-dimensional contract with a transaction ordering algorithm in decentralized blockchain environments. The experiment results demonstrate that our proposed solution offers a 78.42% − 84.57% increase in the miner's utility and 64.47% cost reduction for users, which incentivizes ethical behaviors on the blockchain network.