diff --git a/src/config.ts b/src/config.ts index ebd5c47c..6d8979b3 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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( @@ -237,7 +240,7 @@ export function getBountyEnsureBytecode( // ) // \"minimum sender output\" // ); - return `0x0000000000000000000000000000000000000000000000000000000000000004${inputPrice}${outputPrice}${minimum}956d696e696d756d2073656e646572206f757470757400000000000000000000000000000000000000000000000000000000000000000000000000000000003b0100000d06000203100001011000003d12000003100101011000013d120000011000030110000200100001001000002b120000211200001d020000`; + return `0x0000000000000000000000000000000000000000000000000000000000000006${msgSender}8e756e6b6e6f776e2073656e6465720000000000000000000000000000000000${inputPrice}${outputPrice}${minimum}956d696e696d756d2073656e646572206f7574707574000000000000000000000000000000000000000000000000000000000000000000000000000000000047010000100500000110000103100000011000001e1200001d020000011000050110000403100101011000033d12000003100001011000023d1200002b120000211200001d020000`; } /** @@ -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"); @@ -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( @@ -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`; } /** diff --git a/src/modes/interOrderbook.ts b/src/modes/interOrderbook.ts index d85bdd05..8132d278 100644 --- a/src/modes/interOrderbook.ts +++ b/src/modes/interOrderbook.ts @@ -94,6 +94,7 @@ export async function dryrun({ ethers.utils.parseUnits(inputToEthPrice), ethers.utils.parseUnits(outputToEthPrice), ethers.constants.Zero, + signer.account.address, ), }, signedContext: [], @@ -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, @@ -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, diff --git a/src/modes/intraOrderbook.ts b/src/modes/intraOrderbook.ts index 6314f1a8..4021b6b8 100644 --- a/src/modes/intraOrderbook.ts +++ b/src/modes/intraOrderbook.ts @@ -67,6 +67,7 @@ export async function dryrun({ ethers.utils.parseUnits(inputToEthPrice), ethers.utils.parseUnits(outputToEthPrice), ethers.constants.Zero, + signer.account.address, ), }, signedContext: [], @@ -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, @@ -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, diff --git a/src/modes/routeProcessor.ts b/src/modes/routeProcessor.ts index b961123f..69a2d858 100644 --- a/src/modes/routeProcessor.ts +++ b/src/modes/routeProcessor.ts @@ -169,6 +169,7 @@ export async function dryrun({ ethers.utils.parseUnits(ethPrice), ethers.constants.Zero, ethers.constants.Zero, + signer.account.address, ), }, signedContext: [], @@ -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, @@ -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, diff --git a/test/findOpp.test.js b/test/findOpp.test.js index 2c899f02..d82feca7 100644 --- a/test/findOpp.test.js +++ b/test/findOpp.test.js @@ -88,6 +88,7 @@ describe("Test find opp", async function () { ethers.utils.parseUnits(inputToEthPrice), ethers.constants.Zero, gasLimitEstimation.mul(gasPrice), + signer.account.address, ), }, signedContext: [], @@ -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: [], @@ -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: [], diff --git a/test/mode-interOrderbook.test.js b/test/mode-interOrderbook.test.js index 17d6c5f3..24ac4a2d 100644 --- a/test/mode-interOrderbook.test.js +++ b/test/mode-interOrderbook.test.js @@ -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: [], @@ -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: [], @@ -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: [], diff --git a/test/mode-intraOrderbook.test.js b/test/mode-intraOrderbook.test.js index e2647c24..0718e23d 100644 --- a/test/mode-intraOrderbook.test.js +++ b/test/mode-intraOrderbook.test.js @@ -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: [], @@ -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: [], @@ -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: [], diff --git a/test/mode-routeProcessor.test.js b/test/mode-routeProcessor.test.js index 8040e646..1dbdce30 100644 --- a/test/mode-routeProcessor.test.js +++ b/test/mode-routeProcessor.test.js @@ -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: [], @@ -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: [], @@ -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: [], @@ -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: [], @@ -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: [], @@ -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: [], @@ -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: [],