-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Lately, I started to have a new error message:
Error: bisect endpoints must have different signs
at fr (/home/user/gnagna/node_modules/@shadeprotocol/shadejs/dist/index.umd.cjs:3:42061)
at Et (/home/user/gnagna/node_modules/@shadeprotocol/shadejs/dist/index.umd.cjs:3:42677)
at Oe.findZeroWithPool1Params (/home/user/gnagna/node_modules/@shadeprotocol/shadejs/dist/index.umd.cjs:3:50617)
at Oe.solveInvFnForPool1Size (/home/user/gnagna/node_modules/@shadeprotocol/shadejs/dist/index.umd.cjs:3:43889)
at Oe.simulateToken0WithToken1Trade (/home/user/gnagna/node_modules/@shadeprotocol/shadejs/dist/index.umd.cjs:3:45529)
at Oe.swapToken0WithToken1 (/home/user/gnagna/node_modules/@shadeprotocol/shadejs/dist/index.umd.cjs:3:44237)
at yr (/home/user/gnagna/node_modules/@shadeprotocol/shadejs/dist/index.umd.cjs:3:52564)
at main (/home/user/gnagna/src/test.ts:43:47)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
I am not sure 0o.
Here a piece of faulty code producing the error. BN is an alias for BigNumer and toHuman divides by 100000 the input:
const output = await batchQueryPairsInfo({
...
})
const u = output[0].pairInfo
const humanVal = toHuman(BN(10000000))
console.log("This is humanVal: ", humanVal.toString())
if (!u.stableParams)
return
const inputParams = {
inputToken0Amount: humanVal,
inputToken1Amount: humanVal,
poolToken0Amount: toHuman(BN(u.token0Amount)),
poolToken1Amount: toHuman(BN(u.token1Amount)),
priceRatio: BN(u.stableParams.priceRatio ?? 0),
alpha: BN(u.stableParams.alpha),
gamma1: BN(u.stableParams.gamma1),
gamma2: BN(u.stableParams.gamma2),
liquidityProviderFee: BN(u.lpFee),
daoFee: BN(u.daoFee),
minTradeSizeToken0For1: BN(u.stableParams.minTradeSizeXForY),
minTradeSizeToken1For0: BN(u.stableParams.minTradeSizeYForX),
priceImpactLimit: BN(u.stableParams.maxPriceImpactAllowed)
};
const quote_to_base = stableSwapToken0for1(inputParams).decimalPlaces(6)
Also the value of inputParams:
{
inputToken0Amount: BigNumber { s: 1, e: 1, c: [ 10 ] },
inputToken1Amount: BigNumber { s: 1, e: 1, c: [ 10 ] },
poolToken0Amount: BigNumber { s: 1, e: 3, c: [ 7052, 35108000000000 ] },
poolToken1Amount: BigNumber { s: 1, e: 4, c: [ 11640, 539300000000 ] },
priceRatio: BigNumber { s: 1, e: 0, c: [ 0 ] },
alpha: BigNumber { s: 1, e: 2, c: [ 150 ] },
gamma1: BigNumber { s: 1, e: 0, c: [ 6 ] },
gamma2: BigNumber { s: 1, e: 1, c: [ 50 ] },
liquidityProviderFee: BigNumber { s: 1, e: -4, c: [ 50000000000 ] },
daoFee: BigNumber { s: 1, e: -4, c: [ 50000000000 ] },
minTradeSizeToken0For1: BigNumber { s: 1, e: -4, c: [ 10000000000 ] },
minTradeSizeToken1For0: BigNumber { s: 1, e: -4, c: [ 10000000000 ] },
priceImpactLimit: BigNumber { s: 1, e: 3, c: [ 1000 ] }
}
I am getting a bit lost in Shade's code :/. Thanks for your support.
Metadata
Metadata
Assignees
Labels
No labels