Skip to content

Commit

Permalink
Merge branch 'master' into 2024-12-02-l1-gas
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt authored Dec 3, 2024
2 parents 69cf889 + 29e5626 commit 14de1f8
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,14 @@ export function getBountyEnsureBytecode(
inputToEthPrice: BigNumber,
outputToEthPrice: BigNumber,
minimumExcepted: BigNumber,
sender: string,
): string {
const inputPrice = inputToEthPrice.toHexString().substring(2).padStart(64, "0");
const outputPrice = outputToEthPrice.toHexString().substring(2).padStart(64, "0");
const minimum = minimumExcepted.toHexString().substring(2).padStart(64, "0");
const msgSender = sender.substring(2).padStart(64, "0").toLowerCase();
// rainlang bytecode:
// :ensure(sender context<0 0>()),
// :ensure(
// greater-than-or-equal-to(
// add(
Expand All @@ -237,7 +240,7 @@ export function getBountyEnsureBytecode(
// )
// \"minimum sender output\"
// );
return `0x0000000000000000000000000000000000000000000000000000000000000004${inputPrice}${outputPrice}${minimum}956d696e696d756d2073656e646572206f757470757400000000000000000000000000000000000000000000000000000000000000000000000000000000003b0100000d06000203100001011000003d12000003100101011000013d120000011000030110000200100001001000002b120000211200001d020000`;
return `0x0000000000000000000000000000000000000000000000000000000000000006${msgSender}8e756e6b6e6f776e2073656e6465720000000000000000000000000000000000${inputPrice}${outputPrice}${minimum}956d696e696d756d2073656e646572206f7574707574000000000000000000000000000000000000000000000000000000000000000000000000000000000047010000100500000110000103100000011000001e1200001d020000011000050110000403100101011000033d12000003100001011000023d1200002b120000211200001d020000`;
}

/**
Expand All @@ -260,6 +263,7 @@ export function getWithdrawEnsureBytecode(
inputToEthPrice: BigNumber,
outputToEthPrice: BigNumber,
minimumExcepted: BigNumber,
sender: string,
): string {
const bot = botAddress.substring(2).padStart(64, "0");
const input = inputToken.substring(2).padStart(64, "0");
Expand All @@ -269,7 +273,9 @@ export function getWithdrawEnsureBytecode(
const inputPrice = inputToEthPrice.toHexString().substring(2).padStart(64, "0");
const outputPrice = outputToEthPrice.toHexString().substring(2).padStart(64, "0");
const minimum = minimumExcepted.toHexString().substring(2).padStart(64, "0");
const msgSender = sender.substring(2).padStart(64, "0").toLowerCase();
// rainlang bytecode:
// :ensure(sender context<0 0>()),
// :ensure(
// greater-than-or-equal-to(
// add(
Expand All @@ -280,7 +286,7 @@ export function getWithdrawEnsureBytecode(
// )
// \"minimumSenderOutput\"
// );
return `0x0000000000000000000000000000000000000000000000000000000000000009${input}${bot}${inputBalance}${inputPrice}${output}${outputBalance}${outputPrice}${minimum}936d696e696d756d53656e6465724f757470757400000000000000000000000000000000000000000000000000000000000000000000000000000000000000530100001307000001100008011000070110000601100005011000010110000411120000471200003d1200000110000301100002011000010110000011120000471200003d1200002b120000211200001d020000`;
return `0x000000000000000000000000000000000000000000000000000000000000000b${msgSender}8e756e6b6e6f776e2073656e6465720000000000000000000000000000000000${input}${bot}${inputBalance}${inputPrice}${output}${outputBalance}${outputPrice}${minimum}936d696e696d756d53656e6465724f75747075740000000000000000000000000000000000000000000000000000000000000000000000000000000000000067010000180700000110000103100000011000001e1200001d0200000110000a011000090110000801100007011000030110000611120000471200003d1200000110000501100004011000030110000211120000471200003d1200002b120000211200001d020000`;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/modes/interOrderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export async function dryrun({
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -149,6 +150,7 @@ export async function dryrun({
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
gasCost.mul(headroom).div("100"),
signer.account.address,
);
rawtx.data = arb.interface.encodeFunctionData("arb3", [
orderPairObject.orderbook,
Expand All @@ -168,6 +170,7 @@ export async function dryrun({
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
gasCost.mul(config.gasCoveragePercentage).div("100"),
signer.account.address,
);
rawtx.data = arb.interface.encodeFunctionData("arb3", [
orderPairObject.orderbook,
Expand Down
3 changes: 3 additions & 0 deletions src/modes/intraOrderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export async function dryrun({
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -152,6 +153,7 @@ export async function dryrun({
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
gasCost.mul(headroom).div("100"),
signer.account.address,
);
withdrawOutputCalldata = obInterface.encodeFunctionData("withdraw2", [
orderPairObject.sellToken,
Expand Down Expand Up @@ -180,6 +182,7 @@ export async function dryrun({
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
gasCost.mul(config.gasCoveragePercentage).div("100"),
signer.account.address,
);
withdrawOutputCalldata = obInterface.encodeFunctionData("withdraw2", [
orderPairObject.sellToken,
Expand Down
3 changes: 3 additions & 0 deletions src/modes/routeProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export async function dryrun({
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -228,6 +229,7 @@ export async function dryrun({
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
gasCost.mul(headroom).div("100"),
signer.account.address,
);
rawtx.data = arb.interface.encodeFunctionData("arb3", [
orderPairObject.orderbook,
Expand All @@ -253,6 +255,7 @@ export async function dryrun({
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
gasCost.mul(config.gasCoveragePercentage).div("100"),
signer.account.address,
);
rawtx.data = arb.interface.encodeFunctionData("arb3", [
orderPairObject.orderbook,
Expand Down
3 changes: 3 additions & 0 deletions test/findOpp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ describe("Test find opp", async function () {
ethers.utils.parseUnits(inputToEthPrice),
ethers.constants.Zero,
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -184,6 +185,7 @@ describe("Test find opp", async function () {
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -258,6 +260,7 @@ describe("Test find opp", async function () {
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down
3 changes: 3 additions & 0 deletions test/mode-interOrderbook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ describe("Test inter-orderbook dryrun", async function () {
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -219,6 +220,7 @@ describe("Test inter-orderbook find opp", async function () {
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -314,6 +316,7 @@ describe("Test inter-orderbook find opp", async function () {
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down
3 changes: 3 additions & 0 deletions test/mode-intraOrderbook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe("Test intra-orderbook dryrun", async function () {
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -195,6 +196,7 @@ describe("Test intra-orderbook find opp", async function () {
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -296,6 +298,7 @@ describe("Test intra-orderbook find opp", async function () {
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down
7 changes: 7 additions & 0 deletions test/mode-routeProcessor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe("Test route processor dryrun", async function () {
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -203,6 +204,7 @@ describe("Test route processor dryrun", async function () {
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -285,6 +287,7 @@ describe("Test route processor find opp", async function () {
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -367,6 +370,7 @@ describe("Test route processor find opp", async function () {
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -450,6 +454,7 @@ describe("Test route processor find opp", async function () {
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -566,6 +571,7 @@ describe("Test find opp with retries", async function () {
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
gasLimitEstimation.mul(gasPrice),
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -646,6 +652,7 @@ describe("Test find opp with retries", async function () {
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down

0 comments on commit 14de1f8

Please sign in to comment.