```ts
export function rateCap(price: number, rate: number, most: number): number {
  if (rate < 0) {
    throw new Error("Rate cannot be negative");
  }

  const increase = Math.floor(price * (rate / 100));
  return Math.min(price + increase, most);
}
```