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

Cannot determine which is the AMM Pool on the trustline between the AMM Pool and the token issuer. #4991

Open
tequdev opened this issue Apr 16, 2024 · 6 comments

Comments

@tequdev
Copy link

tequdev commented Apr 16, 2024

Issue Description

Cannot determine which is the AMM Account on the High or Low account on the trust line between the AMM Pool and the token issuer.

This is due to that lsfAMMNode does not have High ,Low information.

{
  "ModifiedNode": {
    "FinalFields": {
      "Balance": {
        "currency": "5553444300000000000000000000000000000000",
        "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
        "value": "-224388.3522748358"
      },
      "Flags": 16908288,
      "HighLimit": {
        "currency": "5553444300000000000000000000000000000000",
        "issuer": "rGHt6LT5v9DVaEAmFzj5ciuxuj41ZjLofs",
        "value": "0"
      },
      "HighNode": "0",
      "LowLimit": {
        "currency": "5553444300000000000000000000000000000000",
        "issuer": "rcEGREd8NmkKRE8GE424sksyt1tJVFZwu",
        "value": "0"
      },
      "LowNode": "10a"
    },
    "LedgerEntryType": "RippleState",
    "LedgerIndex": "CDE55A8290DF221A643F51798BE6294A69384066D1ECFB7C2B9BEE2004B38D63",
    "PreviousFields": {
      "Balance": {
        "currency": "5553444300000000000000000000000000000000",
        "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
        "value": "-224388.1546979297"
      }
    },
    "PreviousTxnID": "FCA38878BFA22CC4941045FB7088755623C6F4B303359371209CACB29A920668",
    "PreviousTxnLgrSeq": 87339469
  }
}
@mvadari
Copy link
Collaborator

mvadari commented Apr 16, 2024

The code I use to determine which is the issuer:

let limit = obj.LowLimit.value === "0" ? obj.LowLimit : obj.HighLimit;
if (obj.Balance.value !== "0") {
    limit = Number(obj.Balance.value) < 0 ? obj.LowLimit : obj.HighLimit;
}
const issuer = limit.issuer;

The balance of an AMM trustline should never be 0, so it should be easy to figure out that way.

@tequdev
Copy link
Author

tequdev commented Apr 16, 2024

It seems that most situations can be handled with that script.
but isn't Balance to be 0 in a situation where an AMMDelete transaction could happen?

@mvadari
Copy link
Collaborator

mvadari commented Apr 16, 2024

In that case, both trustlines should be deleted, so only one account should be in both trustlines, right?

@ximinez
Copy link
Collaborator

ximinez commented Apr 16, 2024

The intention of that flag was only to signal to tooling that an AMM is involved. The expectation was that any tools that care can query the account IDs to determine which is the AMM.

@tequdev
Copy link
Author

tequdev commented Apr 16, 2024

In that case, both trustlines should be deleted, so only one account should be in both trustlines, right?

Ah yes, in SeagullCash's experience, when tokens are gone from the pool, the Pool-Issuer trustline is deleted, so there cannot be a Pool-Issuer trustline with a Balance of 0.

But if the issuer changes the trustline flag, the trustline may not be removed.

@mvadari
Copy link
Collaborator

mvadari commented Apr 17, 2024

In that case, both trustlines should be deleted, so only one account should be in both trustlines, right?

Ah yes, in SeagullCash's experience, when tokens are gone from the pool, the Pool-Issuer trustline is deleted, so there cannot be a Pool-Issuer trustline with a Balance of 0.

But if the issuer changes the trustline flag, the trustline may not be removed.

In that case, the AMMDelete would fail anyways I assume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants