Skip to content

adjust_protocol_liquidity drops emissions if injection would push Balancer weights outside the range #2733

Description

@gztensor

pallet_subtensor_swap::Pallet::adjust_protocol_liquidity (pallets/swap/src/pallet/impls.rs:84-117) calls Balancer::update_weights_for_added_liquidity to recompute the new quote_weight after a disproportional injection. If the computed weight would fall outside [MIN_WEIGHT, 1 - MIN_WEIGHT] = [0.01, 0.99], the call returns BalancerError::InvalidValue. In that case adjust_protocol_liquidity silently logs a warning and returns (TaoBalance::ZERO, AlphaBalance::ZERO):

if balancer
    .update_weights_for_added_liquidity(...)
    .is_err()
{
    log::warn!("Reserves are out of range for emission: ...");
    (TaoBalance::ZERO, AlphaBalance::ZERO)
} else {
    SwapBalancer::<T>::insert(netuid, balancer);
    (tao_delta, alpha_delta)
}

The fix is to either (a) fall back to a clamped weight (MIN_WEIGHT or 1 - MIN_WEIGHT) when the computed weight is out of range and still inject the deltas, (b) at minimum, surface a hard error / event so the coinbase can carry-over the emission to the next block instead of burning it, or (c) accumulate the injection in reserviors and settle later.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions