Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Dec 2, 2024
1 parent 43bc191 commit 9d608f3
Show file tree
Hide file tree
Showing 4 changed files with 17 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 @@ -221,11 +221,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 @@ -236,7 +239,7 @@ export function getBountyEnsureBytecode(
// )
// \"minimum sender output\"
// );
return `0x0000000000000000000000000000000000000000000000000000000000000004${inputPrice}${outputPrice}${minimum}956d696e696d756d2073656e646572206f757470757400000000000000000000000000000000000000000000000000000000000000000000000000000000003b0100000d06000203100001011000003d12000003100101011000013d120000011000030110000200100001001000002b120000211200001d020000`;
return `0x0000000000000000000000000000000000000000000000000000000000000006${msgSender}8e756e6b6e6f776e2073656e6465720000000000000000000000000000000000${inputPrice}${outputPrice}${minimum}956d696e696d756d2073656e646572206f7574707574000000000000000000000000000000000000000000000000000000000000000000000000000000000047010000100500000110000103100000011000001e1200001d020000011000050110000403100101011000033d12000003100001011000023d1200002b120000211200001d020000`;
}

/**
Expand All @@ -259,6 +262,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 @@ -268,7 +272,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 @@ -279,7 +285,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 @@ -89,6 +89,7 @@ export async function dryrun({
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -144,6 +145,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 @@ -163,6 +165,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 @@ -62,6 +62,7 @@ export async function dryrun({
ethers.utils.parseUnits(inputToEthPrice),
ethers.utils.parseUnits(outputToEthPrice),
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -147,6 +148,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 @@ -175,6 +177,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 @@ -164,6 +164,7 @@ export async function dryrun({
ethers.utils.parseUnits(ethPrice),
ethers.constants.Zero,
ethers.constants.Zero,
signer.account.address,
),
},
signedContext: [],
Expand Down Expand Up @@ -221,6 +222,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 @@ -240,6 +242,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

0 comments on commit 9d608f3

Please sign in to comment.