Fix ABI encoding error with two hop buys due to applying slippage to uint(-1) values (#410)

Co-authored-by: Lawrence Forman <me@merklejerk.com>
This commit is contained in:
Lawrence Forman 2022-01-31 12:51:17 -05:00 committed by GitHub
parent f470d282ee
commit c57bf86273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,13 @@
[
{
"version": "16.49.2",
"changes": [
{
"note": "Fix ABI encoding error with two hop buys due to applying slippage to uint(-1) values",
"pr": 410
}
]
},
{
"version": "16.49.1",
"changes": [

View File

@ -701,8 +701,16 @@ function slipNonNativeOrders(quote: MarketSellSwapQuote | MarketBuySwapQuote): O
return {
...o,
...(quote.type === MarketOperation.Sell
? { makerAmount: o.makerAmount.times(1 - slippage).integerValue(BigNumber.ROUND_DOWN) }
: { takerAmount: o.takerAmount.times(1 + slippage).integerValue(BigNumber.ROUND_UP) }),
? {
makerAmount: o.makerAmount.eq(MAX_UINT256)
? MAX_UINT256
: o.makerAmount.times(1 - slippage).integerValue(BigNumber.ROUND_DOWN),
}
: {
takerAmount: o.takerAmount.eq(MAX_UINT256)
? MAX_UINT256
: o.takerAmount.times(1 + slippage).integerValue(BigNumber.ROUND_UP),
}),
};
});
}