What should positive / negative balances represent?

Whether or not everyone is required to implement the conclusion of this discussion, I am certainly planning to implement it.

After talking with @sappenin and @kincaid briefly I’m back to thinking we can make this work with Receivable and Payable balances. If we don’t keep track of the pending amounts separately, we just need to be very careful about when we apply changes to the balances.

The specific features we want to enable are:

  • Automatic settlement (triggering settlement when one party owes the other party more than a configured threshold amount)
  • Automatic netting (I should be able to spend from money you owe me, whether you owe it to me because I fulfilled packets you sent to me or because I sent a settlement to you)
  • Pre-funding (I may want to send you a settlement before I send packets through you to cover packets I will send)
  • Minimal bilateral communication about limits and thresholds (we would like to avoid having to discuss the specific limits and thresholds we’re configuring our systems with)

This is the table of actions and effects:

Action Effect Check Limit / Threshold
Receive Incoming Prepare if Receivable + Prepare Amount <= Max Receivable { + Receivable } else if Payable >= Prepare Amount { - Payable Balance } Limit: Receivable + Prepare Amount - Payable <= Max Receivable
Send Outgoing Prepare No effect
Receive Fulfill for Outgoing Prepare + Payable Balance Net if Payable > 0 and Receivable > 0; Settle if Payable >= Settle Threshold
Send Fulfill for Incoming Prepare No effect
Receive Reject for Outgoing Prepare No effect
Send Reject for Incoming Prepare + Payable Balance Net if Payable > 0 and Receivable > 0, Settle if Payable >= Settle Threshold
Receive Incoming Settlement - Receivable Balance
(Before) Send Outgoing Settlement - Payable Balance
Internal Netting - Receivable Balance, - Payable Balance

@matdehaast I think that two balances enables pre-funding while keeping the communication about the thresholds to a minimum and avoiding the settling back and forth forever problem @kincaid described.

2 Likes