The ICRC-1 spec says:
If the fee argument does not agree with the ledger fee, the ledger MUST return variant { BadFee = record { expected_fee = … } } error.
This sounds like the BadFee
error takes precedence over the InsufficientFunds
error. The ICRC-1 standard should be clearer about this.
To illustrate the difference, say I have 1 ICP in an account and transfer 1 ICP out with a fee of 0. Then I will get a BadFee error and not InsufficientFunds. The same happens if I transfer any amount larger than 1 ICP and a wrong fee. This means BadFee takes precedence over InsufficientFunds. It makes sense that way.
However, TCYCLES is an exception in that it does not follow this rule. The TCYCLES ledger will return InsufficientFunds in the above cases. It’s a bug in TCYCLES.