js-stellar-base icon indicating copy to clipboard operation
js-stellar-base copied to clipboard

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

Open acharb opened this issue 2 years ago • 1 comments

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 avatar May 10 '22 22:05 acharb

looks like same error handling in the liquidityPoolWithdraw op as well https://github.com/stellar/js-stellar-base/blob/98feac63eaf97dc0bbc7f110d004c4636ee29dea/src/operations/liquidity_pool_withdraw.js#L26-L38

acharb avatar May 10 '22 22:05 acharb