Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Support CAP-0003: Account for the "liabilities" on an account #2

Closed
nikhilsaraf opened this issue Aug 24, 2018 · 1 comment
Closed
Labels
feature request New feature or request
Milestone

Comments

@nikhilsaraf
Copy link
Contributor

nikhilsaraf commented Aug 24, 2018

Desired Behavior

The bot should incorporate the liabilities change from Stellar Core (CAP-0003)

This will prevent the bot from placing "phantom" orders on the orderbook, limiting the amounts of the order to the current balance of the asset minus the sum of the amounts in currently open orders.

Impact

The desired behavior will allow me to conform to the new protocol changes and will prevent the bot from being caught off guard when these changes do go into effect in stellar-core.

Feature Suggestion

We can achieve the desired behavior by first summing up the outstanding orders as an initial calculation for liabilities. Once horizon has full support for liabilities we can switchover to using those exposed fields.

References

This feature does not exist anywhere else, please see the specification section below for details.

Additional context

See the Reddit post announcing the liabilities change and the migration schedule to protocol 10, which includes the liabilities change.

Some alternatives that would achieve the same result are:

  • Wait for horizon to get full support for liabilities and then update the bot. This would prevent us from having to compute the liabilities on an account directly.

The feature suggested above was better than these alternatives because we are already fetching all the relevant order information from Horizon and summing up our liabilities for XLM, we just need to extend this logic to non-native assets.

Horizon does not fully support liabilities yet, it has a 0 value for all liabilities, so this solution will allow us to be compliant in the mean time.

Specification

CAP-0003: https://github.com/stellar/stellar-protocol/blob/master/core/cap-0003.md

This section of the specification is particularly important:

  • account.sellingLiabilities
    • For account A: the amount of native asset offered to be sold, aggregated over all offers owned by A
  • account.buyingLiabilities
    • For account A: the amount of native asset offered to be bought, aggregated over all offers owned by A
  • trustline.sellingLiabilities
    • For account A and non-native asset X: the amount of X offered to be sold, aggregated over all offers owned by A
  • trustline.buyingLiabilities
    • For account A and non-native asset X: the amount of X offered to be bought, aggregated over all offers owned by A

Horizon will only show a valid value for liabilities if the latest ledger (/ledger) is using protocol version 10 (which depends on voting by the network). This should be taken into consideration if using the liabilities values from horizon.

@nikhilsaraf nikhilsaraf added the feature request New feature or request label Aug 24, 2018
@nikhilsaraf nikhilsaraf added this to the v1.0.0-rc2 milestone Aug 26, 2018
@nikhilsaraf nikhilsaraf modified the milestones: v1.0.0-rc3, v1.0.0-rc2 Sep 11, 2018
@nikhilsaraf
Copy link
Contributor Author

nikhilsaraf commented Sep 28, 2018

fixed with commits c9562d6..d208c47

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant