@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / index / snapToCadence

Function: snapToCadence()

snapToCadence(sec): number

Defined in: packages/sdk/src/interval.ts:136

Snap a raw cadence (seconds) to the CADENCE_LADDER_SEC rung it is within CADENCE_TOLERANCE_SEC of — 898 → 900, 59 → 60, 3599 → 3600 — so scheduling jitter groups and filters as the cadence it is. A window that matches no rung falls through to snapIntervalSec, which keeps a genuinely different window out of a cadence it isn't (3163 → 3163, 1437 → 1437) but still applies its own ±2s unit snap, so an off-ladder cadence lands on a clean unit rather than on itself: 598 → 600 ("10m"). Non-positive → 0.

Parameters

sec

number

Returns

number