Skip to content

Commit 9c92571

Browse files
committed
update
1 parent b6527b8 commit 9c92571

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/gas.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { ChainId } from "sushi";
22
import { BigNumber } from "ethers";
33
import { getQuoteConfig } from "./utils";
4+
import { publicActionsL2 } from "viem/op-stack";
45
import { encodeFunctionData, multicall3Abi, toHex } from "viem";
5-
import { publicActionsL2, walletActionsL2 } from "viem/op-stack";
66
import { BotConfig, BundledOrders, OperationState, RawTx, ViemClient } from "./types";
77
import { ArbitrumNodeInterfaceAbi, ArbitrumNodeInterfaceAddress, OrderbookQuoteAbi } from "./abis";
88

@@ -32,9 +32,7 @@ export async function estimateGasCost(
3232
};
3333
if (config.isSpecialL2) {
3434
try {
35-
const l1Signer_ = l1Signer
36-
? l1Signer
37-
: signer.extend(walletActionsL2()).extend(publicActionsL2());
35+
const l1Signer_ = l1Signer ? l1Signer : signer.extend(publicActionsL2());
3836
if (typeof l1GasPrice !== "bigint") {
3937
l1GasPrice = (await l1Signer_.getL1BaseFee()) as bigint;
4038
}

src/modes/routeProcessor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ export async function findOppWithRetries({
498498
// ie its maxInput is the greatest
499499
const prom = allPromises[i];
500500
if (prom.status === "fulfilled") {
501-
if (!choice || choice.maximumInput!.lt(prom.value.value!.maximumInput!)) {
501+
if (!choice || choice.estimatedProfit.lt(prom.value.value!.estimatedProfit)) {
502502
// record the attributes of the choosing one
503503
for (const attrKey in prom.value.spanAttributes) {
504504
spanAttributes[attrKey] = prom.value.spanAttributes[attrKey];

test/gas.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { assert } from "chai";
2+
import { ChainId } from "sushi";
23
import { orderPairObject1 } from "./data";
34
import { OperationState, ViemClient } from "../src/types";
45
import { estimateGasCost, getGasPrice, getL1Fee, getQuoteGas, getTxFee } from "../src/gas";
5-
import { ChainId } from "sushi";
66

77
describe("Test gas", async function () {
88
it("should estimate gas correctly for L1 and L2 chains", async function () {
@@ -80,7 +80,9 @@ describe("Test gas", async function () {
8080

8181
it("should get tx fee", async function () {
8282
// mock config and receipt
83-
const config = {} as any;
83+
const config = {
84+
chain: { id: 137 },
85+
} as any;
8486
const receipt = {
8587
effectiveGasPrice: 10n,
8688
gasUsed: 5n,
@@ -102,6 +104,7 @@ describe("Test gas", async function () {
102104
const l1GasPrice = 2n;
103105
// mock config and viem client
104106
const config = {
107+
chain: { id: 137 },
105108
isSpecialL2: false,
106109
gasPriceMultiplier: 100n,
107110
viemClient: { getGasPrice: async () => gasPrice },

0 commit comments

Comments
 (0)