price() fixes; sepolia redeploy
This commit is contained in:
@@ -4,15 +4,15 @@
|
||||
We present a multi-asset automated market maker whose pricing kernel is the Logarithmic Market Scoring Rule (LMSR) ([R. Hanson, 2002](https://mason.gmu.edu/~rhanson/mktscore.pdf)). The pool maintains the convex potential $C(\mathbf{q}) = b(\mathbf{q}) \log\!\Big(\sum_i e^{q_i / b(\mathbf{q})}\Big)$ over normalized inventories $\mathbf{q}$, and sets the effective liquidity parameter proportional to pool size as $b(\mathbf{q}) = \kappa \, S(\mathbf{q})$ with $S(\mathbf{q}) = \sum_i q_i$ and fixed $\kappa>0$. This proportional parameterization preserves scale-invariant responsiveness while retaining softmax-derived pairwise price ratios under a quasi-static-$b$ view, enabling any-to-any swaps within a single potential. We derive and use closed-form expressions for two-asset reductions to compute exact-in, exact-out, limit-hitting (swap-to-limit), and capped-output trades. We discuss stability techniques such as log-sum-exp, ratio-once shortcuts, and domain guards for fixed-point arithmetic. Liquidity operations (proportional and single-asset joins/exits) follow directly from the same potential and admit monotone, invertible mappings. Parameters are immutable post-deployment for transparency and predictable depth calibration.
|
||||
|
||||
## Introduction and Motivation
|
||||
Multi-asset liquidity typically trades off simplicity and expressivity. Classical CFMMs define multiplicative invariants over reserves, while LMSR specifies a convex cost function whose gradient yields prices. Our goal is a multi-asset AMM that uses LMSR to support any-to-any swaps, shares risk across many assets, and scales depth predictably with pool size. By setting $b(\mathbf{q})=\kappa S(\mathbf{q})$, we achieve scale invariance: proportional rescaling of all balances scales $b$ proportionally and preserves pairwise price ratios, so the market’s responsiveness is consistent across liquidity regimes. The derivations below formulate instantaneous prices, closed-form swap mappings, limit logic, and liquidity operations tailored to this parameterization.
|
||||
Classical CFMMs define multiplicative invariants over reserves, while LMSR specifies a convex cost function whose gradient yields prices. Our goal is a multi-asset AMM that uses LMSR to support any-to-any swaps, shares risk across many assets, and scales depth predictably with pool size. By setting $b(\mathbf{q})=\kappa S(\mathbf{q})$, we achieve scale invariance: proportional rescaling of all balances scales $b$ proportionally and preserves pairwise price ratios, so the market’s responsiveness is consistent across liquidity regimes. The derivations below formulate instantaneous prices, closed-form swap mappings, limit logic, and liquidity operations tailored to this parameterization.
|
||||
|
||||
### Relation to liquidity-sensitive LMSR (Othman et al.)
|
||||
[Othman et al., 2013](https://www.cs.cmu.edu/~sandholm/liquidity-sensitive%20market%20maker.EC10.pdf) introduce a liquidity-sensitive variant of LMSR (often called LS-LMSR) in which the liquidity parameter is allowed to evolve continuously via a scaling variable commonly denoted $\alpha$. Their formulation derives the full pricing equations for a continuously varying $b(\cdot)$ as $\alpha$ changes, and it purposefully ties the cost function to the path along which liquidity evolves.
|
||||
- Conceptual correspondence: $\alpha$ in LS-LMSR plays a role analogous to our $\kappa$ in that both modulate how responsive prices are to inventory imbalances; in that sense $\alpha$ and $\kappa$ correspond as liquidity-scaling quantities. However, they are not identical: $\alpha$ in the LS-LMSR literature is a continuous scaling variable used to model an explicitly path-dependent evolution of $b$, while our $\kappa$ is a fixed proportionality constant and $b(\cdot)=\kappa\cdot S(\cdot)$ ties liquidity directly to the instantaneous pool size.
|
||||
- Practical and formal differences: the continuous LS-LMSR pricing equations (with $\alpha$-driven evolution of $b$) generally give up path independence—the final cost can depend on the particular liquidity trajectory—whereas our design preserves path independence on a piecewise or quasi-static basis by evaluating swap steps with $b$ held at the local pre-trade state and then updating $b$ according to the new $S$. This yields a pool that is easier to reason about and whose swap mappings admit closed-form two-asset reductions.
|
||||
- EVM feasibility: the exact continuous LS-LMSR price rules require richer integrals and state-continuous formulas that are substantially more gas-intensive to evaluate on-chain. For that reason we adopt a piecewise/quasi-static treatment that recovers softmax-driven pairwise ratios within each operation and updates $b$ discretely with state changes—combining tractable closed forms, numerical safety, and gas-efficiency.
|
||||
- Naming and convention: because our approach keeps the liquidity sensitivity but enforces quasi-static (piecewise) evaluation, we call it "quasi-static LS-LMSR" rather than LS-LMSR. In the remainder of this document, we use $\kappa$ to denote our fixed proportionality; $\kappa$ corresponds to, but is not the same object as, the $\alpha$ used when deriving continuous LS-LMSR.
|
||||
- Takeaway: Othman et al.'s treatment is closely related in spirit and provides valuable theoretical context, but the continuous $\alpha$-driven pricing equations differ formally from the $\kappa\to b(\cdot)=\kappa S(\cdot)$ parameterization used here; our choice trades full path dependence for piecewise path independence and EVM practicality, while retaining liquidity sensitivity and predictable scaling.
|
||||
[Othman et al., 2013](https://www.cs.cmu.edu/~sandholm/liquidity-sensitive%20market%20maker.EC10.pdf) introduce a liquidity-sensitive variant of LMSR called LS-LMSR in which the liquidity parameter is allowed to evolve continuously via a scaling variable commonly denoted $\alpha$. Their formulation derives the full pricing equations for a continuously varying $b(\cdot)$ as $\alpha$ changes, and it purposefully ties the cost function to the path along which liquidity evolves.
|
||||
- **Conceptual correspondence:** $\alpha$ in LS-LMSR plays a role analogous to our $\kappa$ in that both modulate how responsive prices are to inventory imbalances; in that sense $\alpha$ and $\kappa$ correspond as liquidity-scaling quantities. However, they are not identical: $\alpha$ in the LS-LMSR literature is a continuous scaling variable used to model an explicitly path-dependent evolution of $b$, while our $\kappa$ is a fixed proportionality constant and $b(\cdot)=\kappa\cdot S(\cdot)$ ties liquidity directly to the instantaneous pool size.
|
||||
- **Practical and formal differences:** the continuous LS-LMSR pricing equations (with $\alpha$-driven evolution of $b$) generally give up path independence—the final cost can depend on the particular liquidity trajectory—whereas our design preserves path independence on a piecewise or quasi-static basis by evaluating swap steps with $b$ held at the local pre-trade state and then updating $b$ according to the new $S$. This yields a pool that is easier to reason about and whose swap mappings admit closed-form two-asset reductions.
|
||||
- **EVM feasibility:** the exact continuous LS-LMSR price rules require richer integrals and state-continuous formulas that are substantially more gas-intensive to evaluate on-chain. For that reason we adopt a piecewise/quasi-static treatment that recovers softmax-driven pairwise ratios within each operation and updates $b$ discretely with state changes—combining tractable closed forms, numerical safety, and gas-efficiency.
|
||||
- **Naming and convention:** because our approach keeps the liquidity sensitivity but enforces quasi-static (piecewise) evaluation, we call it "quasi-static LS-LMSR" rather than LS-LMSR. In the remainder of this document, we use $\kappa$ to denote our fixed proportionality; $\kappa$ corresponds to, but is not the same object as, the $\alpha$ used when deriving continuous LS-LMSR.
|
||||
- **Takeaway:** Othman et al.'s treatment is closely related in spirit and provides valuable theoretical context, but the continuous $\alpha$-driven pricing equations differ formally from the $\kappa\to b(\cdot)=\kappa S(\cdot)$ parameterization used here; our choice trades full path dependence for piecewise path independence and EVM practicality, while retaining liquidity sensitivity and predictable scaling.
|
||||
|
||||
## System Model and Pricing Kernel
|
||||
We consider $n\ge 2$ normalized assets with state vector $\mathbf{q}=(q_0,\dots,q_{n-1})\in\mathbb{R}_{\ge 0}^{\,n}$ and size metric $S(\mathbf{q})=\sum_i q_i$. The kernel is the LMSR cost function
|
||||
|
||||
Reference in New Issue
Block a user