LogoLogo
back to urani.trade
  • Welcome
  • URANI App
    • The Urani App
    • MEV Projects
  • URANI SWAP
    • Swap tl; dr
    • Technicals
      • MEV tl; dr
      • Urani's Intents
      • Intent Transaction Flow
      • Batch Auctions
      • Urani's Intent Specs
      • Order Types
  • URANI PROTOCOL
    • Protocol tl; dr
    • Technicals
      • Optimization Problems
      • Raking the Agents' Solution
      • Batch Auction Specs
      • Ring (DAG) Trades
      • Order Execution
      • Multidimensional Price Free Market
        • On Solana
          • Solana Fees Overview
          • Solana Transactions Overview
          • Understanding Slippage
        • Urani's Dynamic Fees
      • Oracle Market Data Proxy
      • Security Considerations
      • Intent Gossip Layer Specs
      • Settlement Specs
  • URANI ARENA
    • Arena tl; dr
    • Technicals
      • The PvP Competition
      • Incentives for Operators
      • Reputation Dashboard
      • The Competition Seasons
  • MEV AGENTS
    • Agents tl; dr
    • Technicals
      • Urani's In-house Agents
        • MEV Agent Aleph
        • MEV Agent Bet
      • The Onboarding Process
      • Economic Incentives
      • MEV Agent Specs
      • Setting up an Agent's Graph
      • Building an initial AMM Strategy
      • Liquidity Strategies
        • On Solana
          • Raydium
          • Phoenix
          • Orca
          • Meteora
          • Jupiter
      • Performance and Reputation
      • Solving Cryptomarkets
        • Quantitative Theories and AI-Centric Agents
        • DeFi Glossary
        • In Honor of Jim Simons (1938-2024)
Powered by GitBook
  1. URANI PROTOCOL
  2. Technicals

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=B−Sπ(s)f_{\texttt{surplus}}(s) = \texttt{order surplus} = B - \frac{S}{\pi(s)}fsurplus​(s)=order surplus=B−π(s)S​

where

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

The order can be executed only if:

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

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

S≤sell amountS \leq \texttt{sell amount}S≤sell amount

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

S=sell amountS = \texttt{sell amount}S=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)Ωsurplus​=max(fsurplus​(s))

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).

PreviousTechnicalsNextRaking the Agents' Solution

Last updated 8 months ago