#### Title:

Accurate mathematical description of p2p trading

#### Applicant name:

Bence Ladóczki

#### Pitch: A one-liner elevator pitch version of your proposal

Improving the usability of p2p exchanges with utility functionals for cryptocurrencies

#### Total Request (USD):

$43000.00 USD

#### Have you previously received a grant from Zcash Community Grants (formerly called ZOMG) or ZF?

No

#### Are you seeking or have you received funding from other sources for this proposed project?

No

#### Applicant background:

Bence Ladóczki: He is an assistant research fellow at the Budapest University of Technology and Economics. He is the developer of the electron repulsion integral driver of the MRCC[1] program suite. During his postgraduate years he developed massively parallel algorithms for the K computer in Japan. Since 2021 he has been working on blockchain related problems, including atomic swaps[2] and signature algorithms. To investigate the success rate of atomic swaps he developed a simulator software[3]. To analyse optimal payment strategies in layer 2 solutions, he used c++ to come up with a discrete time simulator[4]. His results will be published in Kuwait at BCCA 2023[5]. As such he has several years of experience in implementations of algorithms and high performance computing.

[1] mrcc.hu/index.php

[2] B. Ladóczki, J. Bíró and J. Tapolcai, “Stochastic analysis of the success rate in atomic swaps between blockchains,” 2022 Fourth International Conference on Blockchain Computing and Applications (BCCA), San Antonio, TX, USA, 2022, pp. 41-46, doi: 10.1109/BCCA55292.2022.9922365.

[3] github - mlvl36667/mjd_atomic

[4] github - mlvl36667/lnsim

[5] BCCA 2023

#### Description of Problem or Opportunity:

For secure DeFi protocol deployment, it is crucial to understand the nature of peer-to-peer transactions. In other words one has to devise accurate models to predict and improve the success rate of atomic swaps to guarantee a high level of user experience. Imagine that a new user has just registered on a DeFi platform and she/he is trying to exchange tokens, but due to the large number of automated bots that are present on the platform and trying to exploit arbitrage opportunities, the user fails to finalise the desired transactions. No doubt, such things vex the users and no surprise that they no longer want to use such a service. Blatant sandwich attacks are prominent examples.

Therefore, new mechanisms to deter such activities should be designed, and this necessitates the accurate description of the optimality of atomic swaps. The success rate of the swaps is closely related to how the users perceive the changes in cryptocurrency prices and consequently the value of the arising option. Option pricing has been researched thoroughly in the past few decades. The Black-Scholes option-pricing formula, the pure-jump option pricing formula and the binomial option-pricing formula are among the most popular ones that are being used to quantify the value of classical options. These formulas can be used in the context of atomic swaps and the applicant intends to uncover the subtleties arising from the application of these mathematical tools for cross-chain swaps and peer-to-peer trading. We feel that such intellectual work is indispensable and finally culminates in usable and secure DeFi platform implementations.

#### Proposed Solution: Describe the solution at a high level.

There is an increasing number of scientific endeavours to develop protocols that enable the exchange of digital assets between two heterogeneous blockchains without a third party arbitrator. Once two parties agree on an exchange rate and run an atomic swap protocol, they go through a rather complex cooperative process to ensure security and perfect decentralisation. This process introduces optionality as parties can choose to abandon the deal at each step of the swap. Although DeFi (decentralised finance) protocols between different types of chains are being actively developed the nature of optionality is not yet well understood.

Within the scope of this project, the applicant investigates the usability of CARA (Constant Absolute Risk Aversion) and HARA (Hyperbolic Absolute Risk Aversion) utility functions in the context of atomic swaps of cryptocurrencies. Additionally, if these functions turn out to be unsuitable for the accurate description of the underlying game theory, the applicant designs new utility functions to improve the devised stochastic model.

#### Solution Format: What is the exact form of the final deliverable you’re creating?

An open source discrete event simulator written in C++ to gauge the accuracy of the developed mathematical models and to uncover the connection between risk aversion and the success rate of atomic swaps. These numerical results should aid DeFi platform operators to predict and ensure user experience, which would then lead to wider cryptocurrency adoption.

2 scientific articles submitted to IEEE approved blockchain related international conferences. Acknowledgement of the financial support from Zcash included in the publications. Presentations at the conference with an acknowledgement of financial support from Zcash at the end of the presentations.

#### Technical Approach: Dive into the how of your project. Describe your approaches, components, workflows, methodology, etc. Bullet points and diagrams are appreciated!

