-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into xrsv/gas-estimate-quality-metrics
- Loading branch information
Showing
7 changed files
with
96 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { SimulationStatus } from '../providers'; | ||
|
||
export function breakDownTenderlySimulationError( | ||
data?: string | ||
): SimulationStatus { | ||
if (data) { | ||
switch (data) { | ||
case '0x739dbe52': // V3TooMuchRequested | ||
case '0x39d35496': // V3TooLittleReceived | ||
case '0x849eaf98': // V2TooLittleReceived | ||
case '0x8ab0bc16': // V2TooMuchRequested | ||
case '0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000025556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54000000000000000000000000000000000000000000000000000000': // INSUFFICIENT_OUTPUT_AMOUNT | ||
case '0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000034949410000000000000000000000000000000000000000000000000000000000': // IIA | ||
return SimulationStatus.SlippageTooLow; | ||
default: // we don't know why onchain execution reverted, just return generic failed. | ||
return SimulationStatus.Failed; | ||
} | ||
} | ||
|
||
return SimulationStatus.Failed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { | ||
breakDownTenderlySimulationError | ||
} from '../../../src/util/tenderlySimulationErrorBreakDown'; | ||
import { SimulationStatus } from '../../../build/main'; | ||
|
||
describe('tenderly simulation error break down', () => { | ||
it('V3TooMuchRequested', async () => { | ||
const simulationStatus = breakDownTenderlySimulationError('0x739dbe52') | ||
expect(simulationStatus).toEqual(SimulationStatus.SlippageTooLow) | ||
}) | ||
|
||
it('V3TooLittleReceived', async () => { | ||
const simulationStatus = breakDownTenderlySimulationError('0x39d35496') | ||
expect(simulationStatus).toEqual(SimulationStatus.SlippageTooLow) | ||
}) | ||
|
||
it('V2TooLittleReceived', async () => { | ||
const simulationStatus = breakDownTenderlySimulationError('0x849eaf98') | ||
expect(simulationStatus).toEqual(SimulationStatus.SlippageTooLow) | ||
}) | ||
|
||
it('V2TooMuchRequested', async () => { | ||
const simulationStatus = breakDownTenderlySimulationError('0x8ab0bc16') | ||
expect(simulationStatus).toEqual(SimulationStatus.SlippageTooLow) | ||
}) | ||
|
||
it('INSUFFICIENT_OUTPUT_AMOUNT', async () => { | ||
const simulationStatus = breakDownTenderlySimulationError('0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000025556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54000000000000000000000000000000000000000000000000000000'); | ||
expect(simulationStatus).toEqual(SimulationStatus.SlippageTooLow) | ||
}) | ||
|
||
it('IIA', async () => { | ||
const simulationStatus = breakDownTenderlySimulationError('0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000034949410000000000000000000000000000000000000000000000000000000000'); | ||
expect(simulationStatus).toEqual(SimulationStatus.SlippageTooLow) | ||
}) | ||
|
||
it('InsufficientToken', () => { | ||
const simulationStatus = breakDownTenderlySimulationError('0x675cae38'); | ||
expect(simulationStatus).toEqual(SimulationStatus.Failed); | ||
}); | ||
|
||
it('unknown data', () => { | ||
const simulationStatus = breakDownTenderlySimulationError(undefined); | ||
expect(simulationStatus).toEqual(SimulationStatus.Failed); | ||
}); | ||
}); |