def need.of
import cswap-bend-cli@0.1.0.0/policy/algo.bend as Algoimport Base
import cswap-bend-cli@0.1.0.0/policy/safe.bend as SF
45# The least headroom a target needs: drain-first and a proactive automatic
46# switch must land below the threshold; an at-limit switch or a rotation takes
47# any headroom.
48def need.of(+algo: SF.Algo, +via: Via, +a: Nat, +thr: Nat) -> Nat:
49 need.under(drain(algo) || (via.auto(via) && Nat.is_gt(a, 0n)), thr)