Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use DAI as first gas token #610

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

jsy1218
Copy link
Member

@jsy1218 jsy1218 commented Jun 14, 2024

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Bug fix

  • What is the current behavior? (You can also link to an open issue here)
    USDC has 6 decimals, DAI has 18 decimals.

  // 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();
  • What is the new behavior (if this is a feature change)?
    we need to use DAI as primary gas token

  • Other information:

Copy link
Member Author

jsy1218 commented Jun 14, 2024

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

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

@jsy1218 jsy1218 marked this pull request as ready for review June 14, 2024 16:59
@jsy1218 jsy1218 requested a review from a team as a code owner June 14, 2024 16:59
@graphite-app graphite-app bot requested review from mikeki, cgkol and xrsv June 14, 2024 17:00
@jsy1218 jsy1218 merged commit 8dbb487 into main Jun 14, 2024
25 of 26 checks passed
@jsy1218 jsy1218 deleted the 06-14-fix_gas_token_dai_first_on_zksync branch June 14, 2024 17:02
Copy link

graphite-app bot commented Jun 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants