An implementation of the Logarithmic Market Scoring Rule (LMSR) in Sui Move.
LMSR is an automated market maker designed for prediction markets. It provides continuous liquidity and automatic price discovery which ensures that traders can always buy or sell outcome shares while maintaining proper probabilistic pricing that sums to 1.
Add to your Move.toml:
[dependencies]
lmsr = { git = "https://github.com/open-move/lmsr.git", rev = "main" }sui move build
sui move testuse lmsr::lmsr;
// Create market with 3 outcomes
let decimals = 6u8; // Precision for price calculations
let liquidity = 1000 * 10u64.pow(decimals); // Higher = more stable prices
let quantities = vector::tabulate!(3, |_| 100 * 10u64.pow(decimals));
// Get all prices (sum to 1.0)
let prices = lmsr::prices(quantities, liquidity, decimals);
// Cost to buy 50 shares of outcome 1
let cost = lmsr::cost(1, 50, quantities, liquidity, decimals);
quantities[1] = quantities[1] + 50;
// Payout for selling 20 shares of outcome 1
let payout = lmsr::payout(1, 20, quantities, liquidity, decimals);base_cost(quantities, b, decimals)- Total market costprice(quantities, index, b, decimals)- Single outcome priceprices(quantities, b, decimals)- All outcome pricescost(index, amount, quantities, b, decimals)- Buy costpayout(index, amount, quantities, b, decimals)- Sell payout