fix: worstCaseQuoteInfo calculating buys incorrectly [TKR-296] (#402)
* fix: WorstCaseQuoteInfo buy encoding * CHANGELOG
This commit is contained in:
parent
e5ed8b2c81
commit
97575bbde9
@ -1,4 +1,13 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "16.49.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Fix WorstCaseQuoteInfo encoding bug",
|
||||||
|
"pr": 402
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "16.49.0",
|
"version": "16.49.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@ -599,24 +599,25 @@ function calculateTwoHopQuoteInfo(
|
|||||||
secondHopSource: _.pick(secondHopFill, 'source', 'fillData'),
|
secondHopSource: _.pick(secondHopFill, 'source', 'fillData'),
|
||||||
}),
|
}),
|
||||||
).toNumber();
|
).toNumber();
|
||||||
|
const isSell = operation === MarketOperation.Sell;
|
||||||
return {
|
return {
|
||||||
bestCaseQuoteInfo: {
|
bestCaseQuoteInfo: {
|
||||||
makerAmount: operation === MarketOperation.Sell ? secondHopFill.output : secondHopFill.input,
|
makerAmount: isSell ? secondHopFill.output : secondHopFill.input,
|
||||||
takerAmount: operation === MarketOperation.Sell ? firstHopFill.input : firstHopFill.output,
|
takerAmount: isSell ? firstHopFill.input : firstHopFill.output,
|
||||||
totalTakerAmount: operation === MarketOperation.Sell ? firstHopFill.input : firstHopFill.output,
|
totalTakerAmount: isSell ? firstHopFill.input : firstHopFill.output,
|
||||||
feeTakerTokenAmount: constants.ZERO_AMOUNT,
|
feeTakerTokenAmount: constants.ZERO_AMOUNT,
|
||||||
protocolFeeInWeiAmount: constants.ZERO_AMOUNT,
|
protocolFeeInWeiAmount: constants.ZERO_AMOUNT,
|
||||||
gas,
|
gas,
|
||||||
},
|
},
|
||||||
// TODO jacob consolidate this with quote simulation worstCase
|
// TODO jacob consolidate this with quote simulation worstCase
|
||||||
worstCaseQuoteInfo: {
|
worstCaseQuoteInfo: {
|
||||||
makerAmount: MarketOperation.Sell
|
makerAmount: isSell
|
||||||
? secondHopOrder.makerAmount.times(1 - slippage).integerValue()
|
? secondHopOrder.makerAmount.times(1 - slippage).integerValue()
|
||||||
: secondHopOrder.makerAmount,
|
: secondHopOrder.makerAmount,
|
||||||
takerAmount: MarketOperation.Sell
|
takerAmount: isSell
|
||||||
? firstHopOrder.takerAmount
|
? firstHopOrder.takerAmount
|
||||||
: firstHopOrder.takerAmount.times(1 + slippage).integerValue(),
|
: firstHopOrder.takerAmount.times(1 + slippage).integerValue(),
|
||||||
totalTakerAmount: MarketOperation.Sell
|
totalTakerAmount: isSell
|
||||||
? firstHopOrder.takerAmount
|
? firstHopOrder.takerAmount
|
||||||
: firstHopOrder.takerAmount.times(1 + slippage).integerValue(),
|
: firstHopOrder.takerAmount.times(1 + slippage).integerValue(),
|
||||||
feeTakerTokenAmount: constants.ZERO_AMOUNT,
|
feeTakerTokenAmount: constants.ZERO_AMOUNT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user