> check on the users balance and only allow the leftover amount to be used to buy the bonds I.e if I already have $2K worth of bonds then I should be allowed only another $8K worth of bonds.
Your pseudocode already failed the unit tests. The limit is 10k per year, and you can hold I bonds for 30 years. Someone can have 300k of I bonds in their account balance.