rippled icon indicating copy to clipboard operation
rippled copied to clipboard

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

Open tequdev opened this issue 1 year ago • 6 comments

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.

  • LedgerEntry https://xrpscan.com/object/CDE55A8290DF221A643F51798BE6294A69384066D1ECFB7C2B9BEE2004B38D63

  • AffectedNodes https://livenet.xrpl.org/transactions/ECF3BDF47CD916F6134C37581D88F96548B07236E25EAB901BCCBEA37DDFFADB

{
  "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
  }
}

tequdev avatar Apr 16 '24 02:04 tequdev

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.

mvadari avatar Apr 16 '24 08:04 mvadari

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?

tequdev avatar Apr 16 '24 08:04 tequdev

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

mvadari avatar Apr 16 '24 08:04 mvadari

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.

ximinez avatar Apr 16 '24 15:04 ximinez

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.

tequdev avatar Apr 16 '24 15:04 tequdev

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.

mvadari avatar Apr 17 '24 20:04 mvadari