Coffer Docs
Overview

Weights

How weights shape prices and pool exposure

Weights shape the pricing curve. Each token has 1%–99%, and all weights total 100%. They are set at creation and can change through an enabled range manager.

Weights do not promise a fixed real-asset allocation. An unamplified 80/20 pool holds those value shares when priced in line with the market; unequal leverage can change that relationship.

Buying the 80% token versus buying the 20% token

Buying means receiving a token from the pool. At the same fraction of the input token's virtual balance, buying the higher-weight token has less price impact. This does not establish the result for equal-dollar trades, which also depends on balances and prices.

How weights affect swap output

The contract's calc_out_given_in calculates output directly, without computing or storing a pool-wide invariant. Before integer rounding:

amount_out = V_out × (1 − (V_in / (V_in + amount_in))^(w_in / w_out))
  • V_in, V_out: virtual balances of the input and output tokens.
  • amount_in: input after the base swap fee, in the input token's raw units.
  • w_in, w_out: their current weights. On-chain, 80% = 8,000 basis points.

Weights enter through w_in / w_out. Buying the 80% token with the 20% token uses 20 / 80 = 0.25; the reverse direction uses 80 / 20 = 4.

Virtual balances and output use each token's raw units. If amount_out exceeds the actual output reserve, the swap fails. Any dynamic fee is then deducted from the output.

See Pricing Model for rounding and fees, or Weighted Pools Explained for an introduction.

On this page