In the financial context, one can define a set of alternative choices and these can usually be described as payoff profiles, which can be accounted for using probability measures. When the agent (user of a DeFi protocol in this case) has no means to choose a suitable probability measure, uncertainty arises. Going through an atomic swap deal can be thought of as buying (or not) a lottery at each stage. Participants, based on their subjective probability measure and rate of risk aversion can act differently during the execution of the protocol. In [1] the author introduces an axiomatic approach to elucidate the existence of a preference relation based on the utility function of the set of payoffs. Game theoretical approaches can be devised using the notion of expected utility when agents are exposed to financial risk. In the financial context, utility functions were introduced by H. Föllmer and A. Schied[2] as general tools to describe the behaviour of rational players on the market. These mathematical objects can be used to analyse the optionality of cryptocurrency swaps.

During the execution of the atomic swap protocols, the expected utility of the swap should be described accurately to fully understand how rational users would act in real world situations. Such a description shall incorporate both the initial wealth and the risk aversion profiles of the participants.

Borrowing the definition from [2] – an arbitrage opportunity is an investment strategy that yields with positive probability a positive profit and is not exposed to any downside risk. The existence of such an arbitrage opportunity may be regarded as a market inefficiency in the sense that certain assets are not priced in a reasonable way. In real-world markets, arbitrage opportunities are rather hard to find. Should such an opportunity show up, a concomitant large demand appears, prices adjust and the opportunity disappears. Another interesting question is whether atomic swap implementations create arbitrage opportunities and if such opportunities exist in DeFi protocols. It is argued that risk neutral measures exist if the market model is arbitrage free. Whether this is the case in DeFi protocols constitutes another research direction of the proposal.

In a finite discrete-time model, the absence of arbitrage opportunities is equivalent to the existence of an equivalent martingale measure[3]. To the best of our knowledge, the description of this measure for atomic swaps is not yet published in scientific journals. An accurate game theoretic model can only be devised if proper utility functional and probability measures are available. We aim at constructing such mathematical objects and tweak them to make them suitable for the context of cross-chain atomic swaps in blockchains with different signature algorithms.

Citing from a recent work of Alan Guo[7]:

“An interesting line of further work is to consider measures of value other than pure risk-neutral dollar profit. For example, traders may have different risk preferences, and different ordering mechanisms or block time distributions may increase the overall utility if not the overall dollar profit amount.”

The subjective measure of an agent depends on how the underlying stochastic process is described. This perception is abundantly discussed in [3] and we shall investigate these formalisms to shed light on the optimality of atomic swaps. This optimality is closely related to the problem of option pricing on classical stock markets, which no doubt, has abundant literature. Black and Scholes were among the first scientists to derive formulas for the pricing of options[4]. We analyse the applicability of these models in real-world situations, using actual market data obtained from real DeFi protocols.

In 2022, the PI investigated the optimality of atomic swaps[10] using the formalism of Black and Scholes and Merton’s Jump diffusion model. The findings showed that the success rate of the atomic swaps depend much on the applied stochastic model, which is closely related to the perceived probability measure. The assumption of a setting with only one subjective probability measure is too strict. Therefore the simple game theoretical presented in [10] needs to be extended. Our initial idea is to calculate the relative entropy of the two probability measures and then to come up with new measures to minimise (or at least to lower) entropy. This would lead to an arbitrage free description of the swaps between blockchains.

The authors in [6] investigate the issue using rudimentary mathematics and arrive at such a conclusion that the success rate of atomic swaps can be improved by introducing collateral in hash time lock contracts and also that one can achieve a lower failure ratio if the exchange rate is adjusted during the execution of the protocol. All this using a simple Wiener process to describe the underlying stochastics of the problem. Utility functions were introduced based on the expected value of the digital asset, which is described using Brownian motion. In the final section of the paper, the authors allude to a possible extension of their model and such work constitutes the backbone of the proposed research topics. The corresponding results would be of great import for practical implementations.

[1] von Neumann, John, et al. Theory of Games and Economic Behavior (60th Anniversary Commemorative Edition). Princeton University Press, 1944. JSTOR,

[2] Föllmer, Hans and Schied, Alexander. Stochastic Finance: An Introduction in Discrete Time, Berlin, Boston: De Gruyter, 2016.

[3] Gerber, Hans U. and Shiu E.S.W… “Option pricing by Esscher transforms.” Insurance Mathematics & Economics 3 (1995): 287.

[4] Black, F., & Scholes, M. (1973). The Pricing of Options and Corporate Liabilities. Journal of Political Economy, 81(3), 637–654.

[5] B. Ladóczki, J. Bíró and J. Tapolcai, “Stochastic analysis of the success rate in atomic swaps between blockchains,” 2022 Fourth International Conference on Blockchain Computing and Applications (BCCA), San Antonio, TX, USA, 2022, pp. 41-46, doi: 10.1109/BCCA55292.2022.9922365.

[6] Xu, Jiahua & Ackerer, Damien & Dubovitskaya, Alevtina. (2021). A Game-Theoretic Analysis of Cross-Chain Atomic Swaps with HTLCs. 584-594. 10.1109/ICDCS51616.2021.00062.

