Skip to content

Commit

Permalink
Chore: Do not send empty entries on Quote Report (#501)
Browse files Browse the repository at this point in the history
* Chore: Do not send empty entries on Quote Report

* Changelog
  • Loading branch information
Ktl-XV authored and Noah Khamliche committed Jun 15, 2022
1 parent 1b6b238 commit 7b8c1a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/asset-swapper/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
{
"note": "Add Velodrome support on Optimism",
"pr": 494
},
{
"note": "Do not send empty entries on Quote Report",
"pr": 501
}
]
},
Expand Down
7 changes: 4 additions & 3 deletions packages/asset-swapper/src/utils/quote_report_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export function generateExtendedQuoteReportSources(opts: {
..._.flatten(
quotes.dexQuotes.map(dex =>
dex
.filter(quote => isDexSampleForTotalAmount(quote, amount))
.filter(quote => isDexSampleFilter(quote, amount))
.map(quote => dexSampleToReportSource(quote, marketOperation)),
),
),
Expand Down Expand Up @@ -356,8 +356,9 @@ 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, amount: BigNumber): boolean {
return ds.input.eq(amount);
function isDexSampleFilter(ds: DexSample, amount: BigNumber): boolean {
// The entry is for the total amont, not a sampler entry && there was liquidity in the source
return ds.input.eq(amount) && ds.output.isGreaterThan(0);
}

/**
Expand Down

0 comments on commit 7b8c1a7

Please sign in to comment.