> For the complete documentation index, see [llms.txt](https://glimpse.gitbook.io/glimpse/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://glimpse.gitbook.io/glimpse/advanced/look-under-the-hood.md).

# Look Under the Hood

### How Glimpse Generates Forecasts

Glimpse uses an automated market maker based on a modified version of the Liquidity Sensitive Logarithmic Market Scoring Rule (LS-LMSR).

In simple terms, this system allows participants to buy and sell contracts while continuously updating the market's forecast.

Every trade contributes information.

As participants express their expectations through trading, the market maker adjusts prices to reflect changing probabilities.

The result is a live forecast that evolves as new information enters the market.

Unlike traditional order-book markets, participants trade directly with the market maker. This allows Glimpse to generate continuous forecasts across many possible outcomes while maintaining liquidity.

The forecast is not determined by Glimpse.

It is determined by the collective actions of market participants.

### How are the markets operated?

To predict the outcome of some future event, the LS-LMSR cost-function market maker offers $$m$$ event contracts, one for each possible (mutually exclusive) outcome. An event contract pays $$100$$ sats if the corresponding outcome is realized and $$0$$ sats otherwise, and the contracts are priced between $$1$$ and $$100$$ sats before resolution.

Let $$q\_i$$ be the total quantity of contract $$i$$ held by all traders combined, and let $$\bold{q} = (q\_1 \dots q\_n)$$ be the vector of all quantities held. The market maker utilizes a cost function $$C(\bold{q})$$ that records the total amount of money traders have spent as a function of the total number of contracts held on each outcome.

A trader who wants to buy any bundle of contracts such that the total number of outstanding contracts changes from $$q\_{\text{old}}$$ to $$q\_{new}$$ must pay $$C(\bold{q\_{\text{new}}}) - C(\bold{q\_{\text{old}}})$$ sats to the market maker. Negative quantities encode sell orders, and negative “payments” encode sale proceeds earned by the trader.

### How is the cost for any trade determined?

LS-LMSR AMM cost function $$C(\bold{q})$$ determines the cost for any trade which changes the quantity of contracts outstanding. The conventional LMSR cost function is written as&#x20;

$$
C(\bold{q}) = b(\bold{q}) \log{ \left( \sum\_{i}\text{exp}(q\_i/b(\bold{q})) \right) }
$$

where $$b(\bold{q}) = b$$ is an exogenously set constant. Since we are denominating our trades in Bitcoin unit of account (sats), we will be modifying the cost function as follows

$$
C(\bold{q}) = 100 \cdot b(\bold{q}) \log{ \left( \sum\_{i}\text{exp}(q\_i/b(\bold{q})) \right) }
$$

If we let $$b(\bold{q}) = \alpha \cdot \sum\_{j}q\_j$$ then the LMSR cost function and price function become liquidity sensitive (and turns into an LS-LMSR cost function). Sensitivity to liquidity is desirable because it squares intuitively with the way we would want markets to function: small investments move prices less in thick (liquid) markets than in thin (illiquid) markets.

Therefore, our Bitcoin-denominated LS-LMSR cost function is defined as follows:

$$
C(\bold{q}) = 100 \cdot b(\bold{q}) \log{ \left( \sum\_{i}\text{exp}(q\_i/b(\bold{q})) \right) }
$$

In general, if a trader wishes to buy any bundle of contracts from the LS-LMSR AMM  such that the total number of outstanding contracts changes from $$q\_{\text{old}}$$ to $$q\_{new}$$, they must pay $$C(\bold{q\_{\text{new}}}) - C(\bold{q\_{\text{old}}})$$ sats to the market maker. If they are selling some bundle of contracts such that the total number of outstanding contracts changes from $$q\_{\text{old}}$$ to $$q\_{new}$$, then the market maker will pay $$C(\bold{q\_{\text{new}}}) - C(\bold{q\_{\text{old}}})$$ sats to the trader (negative cost encodes sell orders). The cost per trade is ultimately dependent on the quantity of contracts outstanding in the market, hence the prices are determined in a decentralized way through market participation.

### How are prices determined?

Since we are utilizing a path-independent market maker, the instantaneous price of outcome $$i$$ is given by the partial derivative of the cost function along $$i$$. We can take the partial derivative of the cost function to derive the price function as follows:&#x20;

$$
\begin{align\*}
p\_i(\bold{q}) &= \frac{\partial C(\bold{q})}{\partial q\_i} \\
&= \frac{\partial}{\partial q\_i} 100 \cdot b(\bold{q}) \cdot \log \left( \sum\_{i}\exp(q\_i/b(\bold{q})) \right) \\
&= \frac{\partial}{\partial q\_i} 100 \cdot \alpha \cdot \sum\_{j}q\_j \cdot \log \left( \sum\_{i}\exp(q\_i/b(\bold{q})) \right) \\
&= 100 \cdot \alpha \cdot \log \left( \sum\_{j}\exp(q\_j/b(\bold{q})) \right) + 100 \cdot \frac{\sum\_{j}q\_j \exp(q\_i/b(\bold{q})) - \sum\_{j}q\_j \exp(q\_{j}/b(\bold{q})) }{\left(\sum\_{j}q\_j \right) \cdot \left( \sum\_{j}\exp(q\_j/b(\bold{q})) \right)}
\end{align\*}
$$

Therefore, our revised Bitcoin-denominated LS-LMSR price function is:

$$
p\_i(\bold{q}) = 100 \cdot \alpha \cdot \log \left( \sum\_{j}\exp(q\_j/b(\bold{q})) \right) + 100 \cdot \frac{\sum\_{j}q\_j \exp(q\_i/b(\bold{q})) - \sum\_{j}q\_j \exp(q\_{j}/b(\bold{q})) }{\left(\sum\_{j}q\_j \right) \cdot \left( \sum\_{j}\exp(q\_j/b(\bold{q})) \right)}
$$

Since the LS-LMSR price function components sum to greater than 100%, we normalize prices to give us a final probability distribution.

$$
P\_i(\bold{q}) = \frac{p\_i(\bold{q})}{\sum\_{k = 1}^{n}p\_k(\bold{q})}
$$

For a two-outcome LS-LMSR, where the outcomes are yes and no, we have

$$
P\_{\text{yes}} = \frac{p\_{\text{yes}}(\bold{q})}{p\_{\text{yes}}(\bold{q}) + p\_{\text{no}}(\bold{q})} ; ; \text{ and } ; ; P\_{\text{no}} = \frac{p\_{\text{no}}(\bold{q})}{p\_{\text{yes}}(\bold{q}) + p\_{\text{no}}(\bold{q})}
$$

The price function ultimately aggregates information reported from traders and translates that information into a probability distribution. The odds, which reflect the market-consensus probability of each outcome occurring, is determined by the price function. Any time traders buy or sell contracts, the price function updates its forecast, since the quantity of contracts outstanding is changed. Since any trader has the ability to buy or sell, any trader has the ability to change the forecast according to their own beliefs. Probabilities are ultimately determined by the market, and the final probability/price is the consensus belief of all traders aggregated into a single value.

### What are the fees?

The LS-LMSR AMM charges 2% transaction cost on buying or selling any quantity of contracts. The minimum fee rate is 1 sat per transaction.

### Are there any other fees?

No.

###
