Skip to main content

Module weights

Module weights 

Source

Constants§

AMM_RESERVE_PRECISION
Drift AMM reserve precision (used for size normalisation).
SPOT_IMF_PRECISION
Drift IMF factor precision.
SPOT_WEIGHT_PRECISION
Drift spot market weight precision: 10_000 = 100%.

Functions§

calculate_asset_weight
Calculate the effective initial asset weight for a position, applying both scale-down (when market deposits are large) and IMF size discount.
calculate_liability_weight
Calculate the effective initial liability weight for a position, applying IMF size premium.
calculate_scaled_initial_asset_weight
Scales the initial asset weight down when total market deposits exceed a threshold.
calculate_size_discount_asset_weight
Applies IMF size discount to asset weight — larger deposits get less collateral credit.
calculate_size_premium_liability_weight
Applies IMF size premium to liability weight — larger borrows need more margin.
get_strict_price
Get a conservative oracle price for margin calculations.
to_amm_precision
Convert a token balance from native decimals to AMM_RESERVE_PRECISION (1e9).