Describe the bug
The Javascript number toString() method defaults to scientific notation for values greater than 1e20 (this could be an amount as low as 1,000 for a token with 18 decimals). However, the JSBI.BigInt constructor throws an error on these values because it does not recognize values in scientific notation. The error occurs in this block of code within src/connectors/uniswap/clmm-routes/openPosition.ts:
if (baseTokenAmount !== undefined) {
const baseAmountRaw = Math.floor(baseTokenAmount * Math.pow(10, baseTokenObj.decimals));
if (isBaseToken0) {
token0Amount = CurrencyAmount.fromRawAmount(token0, JSBI.BigInt(baseAmountRaw.toString()));
} else {
token1Amount = CurrencyAmount.fromRawAmount(token1, JSBI.BigInt(baseAmountRaw.toString()));
}
}
Using .toLocaleString('fullwide', { useGrouping: false }) fixes it.
Steps to reproduce
- Start hummingbot with gateway and run the following command:
gateway lp uniswap/clmm add-liquidity
- Specify an amount such that raw amount (amount * 10 ^ token_decimals) is greater than 1e20
Release version
dev-2.12.0
Type of installation
Source
Attach required files
No response
Describe the bug
The Javascript number toString() method defaults to scientific notation for values greater than 1e20 (this could be an amount as low as 1,000 for a token with 18 decimals). However, the JSBI.BigInt constructor throws an error on these values because it does not recognize values in scientific notation. The error occurs in this block of code within
src/connectors/uniswap/clmm-routes/openPosition.ts:Using
.toLocaleString('fullwide', { useGrouping: false })fixes it.Steps to reproduce
gateway lp uniswap/clmm add-liquidityRelease version
dev-2.12.0
Type of installation
Source
Attach required files
No response