def need.of

cswap-bend-cli@0.1.0.0 · policy/pick.bend:44

import cswap-bend-cli@0.1.0.0/policy/pick.bend as Pick
import Base
import cswap-bend-cli@0.1.0.0/policy/types.bend as T

44# The least headroom a target needs: at-limit and failover take any
45# headroom; proactive must land below the threshold and beat the active
46# account by the hysteresis margin.
47def need.of(+t: T.Trigger, +ah: Nat, +hy: Nat, +thr: Nat) -> Nat:
48  match t:
49    case T.Proactive{}:
50      Nat.max(Nat.add(ah, hy), Nat.add(Nat.sub(T.full(), thr), 1n))
51    case o:
52      1n

Uses (6)

Used by (1)