Suppose you took a loan and have to to pay it off uniformly. You made more money than you initially thought when you took the loan and have yet to pay 50 000 $ off, but have 20 000 $ credit on an account of the same bank when the bank defaults.
If it is decided that every creditor of the bank gets 20% of what the bank actually owes them, do you still owe 50 000 $ to the bank / the other creditors and get 4 000 $ of the insolvency estate, or do you only owe 30 000 $?
If the question is not answerable in the context of a bank defaulting because they'd be backed (I just remembered that in the EU, all banks need to be backed for the monetary value I stated above anyways, so maybe assume values bigger than 100 000 €.) or are virtually guaranteed to be bought up by a different bank, assume it to be some regular company defaulting with a different company having contracts with each other. For example: Company A is obligated to ship 10 000 parts per month to company B for which company B paid a year ahead, but company B also received some other goods which (by contract) they only have to pay for 2 months after receiving them.
I live in Germany, so my I'm mainly interested in how it is handled in Germany, but I think it's very similar throughout the EU. So if you know the answer in the context of a different EU country, that's also fine. Furthermore, I'm interested in the situation in the US, because ... come on, it's the US.