doc and whitepaper update

This commit is contained in:
tim
2025-11-19 16:01:45 -04:00
parent 30a3f4de5d
commit 24624f8480
2 changed files with 38 additions and 10 deletions

View File

@@ -3,16 +3,12 @@ pragma solidity ^0.8.30;
import {ABDKMath64x64} from "../lib/abdk-libraries-solidity/ABDKMath64x64.sol";
/// @notice Stabilized LMSR library with incremental exp(z) caching for gas efficiency.
/// - Stores b (64.64), M (shift), Z = sum exp(z_i), z[i] = (q_i / b) - M
/// - Caches e[i] = exp(z[i]) so we avoid recomputing exp() for every asset on each trade.
/// - Provides closed-form ΔC on deposit, amount-out for asset->asset,
/// and incremental applyDeposit/applyWithdraw that update e[i] and Z in O(1).
/// @notice Numerically stable library for a Logarithmic Market Scoring Rule based AMM. See docs/whitepaper.md
library LMSRStabilized {
using ABDKMath64x64 for int128;
struct State {
int128 kappa; // liquidity parameter κ (64.64 fixed point)
int128 kappa; // liquidity parameter κ (64.64 fixed point)
int128[] qInternal; // cached internal balances in 64.64 fixed-point format
}