If you think about the bank payment system as a process during the day you'll realise that payments and deposits move around in a variety of different ways completely un-coordinated with each other and turning up at completely different times. Additionally it can take time before a payment requested in one system is recorded as a receipt in another.
Therefore the payment system is actually a specific implementation of a system pattern known as the Producer-Consumer problem The reason the problem is a problem is because of what is known as the 'boundary conditions' - what happens when there is nothing in the buffer or the buffer gets full. That is where it gets its other name - the 'bounded buffer problem'. I've probably spent most of my career trying to implement near optimal solutions to this problem.
Reams of papers have been written about it and many PhDs awarded, but there isn't a solution that operates all the time, handles the boundaries effectively and is optimally efficient. It is always a trade off.
Here it is applied to central banking:
Lots of payers and payees all transacting with the clearing system asynchronously - the buffer here being the clearing accounts at the central bank.
If you operate this system with bounded buffers then in certain circumstances - under strain or when there are mistakes - you will get cascade failures in the payment system. This is exactly the same as what happens when you take your mobile phone into a weak WiFi area. The network buffers exhaust or fill and you start to get applications generating errors or just exploding. Similarly if your disk fills up on your computer. Lots of errors, lots of information loss, lots of clearing up to do afterwards.
The central bank gets around this problem in relatively simple way. It simply redefines the problem and makes the buffer essentially unlimited. Do that and the impact of boundary conditions vanishes. The system is guaranteed to work at its most efficient.
So, intraday, any central bank user gets an effective unlimited overdraft (technically an intraday liquidity repo) to ensure that the payment system always clears. Then at the end of the day everybody squares their positions with each other and the system resets to zero ready for the next day.
Bank A and Bank B both start the day with zero on their account at the central bank, and the payments move around. Towards the end of the day there has been a net transfer of 100 from Bank A to Bank B
|Position 1: Just before end of day|
Bank A now has a debt to the central bank it needs to clear at the end of the day, so it makes an offer to borrow 100 in the overnight market which Bank B gladly takes up. This allows Bank A to clear its position at the central bank.
|Position 2: Just after end of day|
The extra intraday reserves vanish in a puff of accounting logic and the overnight position is in place.
You'll note that the overnight position is precisely the same as the one you get if Bank A did a direct transfer to Bank B. To allow the transfer to happen, Bank B has to take the place of the depositors that wish to move out of Bank A to Bank B. Bank B has to become the creditor of Bank A to balance the extra depositors it now has.
So the extra reserves required to support additional loans made by the banks simply pop into being during the daily clearance process and disappear again just as quickly during the end of day clear up as the interbank lending market does its job. All dynamically, as required, to support the efficient operation of the payment system.
Of course if the banks stop trusting each other and refuse to bid in the overnight market then the central bank has to take action. It then becomes the 'lender of last resort' and position 1 persists overnight with Bank A paying a fee to the central bank, and the central bank likely paying nothing to Bank B.
Another alternative to that facility would be to insure interbank lending, or simply do away with the interbank market completely and leave position 1 in place all the time.