Fix the filter for considered sources on indicative sells for Quote Report (#466)

This commit is contained in:
Jorge Pérez 2022-05-02 15:45:15 -05:00 committed by GitHub
parent ba719a9631
commit d14aebf724
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -1,4 +1,13 @@
[
{
"version": "16.57.2",
"changes": [
{
"note": "Fix missing AMM quotes on indicative Quote Reports",
"pr": 466
}
]
},
{
"version": "16.57.1",
"changes": [

View File

@ -207,7 +207,7 @@ export function generateExtendedQuoteReportSources(
..._.flatten(
quotes.dexQuotes.map(dex =>
dex
.filter(quote => isDexSampleForTotalAmount(quote, marketOperation, amount))
.filter(quote => isDexSampleForTotalAmount(quote, amount))
.map(quote => dexSampleToReportSource(quote, marketOperation)),
),
),
@ -306,16 +306,8 @@ export function dexSampleToReportSource(ds: DexSample, marketOperation: MarketOp
* Checks if a DEX sample is the one that represents the whole amount requested by taker
* NOTE: this is used for the QuoteReport to filter samples
*/
function isDexSampleForTotalAmount(ds: DexSample, marketOperation: MarketOperation, amount: BigNumber): boolean {
// input and output map to different values
// based on the market operation
if (marketOperation === MarketOperation.Buy) {
return ds.input === amount;
} else if (marketOperation === MarketOperation.Sell) {
return ds.output === amount;
} else {
throw new Error(`Unexpected marketOperation ${marketOperation}`);
}
function isDexSampleForTotalAmount(ds: DexSample, amount: BigNumber): boolean {
return ds.input.eq(amount);
}
/**