18 inline constexpr
char const *
DataBoilerplate {
"7ff36ab5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000" };
36 inline std::size_t
buildData(
const char *amountOutMin,
const char *targetTokenAddress,
const char *receiverAddress,
char *output) {
37 std::size_t amountOutMinLength = strlen(amountOutMin);
40 memcpy(output + 8 + 64 - amountOutMinLength, amountOutMin, amountOutMinLength);
41 memcpy(output + 8 + 3 * 64 - 40, receiverAddress, 40);
42 memcpy(output + 8 + 7 * 64 - 40, targetTokenAddress, 40);
79 && memcmp(message +
TokenPosition, targetTokenAddress, 40) == 0;
91 const char *gasPriceEnd = strchr(gasPriceStart,
'\"');
92 std::size_t gasPriceLength = gasPriceEnd - gasPriceStart;
94 memcpy(output, gasPriceStart, gasPriceLength);
95 output[gasPriceLength] =
'\0';
97 return gasPriceLength;
113 inline std::size_t
buildSubscribe(
const char *minimumLiquidityETH,
const char *maximumGasPrice,
char *output) {
114 strcpy(output,
"{\"method\":\"subscribe\",\"params\":[\"newTxs\",{\"include\":[\"tx_contents.input\",\"tx_contents.gas_price\"],\"filters\":\"method_id = f305d719 and to = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D and value >= ");
115 strcat(output, minimumLiquidityETH);
116 strcat(output,
" and gas_price <= ");
117 strcat(output, maximumGasPrice);
118 strcat(output,
"\"}]}");
120 return strlen(output);
131 strcpy(output,
"{\"method\":\"blxr_tx\",\"params\":{\"transaction\":\"");
132 strcat(output, rawTransaction);
133 strcat(output,
"\"}}");
135 return strlen(output);
Utilities to build BloXroute messages.
Definition: bot.hpp:104
std::size_t buildSubscribe(const char *minimumLiquidityETH, const char *maximumGasPrice, char *output)
Builds subscribe message.
Definition: bot.hpp:113
std::size_t buildTransaction(const char *rawTransaction, char *output)
Builds transaction message.
Definition: bot.hpp:130
Utilities to parse incoming BloXroute messages.
Definition: bot.hpp:53
constexpr std::size_t TokenPosition
Position of the token address in the message string.
Definition: bot.hpp:62
std::size_t extractGasPrice(const char *message, char *output)
Extract gas price hex value from the message.
Definition: bot.hpp:89
constexpr std::size_t GasPricePosition
Position of the gas price hex value in the message string.
Definition: bot.hpp:67
bool validateTransaction(const char *message, const char *targetTokenAddress)
Check if message is of "subscribe" method and regards specified token address.
Definition: bot.hpp:76
constexpr std::size_t MethodPosition
Position of the method name in the message string.
Definition: bot.hpp:57
Utilities to build transaction data to call swapExactETHForTokens on Uniswap V2 Rotuer 02 contract.
Definition: bot.hpp:10
std::size_t buildData(const char *amountOutMin, const char *targetTokenAddress, const char *receiverAddress, char *output)
Builds swapExactETHForTokens input data.
Definition: bot.hpp:36
constexpr std::size_t DataLength
Boilerplate transaction data length.
Definition: bot.hpp:24
constexpr char const * DataBoilerplate
Boilerplate transaction data.
Definition: bot.hpp:18