```ts
export function baseAmount(amount: number, unit: string, defs: Record<string, [number, string]>, base: string): number {
  if (amount < 0 || !Number.isInteger(amount)) throw new Error('Invalid amount');
  if (!(unit in defs) && unit !== base) throw new Error('Unknown unit');
  
  const seen = new Set<string>();
  let currentUnit = unit;
  
  while (currentUnit !== base) {
    if (seen.has(currentUnit)) throw new Error('Loop detected in definitions');
    seen.add(currentUnit);
    
    const [factor, finer] = defs[currentUnit];
    if (factor <= 0 || !Number.isInteger(factor)) throw new Error('Invalid factor');
    amount *= factor;
    currentUnit = finer;
  }
  
  return amount;
}
```