const SECONDS_IN_YEAR = 365 * 24 * 60 * 60; export function calculateSnatchShortfall( outstandingStake: bigint, desiredStakeShares: bigint, stakeTotalSupply: bigint, capNumerator: bigint = 2n, capDenominator: bigint = 10n ): bigint { if (capDenominator === 0n) { throw new Error('capDenominator must be greater than zero'); } const cap = (stakeTotalSupply * capNumerator) / capDenominator; const required = outstandingStake + desiredStakeShares; const delta = required - cap; return delta > 0n ? delta : 0n; } export function isPositionDelinquent( lastTaxTimestamp: number, taxRate: number, referenceTimestamp: number = Math.floor(Date.now() / 1000), secondsInYear: number = SECONDS_IN_YEAR ): boolean { const rate = Number(taxRate); if (rate <= 0) return false; const allowance = secondsInYear / rate; return referenceTimestamp - lastTaxTimestamp > allowance; }