Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include pool shares in account response #3832

Closed
tamirms opened this issue Aug 23, 2021 · 0 comments
Closed

Include pool shares in account response #3832

tamirms opened this issue Aug 23, 2021 · 0 comments
Assignees
Labels
amm support cap 38 (automated market makers) in horizon

Comments

@tamirms
Copy link
Contributor

tamirms commented Aug 23, 2021

Horizon already provides an endpoint to query account details. This endpoint will be modified in the case that the account is an LP for a liquidity pool. We will add an extra balance object in the response to describe how many shares of the liquidity pool are held by the account.

In the account response there is a balances field which consists of a list of balance objects. We will introduce the following breaking changes on the balance object which is included in the balances list:

  • asset_type can be liquidity_pool_shares. Previously the asset_type field was restricted to: native, credit_alphanum4, or credit_alphanum12.
  • buying_liabilities, selling_liabilities, asset_code, and asset_issuer are removed from the response for pool shares because they are not relevant to liquidity pools.
{
  "id": "GDI73WJ4SX7LOG3XZDJC3KCK6ED6E5NBYK2JUBQSPBCNNWEG3ZN7T75U",
  "account_id": "GDI73WJ4SX7LOG3XZDJC3KCK6ED6E5NBYK2JUBQSPBCNNWEG3ZN7T75U",
  "sequence": "24739097524306468",
  "subentry_count": 3,
  "inflation_destination": "GDI73WJ4SX7LOG3XZDJC3KCK6ED6E5NBYK2JUBQSPBCNNWEG3ZN7T75U",
  "last_modified_ledger": 23569316,
  "num_sponsoring": 0,
  "num_sponsored": 0,
  "thresholds": {
    "low_threshold": 5,
    "med_threshold": 0,
    "high_threshold": 0
  },
  "flags": {
    "auth_required": false,
    "auth_revocable": true,
    "auth_immutable": false,
    "auth_clawback_enabled": true
  },
  "balances": [
    {
      "balance": "1.0000005",
      "limit": "922337203685.4775807",
      "buying_liabilities": "0.0000000",
      "selling_liabilities": "0.0000000",
      "last_modified_ledger": 22651481,
      "is_authorized": true,
      "is_clawback_enabled": false,
      "asset_type": "credit_alphanum4",
      "asset_code": "EURT",
      "asset_issuer": "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S"
    },
    {
      "balance": "0.0000000",
      "limit": "922337203685.4775807",
      "buying_liabilities": "0.0000000",
      "selling_liabilities": "0.0000000",
      "last_modified_ledger": 7877447,
      "is_authorized": false,
      "is_clawback_enabled": false,
      "asset_type": "credit_alphanum4",
      "asset_code": "PHP",
      "asset_issuer": "GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP"
    },
    {
      "liquidity_pool_id": "abcdef",
      "asset_type": "liquidity_pool_shares",
      "balance": "10",
      "limit": "10000",
      "last_modified_ledger": 7877447,
      "is_authorized": false,
      "is_clawback_enabled": false
    }
  ],
  "signers": [
    {
      "weight": 10,
      "key": "GDI73WJ4SX7LOG3XZDJC3KCK6ED6E5NBYK2JUBQSPBCNNWEG3ZN7T75U",
      "type": "ed25519_public_key"
    }
  ],
}

We also want to add an endpoint to get accounts by a given liquidity pool.

GET /accounts?liquidity_pool=abcdef

Horizon already provides an endpoint to query accounts by one of three filters: signer, asset, or sponsor. We will add another filter, liquidity_pool, which will return all accounts who have a trustline for the given pool.

[
  {
    "id": "GDI73WJ4SX7LOG3XZDJC3KCK6ED6E5NBYK2JUBQSPBCNNWEG3ZN7T75U",
    "account_id": "GDI73WJ4SX7LOG3XZDJC3KCK6ED6E5NBYK2JUBQSPBCNNWEG3ZN7T75U",
    "sequence": "24739097524306468",
    "subentry_count": 3,
    "inflation_destination": "GDI73WJ4SX7LOG3XZDJC3KCK6ED6E5NBYK2JUBQSPBCNNWEG3ZN7T75U",
    "last_modified_ledger": 23569316,
    "num_sponsoring": 0,
    "num_sponsored": 0,
    "thresholds": {
      "low_threshold": 5,
      "med_threshold": 0,
      "high_threshold": 0
    },
    "flags": {
      "auth_required": false,
      "auth_revocable": true,
      "auth_immutable": false,
      "auth_clawback_enabled": true
    },
    "balances": [
      {
        "balance": "1.0000005",
        "limit": "922337203685.4775807",
        "buying_liabilities": "0.0000000",
        "selling_liabilities": "0.0000000",
        "last_modified_ledger": 22651481,
        "is_authorized": true,
        "is_clawback_enabled": false,
        "asset_type": "credit_alphanum4",
        "asset_code": "EURT",
        "asset_issuer": "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S"
      },
      {
        "balance": "0.0000000",
        "limit": "922337203685.4775807",
        "buying_liabilities": "0.0000000",
        "selling_liabilities": "0.0000000",
        "last_modified_ledger": 7877447,
        "is_authorized": false,
        "is_clawback_enabled": false,
        "asset_type": "credit_alphanum4",
        "asset_code": "PHP",
        "asset_issuer": "GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP"
      },
      {
        "liquidity_pool_id": "abcdef",
        "asset_type": "liquidity_pool_shares",
        "balance": "10",
        "limit": "10000",
        "last_modified_ledger": 7877447,
        "is_authorized": false,
        "is_clawback_enabled": false
      }
    ],
    "signers": [
      {
        "weight": 10,
        "key": "GDI73WJ4SX7LOG3XZDJC3KCK6ED6E5NBYK2JUBQSPBCNNWEG3ZN7T75U",
        "type": "ed25519_public_key"
      }
    ]
  }
]

More details about this feature can be found in https://docs.google.com/document/d/1pXL8kr1a2vfYSap9T67R-g72B_WWbaE1YsLMa04OgoU/edit#

@tamirms tamirms added the amm support cap 38 (automated market makers) in horizon label Aug 23, 2021
@2opremio 2opremio assigned 2opremio and Shaptic and unassigned 2opremio Aug 25, 2021
@bartekn bartekn closed this as completed Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
amm support cap 38 (automated market makers) in horizon
Projects
None yet
Development

No branches or pull requests

4 participants