Adding liquidity with Uniswap CLMM connector fails for amounts greater than 1e20
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- blockchain
Research direction
Read src/connectors/uniswap/clmm-routes/openPosition.ts and reproduce the issue with gateway lp uniswap/clmm add-liquidity using an amount whose raw value exceeds 1e20. Trace the raw amount conversion and verify that adding liquidity succeeds for values that previously produced scientific notation.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- TypeScript
- Stars
- 261
- Forks
- 289
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from hummingbot/gateway
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
hummingbot/gateway#694 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
hummingbot/gateway#658 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
hummingbot/gateway#691 ·
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
hummingbot/gateway#689 ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 68/100
hummingbot/gateway#684 · 2 comments ·
All issues in hummingbot/gateway
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100