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

fix: use zero price impact instead of throwing error on 100% buy-tax #54

Merged
merged 4 commits into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading