def tick_at
import cswap-bend-cli@0.1.0.0/tui/fmt.bend as Fmtimport Base
177# Where the threshold tick sits: round(threshold / 100 * width), kept in range.
178def tick_at(+thr: Maybe<&2, U32>, +w: Nat) -> Maybe<&2, Nat>:
179 match thr:
180 case None{}:
181 None{}
182 case Some{t}:
183 Some{Nat.min(Nat.sub(w, 1n), U32.to_nat((((t * U32.from_nat(w)) + 5000 : U32) / 10000 : U32)))}