[7] A. Guo. (2023), Invariance properties of maximal extractable value, arXiv:2304.11010

#### Dependencies: What external entities is your project dependent on? What involvement is required from ZF, ECC, and/or other external organizations? Who would have to incorporate your work in order for it to be usable?

Owing to the theoretical nature of the proposal no dependencies on external entities are envisioned. Similarly, there is no need for intensive involvement from ZF, ECC and other external organisations.

#### Execution risks: What obstacles do you expect? What is most likely to go wrong? Which unknown factors could jeopardize success? Who would have to incorporate your work in order for it to be usable?

The PI intends to develop a formalism for reasoning about the optimality of atomic swaps. At the core is the formalisation of atomic swaps as abstract state machines satisfying natural axioms. The question that cannot be answered at this stage is how some of the proposed simplifying assumptions can be relaxed and how the results extend to more general settings. In other words there is unforeseeable uncertainty as to how much the theoretical model can be applied to real world scenarios.

#### Unintended Consequences: What are the negative ramifications if your project is successful? Consider usability, stability, privacy, integrity, availability, decentralization, interoperability, maintainability, technical debt, requisite education, etc.

Developing mathematical models that describe the optimality of atomic swaps in a more accurate manner than it was done before has hardly any impact on the above mentioned properties of blockchains. If atomic swap implementations turn out to be useful as a result of the proposed work, no doubt, sufficient teaching material shall be provided to the community. Atomic swap implementations should be audited and maintained in the future to ensure continuous adoption.

#### Evaluation plan: What metrics for success will you share with the community once you’re done? In addition to quantitative metrics, what qualitative metrics will you commit to report?

The PI is ready to take part in discussions on a frequent basis if this is required to report on his progress. Online meetings to discuss the results and the new directions of the research can be organised even on a weekly basis if it is necessary. The PI is ready to prepare slides with figures and formulas and other types of explanatory materials in English for these events.

#### Hardware/Software total budget:

$0.00 USD

#### Please provide justification for the total hardware/software budget:

This is mainly a theoretical research with simplified implementations for demonstrative purposes. As such there is no need for specialised hardware or software. The PI intends to use his own computer and free software.

#### Services total budget (cloud, hosting, etc.):

$0.00 USD

#### Please provide justification for the total services budget:

This is mainly a theoretical research with simplified implementations for demonstrative purposes. As such there is no need for services.

#### Compensation total budget:

$43000.00 USD

#### Please provide justification for the total compensation budget:

$3000*12 (salary of the PI for 12 months)+$3500*2 (2 scientific conferences, $1000 for registration, $1500 for airfare and $1000 USD for accommodation) = $36000+$7000 = $43000

According to bing.com the average monthly salary of a senior programmer in the financial sector in Hungary is roughly $3000. This would be paid to the PI to compensate for his efforts. The participation at 2 international conferences incurs three types of costs. Registration fees, airfare and other transportation costs and accommodation. Registration fees in the range of $1000 are not rare these days. Being unable to foretell where the conference will be, an estimate of $1000 has been calculated for airfare, this shall cover flights to distant destinations as well. Most conferences take 4-5 days and rooms of $200 are common in the developed world. As such, $1000 for accommodation per conference has been added to the budget.

#### Do you require startup funding?

No

#### Milestone 1 - estimated completion date:

02/01/2024

#### Milestone 1 - USD value of payout upon completion of deliverables:

$9000.00

#### Deliverable 1.1

Draft of manuscript #1

#### Milestone 2 - estimated completion date:

05/01/2024

#### Milestone 2 - USD value of payout upon completion of deliverables:

$9000.00

#### Deliverable 2.1

Final version of manuscript #1

#### Milestone 3 - USD value of payout upon completion of deliverables:

$9000.00

#### Milestone 3 - estimated completion date:

08/01/2024

#### Deliverable 3.1

Final version of manuscript #2

#### Milestone 4 - USD value of payout upon completion of deliverables:

$7000.00

#### Milestone 4 - estimated completion date:

10/01/2024

#### Deliverable 4.1

Conference related fees

#### Milestone 5 - estimated completion date:

10/01/2023

#### Milestone 5 - USD value of payout upon completion of deliverables:

$9000.00

#### Deliverable 5.1

Upfront payment

#### Total proposed USD value of grant:

$43000.00 USD

#### How was the project timeline determined?

The timeline for the project is 12 months, with 3 major milestones defined by the completion of the 2 scientific papers. An upfront payment of $9000 (three months of salary) is requested. The grant can be paid on a 3-months basis (end of month 3, month 6 and month 9) and the amounts required to cover the attendance at international conferences can be paid right after the papers get accepted for publication.

#### Application submission date:

08/28/2023