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

if a number is passed for maxAmountA in liquidityPoolDeposit, error thrown is "required" #528

Closed
acharb opened this issue May 10, 2022 · 1 comment
Labels

Comments

@acharb
Copy link
Contributor

acharb commented May 10, 2022

Describe the bug
If you pass in a number instead of a string for either maxAmountA or maxAmountB field of the liquidityPoolDeposit operation, the error thrown is TypeError: maxAmountA argument is required, which is misleading as the error is due to an incorrect type.

What version are you on?
stellar-base version 7.0.0
stellar-sdk version 10.0.1

To Reproduce
Steps to reproduce the behavior:

import sdk from "stellar-sdk";

sdk.Operation.liquidityPoolDeposit({
  liquidityPoolId: "1",
  maxAmountA: 2,
  maxAmountB: "2",
  minPrice: "1",
  maxPrice: "1",
});

Expected behavior
A possible easy remedy could be changing the error to: TypeError: invalid maxAmountA argument. Required and must be string, or something similar.

Additional context

although the type is clearly shown as string in the sdk docs, the error thrown doesn't give an accurate description of the error and gave me some confusion while developing :) . Changing could save devs that confusion when using the new AMM functionality of the SDK.

@acharb acharb added the bug label May 10, 2022
@acharb
Copy link
Contributor Author

acharb commented May 10, 2022

looks like same error handling in the liquidityPoolWithdraw op as well

if (!this.isValidAmount(opts.amount)) {
throw new TypeError('amount argument is required');
}
attributes.amount = this._toXDRAmount(opts.amount);
if (!this.isValidAmount(opts.minAmountA, true)) {
throw new TypeError('minAmountA argument is required');
}
attributes.minAmountA = this._toXDRAmount(opts.minAmountA);
if (!this.isValidAmount(opts.minAmountB, true)) {
throw new TypeError('minAmountB argument is required');
}

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

No branches or pull requests

2 participants