Optimization Problems

Optimization problems involve finding the best set of parameters or conditions that maximize or minimize a particular objective function, subject to a set of constraints.


The Main Underlying Goal

Consider an executed user order s, where S represents its executed sell amount and B is its executed buy amount. Then:

fsurplus(s)=order surplus=BSπ(s)f_{\texttt{surplus}}(s) = \texttt{order surplus} = B - \frac{S}{\pi(s)}

where

π(s)=order’s limit price=sell amountbuy amount\pi(s) = \texttt{order's limit price} = \frac{\texttt{sell amount}}{\texttt{buy amount}}

The order can be executed only if:

π(s)SB\pi(s) \geq \frac{S}{B}

Moreover, if the order is executed, we must have:

Ssell amountS \leq \texttt{sell amount}

In the case of a fill-or-kill order, the inequality must be satisfied with equality:

S=sell amountS = \texttt{sell amount}

Given the above definitions, the goal when matching a user order against liquidity sources is to maximize the surplus of the user order:

Ωsurplus=max(fsurplus(s))\Omega_{surplus} = \max \left(f_{\texttt{surplus}}(s)\right)

The Utility Function (Ω)

As seen above, the utility (or objective) function encodes what is desired to maximize under given constraints.

Another example is that in the context of optimal arbitrage, the utility function could encode the goal of finding the best net trade that is entirely nonnegative.

Yet another example is swapping token PHI for token MU, aiming to maximize the output of token MU given a fixed input of token PHI (with arbitrage opportunities captured as part of the swap).

Last updated