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

Incorrect derived prices for Token entities #79

Open
ebma opened this issue Nov 15, 2024 · 3 comments
Open

Incorrect derived prices for Token entities #79

ebma opened this issue Nov 15, 2024 · 3 comments
Labels
type:bug Something isn't working

Comments

@ebma
Copy link
Member

ebma commented Nov 15, 2024

Context

The Zenlink UI showed wrong prices for DOT and XLM on the Pendulum pools, e.g. this one. The PEN price was correct. All token prices are derived relative to the price of the native asset (in this case PEN) so this suggests that the calculation of the relative prices is wrong.

To fix this, I deployed a new squid pendulum-squid@v27 which does not contain any code changes. When comparing the relative token prices between pendulum-squid v26 and v27, it's clear that they are different although the base price is the same.

Query:

query MyQuery {
  tokens(orderBy: id_ASC) {
    decimals
    derivedETH
    id
    name
  }
  bundleById(id: "1") {
    ethPrice
    id
  }
}

v26:

{
  "data": {
    "tokens": [
      {
        "decimals": 12,
        "derivedETH": "1.0000000000",
        "id": "2094-0-0",
        "name": "PENDULUM"
      },
      {
        "decimals": 10,
        "derivedETH": "8.6053151357",
        "id": "2094-2-256",
        "name": "Polkadot"
      },
      {
        "decimals": 18,
        "derivedETH": "6.9919292014",
        "id": "2094-2-262",
        "name": "Moonbeam"
      },
      {
        "decimals": 12,
        "derivedETH": "0.2335241364",
        "id": "2094-2-512",
        "name": "Stellar Native"
      }
    ],
    "bundleById": {
      "ethPrice": "0.0245976878",
      "id": "1"
    }
  }
}

v27

{
  "data": {
    "tokens": [
      {
        "decimals": 12,
        "derivedETH": "1.0000000000",
        "id": "2094-0-0",
        "name": "PENDULUM"
      },
      {
        "decimals": 10,
        "derivedETH": "193.6291165427",
        "id": "2094-2-256",
        "name": "Polkadot"
      },
      {
        "decimals": 18,
        "derivedETH": "6.9919292014",
        "id": "2094-2-262",
        "name": "Moonbeam"
      },
      {
        "decimals": 12,
        "derivedETH": "5.4274148283",
        "id": "2094-2-512",
        "name": "Stellar Native"
      }
    ],
    "bundleById": {
      "ethPrice": "0.0245976878",
      "id": "1"
    }
  }
}

The price of each token is denoted as ethPrice * derivedETH = tokenPrice. So e.g. the derived price for XLM on the v27 indexer would be 0.0245976878 * 5.4274148283 = 0.133501855508 USD which roughly matches the expected price.

TODO

Investigate how the relative prices ended up being incorrect on the v26 indexer and why they are correct on v27.

@ebma ebma added the type:bug Something isn't working label Nov 15, 2024
@ebma ebma changed the title Invalid prices for Token entities Incorrect derived prices for Token entities Nov 15, 2024
@ebma
Copy link
Member Author

ebma commented Nov 15, 2024

@pendulum-chain/product this is for solving a bug that recently caused the Zenlink UI to show different prices. The issue was fixed temporarily by deploying a new squid but the underlying issue should still be solved as we might face the same situation soon.

@TorstenStueber
Copy link
Contributor

@pendulum-chain/product shouldn't we prioritize this bug ticket and move to Ready (or is the bug not critical @ebma?)

@ebma
Copy link
Member Author

ebma commented Nov 25, 2024

It depends. We don't know how likely this is to reoccur. It seems like the prices are still normal/correct at the moment and if the product team doesn't think it's urgent we can always fix it by redeploying the squid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants