Browse Source

Rearranged the document

master
Lev 2 years ago
parent
commit
744c39c131
  1. BIN
      main.pdf
  2. 106
      main.tex

BIN
main.pdf

Binary file not shown.

106
main.tex

@ -92,7 +92,7 @@
% ARTICLE CONTENTS % ARTICLE CONTENTS
%---------------------------------------------------------------------------------------- %----------------------------------------------------------------------------------------
\section{Introduction and overview} \section{Introduction}
\indent There is a variety of standard financial organizations that provide their capital for some simple purely financial deals: banks, brokers, gambling institutions, betting institutions, and many more. Most of them have their own DeFi counterparts, as well as some services that are only possible on the blockchain --- for example, flashloans. \indent There is a variety of standard financial organizations that provide their capital for some simple purely financial deals: banks, brokers, gambling institutions, betting institutions, and many more. Most of them have their own DeFi counterparts, as well as some services that are only possible on the blockchain --- for example, flashloans.
All of these organizations can be generalized to an economic agent that has a utility function and accepts a proposed deal if and only if it is the most beneficial in terms of this function. These particular implementations, however, only consider a very limited subset of deals. Also, all of them work only with purely financial deals which include not more than 3 parties\footnote{An example of such a deal with three parties is a stanard deal on a financial market.}, including the financial organization. All of these organizations can be generalized to an economic agent that has a utility function and accepts a proposed deal if and only if it is the most beneficial in terms of this function. These particular implementations, however, only consider a very limited subset of deals. Also, all of them work only with purely financial deals which include not more than 3 parties\footnote{An example of such a deal with three parties is a stanard deal on a financial market.}, including the financial organization.
@ -102,14 +102,35 @@ It can analyze deal proposals and their combinations into more complex deals (fo
The goal of this whitepaper is to present such an entity --- Agorata. The goal of this whitepaper is to present such an entity --- Agorata.
\section{Overview}
\section{Decision-making strategy} As a service, Agorata has the following path of the user:
In this chapter, the strategy for making decisions is described. \begin{enumerate}
\item User creates a smart contract, which is a proposal for a deal, using Agorata's smart contract builder, or just uploads the contract code directly to the blockchain. The smart contract builder is a web application that allows to create a smart contract in the following ways:
\begin{itemize}
\item Using one of the predefined templates, which are based on the standard financial deals.
\item Using Agorata's simplified language for smart contracts, A-Lisp, which is based on the Lisp language. It is then compiled to the Fift assebly language.
\item Using the No-Code version for creating a finite state machine smart contract.
\end{itemize}
\item Agorata builds its own standardized representation of the smart contract.
\item Agorata evaluates the smart contract or a combination of smart contracts in its pool and decides whether it is profitable or not.
\item Agorata accepts the most profitable deal.
\end{enumerate}
% ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
% CONTRACT REPRESENTATION
% ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
\section{Contract representation}
\subsection{The structure}
A smart contract is considered as an entity with which other entities (users, smart contracts) can interact via messages\footnote{The message concept used here is from The Open Network (TON). A message can include tokens, commands, information, code.}. For a state of the contract we can determine the messages that can be sent to the contract and for each of them --- the response messages and the next state.
The contract is represented as an actor with several states (a finite number of states which can have parameters --- i.e., variables in the contract) that can receive several (a finite numer of) types of messages and change the state. The graph of states, messages, and transitions fully describes the system. Each message has a fixed form with parameters and the output state, which parameters depend on the parameters of the message. This dependency is characterized by an algorithm in the form of code in a pure subset of Lisp --- A-Lisp\footnote{The choice of Lisp is motivated primarily by the fact that it is a good unified way to represent an algorithm. There are also ways to use Lisp programs in formal proofs}.
\subsection{Deal representation}
A deal proposal is made by the user in the form of a smart contract. A smart contract is considered as an entity with which other entities (users, smart contracts) can interact via messages\footnote{The message concept used here is from The Open Network (TON). A message can include tokens, commands, information, code.}.
For a state of the contract we can determine the messages that can be sent to the contract and for each of them --- the response messages and the next state. The deal is represented as a tree with states as leafs and actions (messages) as edges. Depending on the actions, the deal has a total outcome --- the number of tokens that were gained/spent by the agent.
\begin{figure}[!htb] \begin{figure}[!htb]
\centering \centering
@ -121,39 +142,41 @@ For a state of the contract we can determine the messages that can be sent to th
Each action (message) has parameters $\theta$, including: Each action (message) has parameters $\theta$, including:
\begin{enumerate} \begin{enumerate}
\item $s$ --- the sender of the message. \item $s$ --- the sender of the message.
\item $t$ --- the time (block number) at which the message is sent (may be omitted in the representation if it is unimportant). \item $t$ --- the time (block number) at which the message is sent (may be omitted in the representation if it is unimportant for the next states).
\item tokens sent with the message. \item tokens sent with the message.
\item any other possible information. \item any other possible information.
\end{enumerate} \end{enumerate}
The parameter space for each action can be constrained --- the smart contract can reject some of the messages. For instance, this can lead to the entire space consisting of a single element (the contract rejects everything except for one specific message, e.g. a specific person sending a specific amount of tokens). The parameter space for each action can be constrained --- the smart contract can reject some of the messages. For instance, this can lead to the entire space consisting of a small number of elements (the contract rejects everything except for several specific messages, e.g. a specific person sending a specific amount of tokens).
The main parameters of the state are the financial outcomes for the smart contracts. The main parameters of the state are the financial outcomes for the smart contracts.
The state is written as a function of all parameters of all actions in a formal language.
At the first stages of the project, the states and messages will not have variable parameters. The contract, therefore, will be a finite state machine. For that, the contract will have to check the incoming message on being in the list of allowed messages.
\subsection{Agent parameters}
\begin{enumerate}
\item $T_{0}$ is the maximum deal duration --- i.e., the horizon after which the benefits of the deal are not considered.
\item $\tau$ is the charachteristic time of discount --- $\exp({\frac{1\,year}{\tau}}) - 1$ is the minimal yearly rate for a loan.
\item $r$ is the risk parameter for currency switching --- the agent will only agree to swap no less than $(1+r)x$ in one currency for $x$ in another.
\end{enumerate}
Given these parameters, the value function $V((x_{i}), (t_{i}))$ (or $V(S)$) can be determined. It takes the sequence of values $(x_{i}, t_{i})$, where $x_{i}$ are the incoming/outcoming tokens from the agent.
\subsection{Deal evaluation} \subsection{Contract evaluation algorithms}
The agent considers the worst case of the deal from the perspective of game theory: the best (from the perspective of the value function) actions of the agent and the ``worst'' actions of the counteragents. As we will see in the following section, one of the most important parts of the process is finding out whether there exists any action that makes the deal profitable or unprofitable. It is also important to know which actions the agent should make to maximize its output. How do we do that?
This sequence of events is the run through the value function in order to make a decision.
Thus, a deal is considered profitable for the agent (denoted by $A$) $\xLongleftrightarrow{def}$ $p(S_{i})$ $\iff$ The state parameters are represented as functions of action parameters expressed in a formal language. This allows to make all the decision based on mathematical proofs using theorem provers.
$$V(S_{i})>0 \vee \\ (\forall a_{ij} (p(S_{ij}) \vee a.s = A) \wedge \exists a_{ij}: V(S_{ij})>0)$$
Here, $S_{i}$ is state that is analyzed (the state includes the token movements to and from the agent), $a_{ij}$ are the possible actions (messages) in that state. The function $V(S)$ is the value function which analyzes the token movements in terms of profitability.
The algorithm starts at the node $S_{0}$, then considers all the possible actions (including the abscence of one) and calls the algorithm at $S_{0i}$. If there is any action of the counteragent that makes the contract non-profitable for the agent, the deal is considered non-profitable. If there is no possible action and the state includes profit for the agent, the deal is considered acceptable. Note that for a contract with no parameters of messages and states this kind of an algorithm is not required.
\subsection{Building the formal representation}
At the first stages of the project, the formal representation will be obtained in two ways:
\begin{itemize}
\item Pattern matching on the Fift code for standard contracts made from templates
\item The creation of the contract performed by the user through the constructor on the Agorata website
\end{itemize}
Pattern matching will be based on a set of templates with fields. Most prevalent field types will be addresses, token types, and amounts. This algorithm will be able to recognize proposals of many types, including loans, derivative, flashloans, bets. For example, for a loan the paramters are the two involved tokens, sums in them, participating address.
\subsection{Examples} \subsection{Examples}
Figure 2 show graphs for some simple deals.
\begin{figure}[!htb] \begin{figure}[!htb]
\centering \centering
\begin{subfigure}[b]{0.48\textwidth} \begin{subfigure}[b]{0.48\textwidth}
@ -171,37 +194,32 @@ The algorithm starts at the node $S_{0}$, then considers all the possible action
\end{figure} \end{figure}
\section{Contract evaluation algorithms} % ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
% DECISION-MAKING ALGORITHM
In the previous section of the article we specified how the decisions are made. One of the most important parts of the process is finding out whether there exists any action that makes the deal profitable or unprofitable. It is also important to know which actions the agent should make to maximize its output. How do we do that? % ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
\section{Decision-making algorithm}
The state parameters are represented as functions of action parameters expressed in a formal language. This allows to make all the decision based on mathematically proven algorithms.
The algorithm for evaluating a path the deal can take has these main states:
\subsection{Agent parameters}
\begin{enumerate} \begin{enumerate}
\item Building the formal algorithm from the contract code \item $T_{0}$ is the maximum deal duration --- i.e., the horizon after which the benefits of the deal are not considered.
\item Finding the optimal language using the formal language \item $\tau$ is the charachteristic time of discount --- $\exp({\frac{1\,year}{\tau}}) - 1$ is the minimal yearly rate for a loan.
\item $r$ is the risk parameter for currency switching --- the agent will only agree to swap no less than $(1+r)x$ in one currency for $x$ in another.
\end{enumerate} \end{enumerate}
\subsection{The formal representation} Given these parameters, the value function $V((x_{i}), (t_{i}))$ (or $V(S)$) can be determined. It takes the sequence of values $(x_{i}, t_{i})$, where $x_{i}$ are the incoming/outcoming tokens from the agent.
The contract is represented as an actor with several states (a finite number of states which can have parameters --- i.e., variables in the contract) that can receive several (a finite numer of) types of messages and change the state. Each message has a fixed form with parameters and the output state, which parameters depend on the parameters of the message. This dependency is characterized by an algorithm in the form of code in a pure subset of Lisp --- A-Lisp\footnote{The choice of Lisp is motivated primarily by the fact that it is a good unified way to represent an algorithm. There are also ways to use Lisp programs in formal proofs}.
At first, the states and messages will not have parameters. The contract, therefore, will be a finite state machine. For that, the contract will have to check the incoming message on being in the list of allowed messages. \subsection{Deal evaluation}
The agent considers the worst case of the deal from the perspective of game theory: the best (from the perspective of the value function) actions of the agent and the ``worst'' actions of the counteragents.
This sequence of events is the run through the value function in order to make a decision.
\subsection{Building the formal representation} Thus, a deal is considered profitable for the agent (denoted by $A$) $\xLongleftrightarrow{def}$ $p(S_{i})$ $\iff$
$$V(S_{i})>0 \vee \\ (\forall a_{ij} (p(S_{ij}) \vee a.s = A) \wedge \exists a_{ij}: V(S_{ij})>0)$$
At the first stages of the project, the formal representation will be obtained in two ways: Here, $S_{i}$ is state that is analyzed (the state includes the token movements to and from the agent), $a_{ij}$ are the possible actions (messages) in that state. The function $V(S)$ is the value function which analyzes the token movements in terms of profitability.
\begin{itemize}
\item Pattern matching on the Fift code for standard contracts made from templates
\item The creation of the contract performed by the user through the constructor on the Agorata website
\end{itemize}
Pattern matching will be based on a set of templates with fields. Most prevalent field types will be addresses, token types, and amounts. This algorithm will be able to recognize proposals of many types, including loans, derivative, flashloans, bets. For example, for a loan the paramters are the two involved tokens, sums in them, participating address. The algorithm starts at the node $S_{0}$, then considers all the possible actions (including the abscence of one) and calls the algorithm at $S_{0i}$. If there is any action of the counteragent that makes the contract non-profitable for the agent, the deal is considered non-profitable. If there is no possible action and the state includes profit for the agent, the deal is considered acceptable.
\subsection{Considering the deal}
% Here it's about the path consideration algo + formal maximization + *template matching* % Here it's about the path consideration algo + formal maximization + *template matching*

Loading…
Cancel
Save