# What should positive / negative balances represent?

**URL:** <https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501>\
**Category:** Implementations and SDKs\
**Created:** [April 12, 2019, 8:10pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501 "2019-04-12T20:10:23Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![adrianhopebailie](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/adrianhopebailie/32/31_2.png) [@adrianhopebailie](https://forum.interledger.org/u/adrianhopebailie)\
**Post date:** [April 25, 2019, 2:24pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/21 "2019-04-25T14:24:21Z")

</div>

> [@emschwartz](#):
>
> How does Alice’s implementation know when to send these packets?

when she wants to know the state of her config or request changes to it

---

<div class="post-metadata">

**Author:** ![emschwartz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/emschwartz/32/12_2.png) [@emschwartz](https://forum.interledger.org/u/emschwartz)\
**Post date:** [April 25, 2019, 2:26pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/22 "2019-04-25T14:26:09Z")

</div>

Would that be manually triggered by Alice herself or sent automatically by the implementation?

---

<div class="post-metadata">

**Author:** ![adrianhopebailie](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/adrianhopebailie/32/31_2.png) [@adrianhopebailie](https://forum.interledger.org/u/adrianhopebailie)\
**Post date:** [April 25, 2019, 2:32pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/23 "2019-04-25T14:32:35Z")

</div>

Implementation specific. One connector might have logic to send these things automatically based on config other might provide a UI for users to interact with the peer.

All we need to standardize, I think, is the meaning of these values and the expected behaviour when handling these messages (and other ILP packets).

The goal is that if I know those values I should be able to predict when you will send a settlement to me based on the packets we’ve exchanged.

I also have the ability to invoke a settlement from you by requesting that you change those.

An obvious safety net would be that you’d never let me change my balance, min balance or max balance and I clearly can’t put my settleTo below min balance.

The more subtle thing will be deciding on where you’ll let peers put the settleThreshold in relation to settleTo but I don’t think that’s complicated.

---

<div class="post-metadata">

**Author:** ![emschwartz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/emschwartz/32/12_2.png) [@emschwartz](https://forum.interledger.org/u/emschwartz)\
**Post date:** [April 25, 2019, 2:38pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/24 "2019-04-25T14:38:00Z")

</div>

Could you describe an algorithm for doing it automatically? I’m having trouble figuring out exactly when it would make sense to send them.

Two different design goals I have in mind are:

- Generally keeping the API requirements between nodes as minimal as possible to implement the features we need
- Making peering and management as automatic as possible to make operating a node simpler and help us grow the network

---

<div class="post-metadata">

**Author:** ![emschwartz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/emschwartz/32/12_2.png) [@emschwartz](https://forum.interledger.org/u/emschwartz)\
**Post date:** [April 25, 2019, 6:17pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/25 "2019-04-25T18:17:17Z")

</div>

> [@adrianhopebailie](#):
>
> All we need to standardize, I think, is the meaning of these values and the expected behaviour when handling these messages (and other ILP packets).

I agree that this is what we need to _standardize_, but we also need to implement some behavior for it.

Let me know if I’m thinking about this wrong but it seems like to support the method of querying / requesting changes to the limits like you suggest, we would need to:

- Track the current, min, and max `settleThreshold`
- Track the current, min, and max `settleTo`
- Implement an algorithm to trigger a query or request to the peer (maybe tied to whenever you send a settlement or just when you peer initially)
- Handle the cases where the peer a) agrees to the changes b) disagrees c) sets them to something other than what you asked for (for example, meeting you halfway if the value you requested is outside of their acceptable range)
- Ensure that we don’t introduce any vulnerabilities by allowing the peer to change the thresholds inappropriately

My gut reaction is that this seems to introduce more edge cases to code for and test, as well as a potential footgun in the form of not appropriately enforcing min/max values on the thresholds the peer requests and accidentally allowing your node to be drained of funds.

---

<div class="post-metadata">

**Author:** ![emschwartz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/emschwartz/32/12_2.png) [@emschwartz](https://forum.interledger.org/u/emschwartz)\
**Post date:** [April 25, 2019, 9:20pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/26 "2019-04-25T21:20:43Z")

</div>

Going back up the thread, what if we just track a single net balance number and, for nodes that accept pre-payment, have a separate number to track prepaid funds?

All ILP packets would affect the normal net balance position, and outgoing settlements would be based on this position.

When you get an incoming settlement, you would clear out as much of the peer’s debt as the settlement covers and any extra would be put into the prepaid funds account.

To be on the conservative side, if you’re pre-paying, you may want to have an explicit check to make sure you avoid the settling back and forth forever issue (there may be a better check but if you’re sending and receiving settlements with the same peer without having sent ILP packets, you may want to stop).

This still begs the question of what a positive vs negative balance represents 🙃

**Update** : I agree with @sappenin’s original comment that a positive balance should represent a liability. That way, both the balance and the prepaid amount are tracked in the same way.

---

<div class="post-metadata">

**Author:** ![adornala](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/adornala/32/269_2.png) [@adornala](https://forum.interledger.org/u/adornala)\
**Post date:** [April 26, 2019, 12:29pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/27 "2019-04-26T12:29:48Z")

</div>

QQ: Considering privacy: Should Bob at all be authorized to check Alice balance? Wouldn’t that raise security concerns?

---

<div class="post-metadata">

**Author:** ![emschwartz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/emschwartz/32/12_2.png) [@emschwartz](https://forum.interledger.org/u/emschwartz)\
**Post date:** [April 26, 2019, 12:42pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/28 "2019-04-26T12:42:58Z")

</div>

Bob can check _his_ balance on Alice’s system (assuming she exposes an API for that) but not anyone else’s

---

<div class="post-metadata">

**Author:** ![adornala](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/adornala/32/269_2.png) [@adornala](https://forum.interledger.org/u/adornala)\
**Post date:** [April 26, 2019, 1:05pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/29 "2019-04-26T13:05:06Z")

</div>

Thank you @emschwartz. Considering Bob is producer and Alex is consumer, Alex should pre-fund his account with bob to use his service, am I getting it right? That’s a nice idea, it increases scope for many accounting related options.

I somehow remember that using ILP, users can charge consumers without any subscription service. Is this like an addon or am I completely learning it wrong?

---

<div class="post-metadata">

**Author:** ![emschwartz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/emschwartz/32/12_2.png) [@emschwartz](https://forum.interledger.org/u/emschwartz)\
**Post date:** [April 26, 2019, 1:36pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/30 "2019-04-26T13:36:26Z")

</div>

I think you may be confusing this with higher level uses of ILP. If someone has a service or some content they want to offer, they can use ILP micropayments instead of a subscription to charge the users for access.

This thread is about how ILP nodes, such as the end user and their Interledger Service Provider (that they would use for all ILP payments) track balances between themselves on a lower level. If the user trusts the connector/ILSP more than the connector trusts the user, the user may need to prepay some small amount before the connector is willing to forward packets for them.

---

<div class="post-metadata">

**Author:** ![adornala](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/adornala/32/269_2.png) [@adornala](https://forum.interledger.org/u/adornala)\
**Post date:** [April 26, 2019, 1:53pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/31 "2019-04-26T13:53:51Z")

</div>

That’s right. Thanks @emschwartz. 👍

---

<div class="post-metadata">

**Author:** ![Mike\_Chapman](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/mike_chapman/32/95_2.png) [@Mike\_Chapman](https://forum.interledger.org/u/Mike_Chapman)\
**Post date:** [April 26, 2019, 2:27pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/32 "2019-04-26T14:27:46Z")

</div>

Again in my telecoms SMS background (high-volume/micro-cost), standard practice is the service provider displaying the balance of what a user has prefunded, perhaps with no credit line if the relationship is not bidirectional and a dynamic credit line available to them relative to the size of our Payable debt to them.

Netting too frequently with Alice could cause Bob liquidity issues when interacting with Carl, which does nobody any favours.

It’s also worth mentioning that certain geographies have netting restrictions, for example Brazil only allows netting in its local currency. And many geographies require netting to be reported to governments.

EDIT: You only need to read the paragraph above and this one. Netting can’t be forced due to regulatory issues. Two balances are necessary, but it doesn’t really matter how they are presented to users, as long as the accounting is correct. But as an end-user signing in to someones platform and looking at the balance I have available, I’d expect it to be positive if I have money to spend.

---

<div class="post-metadata">

**Author:** ![adrianhopebailie](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/adrianhopebailie/32/31_2.png) [@adrianhopebailie](https://forum.interledger.org/u/adrianhopebailie)\
**Post date:** [April 26, 2019, 2:47pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/33 "2019-04-26T14:47:49Z")

</div>

> [@Mike\_Chapman](#):
>
> an end-user signing in to someones platform and looking at the balance I have available, I’d expect it to be positive if I have money to spend

Agree. I think this is what @sappenin also said above (way above)

---

<div class="post-metadata">

**Author:** ![sappenin](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/sappenin/32/41_2.png) [@sappenin](https://forum.interledger.org/u/sappenin)\
**Post date:** [June 18, 2019, 3:19pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/34 "2019-06-18T15:19:00Z")

</div>

Circling back here to make sure I’m properly understanding things.

**Positive/Negative Balances**

> [@emschwartz](#):
>
> I agree with @sappenin’s original comment that a positive balance should represent a liability. That way, both the balance and the prepaid amount are tracked in the same way.

Cool – if I’m summarizing that and mapping it to some of the accounting terms we’ve been using, does this sound correct:

_From the perspective of the entity tracking an ILP balance, a positive balance represents a payable/liability. A negative balance represents a receivable/asset._

> [@emschwartz](#):
>
> Bob can check _his_ balance on Alice’s system (assuming she exposes an API for that) but not anyone else’s

I also agree with this statement, though it can get a little confusing.

For example, if Bob has prefunded 10 units to Alice, then technically speaking Alice owes Bob 10 units (Alice is holding those units on Bob’s behalf). Alice’s internal balance tracker would show 10 (i.e., Alice’s liability to Bob). If Bob asks Alice, “hey, what’s my balance”, Alice’s API should respond with +10 (from Bob’s point of view, Bob has 10 units stored at Alice).

However, if Bob asks his internal balance tracker what the balance is, it would report -10 (the inverse).

I’m comfortable with this behavior and these definitions, but I figured I’d call it out to both confirm that I’m understanding properly, and to ensure no objections.

---

<div class="post-metadata">

**Author:** ![kincaid](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/kincaid/32/39_2.png) [@kincaid](https://forum.interledger.org/u/kincaid)\
**Post date:** [June 19, 2019, 12:35pm UTC](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501/35 "2019-06-19T12:35:31Z")

</div>

In the net balance + prepaid balance model, what happens if both peers prepay? Does it function correctly? (This sounds odd, but if we ever implement auto-peering, that could be a likely arrangement between two nodes that each are not hubs, but don’t have reputation).

[Previous page](https://forum.interledger.org/t/what-should-positive-negative-balances-represent/501.md?page=1)
