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

temREDUNDANT when swapping Gatehub USD with Bistamp USD (Version: 2.1.1) #4994

Open
VLEFF opened this issue Apr 17, 2024 · 8 comments
Open

Comments

@VLEFF
Copy link

VLEFF commented Apr 17, 2024

Issue Description

When executing a swap transaction between Gatehub USD and Bitstamp USD, a temREDUNDANT error is thrown by the rippled engine.

Same currency with different issuer is the only reason I can see behind this bug, since it only appears for this swap pair.

Steps to Reproduce

{
  "TransactionType":"Payment",
  "Destination":"<my-account>",
  "Account":"<my-account>",
  "Amount":{
      "value":10.8951797815249,
      "currency":"USD",
      "issuer":"rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"
   },
   "SendMax":{
      "value":11.0279832334121,
      "currency":"USD",
      "issuer":"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
   },
   "Fee":"10",
   "Sequence":<my-sequence>,
   "Flags":2147614720,
}
@tequdev
Copy link

tequdev commented Apr 17, 2024

For Swaps with the same currency code, you should specify the Paths field.

if (account == uDstAccountID && uSrcCurrency == uDstCurrency && !bPaths)
{
// You're signing yourself a payment.
// If bPaths is true, you might be trying some arbitrage.
JLOG(j.trace()) << "Malformed transaction: "
<< "Redundant payment from " << to_string(account)
<< " to self without path for "
<< to_string(uDstCurrency);
return temREDUNDANT;
}

@VLEFF
Copy link
Author

VLEFF commented Apr 17, 2024

Why that? Is that a feature or a bug?
Since issuers are different, it should be treated as different currencies

@tequdev
Copy link

tequdev commented Apr 17, 2024

It is a very long-standing process and I don't know about it.
It may be a check that is necessary when considering the Rippling.

@VLEFF
Copy link
Author

VLEFF commented Apr 17, 2024

Ok, at least there is a solution!
I'm still curious about the exact reason, if someone with this knowledge passes by

@VLEFF
Copy link
Author

VLEFF commented Apr 18, 2024

@tequdev
How should the path be built?

I tried many combination with what I found on https://xrpl.org/docs/concepts/tokens/fungible-tokens/paths/ and https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/path-and-order-book-methods/ripple_path_find/

But I always end up with either a temBAD_PATH, temBAD_PATH_LOOP or tecPATH_DRY (trustlines are set, and partial payment flag is on).

I didn't find anything about paths for AMM, maybe it's different?

The only path accepted by rippled engine that threw tecPATH_DRY is this one :

[
	{
		"account": "<my-account>"
	},
	{
		"account": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"
	},
	{
		"currency": "USD",
		"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"
	},
	{
		"currency": "USD",
		"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
	},
	{
		"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
	},
	{
		"account": "<my-account>"
	}
]

EDIT:

ripple-path-find method don't return any path

{
    "method": "ripple_path_find",
    "params": [
        {
            "destination_account": "<my-account>",
            "source_account": "<my-account>",
            "destination_amount": {
                "currency": "USD",
                "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
                "value": "0.001"
            },
            "source_currencies": [
                {
                    "currency": "USD",
                    "issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"
                }
            ]
        }
    ]
}
{
    "result": {
        "alternatives": [],
        "destination_account": "<my-account>",
        "destination_amount": {
            "currency": "USD",
            "issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
            "value": "0.001"
        },
        "destination_currencies": [
            "MAG",
            "EUR",
            "ELS",
            "5845504500000000000000000000000000000000",
            "5553444300000000000000000000000000000000",
            "USD",
            "RPR",
            "434F524500000000000000000000000000000000",
            "XLM",
            "XDX",
            "ARK",
            "XRP"
        ],
        "full_reply": true,
        "source_account": "<my-account>",
        "status": "success"
    }
}

@tequdev
Copy link

tequdev commented Apr 18, 2024

it would work with the following Paths field

"Paths": [
	[
		{
			"currency":"XRP"
		},
		{
			"currency":"USD"
			"issuer":"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
		}
	]
]

When specifying both destination_amount and source_amount in path_find, the amount you want to send should be specified in source_amount, and the value of destination_amount should be "-1".

if (!convert_all_ && (saSendMax || saDstAmount <= beast::zero))
{
// If send max specified, dst amt must be -1.
jvStatus = rpcError(rpcDST_AMT_MALFORMED);
return false;
}

Your code is incorrect, so it is not making the expected path_find result.

@VLEFF
Copy link
Author

VLEFF commented Apr 18, 2024

I'll try the path later,

for the path request, I'm not using source_amount, this is not the problem (I'm not getting the amount malformed exception)

@VLEFF
Copy link
Author

VLEFF commented Apr 18, 2024

I just tried your path, and it works!

I was asking myself "why add XRP in the path since XRP is not involved?"
But after trying to remove it and only use :

"Paths": [
	[
		{
			"currency":"USD"
			"issuer":"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
		}
	]
]

It works too. As simple as that.

Thx for the help ;)

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

2 participants