jup-ag / feedback

0 stars 0 forks source link

RangeError: Division by zero #4

Open bittarou opened 2 years ago

bittarou commented 2 years ago
RangeError: Division by zero
    at Function.divide (/app/node_modules/jsbi/tsc-out/jsbi.mjs:240:19)
    at ceilingDivision (/app/node_modules/@jup-ag/math/src/utils.ts:36:23)
    at t.getOutputAmount (/app/node_modules/@jup-ag/math/src/amm/tokenswap-constant-product.ts:109:35)
    at t.getExpectedOutputAmount (/app/node_modules/@jup-ag/math/src/amm/tokenswap-constant-product.ts:70:17)
    at t.exchange (/app/node_modules/@jup-ag/math/src/amm/tokenswap-constant-product.ts:18:37)
    at De.getQuote (/app/node_modules/@jup-ag/core/src/lib/aldrin/aldrinAmm.ts:106:34)
    at map (/app/node_modules/@jup-ag/core/src/lib/computeRouteInfos.ts:53:40)
    at Array.map (<anonymous>)
    at computeRouteInfos (/app/node_modules/@jup-ag/core/src/lib/computeRouteInfos.ts:34:6)
    at ut.computeRoutes (/app/node_modules/@jup-ag/core/src/lib/jupiter.ts:206:27)

When I tried to swap from USDC to USDC, the above error appeared.

image

I think this is the same thing that pkr mentioned in the developer-support channel on discord. Please check it.

xandyxor commented 2 years ago

Is it resolved please?

bittarou commented 2 years ago

It seems to happen when pass through a Pool with a TVL of 0, which causes an error in the calculation of the jsbi library.

Not sure if this has been fixed in the current version of @jup-ag/core, but at the time I modified jsbi so that the division by zero error does not occur.