mirror of
https://github.com/lux-apps/papers.git
synced 2026-10-30 18:15:21 +00:00
Restructured from flat .tex/.pdf files into per-paper subdirectories. Added Antje Worring as co-author on all papers. Synced PDFs to pdfs/ for download site.
116 lines
3.7 KiB
TeX
116 lines
3.7 KiB
TeX
\section{Bonding Curve Algorithms}
|
|
|
|
|
|
QuantumSwap pools are parameterized by a bonding curve that determines
|
|
price dynamics. Each \texttt{LUXQSAPair} contract is associated with
|
|
exactly one curve. The curves are pure functions: they do not modify
|
|
pool state. State updates occur in the \texttt{LUXRWAPair} contract
|
|
after the curve is consulted.
|
|
|
|
\subsection{Notation}
|
|
|
|
Let $\mathit{spot}$ denote the current spot price (instantaneous price
|
|
to sell one item to the pool), $\delta$ the curve parameter, and $x$
|
|
the trade size. The spot price to \emph{buy} one item from the pool is
|
|
always $\mathit{spot} + \delta$ (additive) or $\mathit{spot} \cdot
|
|
(1 + \delta)$ (multiplicative), depending on the curve.
|
|
|
|
\subsection{Linear Bonding Curve}
|
|
|
|
The linear curve adjusts price by a constant additive amount $\delta$
|
|
per item traded:
|
|
|
|
\begin{align}
|
|
\mathit{spot}_{\text{after sell}} &= \mathit{spot} - \delta
|
|
\label{eq:linear-sell} \\
|
|
\mathit{spot}_{\text{after buy}} &= \mathit{spot} + \delta
|
|
\label{eq:linear-buy}
|
|
\end{align}
|
|
|
|
For a multi-item sell of $x$ items, the total payout is:
|
|
|
|
\begin{equation}\label{eq:linear-multi}
|
|
\text{Payout}(x) = \sum_{i=0}^{x-1} (\mathit{spot} - i\delta)
|
|
= x \cdot \mathit{spot} - \delta \cdot \frac{x(x-1)}{2}
|
|
\end{equation}
|
|
|
|
\begin{remark}
|
|
The LP must set $\delta$ with the same decimal precision as the
|
|
pair's underlying token. For an ETH-denominated pair with
|
|
$\mathit{spot} = 1\,\text{ETH}$ and $\delta = 0.1\,\text{ETH}$,
|
|
selling 5~NFTs yields
|
|
$5 \cdot 1 - 0.1 \cdot 10 = 4\,\text{ETH}$, distributed as
|
|
$\{1, 0.9, 0.8, 0.7, 0.6\}$.
|
|
\end{remark}
|
|
|
|
\subsection{Exponential Bonding Curve}
|
|
|
|
The exponential curve adjusts price by a multiplicative factor:
|
|
|
|
\begin{align}
|
|
\mathit{spot}_{\text{after buy}} &= \mathit{spot} \cdot (1 + \delta)
|
|
\label{eq:exp-buy} \\
|
|
\mathit{spot}_{\text{after sell}} &= \frac{\mathit{spot}}{1 + \delta}
|
|
\label{eq:exp-sell}
|
|
\end{align}
|
|
|
|
After $x$ consecutive buys from an initial spot price $p_0$:
|
|
|
|
\begin{equation}\label{eq:exp-multi}
|
|
\mathit{spot}(x) = p_0 \cdot (1+\delta)^x
|
|
\end{equation}
|
|
|
|
The total cost of buying $x$ items is:
|
|
|
|
\begin{equation}
|
|
\text{Cost}(x) = p_0 \cdot (1+\delta) \cdot
|
|
\frac{(1+\delta)^x - 1}{\delta}
|
|
\end{equation}
|
|
|
|
\begin{remark}
|
|
With $p_0 = 2\,\text{ETH}$ and $\delta = 0.5$ (50\%), the price
|
|
sequence for 3~buys is $\{3, 4.5, 6.75\}$ ETH. Selling into the
|
|
pool divides by $1.5$ at each step.
|
|
\end{remark}
|
|
|
|
\subsection{XYK Bonding Curve}
|
|
|
|
The XYK curve maintains a constant-product invariant over virtual
|
|
reserves, adapted for NFT pools. At pool creation:
|
|
|
|
\begin{align}
|
|
R_{\text{nft}} &= \text{(number of items to buy or sell)} + 1
|
|
\label{eq:xyk-nft} \\
|
|
R_{\text{token}} &= R_{\text{nft}} \cdot \mathit{spot}
|
|
\label{eq:xyk-token}
|
|
\end{align}
|
|
|
|
The price to buy $x$ items from the pool (receiving NFTs, sending
|
|
tokens) is:
|
|
|
|
\begin{equation}\label{eq:xyk-buy}
|
|
\text{Cost}(x) = \frac{x \cdot R_{\text{token}}}{R_{\text{nft}} - x}
|
|
\end{equation}
|
|
|
|
The price to sell $x$ items to the pool is:
|
|
|
|
\begin{equation}\label{eq:xyk-sell}
|
|
\text{Payout}(x) = \frac{x \cdot R_{\text{token}}}{R_{\text{nft}} + x}
|
|
\end{equation}
|
|
|
|
After each trade, the virtual reserves update:
|
|
\begin{itemize}[nosep]
|
|
\item Pool sells NFTs:
|
|
$R_{\text{nft}} \leftarrow R_{\text{nft}} - x$, \;
|
|
$R_{\text{token}} \leftarrow R_{\text{token}} + \text{Cost}(x)$
|
|
\item Pool buys NFTs:
|
|
$R_{\text{nft}} \leftarrow R_{\text{nft}} + x$, \;
|
|
$R_{\text{token}} \leftarrow R_{\text{token}} - \text{Payout}(x)$
|
|
\end{itemize}
|
|
|
|
A concentration parameter allows LPs to tighten or loosen the curve
|
|
around the current price, analogous to Uniswap V3's concentrated
|
|
liquidity~\cite{uniswapv3} but applied to discrete (NFT) assets.
|
|
|
|
%% ============================================================
|