Skip to content

Commit

Permalink
fix: add tenderly simulation request bodies in the mismatch error log…
Browse files Browse the repository at this point in the history
…ging (Uniswap#608)

* fix: add tenderly simulation request bodies in the mismatch error logging

* fix prettier
  • Loading branch information
jsy1218 authored Jun 14, 2024
1 parent ef44409 commit 6816bbc
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/providers/tenderly-simulation-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import https from 'https';

import { MaxUint256 } from '@ethersproject/constants';
import { JsonRpcProvider } from '@ethersproject/providers';
import { permit2Address } from '@uniswap/permit2-sdk';
import { ChainId } from '@uniswap/sdk-core';
import {
UNIVERSAL_ROUTER_ADDRESS,
Expand Down Expand Up @@ -41,7 +42,6 @@ import {
} from './simulation-provider';
import { IV2PoolProvider } from './v2/pool-provider';
import { IV3PoolProvider } from './v3/pool-provider';
import { permit2Address } from '@uniswap/permit2-sdk';

export type TenderlyResponseUniversalRouter = {
config: {
Expand Down Expand Up @@ -398,6 +398,7 @@ export class TenderlySimulator extends Simulator {
approvePermit2,
approveUniversalRouter,
swap,
body,
resp
);

Expand Down Expand Up @@ -677,6 +678,7 @@ export class TenderlySimulator extends Simulator {
approvePermit2: TenderlySimulationRequest,
approveUniversalRouter: TenderlySimulationRequest,
swap: TenderlySimulationRequest,
gatewayReq: TenderlySimulationBody,
gatewayResp: TenderlyResponseUniversalRouter
): Promise<void> {
if (
Expand Down Expand Up @@ -782,7 +784,13 @@ export class TenderlySimulator extends Simulator {

if (gatewayGas !== nodeGas) {
log.error(
`Gateway gas and node gas estimates do not match for index ${i}`,
`Gateway gas and node gas estimates do not match for index ${i}
gateway request body ${JSON.stringify(
gatewayReq.simulations[i],
null,
2
)}
node request body ${JSON.stringify(body.params[i], null, 2)}`,
{ gatewayGas, nodeGas }
);
metric.putMetric(
Expand All @@ -795,7 +803,13 @@ export class TenderlySimulator extends Simulator {

if (gatewayGasUsed !== nodeGasUsed) {
log.error(
`Gateway gas and node gas used estimates do not match for index ${i}`,
`Gateway gas and node gas used estimates do not match for index ${i}
gateway request body ${JSON.stringify(
gatewayReq.simulations[i],
null,
2
)}
node request body ${JSON.stringify(body.params[i], null, 2)}`,
{ gatewayGasUsed, nodeGasUsed }
);
metric.putMetric(
Expand Down

0 comments on commit 6816bbc

Please sign in to comment.