Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #54 from Uniswap/tina/nvm
Browse files Browse the repository at this point in the history
fix: use zero price impact instead of throwing error on 100% buy-tax
  • Loading branch information
tinaszheng authored Oct 14, 2023
2 parents 845cf1a + 03663bc commit bf44f55
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/entities/trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ export class Trade<TInput extends Currency, TOutput extends Currency, TTradeType
return this._priceImpact
}

if (this.outputTax.equalTo(ONE_HUNDRED_PERCENT)) {
throw new Error('Unable to calculate price impact for a 100% buy-tax token')
}
// returns 0% price impact even though this may be inaccurate as a swap may have occured.
// because we're unable to derive the pre-buy-tax amount, use 0% as a placeholder.
if (this.outputTax.equalTo(ONE_HUNDRED_PERCENT)) return ZERO_PERCENT

let spotOutputAmount = CurrencyAmount.fromRawAmount(this.outputAmount.currency, 0)
for (const { route, inputAmount } of this.swaps) {
Expand Down

0 comments on commit bf44f55

Please sign in to comment.