Uniswap / smart-order-router

GNU General Public License v3.0
384 stars 388 forks source link

fix: use DAI as first gas token #610

Closed jsy1218 closed 3 weeks ago

jsy1218 commented 3 weeks ago
  // For each gas estimate, normalize decimals to that of the chosen usd token.
  const estimatedGasUsedUSDs = _(bestSwap)
    .map((routeWithValidQuote) => {
      // TODO: will error if gasToken has decimals greater than usdToken
      const decimalsDiff =
        usdTokenDecimals - routeWithValidQuote.gasCostInUSD.currency.decimals;

      if (decimalsDiff == 0) {
        return CurrencyAmount.fromRawAmount(
          usdToken,
          routeWithValidQuote.gasCostInUSD.quotient
        );
      }

      return CurrencyAmount.fromRawAmount(
        usdToken,
        JSBI.multiply(
          routeWithValidQuote.gasCostInUSD.quotient,
          JSBI.exponentiate(JSBI.BigInt(10), JSBI.BigInt(decimalsDiff))
        )
      );
    })
    .value();
jsy1218 commented 3 weeks ago

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @jsy1218 and the rest of your teammates on Graphite Graphite

graphite-app[bot] commented 3 weeks ago

Graphite Automations

"Request reviewers once CI passes on smart-order-router repo" took an action on this PR • (06/14/24)

4 reviewers were added and 1 assignee was added to this PR based on 's automation.