Skip to content

Commit

Permalink
fix: Use syntheticGasCostInTermsOfQuoteToken only if within 30% of ga…
Browse files Browse the repository at this point in the history
…sCostInTermsOfQuoteToken
  • Loading branch information
xrsv committed Dec 3, 2024
1 parent edc92dd commit b1d030a
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,16 @@ export abstract class TickBasedHeuristicGasModelFactory<
// Note that the syntheticGasCost being lessThan the original quoted value is not always strictly better
// e.g. the scenario where the amountToken/ETH pool is very illiquid as well and returns an extremely small number
// however, it is better to have the gasEstimation be almost 0 than almost infinity, as the user will still receive a quote
// Only use syntheticGasCostInTermsOfQuoteToken if it's within 30% of the original gasCostInTermsOfQuoteToken as a safeguard.
if (
syntheticGasCostInTermsOfQuoteToken !== null &&
(gasCostInTermsOfQuoteToken === null ||
(gasCostInTermsOfQuoteToken === null || (
syntheticGasCostInTermsOfQuoteToken.lessThan(
gasCostInTermsOfQuoteToken.asFraction
))
) &&
gasCostInTermsOfQuoteToken.subtract(syntheticGasCostInTermsOfQuoteToken)
.lessThan(gasCostInTermsOfQuoteToken.multiply(0.3))
))
) {
log.info(
{
Expand Down

0 comments on commit b1d030a

Please sign in to comment.