diff --git a/.gitignore b/.gitignore index 48cd92b..a3995b9 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ __pycache__/ # JS tests/node_modules -tests/lib \ No newline at end of file +tests/lib +tests/snapshots-tmp \ No newline at end of file diff --git a/README.md b/README.md index dc547f0..653d6c6 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,42 @@ The flow processed in [GitHub Actions](https://github.com/features/actions) is t - Code formatting with [clang-format](http://clang.llvm.org/docs/ClangFormat.html) - Compilation of the application for Ledger Nano S in [ledger-app-builder](https://github.com/LedgerHQ/ledger-app-builder) + + +## RDP tests execution + +You can test the plugin using a remote development host, if you deal with an unsupported CPU architecture (Ex.: Apple M1). Your server must have a GUI Desktop installed. + +1. Install first xrdp on remote linux VM (Ex: Ubuntu 20.04.1) +``` +sudo apt install xrdp +```` + +2. Set access control to none : +``` +xhost + +``` +> ```access control disabled, clients can connect from any host``` + + +3. Connect to the VM using Remote Desktop Client using port forwarding through ssh connection on port 3389. This will keep the security at maximum and avoid exposing the VM to the web on RDP port. + +``` +ssh -i PRIVATEKEY USERNAME@PUBLICIP -L 3389:localhost:3389 +``` + +4. Identify the Display index: +``` +echo $DISPLAY +``` +>```:10.0``` + +5. In the terminal where are executed the tests set Display to the RDP previous value, here ``:10.0``: + +``` +export DISPLAY=:10.0 +``` + +6. After this setup you could run ``yarn test`` and see the emulator in the RDP display going through the test sequence. + + diff --git a/src/handle_finalize.c b/src/handle_finalize.c new file mode 100644 index 0000000..97ecbd8 --- /dev/null +++ b/src/handle_finalize.c @@ -0,0 +1,50 @@ +#include "paraswap_plugin.h" + +void handle_finalize(void *parameters) { + ethPluginFinalize_t *msg = (ethPluginFinalize_t *) parameters; + paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext; + if (context->valid) { + msg->numScreens = 2; + if ((context->selectorIndex == SIMPLE_SWAP || context->selectorIndex == SIMPLE_BUY || + context->selectorIndex == SIMPLE_SWAP_V4) && + (strncmp(context->beneficiary, + (const unsigned char *) NULL_ETH_ADDRESS, + ADDRESS_LENGTH) != 0)) { + // An addiitonal screen is required to display the `beneficiary` field. + msg->numScreens += 1; + } + if (!ADDRESS_IS_ETH(context->contract_address_sent)) { + // Address is not ETH so we will need to look up the token in the CAL. + msg->tokenLookup1 = context->contract_address_sent; + PRINTF("Setting address sent to: %.*H\n", + ADDRESS_LENGTH, + context->contract_address_sent); + + // The user is not swapping ETH, so make sure there's no ETH being sent in this tx. + if (!allzeroes(msg->pluginSharedRO->txContent->value.value, + msg->pluginSharedRO->txContent->value.length)) { + PRINTF("ETH attached to tx when token being swapped is %.*H\n", + sizeof(context->contract_address_sent), + context->contract_address_sent); + msg->result = ETH_PLUGIN_RESULT_ERROR; + } + } else { + msg->tokenLookup1 = NULL; + } + if (!ADDRESS_IS_ETH(context->contract_address_received)) { + // Address is not ETH so we will need to look up the token in the CAL. + PRINTF("Setting address receiving to: %.*H\n", + ADDRESS_LENGTH, + context->contract_address_received); + msg->tokenLookup2 = context->contract_address_received; + } else { + msg->tokenLookup2 = NULL; + } + + msg->uiType = ETH_UI_TYPE_GENERIC; + msg->result = ETH_PLUGIN_RESULT_OK; + } else { + PRINTF("Context not valid\n"); + msg->result = ETH_PLUGIN_RESULT_FALLBACK; + } +} \ No newline at end of file diff --git a/src/handle_init_contract.c b/src/handle_init_contract.c new file mode 100644 index 0000000..81afb71 --- /dev/null +++ b/src/handle_init_contract.c @@ -0,0 +1,75 @@ +#include "paraswap_plugin.h" + +// Called once to init. +void handle_init_contract(void *parameters) { + ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters; + + if (msg->interfaceVersion != ETH_PLUGIN_INTERFACE_VERSION_LATEST) { + PRINTF("Wrong interface version: expected %d got %d\n", + ETH_PLUGIN_INTERFACE_VERSION_LATEST, + msg->interfaceVersion); + msg->result = ETH_PLUGIN_RESULT_UNAVAILABLE; + return; + } + + if (msg->pluginContextLength < sizeof(paraswap_parameters_t)) { + PRINTF("Paraswap context size too big: expected %d got %d\n", + sizeof(paraswap_parameters_t), + msg->pluginContextLength); + msg->result = ETH_PLUGIN_RESULT_ERROR; + return; + } + + paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext; + memset(context, 0, sizeof(*context)); + context->valid = 1; + + for (uint8_t i = 0; i < NUM_PARASWAP_SELECTORS; i++) { + if (memcmp((uint8_t *) PIC(PARASWAP_SELECTORS[i]), msg->selector, SELECTOR_SIZE) == 0) { + context->selectorIndex = i; + break; + } + } + + // Set `next_param` to be the first field we expect to parse. + switch (context->selectorIndex) { + case BUY_ON_UNI_FORK: + case SWAP_ON_UNI_FORK: + case BUY_ON_UNI: + case SWAP_ON_UNI: + case SWAP_ON_UNI_V4: + case SWAP_ON_UNI_FORK_V4: + case BUY_ON_UNI_V4: + case BUY_ON_UNI_FORK_V4: + if (context->selectorIndex == SWAP_ON_UNI_FORK || + context->selectorIndex == BUY_ON_UNI_FORK || + context->selectorIndex == SWAP_ON_UNI_FORK_V4 || + context->selectorIndex == BUY_ON_UNI_FORK_V4) { + context->skip = + 2; // Skip the first two parameters (factory and initCode) for uni forks. + } + context->next_param = AMOUNT_SENT; + break; + case SWAP_ON_ZERO_V4: + case SWAP_ON_ZERO_V2: + context->next_param = TOKEN_SENT; + break; + case MEGA_SWAP: + case BUY: + case MULTI_SWAP: + case SIMPLE_BUY: + case SIMPLE_SWAP: + case SIMPLE_SWAP_V4: + case MULTI_SWAP_V4: + case MEGA_SWAP_V4: + context->next_param = TOKEN_SENT; + if (context->selectorIndex != SIMPLE_SWAP_V4) + context->skip = 1; // Skipping 0x20 (offset of structure) + break; + default: + PRINTF("Missing selectorIndex\n"); + msg->result = ETH_PLUGIN_RESULT_ERROR; + return; + } + msg->result = ETH_PLUGIN_RESULT_OK; +} diff --git a/src/provide_parameters.c b/src/handle_provide_parameter.c similarity index 80% rename from src/provide_parameters.c rename to src/handle_provide_parameter.c index f237c0f..fabeb16 100644 --- a/src/provide_parameters.c +++ b/src/handle_provide_parameter.c @@ -2,7 +2,8 @@ // Store the amount sent in the form of a string, without any ticker or decimals. These will be // added when displaying. -static void handle_amount_sent(ethPluginProvideParameter_t *msg, paraswap_parameters_t *context) { +static void handle_amount_sent(const ethPluginProvideParameter_t *msg, + paraswap_parameters_t *context) { memset(context->amount_sent, 0, sizeof(context->amount_sent)); // Convert to string. @@ -17,7 +18,7 @@ static void handle_amount_sent(ethPluginProvideParameter_t *msg, paraswap_parame // Store the amount received in the form of a string, without any ticker or decimals. These will be // added when displaying. -static void handle_amount_received(ethPluginProvideParameter_t *msg, +static void handle_amount_received(const ethPluginProvideParameter_t *msg, paraswap_parameters_t *context) { memset(context->amount_received, 0, sizeof(context->amount_received)); @@ -31,7 +32,8 @@ static void handle_amount_received(ethPluginProvideParameter_t *msg, PRINTF("AMOUNT RECEIVED: %s\n", context->amount_received); } -static void handle_beneficiary(ethPluginProvideParameter_t *msg, paraswap_parameters_t *context) { +static void handle_beneficiary(const ethPluginProvideParameter_t *msg, + paraswap_parameters_t *context) { memset(context->beneficiary, 0, sizeof(context->beneficiary)); memcpy(context->beneficiary, &msg->parameter[PARAMETER_LENGTH - ADDRESS_LENGTH], @@ -39,12 +41,14 @@ static void handle_beneficiary(ethPluginProvideParameter_t *msg, paraswap_parame PRINTF("BENEFICIARY: %.*H\n", ADDRESS_LENGTH, context->beneficiary); } -static void handle_array_len(ethPluginProvideParameter_t *msg, paraswap_parameters_t *context) { +static void handle_array_len(const ethPluginProvideParameter_t *msg, + paraswap_parameters_t *context) { context->array_len = msg->parameter[PARAMETER_LENGTH - 1]; PRINTF("LIST LEN: %d\n", context->array_len); } -static void handle_token_sent(ethPluginProvideParameter_t *msg, paraswap_parameters_t *context) { +static void handle_token_sent(const ethPluginProvideParameter_t *msg, + paraswap_parameters_t *context) { memset(context->contract_address_sent, 0, sizeof(context->contract_address_sent)); memcpy(context->contract_address_sent, &msg->parameter[PARAMETER_LENGTH - ADDRESS_LENGTH], @@ -52,13 +56,13 @@ static void handle_token_sent(ethPluginProvideParameter_t *msg, paraswap_paramet PRINTF("TOKEN SENT: %.*H\n", ADDRESS_LENGTH, context->contract_address_sent); } -static void handle_token_received(ethPluginProvideParameter_t *msg, +static void handle_token_received(const ethPluginProvideParameter_t *msg, paraswap_parameters_t *context) { memset(context->contract_address_received, 0, sizeof(context->contract_address_received)); memcpy(context->contract_address_received, &msg->parameter[PARAMETER_LENGTH - ADDRESS_LENGTH], sizeof(context->contract_address_received)); - PRINTF("TOKEN RECIEVED: %.*H\n", ADDRESS_LENGTH, context->contract_address_received); + PRINTF("TOKEN RECEIVED: %.*H\n", ADDRESS_LENGTH, context->contract_address_received); } static void handle_uniswap_and_forks(ethPluginProvideParameter_t *msg, @@ -69,7 +73,9 @@ static void handle_uniswap_and_forks(ethPluginProvideParameter_t *msg, context->next_param = AMOUNT_RECEIVED; context->checkpoint = msg->parameterOffset; if (context->selectorIndex == BUY_ON_UNI_FORK || - context->selectorIndex == SWAP_ON_UNI_FORK) { + context->selectorIndex == SWAP_ON_UNI_FORK || + context->selectorIndex == SWAP_ON_UNI_FORK_V4 || + context->selectorIndex == BUY_ON_UNI_FORK_V4) { // Substract two chunks because we've skipped the first two parameters. // No underflow possible because we've skipped the first two chunks, so // msg->parameterOffset >= 2 * PARAMETER_LENGTH. @@ -81,7 +87,7 @@ static void handle_uniswap_and_forks(ethPluginProvideParameter_t *msg, context->next_param = PATHS_OFFSET; break; case PATHS_OFFSET: - context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - 2); + context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->offset)); context->next_param = PATH; break; case PATH: // len(path) @@ -125,7 +131,7 @@ static void handle_simple_calls(ethPluginProvideParameter_t *msg, paraswap_param handle_amount_received(msg, context); context->next_param = BENEFICIARY; context->skip = 4; // callees, exchangeData, startIndexes, values. - if (context->selectorIndex == SIMPLE_SWAP) { + if (context->selectorIndex == SIMPLE_SWAP || context->selectorIndex == SIMPLE_SWAP_V4) { context->skip++; // skip field expectedAmount for simple swap. } break; @@ -161,7 +167,9 @@ static void handle_multiswap(ethPluginProvideParameter_t *msg, paraswap_paramete case BENEFICIARY: // beneficiary handle_beneficiary(msg, context); context->next_param = PATHS_OFFSET; - context->skip = 2; // Skip referrer and useReduxtoken + if (context->selectorIndex == MULTI_SWAP_V4) { + context->skip = 2; // Skip referrer and useReduxtoken + } break; case PATHS_OFFSET: context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - 2); @@ -222,6 +230,37 @@ static void handle_buy(ethPluginProvideParameter_t *msg, paraswap_parameters_t * } } +static void handle_swap_on_zero(ethPluginProvideParameter_t *msg, paraswap_parameters_t *context) { + switch (context->next_param) { + case TOKEN_SENT: // fromToken + handle_token_sent(msg, context); + context->next_param = TOKEN_RECEIVED; + break; + case TOKEN_RECEIVED: // toToken + handle_token_received(msg, context); + context->next_param = AMOUNT_SENT; + break; + case AMOUNT_SENT: // fromAmount + handle_amount_sent(msg, context); + context->next_param = AMOUNT_RECEIVED; + break; + case AMOUNT_RECEIVED: // toAmount + handle_amount_received(msg, context); + context->next_param = NONE; + break; + case BENEFICIARY: // beneficiary + handle_beneficiary(msg, context); + context->next_param = NONE; + break; + case NONE: + break; + default: + PRINTF("Param not supported\n"); + msg->result = ETH_PLUGIN_RESULT_ERROR; + break; + } +} + static void handle_megaswap(ethPluginProvideParameter_t *msg, paraswap_parameters_t *context) { switch (context->next_param) { case TOKEN_SENT: // fromToken @@ -241,7 +280,9 @@ static void handle_megaswap(ethPluginProvideParameter_t *msg, paraswap_parameter case BENEFICIARY: handle_beneficiary(msg, context); context->next_param = MEGA_PATHS_OFFSET; - context->skip = 2; // Skip referrer and useReduxToken. + if (context->selectorIndex == MEGA_SWAP_V4) { + context->skip = 2; // Skip referrer and useReduxToken. + } break; case MEGA_PATHS_OFFSET: context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - 2); @@ -303,37 +344,43 @@ void handle_provide_parameter(void *parameters) { msg->parameterOffset); return; } - context->offset = 0; // Reset offset switch (context->selectorIndex) { case BUY_ON_UNI_FORK: case SWAP_ON_UNI_FORK: case BUY_ON_UNI: - case SWAP_ON_UNI: { + case SWAP_ON_UNI: + case SWAP_ON_UNI_V4: + case SWAP_ON_UNI_FORK_V4: + case BUY_ON_UNI_V4: + case BUY_ON_UNI_FORK_V4: handle_uniswap_and_forks(msg, context); break; - } case SIMPLE_BUY: - case SIMPLE_SWAP: { + case SIMPLE_SWAP: + case SIMPLE_SWAP_V4: handle_simple_calls(msg, context); break; - } - case MULTI_SWAP: { + case MULTI_SWAP: + case MULTI_SWAP_V4: handle_multiswap(msg, context); break; - } - case BUY: { + case BUY: handle_buy(msg, context); break; - } - case MEGA_SWAP: { + case MEGA_SWAP: + case MEGA_SWAP_V4: handle_megaswap(msg, context); break; - } + + case SWAP_ON_ZERO_V2: + case SWAP_ON_ZERO_V4: + handle_swap_on_zero(msg, context); + break; default: PRINTF("Selector Index %d not supported\n", context->selectorIndex); diff --git a/src/handle_provide_token.c b/src/handle_provide_token.c new file mode 100644 index 0000000..5c9ebba --- /dev/null +++ b/src/handle_provide_token.c @@ -0,0 +1,43 @@ +#include "paraswap_plugin.h" + +void handle_provide_token(void *parameters) { + ethPluginProvideToken_t *msg = (ethPluginProvideToken_t *) parameters; + paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext; + PRINTF("PARASWAP plugin provide token: 0x%p, 0x%p\n", msg->token1, msg->token2); + + if (ADDRESS_IS_ETH(context->contract_address_sent)) { + context->decimals_sent = WEI_TO_ETHER; + strlcpy(context->ticker_sent, "ETH", sizeof(context->ticker_sent)); + context->tokens_found |= TOKEN_SENT_FOUND; + } else if (msg->token1 != NULL) { + context->decimals_sent = msg->token1->decimals; + strlcpy(context->ticker_sent, (char *) msg->token1->ticker, sizeof(context->ticker_sent)); + context->tokens_found |= TOKEN_SENT_FOUND; + } else { + // CAL did not find the token and token is not ETH. + context->decimals_sent = DEFAULT_DECIMAL; + strlcpy(context->ticker_sent, DEFAULT_TICKER, sizeof(context->ticker_sent)); + // We will need an additional screen to display a warning message. + msg->additionalScreens++; + } + + if (ADDRESS_IS_ETH(context->contract_address_received)) { + context->decimals_received = WEI_TO_ETHER; + strlcpy(context->ticker_received, "ETH", sizeof(context->ticker_received)); + context->tokens_found |= TOKEN_RECEIVED_FOUND; + } else if (msg->token2 != NULL) { + context->decimals_received = msg->token2->decimals; + strlcpy(context->ticker_received, + (char *) msg->token2->ticker, + sizeof(context->ticker_received)); + context->tokens_found |= TOKEN_RECEIVED_FOUND; + } else { + // CAL did not find the token and token is not ETH. + context->decimals_received = DEFAULT_DECIMAL; + strlcpy(context->ticker_received, DEFAULT_TICKER, sizeof(context->ticker_sent)); + // We will need an additional screen to display a warning message. + msg->additionalScreens++; + } + + msg->result = ETH_PLUGIN_RESULT_OK; +} \ No newline at end of file diff --git a/src/handle_query_contract_id.c b/src/handle_query_contract_id.c new file mode 100644 index 0000000..abe6b50 --- /dev/null +++ b/src/handle_query_contract_id.c @@ -0,0 +1,39 @@ +#include "paraswap_plugin.h" + +void handle_query_contract_id(void *parameters) { + ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters; + const paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext; + + strlcpy(msg->name, PLUGIN_NAME, msg->nameLength); + + switch (context->selectorIndex) { + case MEGA_SWAP: + case MULTI_SWAP: + case SIMPLE_SWAP: + case SIMPLE_SWAP_V4: + case SWAP_ON_UNI_FORK: + case SWAP_ON_UNI: + case SWAP_ON_ZERO_V4: + case SWAP_ON_ZERO_V2: + case SWAP_ON_UNI_V4: + case SWAP_ON_UNI_FORK_V4: + case MULTI_SWAP_V4: + case MEGA_SWAP_V4: + strlcpy(msg->version, "Swap", msg->versionLength); + break; + case SIMPLE_BUY: + case BUY_ON_UNI_FORK: + case BUY_ON_UNI: + case BUY: + case BUY_ON_UNI_V4: + case BUY_ON_UNI_FORK_V4: + strlcpy(msg->version, "Buy", msg->versionLength); + break; + default: + PRINTF("Selector Index :%d not supported\n", context->selectorIndex); + msg->result = ETH_PLUGIN_RESULT_ERROR; + return; + } + + msg->result = ETH_PLUGIN_RESULT_OK; +} diff --git a/src/paraswap_ui.c b/src/handle_query_contract_ui.c similarity index 64% rename from src/paraswap_ui.c rename to src/handle_query_contract_ui.c index 5712270..eaa1c16 100644 --- a/src/paraswap_ui.c +++ b/src/handle_query_contract_ui.c @@ -1,13 +1,20 @@ #include "paraswap_plugin.h" +int secure_len(char *src) { + char dest[256]; + strncpy(dest, src, sizeof dest); // Truncation may happen + dest[sizeof dest - 1] = 0; + return strlen(dest); // Compliant: "dest" is guaranteed to be null-terminated +} + // Prepend `dest` with `ticker`. // Dest must be big enough to hold `ticker` + `dest` + `\0`. -static void prepend_ticker(char *dest, uint8_t destsize, char *ticker) { +static void prepend_ticker(char *dest, size_t destsize, const char *ticker) { if (dest == NULL || ticker == NULL) { THROW(0x6503); } - uint8_t ticker_len = strlen(ticker); - uint8_t dest_len = strlen(dest); + uint8_t ticker_len = secure_len(ticker); + uint8_t dest_len = secure_len(dest); if (dest_len + ticker_len >= destsize) { THROW(0x6503); @@ -31,14 +38,23 @@ static void set_send_ui(ethQueryContractUI_t *msg, paraswap_parameters_t *contex case SWAP_ON_UNI_FORK: case SWAP_ON_UNI: case SIMPLE_SWAP: + case SIMPLE_SWAP_V4: case MEGA_SWAP: case MULTI_SWAP: + case SWAP_ON_ZERO_V4: + case SWAP_ON_ZERO_V2: + case SWAP_ON_UNI_V4: + case SWAP_ON_UNI_FORK_V4: + case MULTI_SWAP_V4: + case MEGA_SWAP_V4: strlcpy(msg->title, "Send", msg->titleLength); break; case BUY_ON_UNI_FORK: case BUY_ON_UNI: case BUY: case SIMPLE_BUY: + case BUY_ON_UNI_V4: + case BUY_ON_UNI_FORK_V4: strlcpy(msg->title, "Send Max", msg->titleLength); break; default: @@ -62,14 +78,23 @@ static void set_receive_ui(ethQueryContractUI_t *msg, paraswap_parameters_t *con case SWAP_ON_UNI_FORK: case SWAP_ON_UNI: case SIMPLE_SWAP: + case SIMPLE_SWAP_V4: case MEGA_SWAP: case MULTI_SWAP: + case SWAP_ON_ZERO_V4: + case SWAP_ON_ZERO_V2: + case SWAP_ON_UNI_V4: + case SWAP_ON_UNI_FORK_V4: + case MULTI_SWAP_V4: + case MEGA_SWAP_V4: strlcpy(msg->title, "Receive Min", msg->titleLength); break; case BUY_ON_UNI_FORK: case BUY_ON_UNI: case BUY: case SIMPLE_BUY: + case BUY_ON_UNI_V4: + case BUY_ON_UNI_FORK_V4: strlcpy(msg->title, "Receive", msg->titleLength); break; default: @@ -104,13 +129,13 @@ static void set_beneficiary_ui(ethQueryContractUI_t *msg, paraswap_parameters_t // Set UI for "Warning" screen. static void set_warning_ui(ethQueryContractUI_t *msg, - paraswap_parameters_t *context __attribute__((unused))) { + const paraswap_parameters_t *context __attribute__((unused))) { strlcpy(msg->title, "WARNING", msg->titleLength); strlcpy(msg->msg, "Unknown token", msg->msgLength); } // Helper function that returns the enum corresponding to the screen that should be displayed. -static screens_t get_screen(ethQueryContractUI_t *msg, paraswap_parameters_t *context) { +static screens_t get_screen(const ethQueryContractUI_t *msg, const paraswap_parameters_t *context) { uint8_t index = msg->screenIndex; bool token_sent_found = context->tokens_found & TOKEN_SENT_FOUND; @@ -119,50 +144,59 @@ static screens_t get_screen(ethQueryContractUI_t *msg, paraswap_parameters_t *co bool both_tokens_found = token_received_found && token_sent_found; bool both_tokens_not_found = !token_received_found && !token_sent_found; - if (index == 0) { - if (both_tokens_found) { - return SEND_SCREEN; - } else if (both_tokens_not_found) { - return WARN_SCREEN; - } else if (token_sent_found) { - return SEND_SCREEN; - } else if (token_received_found) { - return WARN_SCREEN; - } - } else if (index == 1) { - if (both_tokens_found) { - return RECEIVE_SCREEN; - } else if (both_tokens_not_found) { - return SEND_SCREEN; - } else if (token_sent_found) { - return WARN_SCREEN; - } else if (token_received_found) { - return SEND_SCREEN; - } - } else if (index == 2) { - if (both_tokens_found) { - return BENEFICIARY_SCREEN; - } else if (both_tokens_not_found) { - return WARN_SCREEN; - } else { - return RECEIVE_SCREEN; - } - } else if (index == 3) { - if (both_tokens_found) { - return ERROR; - } else if (both_tokens_not_found) { - return RECEIVE_SCREEN; - } else { - return BENEFICIARY_SCREEN; - } - } else if (index == 4) { - if (both_tokens_not_found) { - return BENEFICIARY_SCREEN; - } else { + switch (index) { + case 0: + if (both_tokens_found) { + return SEND_SCREEN; + } else if (both_tokens_not_found) { + return WARN_SCREEN; + } else if (token_sent_found) { + return SEND_SCREEN; + } else if (token_received_found) { + return WARN_SCREEN; + } + break; + case 1: + if (both_tokens_found) { + return RECEIVE_SCREEN; + } else if (both_tokens_not_found) { + return SEND_SCREEN; + } else if (token_sent_found) { + return WARN_SCREEN; + } else if (token_received_found) { + return SEND_SCREEN; + } + break; + + case 2: + if (both_tokens_found) { + return BENEFICIARY_SCREEN; + } else if (both_tokens_not_found) { + return WARN_SCREEN; + } else { + return RECEIVE_SCREEN; + } + break; + case 3: + if (both_tokens_found) { + return ERROR; + } else if (both_tokens_not_found) { + return RECEIVE_SCREEN; + } else { + return BENEFICIARY_SCREEN; + } + break; + case 4: + if (both_tokens_not_found) { + return BENEFICIARY_SCREEN; + } else { + return ERROR; + } + break; + default: return ERROR; - } + break; } - return ERROR; } void handle_query_contract_ui(void *parameters) { diff --git a/src/main.c b/src/main.c index a02169d..4e4ecde 100644 --- a/src/main.c +++ b/src/main.c @@ -25,6 +25,174 @@ #include "paraswap_plugin.h" +// ---------- Paraswap V5 ------------- +// Function: swapOnUniswap(uint256 amountIn, uint256 amountOutMin, address[] path) *** +// Selector: 0x54840d1a +static const uint8_t PARASWAP_SWAP_ON_UNISWAP_SELECTOR[SELECTOR_SIZE] = {0x54, 0x84, 0x0d, 0x1a}; + +// Function: swapOnUniswapFork(address factory, bytes32 initCode, uint256 amountIn, uint256 +// amountOutMin, address[] path) +// Selector : 0xf5661034 +static const uint8_t PARASWAP_SWAP_ON_UNISWAP_FORK_SELECTOR[SELECTOR_SIZE] = {0xf5, + 0x66, + 0x10, + 0x34}; + +// Function: buyOnUniswap(uint256 amountInMax, uint256 amountOut, address[] path) +// Selector: 0x935fb84b +static const uint8_t PARASWAP_BUY_ON_UNISWAP_SELECTOR[SELECTOR_SIZE] = {0x93, 0x5f, 0xb8, 0x4b}; + +// Function: buyOnUniswapFork(address factory, bytes32 initCode, uint256 amountInMax, uint256 +// amountOut, address[] path) *** +// Selector: 0xc03786b0 +static const uint8_t PARASWAP_BUY_ON_UNISWAP_FORK_SELECTOR[SELECTOR_SIZE] = {0xc0, + 0x37, + 0x86, + 0xb0}; + +// Function : simpleSwap((address fromToken,address toToken,uint256 fromAmount,uint256 toAmount, +// uint256 expectedAmount,address[] callees,bytes exchangeData,uint256[] startIndexes, +// uint256[] values,address beneficiary,address partner,uint256 feePercent,bytes permit, +// uint256 deadline,bytes16 uuid)) +// Selector : 0x54e3f31b +static const uint8_t PARASWAP_SIMPLE_SWAP_SELECTOR[SELECTOR_SIZE] = {0x54, 0xe3, 0xf3, 0x1b}; + +// Function: multiSwap ((address fromToken, uint256 fromAmount, uint256 toAmount, uint256 +// expectedAmount, address payable beneficiary, Utils.Path[] path, address payable partner, uint256 +// feePercent, bytes permit, uint256 deadline, bytes16 uuid)) ) +// Selector: 0xa94e78ef +static const uint8_t PARASWAP_MULTI_SWAP_SELECTOR[SELECTOR_SIZE] = {0xa9, 0x4e, 0x78, 0xef}; + +// Function: megaSwap (( address fromToken, uint256 fromAmount, uint256 toAmount, uint256 +// expectedAmount, address payable beneficiary, Utils.MegaSwapPath[] path, address payable partner, +// uint256 feePercent, bytes permit, uint256 deadline, bytes16 uuid)) external returns ( +// uint256 ) +// Selector: 0x46c67b6d +static const uint8_t PARASWAP_MEGA_SWAP_SELECTOR[SELECTOR_SIZE] = {0x46, 0xc6, 0x7b, 0x6d}; + +// Function: simpleBuy(( address fromToken, address toToken, uint256 fromAmount, uint256 +// toAmount, uint256 expectedAmount, address[] callees, bytes exchangeData, uint256[] +// startIndexes, uint256[] values, address payable beneficiary, address payable partner, uint256 +// feePercent, bytes permit, uint256 deadline, bytes16 uuid,) ) external payable, +// Selector: 0x2298207a +static const uint8_t PARASWAP_SIMPLE_BUY_SELECTOR[SELECTOR_SIZE] = {0x22, 0x98, 0x20, 0x7a}; + +// Function swapOnZeroXv4 ( address fromToken, address toToken, uint256 fromAmount, uint256 +// amountOutMin, address exchange, bytes payload ) +// Selector 0x64466805 +static const uint8_t PARASWAP_SWAP_ON_ZERO_V4_SELECTOR[SELECTOR_SIZE] = {0x64, 0x46, 0x68, 0x05}; + +// Function: swapOnZeroXv2(address fromToken, address toToken, uint256 fromAmount, uint256 +// amountOutMin, address exchange, bytes payload) +// Selector: 0x81033120 +static const uint8_t PARASWAP_SWAP_ON_ZERO_V2_SELECTOR[SELECTOR_SIZE] = {0x81, 0x03, 0x31, 0x20}; +// ---------- End Paraswap V5 ------------- + +// ---------- Paraswap V4 ------------- +// Function : simpleSwap(address fromToken, address toToken, uint256 fromAmount, uint256 toAmount, +// uint256 expectedAmount, address[] callees, bytes exchangeData, uint256[] startIndexes, +// uint256[] values, address beneficiary, string referrer, bool useReduxToken) +// Selector : 0xcfc0afeb +static const uint8_t PARASWAP_SIMPLE_SWAP_V4_SELECTOR[SELECTOR_SIZE] = {0xcf, 0xc0, 0xaf, 0xeb}; + +// Function: swapOnUniswap(uint256 amountIn, uint256 amountOutMin, address[] path, uint8 referrer) +// Selector: 0x58b9d179 +static const uint8_t PARASWAP_SWAP_ON_UNISWAP_V4_SELECTOR[SELECTOR_SIZE] = {0x58, 0xb9, 0xd1, 0x79}; + +// Function: swapOnUniswapFork(address factory, bytes32 initCode, uint256 amountIn, uint256 +// amountOutMin, address[] path, uint8 referrer) +// Selector: 0x0863b7ac +static const uint8_t PARASWAP_SWAP_ON_UNISWAP_FORK_V4_SELECTOR[SELECTOR_SIZE] = {0x08, + 0x63, + 0xb7, + 0xac}; + +// Function: multiSwap ((address fromToken, uint256 fromAmount, uint256 toAmount, uint256 +// expectedAmount, address beneficiary, string referrer, bool useReduxToken, Utils.Path[] path))) +// Selector: 0x8f00eccb +static const uint8_t PARASWAP_MULTI_SWAP_V4_SELECTOR[SELECTOR_SIZE] = {0x8f, 0x00, 0xec, 0xcb}; + +// Function: megaSwap ((address fromToken, uint256 fromAmount, uint256 toAmount, uint256 +// expectedAmount, address beneficiary, string referrer, bool useReduxToken, Utils.Path[] path))) +// Selector: 0xec1d21dd +static const uint8_t PARASWAP_MEGA_SWAP_V4_SELECTOR[SELECTOR_SIZE] = {0xec, 0x1d, 0x21, 0xdd}; + +// Function : buy(address fromToken, address toToken, uint256 fromAmount, uint256 toAmount, +// address beneficiary, string referrer, bool useReduxToken, Utils.BuyRoute[] route) +// Selector: 0xf95a49eb +static const uint8_t PARASWAP_BUY_SELECTOR[SELECTOR_SIZE] = {0xf9, 0x5a, 0x49, 0xeb}; + +// Function: buyOnUniswap(uint256 amountInMax, uint256 amountOut, address[] path, uint8 referrer) +// Selector: 0xf9355f72 +static const uint8_t PARASWAP_BUY_ON_UNISWAP_V4_SELECTOR[SELECTOR_SIZE] = {0xf9, 0x35, 0x5f, 0x72}; + +// Function: buyOnUniswapFork(address factory, bytes32 initCode, uint256 amountInMax, uint256 +// amountOut, address[] path, uint8 referrer) +// Selector: 0x33635226 +static const uint8_t PARASWAP_BUY_ON_UNISWAP_FORK_V4_SELECTOR[SELECTOR_SIZE] = {0x33, + 0x63, + 0x52, + 0x26}; + +// ---------- End Paraswap V4 ------------- + +// Array of all the different paraswap selectors. +const uint8_t *const PARASWAP_SELECTORS[NUM_PARASWAP_SELECTORS] = { + PARASWAP_SWAP_ON_UNISWAP_SELECTOR, + PARASWAP_BUY_ON_UNISWAP_SELECTOR, + PARASWAP_SWAP_ON_UNISWAP_FORK_SELECTOR, + PARASWAP_BUY_ON_UNISWAP_FORK_SELECTOR, + PARASWAP_SIMPLE_SWAP_SELECTOR, + PARASWAP_SIMPLE_BUY_SELECTOR, + PARASWAP_MULTI_SWAP_SELECTOR, + PARASWAP_BUY_SELECTOR, + PARASWAP_MEGA_SWAP_SELECTOR, + PARASWAP_SWAP_ON_ZERO_V4_SELECTOR, + PARASWAP_SWAP_ON_ZERO_V2_SELECTOR, + PARASWAP_SIMPLE_SWAP_V4_SELECTOR, + PARASWAP_SWAP_ON_UNISWAP_V4_SELECTOR, + PARASWAP_SWAP_ON_UNISWAP_FORK_V4_SELECTOR, + PARASWAP_MULTI_SWAP_V4_SELECTOR, + PARASWAP_MEGA_SWAP_V4_SELECTOR, + PARASWAP_BUY_ON_UNISWAP_V4_SELECTOR, + PARASWAP_BUY_ON_UNISWAP_FORK_V4_SELECTOR}; + +// Paraswap uses `0xeeeee` as a dummy address to represent ETH. +const uint8_t PARASWAP_ETH_ADDRESS[ADDRESS_LENGTH] = {0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, + 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, + 0xee, 0xee, 0xee, 0xee, 0xee, 0xee}; + +// Used to indicate that the beneficiary should be the sender. +const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +void paraswap_plugin_call(int message, void *parameters) { + switch (message) { + case ETH_PLUGIN_INIT_CONTRACT: + handle_init_contract(parameters); + break; + case ETH_PLUGIN_PROVIDE_PARAMETER: + handle_provide_parameter(parameters); + break; + case ETH_PLUGIN_FINALIZE: + handle_finalize(parameters); + break; + case ETH_PLUGIN_PROVIDE_TOKEN: + handle_provide_token(parameters); + break; + case ETH_PLUGIN_QUERY_CONTRACT_ID: + handle_query_contract_id(parameters); + break; + case ETH_PLUGIN_QUERY_CONTRACT_UI: + handle_query_contract_ui(parameters); + break; + default: + PRINTF("Unhandled message %d\n", message); + break; + } +} + void call_app_ethereum() { unsigned int libcall_params[3]; libcall_params[0] = (unsigned int) "Ethereum"; @@ -40,18 +208,22 @@ __attribute__((section(".boot"))) int main(int arg0) { // ensure exception will work as planned os_boot(); + // Try catch block. Please read the docs for more information on how to use those! BEGIN_TRY { TRY { + // Low-level black magic. check_api_level(CX_COMPAT_APILEVEL); - + // Check if we are called from the dashboard. if (!arg0) { // called from dashboard, launch Ethereum app call_app_ethereum(); return 0; } else { - // regular call from ethereum - unsigned int *args = (unsigned int *) arg0; + // Not called from dashboard: called from the ethereum app! + const unsigned int *args = (unsigned int *) arg0; + // If `ETH_PLUGIN_CHECK_PRESENCE` is set, this means the caller is just trying to + // know whether this app exists or not. We can skip `paraswap_plugin_call`. if (args[0] != ETH_PLUGIN_CHECK_PRESENCE) { paraswap_plugin_call(args[0], (void *) args[1]); } diff --git a/src/paraswap_plugin.c b/src/paraswap_plugin.c deleted file mode 100644 index d1c0d51..0000000 --- a/src/paraswap_plugin.c +++ /dev/null @@ -1,249 +0,0 @@ -#include "paraswap_plugin.h" - -// Need more information about the interface for plugins? Please read the README.md! - -static const uint8_t PARASWAP_SWAP_ON_UNISWAP_SELECTOR[SELECTOR_SIZE] = {0x58, 0xb9, 0xd1, 0x79}; -static const uint8_t PARASWAP_SWAP_ON_UNISWAP_FORK_SELECTOR[SELECTOR_SIZE] = {0x08, - 0x63, - 0xb7, - 0xac}; -static const uint8_t PARASWAP_SIMPLE_SWAP_SELECTOR[SELECTOR_SIZE] = {0xcf, 0xc0, 0xaf, 0xeb}; -static const uint8_t PARASWAP_MULTI_SWAP_SELECTOR[SELECTOR_SIZE] = {0x8f, 0x00, 0xec, 0xcb}; -static const uint8_t PARASWAP_MEGA_SWAP_SELECTOR[SELECTOR_SIZE] = {0xec, 0x1d, 0x21, 0xdd}; -static const uint8_t PARASWAP_BUY_ON_UNISWAP_SELECTOR[SELECTOR_SIZE] = {0xf9, 0x35, 0x5f, 0x72}; -static const uint8_t PARASWAP_BUY_ON_UNISWAP_FORK_SELECTOR[SELECTOR_SIZE] = {0x33, - 0x63, - 0x52, - 0x26}; -static const uint8_t PARASWAP_SIMPLE_BUY_SELECTOR[SELECTOR_SIZE] = {0xa2, 0x7e, 0x8b, 0x6b}; -static const uint8_t PARASWAP_BUY_SELECTOR[SELECTOR_SIZE] = {0xf9, 0x5a, 0x49, 0xeb}; - -// Array of all the different paraswap selectors. -const uint8_t *const PARASWAP_SELECTORS[NUM_PARASWAP_SELECTORS] = { - PARASWAP_SWAP_ON_UNISWAP_SELECTOR, - PARASWAP_BUY_ON_UNISWAP_SELECTOR, - PARASWAP_SWAP_ON_UNISWAP_FORK_SELECTOR, - PARASWAP_BUY_ON_UNISWAP_FORK_SELECTOR, - PARASWAP_SIMPLE_SWAP_SELECTOR, - PARASWAP_SIMPLE_BUY_SELECTOR, - PARASWAP_MULTI_SWAP_SELECTOR, - PARASWAP_BUY_SELECTOR, - PARASWAP_MEGA_SWAP_SELECTOR, -}; - -// Paraswap uses `0xeeeee` as a dummy address to represent ETH. -const uint8_t PARASWAP_ETH_ADDRESS[ADDRESS_LENGTH] = {0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, - 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, - 0xee, 0xee, 0xee, 0xee, 0xee, 0xee}; - -// Used to indicate that the beneficiary should be the sender. -const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -// Called once to init. -static void handle_init_contract(void *parameters) { - ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters; - - if (msg->interfaceVersion != ETH_PLUGIN_INTERFACE_VERSION_LATEST) { - PRINTF("Wrong interface version: expected %d got %d\n", - ETH_PLUGIN_INTERFACE_VERSION_LATEST, - msg->interfaceVersion); - msg->result = ETH_PLUGIN_RESULT_UNAVAILABLE; - return; - } - - if (msg->pluginContextLength < sizeof(paraswap_parameters_t)) { - PRINTF("Paraswap context size too big: expected %d got %d\n", - sizeof(paraswap_parameters_t), - msg->pluginContextLength); - msg->result = ETH_PLUGIN_RESULT_ERROR; - return; - } - - paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext; - memset(context, 0, sizeof(*context)); - context->valid = 1; - - size_t i; - for (i = 0; i < NUM_PARASWAP_SELECTORS; i++) { - if (memcmp((uint8_t *) PIC(PARASWAP_SELECTORS[i]), msg->selector, SELECTOR_SIZE) == 0) { - context->selectorIndex = i; - break; - } - } - - // Set `next_param` to be the first field we expect to parse. - switch (context->selectorIndex) { - case BUY_ON_UNI_FORK: - case SWAP_ON_UNI_FORK: - case BUY_ON_UNI: - case SWAP_ON_UNI: - if (context->selectorIndex == SWAP_ON_UNI_FORK || - context->selectorIndex == BUY_ON_UNI_FORK) { - context->skip = - 2; // Skip the first two parameters (factory and initCode) for uni forks. - } - context->next_param = AMOUNT_SENT; - break; - case SIMPLE_BUY: - case SIMPLE_SWAP: - context->next_param = TOKEN_SENT; - break; - case MEGA_SWAP: - case BUY: - case MULTI_SWAP: - context->next_param = TOKEN_SENT; - context->skip = 1; // Skipping 0x20 (offset of structure) - break; - default: - PRINTF("Missing selectorIndex\n"); - msg->result = ETH_PLUGIN_RESULT_ERROR; - return; - } - - msg->result = ETH_PLUGIN_RESULT_OK; -} - -static void handle_finalize(void *parameters) { - ethPluginFinalize_t *msg = (ethPluginFinalize_t *) parameters; - paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext; - if (context->valid) { - msg->numScreens = 2; - if (context->selectorIndex == SIMPLE_SWAP || context->selectorIndex == SIMPLE_BUY) - if (strncmp(context->beneficiary, (char *) NULL_ETH_ADDRESS, ADDRESS_LENGTH) != 0) { - // An addiitonal screen is required to display the `beneficiary` field. - msg->numScreens += 1; - } - if (!ADDRESS_IS_ETH(context->contract_address_sent)) { - // Address is not ETH so we will need to look up the token in the CAL. - msg->tokenLookup1 = context->contract_address_sent; - PRINTF("Setting address sent to: %.*H\n", - ADDRESS_LENGTH, - context->contract_address_sent); - - // The user is not swapping ETH, so make sure there's no ETH being sent in this tx. - if (!allzeroes(msg->pluginSharedRO->txContent->value.value, - msg->pluginSharedRO->txContent->value.length)) { - PRINTF("ETH attached to tx when token being swapped is %.*H\n", - sizeof(context->contract_address_sent), - context->contract_address_sent); - msg->result = ETH_PLUGIN_RESULT_ERROR; - } - } else { - msg->tokenLookup1 = NULL; - } - if (!ADDRESS_IS_ETH(context->contract_address_received)) { - // Address is not ETH so we will need to look up the token in the CAL. - PRINTF("Setting address receiving to: %.*H\n", - ADDRESS_LENGTH, - context->contract_address_received); - msg->tokenLookup2 = context->contract_address_received; - } else { - msg->tokenLookup2 = NULL; - } - - msg->uiType = ETH_UI_TYPE_GENERIC; - msg->result = ETH_PLUGIN_RESULT_OK; - } else { - PRINTF("Context not valid\n"); - msg->result = ETH_PLUGIN_RESULT_FALLBACK; - } -} - -static void handle_provide_token(void *parameters) { - ethPluginProvideToken_t *msg = (ethPluginProvideToken_t *) parameters; - paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext; - PRINTF("PARASWAP plugin provide token: 0x%p, 0x%p\n", msg->token1, msg->token2); - - if (ADDRESS_IS_ETH(context->contract_address_sent)) { - context->decimals_sent = WEI_TO_ETHER; - strlcpy(context->ticker_sent, "ETH", sizeof(context->ticker_sent)); - context->tokens_found |= TOKEN_SENT_FOUND; - } else if (msg->token1 != NULL) { - context->decimals_sent = msg->token1->decimals; - strlcpy(context->ticker_sent, (char *) msg->token1->ticker, sizeof(context->ticker_sent)); - context->tokens_found |= TOKEN_SENT_FOUND; - } else { - // CAL did not find the token and token is not ETH. - context->decimals_sent = DEFAULT_DECIMAL; - strlcpy(context->ticker_sent, DEFAULT_TICKER, sizeof(context->ticker_sent)); - // We will need an additional screen to display a warning message. - msg->additionalScreens++; - } - - if (ADDRESS_IS_ETH(context->contract_address_received)) { - context->decimals_received = WEI_TO_ETHER; - strlcpy(context->ticker_received, "ETH", sizeof(context->ticker_received)); - context->tokens_found |= TOKEN_RECEIVED_FOUND; - } else if (msg->token2 != NULL) { - context->decimals_received = msg->token2->decimals; - strlcpy(context->ticker_received, - (char *) msg->token2->ticker, - sizeof(context->ticker_received)); - context->tokens_found |= TOKEN_RECEIVED_FOUND; - } else { - // CAL did not find the token and token is not ETH. - context->decimals_received = DEFAULT_DECIMAL; - strlcpy(context->ticker_received, DEFAULT_TICKER, sizeof(context->ticker_sent)); - // We will need an additional screen to display a warning message. - msg->additionalScreens++; - } - - msg->result = ETH_PLUGIN_RESULT_OK; -} - -static void handle_query_contract_id(void *parameters) { - ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters; - paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext; - - strlcpy(msg->name, PLUGIN_NAME, msg->nameLength); - - switch (context->selectorIndex) { - case MEGA_SWAP: - case MULTI_SWAP: - case SIMPLE_SWAP: - case SWAP_ON_UNI_FORK: - case SWAP_ON_UNI: - strlcpy(msg->version, "Swap", msg->versionLength); - break; - case SIMPLE_BUY: - case BUY_ON_UNI_FORK: - case BUY_ON_UNI: - case BUY: - strlcpy(msg->version, "Buy", msg->versionLength); - break; - default: - PRINTF("Selector Index :%d not supported\n", context->selectorIndex); - msg->result = ETH_PLUGIN_RESULT_ERROR; - return; - } - - msg->result = ETH_PLUGIN_RESULT_OK; -} - -void paraswap_plugin_call(int message, void *parameters) { - switch (message) { - case ETH_PLUGIN_INIT_CONTRACT: - handle_init_contract(parameters); - break; - case ETH_PLUGIN_PROVIDE_PARAMETER: - handle_provide_parameter(parameters); - break; - case ETH_PLUGIN_FINALIZE: - handle_finalize(parameters); - break; - case ETH_PLUGIN_PROVIDE_TOKEN: - handle_provide_token(parameters); - break; - case ETH_PLUGIN_QUERY_CONTRACT_ID: - handle_query_contract_id(parameters); - break; - case ETH_PLUGIN_QUERY_CONTRACT_UI: - handle_query_contract_ui(parameters); - break; - default: - PRINTF("Unhandled message %d\n", message); - break; - } -} diff --git a/src/paraswap_plugin.h b/src/paraswap_plugin.h index c654a8e..a9ff4ca 100644 --- a/src/paraswap_plugin.h +++ b/src/paraswap_plugin.h @@ -2,13 +2,14 @@ #include "eth_internals.h" #include "eth_plugin_interface.h" +#include #define PARAMETER_LENGTH 32 #define SELECTOR_SIZE 4 #define RUN_APPLICATION 1 -#define NUM_PARASWAP_SELECTORS 9 +#define NUM_PARASWAP_SELECTORS 18 #define SELECTOR_SIZE 4 #define PLUGIN_NAME "Paraswap" @@ -35,8 +36,19 @@ typedef enum { MULTI_SWAP, BUY, MEGA_SWAP, + SWAP_ON_ZERO_V4, + SWAP_ON_ZERO_V2, + SIMPLE_SWAP_V4, + SWAP_ON_UNI_V4, + SWAP_ON_UNI_FORK_V4, + MULTI_SWAP_V4, + MEGA_SWAP_V4, + BUY_ON_UNI_V4, + BUY_ON_UNI_FORK_V4 } paraswapSelector_t; +extern const uint8_t *const PARASWAP_SELECTORS[NUM_PARASWAP_SELECTORS]; + typedef enum { SEND_SCREEN, RECEIVE_SCREEN, @@ -96,6 +108,9 @@ typedef struct paraswap_parameters_t { // 4 * 1 + 2 * 2 + 7 * 1 == 8 + 7 == 15 bytes. There are 16 - 15 == 1 byte left. } paraswap_parameters_t; +void handle_init_contract(void *parameters); void handle_provide_parameter(void *parameters); void handle_query_contract_ui(void *parameters); -void paraswap_plugin_call(int message, void *parameters); \ No newline at end of file +void handle_finalize(void *parameters); +void handle_provide_token(void *parameters); +void handle_query_contract_id(void *parameters); \ No newline at end of file diff --git a/tests/build_local_test_elfs.sh b/tests/build_local_test_elfs.sh index d4f8d43..c8cdaaa 100755 --- a/tests/build_local_test_elfs.sh +++ b/tests/build_local_test_elfs.sh @@ -1,9 +1,9 @@ #!/bin/bash # FILL THESE WITH YOUR OWN SDKs PATHS and APP-ETHEREUM's ROOT -# NANOS_SDK= -# NANOX_SDK= -# APP_ETHEREUM= +NANOS_SDK=$NANOS_SDK +NANOX_SDK=$NANOX_SDK +APP_ETHEREUM=/plugin_dev/app-ethereum # create elfs folder if it doesn't exist mkdir -p elfs @@ -21,7 +21,7 @@ cp bin/app.elf "tests/elfs/paraswap_nanos.elf" echo "**Building app-ethereum for Nano S..." cd $APP_ETHEREUM make clean BOLOS_SDK=$NANOS_SDK -make -j DEBUG=1 BOLOS_SDK=$NANOS_SDK CHAIN=ethereum +make -j DEBUG=1 BOLOS_SDK=$NANOS_SDK CHAIN=ethereum BYPASS_SIGNATURES=1 cd - cp "${APP_ETHEREUM}/bin/app.elf" "tests/elfs/ethereum_nanos.elf" @@ -36,7 +36,7 @@ cp bin/app.elf "tests/elfs/paraswap_nanox.elf" echo "**Building app-ethereum for Nano X..." cd $APP_ETHEREUM make clean BOLOS_SDK=$NANOX_SDK -make -j DEBUG=1 BOLOS_SDK=$NANOX_SDK CHAIN=ethereum +make -j DEBUG=1 BOLOS_SDK=$NANOX_SDK CHAIN=ethereum BYPASS_SIGNATURES=1 cd - cp "${APP_ETHEREUM}/bin/app.elf" "tests/elfs/ethereum_nanox.elf" diff --git a/tests/elfs/ethereum_nanos.elf b/tests/elfs/ethereum_nanos.elf index fcea1c8..46b5d54 100755 Binary files a/tests/elfs/ethereum_nanos.elf and b/tests/elfs/ethereum_nanos.elf differ diff --git a/tests/elfs/ethereum_nanox.elf b/tests/elfs/ethereum_nanox.elf index 3cb0b3e..d01335a 100755 Binary files a/tests/elfs/ethereum_nanox.elf and b/tests/elfs/ethereum_nanox.elf differ diff --git a/tests/elfs/paraswap_nanos.elf b/tests/elfs/paraswap_nanos.elf index aa02b40..8cb606c 100755 Binary files a/tests/elfs/paraswap_nanos.elf and b/tests/elfs/paraswap_nanos.elf differ diff --git a/tests/elfs/paraswap_nanox.elf b/tests/elfs/paraswap_nanox.elf index 74aa58b..84725a9 100755 Binary files a/tests/elfs/paraswap_nanox.elf and b/tests/elfs/paraswap_nanox.elf differ diff --git a/tests/paraswap/abis/0x1bd435f3c054b6e901b7b108a0ab7617c808677b.json b/tests/paraswap/abis/0x1bd435f3c054b6e901b7b108a0ab7617c808677b.json new file mode 100644 index 0000000..aba6244 --- /dev/null +++ b/tests/paraswap/abis/0x1bd435f3c054b6e901b7b108a0ab7617c808677b.json @@ -0,0 +1,1113 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "adapter", + "type": "address" + } + ], + "name": "AdapterInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "initiator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "beneficiary", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "srcToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "destToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "srcAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "receivedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "referrer", + "type": "string" + } + ], + "name": "Bought", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "partnerShare", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "paraswapShare", + "type": "uint256" + } + ], + "name": "FeeTaken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "initiator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "beneficiary", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "srcToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "destToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "srcAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "receivedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "referrer", + "type": "string" + } + ], + "name": "Swapped", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "string", + "name": "referrer", + "type": "string" + }, + { + "internalType": "bool", + "name": "useReduxToken", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address payable", + "name": "exchange", + "type": "address" + }, + { + "internalType": "address", + "name": "targetExchange", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + } + ], + "internalType": "struct Utils.BuyRoute[]", + "name": "route", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.BuyData", + "name": "data", + "type": "tuple" + } + ], + "name": "buy", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountInMax", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "uint8", + "name": "referrer", + "type": "uint8" + } + ], + "name": "buyOnUniswap", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "factory", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "initCode", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "amountInMax", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "uint8", + "name": "referrer", + "type": "uint8" + } + ], + "name": "buyOnUniswapFork", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "uniswapProxy", + "type": "address" + } + ], + "name": "changeUniswapProxy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "confirmUniswapProxyChange", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getChangeRequestedBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + } + ], + "name": "getData", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFeeWallet", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPartnerRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPendingUniswapProxy", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTimeLock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTokenTransferProxy", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getUniswapProxy", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVersion", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWhitelistAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "whitelist", + "type": "address" + }, + { + "internalType": "address", + "name": "reduxToken", + "type": "address" + }, + { + "internalType": "address", + "name": "partnerRegistry", + "type": "address" + }, + { + "internalType": "address payable", + "name": "feeWallet", + "type": "address" + }, + { + "internalType": "address", + "name": "uniswapProxy", + "type": "address" + }, + { + "internalType": "uint256", + "name": "timelock", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "adapter", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "initializeAdapter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + } + ], + "name": "isInitialized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "string", + "name": "referrer", + "type": "string" + }, + { + "internalType": "bool", + "name": "useReduxToken", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "fromAmountPercent", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "totalNetworkFee", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address payable", + "name": "exchange", + "type": "address" + }, + { + "internalType": "address", + "name": "targetExchange", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + } + ], + "internalType": "struct Utils.Route[]", + "name": "routes", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.Path[]", + "name": "path", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.MegaSwapPath[]", + "name": "path", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.MegaSwapSellData", + "name": "data", + "type": "tuple" + } + ], + "name": "megaSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "string", + "name": "referrer", + "type": "string" + }, + { + "internalType": "bool", + "name": "useReduxToken", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "totalNetworkFee", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address payable", + "name": "exchange", + "type": "address" + }, + { + "internalType": "address", + "name": "targetExchange", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + } + ], + "internalType": "struct Utils.Route[]", + "name": "routes", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.Path[]", + "name": "path", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.SellData", + "name": "data", + "type": "tuple" + } + ], + "name": "multiSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "feeWallet", + "type": "address" + } + ], + "name": "setFeeWallet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "partnerRegistry", + "type": "address" + } + ], + "name": "setPartnerRegistry", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "whitelisted", + "type": "address" + } + ], + "name": "setWhitelistAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "callees", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "exchangeData", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "startIndexes", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "string", + "name": "referrer", + "type": "string" + }, + { + "internalType": "bool", + "name": "useReduxToken", + "type": "bool" + } + ], + "name": "simplBuy", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "callees", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "exchangeData", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "startIndexes", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "string", + "name": "referrer", + "type": "string" + }, + { + "internalType": "bool", + "name": "useReduxToken", + "type": "bool" + } + ], + "name": "simpleSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "receivedAmount", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "uint8", + "name": "referrer", + "type": "uint8" + } + ], + "name": "swapOnUniswap", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "factory", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "initCode", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + }, + { + "internalType": "uint8", + "name": "referrer", + "type": "uint8" + } + ], + "name": "swapOnUniswapFork", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address payable", + "name": "destination", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IWETH", + "name": "token", + "type": "address" + } + ], + "name": "withdrawAllWETH", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/tests/paraswap/abis/0xdef171fe48cf0115b1d80b88dc8eab59176fee57.json b/tests/paraswap/abis/0xdef171fe48cf0115b1d80b88dc8eab59176fee57.json new file mode 100644 index 0000000..f15631a --- /dev/null +++ b/tests/paraswap/abis/0xdef171fe48cf0115b1d80b88dc8eab59176fee57.json @@ -0,0 +1,1966 @@ +[ + { + "inputs": [ + { + "internalType": "address payable", + "name": "_feeWallet", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "adapter", + "type": "address" + } + ], + "name": "AdapterInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "router", + "type": "address" + } + ], + "name": "RouterInitialized", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ROUTER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WHITELISTED_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + } + ], + "name": "getAdapterData", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFeeWallet", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + } + ], + "name": "getImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "partner", + "type": "address" + } + ], + "name": "getPartnerFeeStructure", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "partnerShare", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "noPositiveSlippage", + "type": "bool" + }, + { + "internalType": "bool", + "name": "positiveSlippageToUser", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "feePercent", + "type": "uint16" + }, + { + "internalType": "string", + "name": "partnerId", + "type": "string" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct AugustusStorage.FeeStructure", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getRoleMember", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleMemberCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + } + ], + "name": "getRouterData", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTokenTransferProxy", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVersion", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "adapter", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "initializeAdapter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "router", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "initializeRouter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + } + ], + "name": "isAdapterInitialized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + } + ], + "name": "isRouterInitialized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "partner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_partnerShare", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_noPositiveSlippage", + "type": "bool" + }, + { + "internalType": "bool", + "name": "_positiveSlippageToUser", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "_feePercent", + "type": "uint16" + }, + { + "internalType": "string", + "name": "partnerId", + "type": "string" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "registerPartner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_feeWallet", + "type": "address" + } + ], + "name": "setFeeWallet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "setImplementation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address payable", + "name": "destination", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes16", + "name": "uuid", + "type": "bytes16" + }, + { + "indexed": false, + "internalType": "address", + "name": "initiator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "beneficiary", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "srcToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "destToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "srcAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "receivedAmount", + "type": "uint256" + } + ], + "name": "Bought", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "partnerShare", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "paraswapShare", + "type": "uint256" + } + ], + "name": "FeeTaken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes16", + "name": "uuid", + "type": "bytes16" + }, + { + "indexed": false, + "internalType": "address", + "name": "initiator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "beneficiary", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "srcToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "destToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "srcAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "receivedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + } + ], + "name": "Swapped", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountInMax", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + } + ], + "name": "buyOnUniswap", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "factory", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "initCode", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "amountInMax", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + } + ], + "name": "buyOnUniswapFork", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountInMax", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "address", + "name": "weth", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "pools", + "type": "uint256[]" + } + ], + "name": "buyOnUniswapV2Fork", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "fromAmountPercent", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "totalNetworkFee", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address payable", + "name": "adapter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "address", + "name": "targetExchange", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + } + ], + "internalType": "struct Utils.Route[]", + "name": "route", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.Adapter[]", + "name": "adapters", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.Path[]", + "name": "path", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.MegaSwapPath[]", + "name": "path", + "type": "tuple[]" + }, + { + "internalType": "address payable", + "name": "partner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feePercent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes16", + "name": "uuid", + "type": "bytes16" + } + ], + "internalType": "struct Utils.MegaSwapSellData", + "name": "data", + "type": "tuple" + } + ], + "name": "megaSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "totalNetworkFee", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address payable", + "name": "adapter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "address", + "name": "targetExchange", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + } + ], + "internalType": "struct Utils.Route[]", + "name": "route", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.Adapter[]", + "name": "adapters", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.Path[]", + "name": "path", + "type": "tuple[]" + }, + { + "internalType": "address payable", + "name": "partner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feePercent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes16", + "name": "uuid", + "type": "bytes16" + } + ], + "internalType": "struct Utils.SellData", + "name": "data", + "type": "tuple" + } + ], + "name": "multiSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "fromAmountPercent", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "totalNetworkFee", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address payable", + "name": "adapter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "address", + "name": "targetExchange", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + } + ], + "internalType": "struct Utils.Route[]", + "name": "route", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.Adapter[]", + "name": "adapters", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.Path[]", + "name": "path", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.MegaSwapPath[]", + "name": "path", + "type": "tuple[]" + }, + { + "internalType": "address payable", + "name": "partner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feePercent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes16", + "name": "uuid", + "type": "bytes16" + } + ], + "internalType": "struct Utils.MegaSwapSellData", + "name": "data", + "type": "tuple" + } + ], + "name": "protectedMegaSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "totalNetworkFee", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address payable", + "name": "adapter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "address", + "name": "targetExchange", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "networkFee", + "type": "uint256" + } + ], + "internalType": "struct Utils.Route[]", + "name": "route", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.Adapter[]", + "name": "adapters", + "type": "tuple[]" + } + ], + "internalType": "struct Utils.Path[]", + "name": "path", + "type": "tuple[]" + }, + { + "internalType": "address payable", + "name": "partner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feePercent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes16", + "name": "uuid", + "type": "bytes16" + } + ], + "internalType": "struct Utils.SellData", + "name": "data", + "type": "tuple" + } + ], + "name": "protectedMultiSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "callees", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "exchangeData", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "startIndexes", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "address payable", + "name": "partner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feePercent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes16", + "name": "uuid", + "type": "bytes16" + } + ], + "internalType": "struct Utils.SimpleData", + "name": "data", + "type": "tuple" + } + ], + "name": "protectedSimpleBuy", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "callees", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "exchangeData", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "startIndexes", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "address payable", + "name": "partner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feePercent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes16", + "name": "uuid", + "type": "bytes16" + } + ], + "internalType": "struct Utils.SimpleData", + "name": "data", + "type": "tuple" + } + ], + "name": "protectedSimpleSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "receivedAmount", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "callees", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "exchangeData", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "startIndexes", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "address payable", + "name": "partner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feePercent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes16", + "name": "uuid", + "type": "bytes16" + } + ], + "internalType": "struct Utils.SimpleData", + "name": "data", + "type": "tuple" + } + ], + "name": "simpleBuy", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedAmount", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "callees", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "exchangeData", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "startIndexes", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "address payable", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "address payable", + "name": "partner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feePercent", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes16", + "name": "uuid", + "type": "bytes16" + } + ], + "internalType": "struct Utils.SimpleData", + "name": "data", + "type": "tuple" + } + ], + "name": "simpleSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "receivedAmount", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + } + ], + "name": "swapOnUniswap", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "factory", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "initCode", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "path", + "type": "address[]" + } + ], + "name": "swapOnUniswapFork", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "weth", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "pools", + "type": "uint256[]" + } + ], + "name": "swapOnUniswapV2Fork", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "exchange", + "type": "address" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + } + ], + "name": "swapOnZeroXv2", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "exchange", + "type": "address" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + } + ], + "name": "swapOnZeroXv4", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } + ] \ No newline at end of file diff --git a/tests/paraswap/b2c.json b/tests/paraswap/b2c.json new file mode 100644 index 0000000..7a11fc4 --- /dev/null +++ b/tests/paraswap/b2c.json @@ -0,0 +1,102 @@ +{ + "chainId": 1, + "contracts": [ + { + "address": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57", + "contractName": "AugustusSwapper", + "selectors": { + "0x54840d1a": { + "erc20OfInterest": [ + "path.0" + ], + "method": "swapOnUniswap", + "plugin": "Paraswap" + }, + "0xf5661034": { + "erc20OfInterest": [ + "path.0" + ], + "method": "swapOnUniswapFork", + "plugin": "Paraswap" + }, + "0x54e3f31b": { + "erc20OfInterest": [ + "data.fromToken", + "data.toToken" + ], + "method": "SimpleSwap", + "plugin": "Paraswap" + }, + "0x935fb84b": { + "erc20OfInterest": [ + "path.1" + ], + "method": "buyOnUniswap", + "plugin": "Paraswap" + }, + "0xc03786b0": { + "erc20OfInterest": [ + "path.1" + ], + "method": "buyOnUniswapFork", + "plugin": "Paraswap" + }, + "0xa94e78ef": { + "erc20OfInterest": [ + "data.fromToken", + "data.path.1.to" + ], + "method": "multiSwap", + "plugin": "Paraswap" + }, + "0x46c67b6d": { + "erc20OfInterest": [ + "data.fromToken", + "data.path.1.path.1.to" + ], + "method": "megaSwap", + "plugin": "Paraswap" + }, + "0x2298207a": { + "erc20OfInterest": [ + "data.fromToken", + "data.toToken" + ], + "method": "simpleBuy", + "plugin": "Paraswap" + }, + "0x64466805": { + "erc20OfInterest": [ + "fromToken", + "toToken" + ], + "method": "swapOnZeroXv4", + "plugin": "Paraswap" + }, + "0x81033120": { + "erc20OfInterest": [ + "fromToken", + "toToken" + ], + "method": "swapOnZeroXv2", + "plugin": "Paraswap" + } + } + }, + { + "address": "0x1bd435f3c054b6e901b7b108a0ab7617c808677b", + "contractName": "AugustusSwapper", + "selectors": { + "0xcfc0afeb": { + "erc20OfInterest": [ + "fromToken","toToken" + ], + "method": "simpleSwap", + "plugin": "Paraswap" + } + } + } + + ], + "name": "Paraswap" +} \ No newline at end of file diff --git a/tests/snapshots/nanos_buy_on_uniswap/00000.png b/tests/snapshots/nanos_buy_on_uniswap/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap/00000.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap/00001.png b/tests/snapshots/nanos_buy_on_uniswap/00001.png new file mode 100644 index 0000000..42df075 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap/00001.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap/00002.png b/tests/snapshots/nanos_buy_on_uniswap/00002.png new file mode 100644 index 0000000..7486671 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap/00002.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap/00003.png b/tests/snapshots/nanos_buy_on_uniswap/00003.png new file mode 100644 index 0000000..81ad04b Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap/00003.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap/00004.png b/tests/snapshots/nanos_buy_on_uniswap/00004.png new file mode 100644 index 0000000..90a796d Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap/00004.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap/00005.png b/tests/snapshots/nanos_buy_on_uniswap/00005.png new file mode 100644 index 0000000..11c298f Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap/00005.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap/00006.png b/tests/snapshots/nanos_buy_on_uniswap/00006.png new file mode 100644 index 0000000..68299b2 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap/00006.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap/00007.png b/tests/snapshots/nanos_buy_on_uniswap/00007.png new file mode 100644 index 0000000..d343e67 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap/00007.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap/00008.png b/tests/snapshots/nanos_buy_on_uniswap/00008.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap/00008.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap/00009.png b/tests/snapshots/nanos_buy_on_uniswap/00009.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap/00009.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork/00000.png b/tests/snapshots/nanos_buy_on_uniswap_fork/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork/00000.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork/00001.png b/tests/snapshots/nanos_buy_on_uniswap_fork/00001.png new file mode 100644 index 0000000..42df075 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork/00001.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork/00002.png b/tests/snapshots/nanos_buy_on_uniswap_fork/00002.png new file mode 100644 index 0000000..137b732 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork/00002.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork/00003.png b/tests/snapshots/nanos_buy_on_uniswap_fork/00003.png new file mode 100644 index 0000000..c63fcc2 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork/00003.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork/00004.png b/tests/snapshots/nanos_buy_on_uniswap_fork/00004.png new file mode 100644 index 0000000..6272877 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork/00004.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork/00005.png b/tests/snapshots/nanos_buy_on_uniswap_fork/00005.png new file mode 100644 index 0000000..11c298f Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork/00005.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork/00006.png b/tests/snapshots/nanos_buy_on_uniswap_fork/00006.png new file mode 100644 index 0000000..91ca276 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork/00006.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork/00007.png b/tests/snapshots/nanos_buy_on_uniswap_fork/00007.png new file mode 100644 index 0000000..7d6bf22 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork/00007.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork/00008.png b/tests/snapshots/nanos_buy_on_uniswap_fork/00008.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork/00008.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork/00009.png b/tests/snapshots/nanos_buy_on_uniswap_fork/00009.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork/00009.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00000.png b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00000.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00001.png b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00001.png new file mode 100644 index 0000000..42df075 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00001.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00002.png b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00002.png new file mode 100644 index 0000000..2d3d40a Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00002.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00003.png b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00003.png new file mode 100644 index 0000000..e9b9848 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00003.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00004.png b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00004.png new file mode 100644 index 0000000..988baff Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00004.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00005.png b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00005.png new file mode 100644 index 0000000..1ca532a Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00005.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00006.png b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00006.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00006.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00007.png b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00007.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_fork_v4/00007.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_v4/00000.png b/tests/snapshots/nanos_buy_on_uniswap_v4/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_v4/00000.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_v4/00001.png b/tests/snapshots/nanos_buy_on_uniswap_v4/00001.png new file mode 100644 index 0000000..42df075 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_v4/00001.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_v4/00002.png b/tests/snapshots/nanos_buy_on_uniswap_v4/00002.png new file mode 100644 index 0000000..abec1db Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_v4/00002.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_v4/00003.png b/tests/snapshots/nanos_buy_on_uniswap_v4/00003.png new file mode 100644 index 0000000..33d60c4 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_v4/00003.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_v4/00004.png b/tests/snapshots/nanos_buy_on_uniswap_v4/00004.png new file mode 100644 index 0000000..5af44c8 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_v4/00004.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_v4/00005.png b/tests/snapshots/nanos_buy_on_uniswap_v4/00005.png new file mode 100644 index 0000000..bdd620c Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_v4/00005.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_v4/00006.png b/tests/snapshots/nanos_buy_on_uniswap_v4/00006.png new file mode 100644 index 0000000..10cc632 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_v4/00006.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_v4/00007.png b/tests/snapshots/nanos_buy_on_uniswap_v4/00007.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_v4/00007.png differ diff --git a/tests/snapshots/nanos_buy_on_uniswap_v4/00008.png b/tests/snapshots/nanos_buy_on_uniswap_v4/00008.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_buy_on_uniswap_v4/00008.png differ diff --git a/tests/snapshots/nanos_buy_v4/00000.png b/tests/snapshots/nanos_buy_v4/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_buy_v4/00000.png differ diff --git a/tests/snapshots/nanos_buy_v4/00001.png b/tests/snapshots/nanos_buy_v4/00001.png new file mode 100644 index 0000000..42df075 Binary files /dev/null and b/tests/snapshots/nanos_buy_v4/00001.png differ diff --git a/tests/snapshots/nanos_buy_v4/00002.png b/tests/snapshots/nanos_buy_v4/00002.png new file mode 100644 index 0000000..21c7d9a Binary files /dev/null and b/tests/snapshots/nanos_buy_v4/00002.png differ diff --git a/tests/snapshots/nanos_buy_v4/00003.png b/tests/snapshots/nanos_buy_v4/00003.png new file mode 100644 index 0000000..4846402 Binary files /dev/null and b/tests/snapshots/nanos_buy_v4/00003.png differ diff --git a/tests/snapshots/nanos_buy_v4/00004.png b/tests/snapshots/nanos_buy_v4/00004.png new file mode 100644 index 0000000..f5e292d Binary files /dev/null and b/tests/snapshots/nanos_buy_v4/00004.png differ diff --git a/tests/snapshots/nanos_buy_v4/00005.png b/tests/snapshots/nanos_buy_v4/00005.png new file mode 100644 index 0000000..ea56ae8 Binary files /dev/null and b/tests/snapshots/nanos_buy_v4/00005.png differ diff --git a/tests/snapshots/nanos_buy_v4/00006.png b/tests/snapshots/nanos_buy_v4/00006.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_buy_v4/00006.png differ diff --git a/tests/snapshots/nanos_buy_v4/00007.png b/tests/snapshots/nanos_buy_v4/00007.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_buy_v4/00007.png differ diff --git a/tests/snapshots/nanos_mega_swap/00000.png b/tests/snapshots/nanos_mega_swap/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap/00000.png differ diff --git a/tests/snapshots/nanos_mega_swap/00001.png b/tests/snapshots/nanos_mega_swap/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_mega_swap/00001.png differ diff --git a/tests/snapshots/nanos_mega_swap/00002.png b/tests/snapshots/nanos_mega_swap/00002.png new file mode 100644 index 0000000..0a21887 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap/00002.png differ diff --git a/tests/snapshots/nanos_mega_swap/00003.png b/tests/snapshots/nanos_mega_swap/00003.png new file mode 100644 index 0000000..663f336 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap/00003.png differ diff --git a/tests/snapshots/nanos_mega_swap/00004.png b/tests/snapshots/nanos_mega_swap/00004.png new file mode 100644 index 0000000..f22a9f2 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap/00004.png differ diff --git a/tests/snapshots/nanos_mega_swap/00005.png b/tests/snapshots/nanos_mega_swap/00005.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap/00005.png differ diff --git a/tests/snapshots/nanos_mega_swap/00006.png b/tests/snapshots/nanos_mega_swap/00006.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap/00006.png differ diff --git a/tests/snapshots/nanos_mega_swap_v4/00000.png b/tests/snapshots/nanos_mega_swap_v4/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap_v4/00000.png differ diff --git a/tests/snapshots/nanos_mega_swap_v4/00001.png b/tests/snapshots/nanos_mega_swap_v4/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_mega_swap_v4/00001.png differ diff --git a/tests/snapshots/nanos_mega_swap_v4/00002.png b/tests/snapshots/nanos_mega_swap_v4/00002.png new file mode 100644 index 0000000..4a73f27 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap_v4/00002.png differ diff --git a/tests/snapshots/nanos_mega_swap_v4/00003.png b/tests/snapshots/nanos_mega_swap_v4/00003.png new file mode 100644 index 0000000..72e1031 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap_v4/00003.png differ diff --git a/tests/snapshots/nanos_mega_swap_v4/00004.png b/tests/snapshots/nanos_mega_swap_v4/00004.png new file mode 100644 index 0000000..6ad25d8 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap_v4/00004.png differ diff --git a/tests/snapshots/nanos_mega_swap_v4/00005.png b/tests/snapshots/nanos_mega_swap_v4/00005.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap_v4/00005.png differ diff --git a/tests/snapshots/nanos_mega_swap_v4/00006.png b/tests/snapshots/nanos_mega_swap_v4/00006.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_mega_swap_v4/00006.png differ diff --git a/tests/snapshots/nanos_multi_swap/00000.png b/tests/snapshots/nanos_multi_swap/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_multi_swap/00000.png differ diff --git a/tests/snapshots/nanos_multi_swap/00001.png b/tests/snapshots/nanos_multi_swap/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_multi_swap/00001.png differ diff --git a/tests/snapshots/nanos_multi_swap/00002.png b/tests/snapshots/nanos_multi_swap/00002.png new file mode 100644 index 0000000..226e4aa Binary files /dev/null and b/tests/snapshots/nanos_multi_swap/00002.png differ diff --git a/tests/snapshots/nanos_multi_swap/00003.png b/tests/snapshots/nanos_multi_swap/00003.png new file mode 100644 index 0000000..2c324df Binary files /dev/null and b/tests/snapshots/nanos_multi_swap/00003.png differ diff --git a/tests/snapshots/nanos_multi_swap/00004.png b/tests/snapshots/nanos_multi_swap/00004.png new file mode 100644 index 0000000..11c298f Binary files /dev/null and b/tests/snapshots/nanos_multi_swap/00004.png differ diff --git a/tests/snapshots/nanos_multi_swap/00005.png b/tests/snapshots/nanos_multi_swap/00005.png new file mode 100644 index 0000000..b7fc3f0 Binary files /dev/null and b/tests/snapshots/nanos_multi_swap/00005.png differ diff --git a/tests/snapshots/nanos_multi_swap/00006.png b/tests/snapshots/nanos_multi_swap/00006.png new file mode 100644 index 0000000..4370c30 Binary files /dev/null and b/tests/snapshots/nanos_multi_swap/00006.png differ diff --git a/tests/snapshots/nanos_multi_swap/00007.png b/tests/snapshots/nanos_multi_swap/00007.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_multi_swap/00007.png differ diff --git a/tests/snapshots/nanos_multi_swap/00008.png b/tests/snapshots/nanos_multi_swap/00008.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_multi_swap/00008.png differ diff --git a/tests/snapshots/nanos_multi_swap_v4/00000.png b/tests/snapshots/nanos_multi_swap_v4/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_multi_swap_v4/00000.png differ diff --git a/tests/snapshots/nanos_multi_swap_v4/00001.png b/tests/snapshots/nanos_multi_swap_v4/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_multi_swap_v4/00001.png differ diff --git a/tests/snapshots/nanos_multi_swap_v4/00002.png b/tests/snapshots/nanos_multi_swap_v4/00002.png new file mode 100644 index 0000000..8d4996c Binary files /dev/null and b/tests/snapshots/nanos_multi_swap_v4/00002.png differ diff --git a/tests/snapshots/nanos_multi_swap_v4/00003.png b/tests/snapshots/nanos_multi_swap_v4/00003.png new file mode 100644 index 0000000..b857c47 Binary files /dev/null and b/tests/snapshots/nanos_multi_swap_v4/00003.png differ diff --git a/tests/snapshots/nanos_multi_swap_v4/00004.png b/tests/snapshots/nanos_multi_swap_v4/00004.png new file mode 100644 index 0000000..4561c33 Binary files /dev/null and b/tests/snapshots/nanos_multi_swap_v4/00004.png differ diff --git a/tests/snapshots/nanos_multi_swap_v4/00005.png b/tests/snapshots/nanos_multi_swap_v4/00005.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_multi_swap_v4/00005.png differ diff --git a/tests/snapshots/nanos_multi_swap_v4/00006.png b/tests/snapshots/nanos_multi_swap_v4/00006.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_multi_swap_v4/00006.png differ diff --git a/tests/snapshots/nanos_simple_buy/00000.png b/tests/snapshots/nanos_simple_buy/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_simple_buy/00000.png differ diff --git a/tests/snapshots/nanos_simple_buy/00001.png b/tests/snapshots/nanos_simple_buy/00001.png new file mode 100644 index 0000000..42df075 Binary files /dev/null and b/tests/snapshots/nanos_simple_buy/00001.png differ diff --git a/tests/snapshots/nanos_simple_buy/00002.png b/tests/snapshots/nanos_simple_buy/00002.png new file mode 100644 index 0000000..0f19e16 Binary files /dev/null and b/tests/snapshots/nanos_simple_buy/00002.png differ diff --git a/tests/snapshots/nanos_simple_buy/00003.png b/tests/snapshots/nanos_simple_buy/00003.png new file mode 100644 index 0000000..2ed08e5 Binary files /dev/null and b/tests/snapshots/nanos_simple_buy/00003.png differ diff --git a/tests/snapshots/nanos_simple_buy/00004.png b/tests/snapshots/nanos_simple_buy/00004.png new file mode 100644 index 0000000..235d7bc Binary files /dev/null and b/tests/snapshots/nanos_simple_buy/00004.png differ diff --git a/tests/snapshots/nanos_simple_buy/00005.png b/tests/snapshots/nanos_simple_buy/00005.png new file mode 100644 index 0000000..1e67a3c Binary files /dev/null and b/tests/snapshots/nanos_simple_buy/00005.png differ diff --git a/tests/snapshots/nanos_simple_buy/00006.png b/tests/snapshots/nanos_simple_buy/00006.png new file mode 100644 index 0000000..3601ed0 Binary files /dev/null and b/tests/snapshots/nanos_simple_buy/00006.png differ diff --git a/tests/snapshots/nanos_simple_buy/00007.png b/tests/snapshots/nanos_simple_buy/00007.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_simple_buy/00007.png differ diff --git a/tests/snapshots/nanos_simple_buy/00008.png b/tests/snapshots/nanos_simple_buy/00008.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_simple_buy/00008.png differ diff --git a/tests/snapshots/nanos_simple_swap/00000.png b/tests/snapshots/nanos_simple_swap/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap/00000.png differ diff --git a/tests/snapshots/nanos_simple_swap/00001.png b/tests/snapshots/nanos_simple_swap/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_simple_swap/00001.png differ diff --git a/tests/snapshots/nanos_simple_swap/00002.png b/tests/snapshots/nanos_simple_swap/00002.png new file mode 100644 index 0000000..ff4e292 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap/00002.png differ diff --git a/tests/snapshots/nanos_simple_swap/00003.png b/tests/snapshots/nanos_simple_swap/00003.png new file mode 100644 index 0000000..1db58ac Binary files /dev/null and b/tests/snapshots/nanos_simple_swap/00003.png differ diff --git a/tests/snapshots/nanos_simple_swap/00004.png b/tests/snapshots/nanos_simple_swap/00004.png new file mode 100644 index 0000000..3c73138 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap/00004.png differ diff --git a/tests/snapshots/nanos_simple_swap/00005.png b/tests/snapshots/nanos_simple_swap/00005.png new file mode 100644 index 0000000..f71b768 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap/00005.png differ diff --git a/tests/snapshots/nanos_simple_swap/00006.png b/tests/snapshots/nanos_simple_swap/00006.png new file mode 100644 index 0000000..765731b Binary files /dev/null and b/tests/snapshots/nanos_simple_swap/00006.png differ diff --git a/tests/snapshots/nanos_simple_swap/00007.png b/tests/snapshots/nanos_simple_swap/00007.png new file mode 100644 index 0000000..f1a7a38 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap/00007.png differ diff --git a/tests/snapshots/nanos_simple_swap/00008.png b/tests/snapshots/nanos_simple_swap/00008.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap/00008.png differ diff --git a/tests/snapshots/nanos_simple_swap/00009.png b/tests/snapshots/nanos_simple_swap/00009.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap/00009.png differ diff --git a/tests/snapshots/nanos_simple_swap_v4/00000.png b/tests/snapshots/nanos_simple_swap_v4/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap_v4/00000.png differ diff --git a/tests/snapshots/nanos_simple_swap_v4/00001.png b/tests/snapshots/nanos_simple_swap_v4/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_simple_swap_v4/00001.png differ diff --git a/tests/snapshots/nanos_simple_swap_v4/00002.png b/tests/snapshots/nanos_simple_swap_v4/00002.png new file mode 100644 index 0000000..ec93430 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap_v4/00002.png differ diff --git a/tests/snapshots/nanos_simple_swap_v4/00003.png b/tests/snapshots/nanos_simple_swap_v4/00003.png new file mode 100644 index 0000000..b207c25 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap_v4/00003.png differ diff --git a/tests/snapshots/nanos_simple_swap_v4/00004.png b/tests/snapshots/nanos_simple_swap_v4/00004.png new file mode 100644 index 0000000..343e5ff Binary files /dev/null and b/tests/snapshots/nanos_simple_swap_v4/00004.png differ diff --git a/tests/snapshots/nanos_simple_swap_v4/00005.png b/tests/snapshots/nanos_simple_swap_v4/00005.png new file mode 100644 index 0000000..c46afa5 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap_v4/00005.png differ diff --git a/tests/snapshots/nanos_simple_swap_v4/00006.png b/tests/snapshots/nanos_simple_swap_v4/00006.png new file mode 100644 index 0000000..6d77794 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap_v4/00006.png differ diff --git a/tests/snapshots/nanos_simple_swap_v4/00007.png b/tests/snapshots/nanos_simple_swap_v4/00007.png new file mode 100644 index 0000000..7ff97b8 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap_v4/00007.png differ diff --git a/tests/snapshots/nanos_simple_swap_v4/00008.png b/tests/snapshots/nanos_simple_swap_v4/00008.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap_v4/00008.png differ diff --git a/tests/snapshots/nanos_simple_swap_v4/00009.png b/tests/snapshots/nanos_simple_swap_v4/00009.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_simple_swap_v4/00009.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap/00000.png b/tests/snapshots/nanos_swap_on_uniswap/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap/00000.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap/00001.png b/tests/snapshots/nanos_swap_on_uniswap/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap/00001.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap/00002.png b/tests/snapshots/nanos_swap_on_uniswap/00002.png new file mode 100644 index 0000000..6e9e71d Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap/00002.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap/00003.png b/tests/snapshots/nanos_swap_on_uniswap/00003.png new file mode 100644 index 0000000..7c8d52a Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap/00003.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap/00004.png b/tests/snapshots/nanos_swap_on_uniswap/00004.png new file mode 100644 index 0000000..8983f0a Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap/00004.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap/00005.png b/tests/snapshots/nanos_swap_on_uniswap/00005.png new file mode 100644 index 0000000..2f0cdf6 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap/00005.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap/00006.png b/tests/snapshots/nanos_swap_on_uniswap/00006.png new file mode 100644 index 0000000..1a19a10 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap/00006.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap/00007.png b/tests/snapshots/nanos_swap_on_uniswap/00007.png new file mode 100644 index 0000000..c35db03 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap/00007.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap/00008.png b/tests/snapshots/nanos_swap_on_uniswap/00008.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap/00008.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap/00009.png b/tests/snapshots/nanos_swap_on_uniswap/00009.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap/00009.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork/00000.png b/tests/snapshots/nanos_swap_on_uniswap_fork/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork/00000.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork/00001.png b/tests/snapshots/nanos_swap_on_uniswap_fork/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork/00001.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork/00002.png b/tests/snapshots/nanos_swap_on_uniswap_fork/00002.png new file mode 100644 index 0000000..1155457 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork/00002.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork/00003.png b/tests/snapshots/nanos_swap_on_uniswap_fork/00003.png new file mode 100644 index 0000000..677e469 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork/00003.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork/00004.png b/tests/snapshots/nanos_swap_on_uniswap_fork/00004.png new file mode 100644 index 0000000..1f2fffa Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork/00004.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork/00005.png b/tests/snapshots/nanos_swap_on_uniswap_fork/00005.png new file mode 100644 index 0000000..0b3b9b9 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork/00005.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork/00006.png b/tests/snapshots/nanos_swap_on_uniswap_fork/00006.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork/00006.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork/00007.png b/tests/snapshots/nanos_swap_on_uniswap_fork/00007.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork/00007.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork/00008.png b/tests/snapshots/nanos_swap_on_uniswap_fork/00008.png new file mode 100644 index 0000000..699254d Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork/00008.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00000.png b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00000.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00001.png b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00001.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00002.png b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00002.png new file mode 100644 index 0000000..a9fe9f6 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00002.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00003.png b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00003.png new file mode 100644 index 0000000..a166cb5 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00003.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00004.png b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00004.png new file mode 100644 index 0000000..853495d Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00004.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00005.png b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00005.png new file mode 100644 index 0000000..316d2e0 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00005.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00006.png b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00006.png new file mode 100644 index 0000000..6ffa3b5 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00006.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00007.png b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00007.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00007.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00008.png b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00008.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_fork_v4/00008.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_v4/00000.png b/tests/snapshots/nanos_swap_on_uniswap_v4/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_v4/00000.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_v4/00001.png b/tests/snapshots/nanos_swap_on_uniswap_v4/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_v4/00001.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_v4/00002.png b/tests/snapshots/nanos_swap_on_uniswap_v4/00002.png new file mode 100644 index 0000000..4b87921 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_v4/00002.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_v4/00003.png b/tests/snapshots/nanos_swap_on_uniswap_v4/00003.png new file mode 100644 index 0000000..519d978 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_v4/00003.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_v4/00004.png b/tests/snapshots/nanos_swap_on_uniswap_v4/00004.png new file mode 100644 index 0000000..3cd6760 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_v4/00004.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_v4/00005.png b/tests/snapshots/nanos_swap_on_uniswap_v4/00005.png new file mode 100644 index 0000000..77295b2 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_v4/00005.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_v4/00006.png b/tests/snapshots/nanos_swap_on_uniswap_v4/00006.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_v4/00006.png differ diff --git a/tests/snapshots/nanos_swap_on_uniswap_v4/00007.png b/tests/snapshots/nanos_swap_on_uniswap_v4/00007.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_uniswap_v4/00007.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v2/00000.png b/tests/snapshots/nanos_swap_on_zero_v2/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v2/00000.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v2/00001.png b/tests/snapshots/nanos_swap_on_zero_v2/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v2/00001.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v2/00002.png b/tests/snapshots/nanos_swap_on_zero_v2/00002.png new file mode 100644 index 0000000..8021560 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v2/00002.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v2/00003.png b/tests/snapshots/nanos_swap_on_zero_v2/00003.png new file mode 100644 index 0000000..075b54d Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v2/00003.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v2/00004.png b/tests/snapshots/nanos_swap_on_zero_v2/00004.png new file mode 100644 index 0000000..91edc28 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v2/00004.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v2/00005.png b/tests/snapshots/nanos_swap_on_zero_v2/00005.png new file mode 100644 index 0000000..6842252 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v2/00005.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v2/00006.png b/tests/snapshots/nanos_swap_on_zero_v2/00006.png new file mode 100644 index 0000000..aa1f5ad Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v2/00006.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v2/00007.png b/tests/snapshots/nanos_swap_on_zero_v2/00007.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v2/00007.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v2/00008.png b/tests/snapshots/nanos_swap_on_zero_v2/00008.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v2/00008.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v4/00000.png b/tests/snapshots/nanos_swap_on_zero_v4/00000.png new file mode 100644 index 0000000..2994983 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v4/00000.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v4/00001.png b/tests/snapshots/nanos_swap_on_zero_v4/00001.png new file mode 100644 index 0000000..bfa8c5a Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v4/00001.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v4/00002.png b/tests/snapshots/nanos_swap_on_zero_v4/00002.png new file mode 100644 index 0000000..1a391b8 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v4/00002.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v4/00003.png b/tests/snapshots/nanos_swap_on_zero_v4/00003.png new file mode 100644 index 0000000..cc36a54 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v4/00003.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v4/00004.png b/tests/snapshots/nanos_swap_on_zero_v4/00004.png new file mode 100644 index 0000000..2e1289d Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v4/00004.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v4/00005.png b/tests/snapshots/nanos_swap_on_zero_v4/00005.png new file mode 100644 index 0000000..3158ea6 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v4/00005.png differ diff --git a/tests/snapshots/nanos_swap_on_zero_v4/00006.png b/tests/snapshots/nanos_swap_on_zero_v4/00006.png new file mode 100644 index 0000000..0bef4f3 Binary files /dev/null and b/tests/snapshots/nanos_swap_on_zero_v4/00006.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap/00000.png b/tests/snapshots/nanox_buy_on_uniswap/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap/00000.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap/00001.png b/tests/snapshots/nanox_buy_on_uniswap/00001.png new file mode 100644 index 0000000..697b756 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap/00001.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap/00002.png b/tests/snapshots/nanox_buy_on_uniswap/00002.png new file mode 100644 index 0000000..5f12a7c Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap/00002.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap/00003.png b/tests/snapshots/nanox_buy_on_uniswap/00003.png new file mode 100644 index 0000000..970a261 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap/00003.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap/00004.png b/tests/snapshots/nanox_buy_on_uniswap/00004.png new file mode 100644 index 0000000..2c64d96 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap/00004.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap/00005.png b/tests/snapshots/nanox_buy_on_uniswap/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap/00005.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap/00006.png b/tests/snapshots/nanox_buy_on_uniswap/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap/00006.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork/00000.png b/tests/snapshots/nanox_buy_on_uniswap_fork/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork/00000.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork/00001.png b/tests/snapshots/nanox_buy_on_uniswap_fork/00001.png new file mode 100644 index 0000000..697b756 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork/00001.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork/00002.png b/tests/snapshots/nanox_buy_on_uniswap_fork/00002.png new file mode 100644 index 0000000..dc9fd1d Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork/00002.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork/00003.png b/tests/snapshots/nanox_buy_on_uniswap_fork/00003.png new file mode 100644 index 0000000..d32450a Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork/00003.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork/00004.png b/tests/snapshots/nanox_buy_on_uniswap_fork/00004.png new file mode 100644 index 0000000..2d7cfd5 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork/00004.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork/00005.png b/tests/snapshots/nanox_buy_on_uniswap_fork/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork/00005.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork/00006.png b/tests/snapshots/nanox_buy_on_uniswap_fork/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork/00006.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00000.png b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00000.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00001.png b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00001.png new file mode 100644 index 0000000..697b756 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00001.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00002.png b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00002.png new file mode 100644 index 0000000..432c06e Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00002.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00003.png b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00003.png new file mode 100644 index 0000000..96d08db Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00003.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00004.png b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00004.png new file mode 100644 index 0000000..414113f Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00004.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00005.png b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00005.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00006.png b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_fork_v4/00006.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_v4/00000.png b/tests/snapshots/nanox_buy_on_uniswap_v4/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_v4/00000.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_v4/00001.png b/tests/snapshots/nanox_buy_on_uniswap_v4/00001.png new file mode 100644 index 0000000..697b756 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_v4/00001.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_v4/00002.png b/tests/snapshots/nanox_buy_on_uniswap_v4/00002.png new file mode 100644 index 0000000..8cd14de Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_v4/00002.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_v4/00003.png b/tests/snapshots/nanox_buy_on_uniswap_v4/00003.png new file mode 100644 index 0000000..932081a Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_v4/00003.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_v4/00004.png b/tests/snapshots/nanox_buy_on_uniswap_v4/00004.png new file mode 100644 index 0000000..12af5b0 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_v4/00004.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_v4/00005.png b/tests/snapshots/nanox_buy_on_uniswap_v4/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_v4/00005.png differ diff --git a/tests/snapshots/nanox_buy_on_uniswap_v4/00006.png b/tests/snapshots/nanox_buy_on_uniswap_v4/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_buy_on_uniswap_v4/00006.png differ diff --git a/tests/snapshots/nanox_buy_v4/00000.png b/tests/snapshots/nanox_buy_v4/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_buy_v4/00000.png differ diff --git a/tests/snapshots/nanox_buy_v4/00001.png b/tests/snapshots/nanox_buy_v4/00001.png new file mode 100644 index 0000000..697b756 Binary files /dev/null and b/tests/snapshots/nanox_buy_v4/00001.png differ diff --git a/tests/snapshots/nanox_buy_v4/00002.png b/tests/snapshots/nanox_buy_v4/00002.png new file mode 100644 index 0000000..02d5b3b Binary files /dev/null and b/tests/snapshots/nanox_buy_v4/00002.png differ diff --git a/tests/snapshots/nanox_buy_v4/00003.png b/tests/snapshots/nanox_buy_v4/00003.png new file mode 100644 index 0000000..90280d5 Binary files /dev/null and b/tests/snapshots/nanox_buy_v4/00003.png differ diff --git a/tests/snapshots/nanox_buy_v4/00004.png b/tests/snapshots/nanox_buy_v4/00004.png new file mode 100644 index 0000000..8629f0d Binary files /dev/null and b/tests/snapshots/nanox_buy_v4/00004.png differ diff --git a/tests/snapshots/nanox_buy_v4/00005.png b/tests/snapshots/nanox_buy_v4/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_buy_v4/00005.png differ diff --git a/tests/snapshots/nanox_buy_v4/00006.png b/tests/snapshots/nanox_buy_v4/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_buy_v4/00006.png differ diff --git a/tests/snapshots/nanox_mega_swap/00000.png b/tests/snapshots/nanox_mega_swap/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap/00000.png differ diff --git a/tests/snapshots/nanox_mega_swap/00001.png b/tests/snapshots/nanox_mega_swap/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap/00001.png differ diff --git a/tests/snapshots/nanox_mega_swap/00002.png b/tests/snapshots/nanox_mega_swap/00002.png new file mode 100644 index 0000000..e5537bc Binary files /dev/null and b/tests/snapshots/nanox_mega_swap/00002.png differ diff --git a/tests/snapshots/nanox_mega_swap/00003.png b/tests/snapshots/nanox_mega_swap/00003.png new file mode 100644 index 0000000..7b1a812 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap/00003.png differ diff --git a/tests/snapshots/nanox_mega_swap/00004.png b/tests/snapshots/nanox_mega_swap/00004.png new file mode 100644 index 0000000..f9122de Binary files /dev/null and b/tests/snapshots/nanox_mega_swap/00004.png differ diff --git a/tests/snapshots/nanox_mega_swap/00005.png b/tests/snapshots/nanox_mega_swap/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap/00005.png differ diff --git a/tests/snapshots/nanox_mega_swap/00006.png b/tests/snapshots/nanox_mega_swap/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap/00006.png differ diff --git a/tests/snapshots/nanox_mega_swap_v4/00000.png b/tests/snapshots/nanox_mega_swap_v4/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap_v4/00000.png differ diff --git a/tests/snapshots/nanox_mega_swap_v4/00001.png b/tests/snapshots/nanox_mega_swap_v4/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap_v4/00001.png differ diff --git a/tests/snapshots/nanox_mega_swap_v4/00002.png b/tests/snapshots/nanox_mega_swap_v4/00002.png new file mode 100644 index 0000000..03f4469 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap_v4/00002.png differ diff --git a/tests/snapshots/nanox_mega_swap_v4/00003.png b/tests/snapshots/nanox_mega_swap_v4/00003.png new file mode 100644 index 0000000..929cd87 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap_v4/00003.png differ diff --git a/tests/snapshots/nanox_mega_swap_v4/00004.png b/tests/snapshots/nanox_mega_swap_v4/00004.png new file mode 100644 index 0000000..2ac44ab Binary files /dev/null and b/tests/snapshots/nanox_mega_swap_v4/00004.png differ diff --git a/tests/snapshots/nanox_mega_swap_v4/00005.png b/tests/snapshots/nanox_mega_swap_v4/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap_v4/00005.png differ diff --git a/tests/snapshots/nanox_mega_swap_v4/00006.png b/tests/snapshots/nanox_mega_swap_v4/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_mega_swap_v4/00006.png differ diff --git a/tests/snapshots/nanox_multi_swap/00000.png b/tests/snapshots/nanox_multi_swap/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap/00000.png differ diff --git a/tests/snapshots/nanox_multi_swap/00001.png b/tests/snapshots/nanox_multi_swap/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap/00001.png differ diff --git a/tests/snapshots/nanox_multi_swap/00002.png b/tests/snapshots/nanox_multi_swap/00002.png new file mode 100644 index 0000000..bb5efe2 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap/00002.png differ diff --git a/tests/snapshots/nanox_multi_swap/00003.png b/tests/snapshots/nanox_multi_swap/00003.png new file mode 100644 index 0000000..3bdf364 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap/00003.png differ diff --git a/tests/snapshots/nanox_multi_swap/00004.png b/tests/snapshots/nanox_multi_swap/00004.png new file mode 100644 index 0000000..afa8606 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap/00004.png differ diff --git a/tests/snapshots/nanox_multi_swap/00005.png b/tests/snapshots/nanox_multi_swap/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap/00005.png differ diff --git a/tests/snapshots/nanox_multi_swap/00006.png b/tests/snapshots/nanox_multi_swap/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap/00006.png differ diff --git a/tests/snapshots/nanox_multi_swap_v4/00000.png b/tests/snapshots/nanox_multi_swap_v4/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap_v4/00000.png differ diff --git a/tests/snapshots/nanox_multi_swap_v4/00001.png b/tests/snapshots/nanox_multi_swap_v4/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap_v4/00001.png differ diff --git a/tests/snapshots/nanox_multi_swap_v4/00002.png b/tests/snapshots/nanox_multi_swap_v4/00002.png new file mode 100644 index 0000000..c25dc42 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap_v4/00002.png differ diff --git a/tests/snapshots/nanox_multi_swap_v4/00003.png b/tests/snapshots/nanox_multi_swap_v4/00003.png new file mode 100644 index 0000000..62a3ffd Binary files /dev/null and b/tests/snapshots/nanox_multi_swap_v4/00003.png differ diff --git a/tests/snapshots/nanox_multi_swap_v4/00004.png b/tests/snapshots/nanox_multi_swap_v4/00004.png new file mode 100644 index 0000000..3ddf5e5 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap_v4/00004.png differ diff --git a/tests/snapshots/nanox_multi_swap_v4/00005.png b/tests/snapshots/nanox_multi_swap_v4/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap_v4/00005.png differ diff --git a/tests/snapshots/nanox_multi_swap_v4/00006.png b/tests/snapshots/nanox_multi_swap_v4/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_multi_swap_v4/00006.png differ diff --git a/tests/snapshots/nanox_simple_buy/00000.png b/tests/snapshots/nanox_simple_buy/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_simple_buy/00000.png differ diff --git a/tests/snapshots/nanox_simple_buy/00001.png b/tests/snapshots/nanox_simple_buy/00001.png new file mode 100644 index 0000000..697b756 Binary files /dev/null and b/tests/snapshots/nanox_simple_buy/00001.png differ diff --git a/tests/snapshots/nanox_simple_buy/00002.png b/tests/snapshots/nanox_simple_buy/00002.png new file mode 100644 index 0000000..c1d6992 Binary files /dev/null and b/tests/snapshots/nanox_simple_buy/00002.png differ diff --git a/tests/snapshots/nanox_simple_buy/00003.png b/tests/snapshots/nanox_simple_buy/00003.png new file mode 100644 index 0000000..c4d8695 Binary files /dev/null and b/tests/snapshots/nanox_simple_buy/00003.png differ diff --git a/tests/snapshots/nanox_simple_buy/00004.png b/tests/snapshots/nanox_simple_buy/00004.png new file mode 100644 index 0000000..2752cc2 Binary files /dev/null and b/tests/snapshots/nanox_simple_buy/00004.png differ diff --git a/tests/snapshots/nanox_simple_buy/00005.png b/tests/snapshots/nanox_simple_buy/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_simple_buy/00005.png differ diff --git a/tests/snapshots/nanox_simple_buy/00006.png b/tests/snapshots/nanox_simple_buy/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_simple_buy/00006.png differ diff --git a/tests/snapshots/nanox_simple_swap/00000.png b/tests/snapshots/nanox_simple_swap/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap/00000.png differ diff --git a/tests/snapshots/nanox_simple_swap/00001.png b/tests/snapshots/nanox_simple_swap/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap/00001.png differ diff --git a/tests/snapshots/nanox_simple_swap/00002.png b/tests/snapshots/nanox_simple_swap/00002.png new file mode 100644 index 0000000..33fba73 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap/00002.png differ diff --git a/tests/snapshots/nanox_simple_swap/00003.png b/tests/snapshots/nanox_simple_swap/00003.png new file mode 100644 index 0000000..48c28eb Binary files /dev/null and b/tests/snapshots/nanox_simple_swap/00003.png differ diff --git a/tests/snapshots/nanox_simple_swap/00004.png b/tests/snapshots/nanox_simple_swap/00004.png new file mode 100644 index 0000000..5e8d260 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap/00004.png differ diff --git a/tests/snapshots/nanox_simple_swap/00005.png b/tests/snapshots/nanox_simple_swap/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap/00005.png differ diff --git a/tests/snapshots/nanox_simple_swap/00006.png b/tests/snapshots/nanox_simple_swap/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap/00006.png differ diff --git a/tests/snapshots/nanox_simple_swap_v4/00000.png b/tests/snapshots/nanox_simple_swap_v4/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap_v4/00000.png differ diff --git a/tests/snapshots/nanox_simple_swap_v4/00001.png b/tests/snapshots/nanox_simple_swap_v4/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap_v4/00001.png differ diff --git a/tests/snapshots/nanox_simple_swap_v4/00002.png b/tests/snapshots/nanox_simple_swap_v4/00002.png new file mode 100644 index 0000000..d803ff6 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap_v4/00002.png differ diff --git a/tests/snapshots/nanox_simple_swap_v4/00003.png b/tests/snapshots/nanox_simple_swap_v4/00003.png new file mode 100644 index 0000000..ffb1bd1 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap_v4/00003.png differ diff --git a/tests/snapshots/nanox_simple_swap_v4/00004.png b/tests/snapshots/nanox_simple_swap_v4/00004.png new file mode 100644 index 0000000..52f7458 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap_v4/00004.png differ diff --git a/tests/snapshots/nanox_simple_swap_v4/00005.png b/tests/snapshots/nanox_simple_swap_v4/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap_v4/00005.png differ diff --git a/tests/snapshots/nanox_simple_swap_v4/00006.png b/tests/snapshots/nanox_simple_swap_v4/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_simple_swap_v4/00006.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap/00000.png b/tests/snapshots/nanox_swap_on_uniswap/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap/00000.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap/00001.png b/tests/snapshots/nanox_swap_on_uniswap/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap/00001.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap/00002.png b/tests/snapshots/nanox_swap_on_uniswap/00002.png new file mode 100644 index 0000000..be9b1f4 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap/00002.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap/00003.png b/tests/snapshots/nanox_swap_on_uniswap/00003.png new file mode 100644 index 0000000..09143d1 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap/00003.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap/00004.png b/tests/snapshots/nanox_swap_on_uniswap/00004.png new file mode 100644 index 0000000..351e360 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap/00004.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap/00005.png b/tests/snapshots/nanox_swap_on_uniswap/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap/00005.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap/00006.png b/tests/snapshots/nanox_swap_on_uniswap/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap/00006.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork/00000.png b/tests/snapshots/nanox_swap_on_uniswap_fork/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork/00000.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork/00001.png b/tests/snapshots/nanox_swap_on_uniswap_fork/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork/00001.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork/00002.png b/tests/snapshots/nanox_swap_on_uniswap_fork/00002.png new file mode 100644 index 0000000..4325081 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork/00002.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork/00003.png b/tests/snapshots/nanox_swap_on_uniswap_fork/00003.png new file mode 100644 index 0000000..62e8243 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork/00003.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork/00004.png b/tests/snapshots/nanox_swap_on_uniswap_fork/00004.png new file mode 100644 index 0000000..6c0c273 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork/00004.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork/00005.png b/tests/snapshots/nanox_swap_on_uniswap_fork/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork/00005.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork/00006.png b/tests/snapshots/nanox_swap_on_uniswap_fork/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork/00006.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00000.png b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00000.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00001.png b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00001.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00002.png b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00002.png new file mode 100644 index 0000000..96d16a3 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00002.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00003.png b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00003.png new file mode 100644 index 0000000..3e8948c Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00003.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00004.png b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00004.png new file mode 100644 index 0000000..ccfa62e Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00004.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00005.png b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00005.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00006.png b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_fork_v4/00006.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_v4/00000.png b/tests/snapshots/nanox_swap_on_uniswap_v4/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_v4/00000.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_v4/00001.png b/tests/snapshots/nanox_swap_on_uniswap_v4/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_v4/00001.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_v4/00002.png b/tests/snapshots/nanox_swap_on_uniswap_v4/00002.png new file mode 100644 index 0000000..2647ec9 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_v4/00002.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_v4/00003.png b/tests/snapshots/nanox_swap_on_uniswap_v4/00003.png new file mode 100644 index 0000000..0a8071d Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_v4/00003.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_v4/00004.png b/tests/snapshots/nanox_swap_on_uniswap_v4/00004.png new file mode 100644 index 0000000..40ad57a Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_v4/00004.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_v4/00005.png b/tests/snapshots/nanox_swap_on_uniswap_v4/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_v4/00005.png differ diff --git a/tests/snapshots/nanox_swap_on_uniswap_v4/00006.png b/tests/snapshots/nanox_swap_on_uniswap_v4/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_uniswap_v4/00006.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v2/00000.png b/tests/snapshots/nanox_swap_on_zero_v2/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v2/00000.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v2/00001.png b/tests/snapshots/nanox_swap_on_zero_v2/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v2/00001.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v2/00002.png b/tests/snapshots/nanox_swap_on_zero_v2/00002.png new file mode 100644 index 0000000..b4a7a79 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v2/00002.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v2/00003.png b/tests/snapshots/nanox_swap_on_zero_v2/00003.png new file mode 100644 index 0000000..70074dd Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v2/00003.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v2/00004.png b/tests/snapshots/nanox_swap_on_zero_v2/00004.png new file mode 100644 index 0000000..cf76d13 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v2/00004.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v2/00005.png b/tests/snapshots/nanox_swap_on_zero_v2/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v2/00005.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v2/00006.png b/tests/snapshots/nanox_swap_on_zero_v2/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v2/00006.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v4/00000.png b/tests/snapshots/nanox_swap_on_zero_v4/00000.png new file mode 100644 index 0000000..4a982c5 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v4/00000.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v4/00001.png b/tests/snapshots/nanox_swap_on_zero_v4/00001.png new file mode 100644 index 0000000..b385148 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v4/00001.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v4/00002.png b/tests/snapshots/nanox_swap_on_zero_v4/00002.png new file mode 100644 index 0000000..8bf0fbd Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v4/00002.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v4/00003.png b/tests/snapshots/nanox_swap_on_zero_v4/00003.png new file mode 100644 index 0000000..2284a75 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v4/00003.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v4/00004.png b/tests/snapshots/nanox_swap_on_zero_v4/00004.png new file mode 100644 index 0000000..4cc1fc9 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v4/00004.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v4/00005.png b/tests/snapshots/nanox_swap_on_zero_v4/00005.png new file mode 100644 index 0000000..a2cb8f9 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v4/00005.png differ diff --git a/tests/snapshots/nanox_swap_on_zero_v4/00006.png b/tests/snapshots/nanox_swap_on_zero_v4/00006.png new file mode 100644 index 0000000..7a77cb1 Binary files /dev/null and b/tests/snapshots/nanox_swap_on_zero_v4/00006.png differ diff --git a/tests/src/generate_plugin_config.js b/tests/src/generate_plugin_config.js new file mode 100644 index 0000000..c4eef17 --- /dev/null +++ b/tests/src/generate_plugin_config.js @@ -0,0 +1,84 @@ +// You will need to create a folder with this name, and put in the abis of your contracts in `abis/`. +// You will also need to create a `b2c.json` file that will hold the methodIDs and location of +// the erc20 tokens that should get displayed. +// EDIT THIS: replace with the name of your plugin (lowercase) +const pluginFolder = "paraswap"; + +function serialize_data(pluginName, contractAddress, selector) { + const len = Buffer.from([pluginName.length]); + const name = Buffer.from(pluginName) + const address = Buffer.from(contractAddress.slice(2), "hex"); + const methodid = Buffer.from(selector.slice(2), "hex"); + // Taking .slice(2) to remove the "0x" prefix + return Buffer.concat([len, name, address, methodid]); +} + +function assert(condition, message) { + if (!condition) { + throw message || "Assertion failed"; + } +} + +// Function to generate the plugin configuration. +function generate_plugin_config() { + + var fs = require('fs'); + var files = fs.readdirSync(`${pluginFolder}/abis/`); + + // `contracts_to_abis` holds a maping of contract addresses to abis + let contracts_to_abis = {}; + for (let abiFileName of files) { + assert(abiFileName.toLocaleLowerCase() == abiFileName, `FAILED: File ${abiFileName} should be lower case.`); + + // Strip ".json" suffix + let contractAddress = abiFileName.slice(0, abiFileName.length - ".json".length); + // Load abi + let abi = require(`../${pluginFolder}/abis/${abiFileName}`); + // Add it to contracts + contracts_to_abis[contractAddress] = abi; + } + + // Load the b2c.json file + const b2c = require(`../${pluginFolder}/b2c.json`); + + let res = {}; + + // Place holder signature + const PLACE_HOLDER_SIGNATURE = "3045022100f6e1a922c745e244fa3ed9a865491672808ef93f492ee0410861d748c5de201f0220160d6522499f3a84fa3e744b3b81e49e129e997b28495e58671a1169b16fa777"; + + // Iterate through contracts in b2c.json file + for (let contract of b2c["contracts"]) { + let methods_info = {}; + const contractAddress = contract["address"]; + assert(contractAddress.toLowerCase() == contractAddress, `FAILED: Contract Address ${contractAddress} should be lower case`); + + for (let [selector, values] of Object.entries(contract["selectors"])) { + + assert(selector.toLowerCase() == selector, `FAILED: Selector ${selector} should be lower case`); + + // Gather up the info needed for the end result + const pluginName = values["plugin"]; + const serializedData = serialize_data(pluginName, contractAddress, selector); + const signature = PLACE_HOLDER_SIGNATURE; + + const erc20OfInterest = values["erc20OfInterest"]; + assert(erc20OfInterest.length <= 2, `Maximum of 2 erc20OfInterest allowed. Got ${erc20OfInterest.length}`); + + + // Put them in `methods_info` + methods_info[selector] = {"erc20OfInterest": values["erc20OfInterest"], "plugin": pluginName, "serialized_data": serializedData, "signature": signature}; + } + // Add the abi to methods_info + methods_info["abi"] = contracts_to_abis[contractAddress]; + // Add the methods_info to the end result + res[contractAddress] = methods_info; + } + + assert(res.length == contracts_to_abis.length, `FAILED: ${res.length} contracts in b2c.json and ${contracts_to_abis.length} contracts in abis/ folder`); + + return res; +} + +module.exports = { + generate_plugin_config, +}; diff --git a/tests/src/generic.js b/tests/src/generic.js deleted file mode 100644 index 39192a4..0000000 --- a/tests/src/generic.js +++ /dev/null @@ -1,33 +0,0 @@ -const sim_options_nanos = { - model: "nanos", - logging: true, - start_delay: 2000, - X11: true, - custom: "", -}; - -const sim_options_nanox = { - model: "nanox", - logging: true, - start_delay: 2000, - X11: true, - custom: "", -}; - -const Resolve = require("path").resolve; -const NANOS_ETH_ELF_PATH = Resolve("elfs/ethereum_nanos.elf"); -const NANOX_ETH_ELF_PATH = Resolve("elfs/ethereum_nanox.elf"); -const NANOS_PARASWAP_LIB = { Paraswap: Resolve("elfs/paraswap_nanos.elf") }; -const NANOX_PARASWAP_LIB = { Paraswap: Resolve("elfs/paraswap_nanox.elf") }; - -const TIMEOUT = 1000000; - -module.exports = { - NANOS_ETH_ELF_PATH, - NANOX_ETH_ELF_PATH, - NANOS_PARASWAP_LIB, - NANOX_PARASWAP_LIB, - sim_options_nanos, - sim_options_nanox, - TIMEOUT, -} \ No newline at end of file diff --git a/tests/src/megaswap.test.js b/tests/src/megaswap.test.js deleted file mode 100644 index 9c6aca9..0000000 --- a/tests/src/megaswap.test.js +++ /dev/null @@ -1,40 +0,0 @@ -import "core-js/stable"; -import "regenerator-runtime/runtime"; -import Eth from "@ledgerhq/hw-app-eth"; -import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20"; -import Zemu from "@zondax/zemu"; -import { TransportStatusError } from "@ledgerhq/errors"; - -const {NANOS_ETH_ELF_PATH, NANOX_ETH_ELF_PATH, NANOS_PARASWAP_LIB, NANOX_PARASWAP_LIB, sim_options_nanos, sim_options_nanox, TIMEOUT} = require("generic.js"); - -test("Test MegaSwap", async () => { - jest.setTimeout(200000); - const sim = new Zemu(NANOS_ETH_ELF_PATH, NANOS_PARASWAP_LIB); - try { - await sim.start(sim_options_nanos); - - let transport = await sim.getTransport(); - const eth = new Eth(transport); - - // Original TX: https://etherscan.io/tx/0xf87e29ee49230352f56f099ef2ae9c7144b3ecb2d0085212e2478b267479b4df - // Send 10 ETH - // Receive 933280.59 TEL - // Max Fees 0.035325396 - let tx = eth.signTransaction( - "44'/60'/0'/0/0", - "f90b55820a13850c92a69c008309fb5e941bd435f3c054b6e901b7b108a0ab7617c808677b888ac7230489e80000b90b24ec1d21dd0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000000000059012bb00000000000000000000000000000000000000000000000000000000059e752f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000b70617261737761702e696f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000020d0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000467bccd9d29f223bce8043b84e8c8b282827790f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000695725627e04898ef4a126ae71fc30aa935c5fb600000000000000000000000086d3579b043585a97532514016dcf0c2d6c4b6a100000000000000000000000000000000000000000000000000000000000011ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000467bccd9d29f223bce8043b84e8c8b282827790f00000000000000000000000017312cbd32df845a3941f1bc80f33ad8f59c84260000000000000000000000006317c5e82a06e1d8bf200d21f4510ac2c038ac81000000000000000000000000000000000000000000000000000000000000156400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006cb5c5cb789fae62ce5ce280e1fbc5dd3bbdad810000000000000000000000000000000000000000000000003fd67ba0cecc00000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000280000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000017312cbd32df845a3941f1bc80f33ad8f59c84260000000000000000000000006317c5e82a06e1d8bf200d21f4510ac2c038ac81000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000059a19d8c652fa0284f44113d0ff9aba70bd46fb400000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000467bccd9d29f223bce8043b84e8c8b282827790f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000017312cbd32df845a3941f1bc80f33ad8f59c84260000000000000000000000006317c5e82a06e1d8bf200d21f4510ac2c038ac81000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000003b63a353c996a2c0a7beadd8a9052a04ca8d7a5c000000000000000000000000000000000000000000000004972411230cd2fd700000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018080" - ); - - await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot(), 200000); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickBoth(); - - await tx; - } finally { - await sim.close(); - } -}); diff --git a/tests/src/multiswap.test.js b/tests/src/multiswap.test.js deleted file mode 100644 index 60075a7..0000000 --- a/tests/src/multiswap.test.js +++ /dev/null @@ -1,46 +0,0 @@ -import "core-js/stable"; -import "regenerator-runtime/runtime"; -import Eth from "@ledgerhq/hw-app-eth"; -import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20"; -import Zemu from "@zondax/zemu"; -import { TransportStatusError } from "@ledgerhq/errors"; - -const {NANOS_ETH_ELF_PATH, NANOX_ETH_ELF_PATH, NANOS_PARASWAP_LIB, NANOX_PARASWAP_LIB, sim_options_nanos, sim_options_nanox, TIMEOUT} = require("generic.js"); - -test("Test SimpleSwap", async () => { - jest.setTimeout(200000); - const sim = new Zemu(NANOS_ETH_ELF_PATH, NANOS_PARASWAP_LIB); - try { - await sim.start(sim_options_nanos); - - let transport = await sim.getTransport(); - const eth = new Eth(transport); - - // Original TX: https://etherscan.io/tx/0xe89743d41a79ab41df4a5bc1ec05aae3b55b17aab96cffceb002997bcc183f1e - let tx = eth.signTransaction( - "44'/60'/0'/0/0", - "f90a7480850bdfd63e00830eeb08941bd435f3c054b6e901b7b108a0ab7617c808677b89055de6a779bbac0000b90a448f00eccb0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000055de6a779bbac00000000000000000000000000000000000000000000000047ce107590e650f1c9e00000000000000000000000000000000000000000000047e076fa6ca8052c75000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000b70617261737761702e696f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006c0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000004a0000000000000000000000000ae0eea652303d174e267e4d51f656254d3039f76000000000000000000000000080bf510fcbf18b91105470639e956102293771200000000000000000000000000000000000000000000000000000000000015e000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000006daea1723962647b7e189d311d757fb7930000000000000000000000001bd435f3c054b6e901b7b108a0ab7617c808677b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc425ad6100000000000000000000000000000000000000000000000309141221032200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000609507290000000000000000000000000000000000000000000000000000000013c54901000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000421b730fe699c976e5a4f9427c7bfbfccc436c5d6d18f733247389e7f302f14dcb0306f15ddff604f405b6affe1b43df13bc41180874aa6258935ca533297939e6a30400000000000000000000000000000000000000000000000000000000000000000000000000000000000077bc1a1ba4e9a6df5bdb21f2bbc07b9854e8d1a8000000000000000000000000bc1315cd2671bc498fdab42ae1214068003dc51e000000000000000000000000000000000000000000000000000000000000113000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000a47c8bf37f92abed4a126bda807a7b7498661acd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000007b566ec2b0f914e03e508ea2ae591ea2facf713a000000000000000000000000890f4e345b1daed0367a877a1612f86a1f86985f000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001018080" - ); - - await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot(), 200000); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickBoth(); - - await tx; - - } finally { - await sim.close(); - } -}); - -// TODO: add those tests - -// https://etherscan.io/tx/0xe89743d41a79ab41df4a5bc1ec05aae3b55b17aab96cffceb002997bcc183f1e -// https://etherscan.io/tx/0x2273d6c6ed86759fdd452dd5ef59c29179718b1acf6b7266e4fa641e4ded0362 -// https://etherscan.io/tx/0x4c3b661fd93bca785942c7740d3c725ce02b938f9c673df2f251f779d933905b \ No newline at end of file diff --git a/tests/src/simpleswap.test.js b/tests/src/simpleswap.test.js deleted file mode 100644 index fb40ad0..0000000 --- a/tests/src/simpleswap.test.js +++ /dev/null @@ -1,43 +0,0 @@ -import "core-js/stable"; -import "regenerator-runtime/runtime"; -import Eth from "@ledgerhq/hw-app-eth"; -import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20"; -import Zemu from "@zondax/zemu"; -import { TransportStatusError } from "@ledgerhq/errors"; - -const {NANOS_ETH_ELF_PATH, NANOX_ETH_ELF_PATH, NANOS_PARASWAP_LIB, NANOX_PARASWAP_LIB, sim_options_nanos, sim_options_nanox, TIMEOUT} = require("generic.js"); - -test("Test SimpleSwap", async () => { - jest.setTimeout(200000); - const sim = new Zemu(NANOS_ETH_ELF_PATH, NANOS_PARASWAP_LIB); - try { - await sim.start(sim_options_nanos); - - let transport = await sim.getTransport(); - const eth = new Eth(transport); - - // Original TX: https://etherscan.io/tx/0x6b2c4d8e3292d59712b3092fda9b92b2ea9f6714d43c31e80a2d720d541748b2 - // Send 2796.674211928951577378 CRV - // Receive ETH 2.6546870621893189 - // Max Fees: 0.0125817 - let tx = eth.signTransaction( - "44'/60'/0'/0/0", - "f9056d8203fc850bdfd63e008303c3ac941bd435f3c054b6e901b7b108a0ab7617c808677b80b90544cfc0afeb000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000979ba6ba5598ad5b2200000000000000000000000000000000000000000000000024d757d1639ea2f40000000000000000000000000000000000000000000000002506bc99d69cdc60000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff0000000000000000000000001bd435f3c054b6e901b7b108a0ab7617c808677b0000000000000000000000000000000000000000000000000000000000000208aa77476c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd520000000000000000000000000000000000000000000000002570c704bf68300000000000000000000000000000000000000000000000009924c024822e84000000000000000000000000000056178a0d5f301baf6cf3e1cd53d9863437345bf90000000000000000000000001bd435f3c054b6e901b7b108a0ab7617c808677b0000000000000000000000003be0d7d9365f085bb08c395d022c5834aae69a3a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006095036f000000000000000000000000000000000000000000000000167cbd81571c7dbc0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000001cf7758b0cce1249cd921b7341015e6a25dc7412e8e19e81482b1b3aa6e15160bd1222f2c76342d45135e03c8517cfa517def897267c877627ffd20fc811f125350000000000000000000000000000000000000000000000979ba6ba5598ad5b22e1829cfe000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e40000000000000000000000000000000000000000000000000000000000000208000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b70617261737761702e696f000000000000000000000000000000000000000000018080" - ); - - await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot(), 200000); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickBoth(); - await tx; - - } finally { - await sim.close(); - } -}); diff --git a/tests/src/swap_on_uniswap.test.js b/tests/src/swap_on_uniswap.test.js deleted file mode 100644 index daa90d4..0000000 --- a/tests/src/swap_on_uniswap.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import "core-js/stable"; -import "regenerator-runtime/runtime"; -import Eth from "@ledgerhq/hw-app-eth"; -import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20"; -import Zemu from "@zondax/zemu"; -import { TransportStatusError } from "@ledgerhq/errors"; - -const {NANOS_ETH_ELF_PATH, NANOX_ETH_ELF_PATH, NANOS_PARASWAP_LIB, NANOX_PARASWAP_LIB, sim_options_nanos, sim_options_nanox, TIMEOUT} = require("generic.js"); - -test("Test Swap on Uniswap", async () => { - jest.setTimeout(100000); - const sim = new Zemu(NANOS_ETH_ELF_PATH, NANOS_PARASWAP_LIB); - try { - await sim.start(sim_options_nanos); - - let transport = await sim.getTransport(); - const eth = new Eth(transport); - - // Original TX: https://etherscan.io/tx/0x6b6aeef79fc7e295109fd6dd6f614753e30996a8ac1d5c15269c440c4c768df5 - // Send 145 API3 - // Receive 0.283184134935736098 - // Fees 0.008769654 - let tx = eth.signTransaction( - "44'/60'/0'/0/0", - "f9010a30850bdfd63e0083029fb2941bd435f3c054b6e901b7b108a0ab7617c808677b80b8e458b9d179000000000000000000000000000000000000000000000007dc477bc1cfa4000000000000000000000000000000000000000000000000000003ee127868deef220000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000b38210ea11411557c13457d4da7dc6ea731b88a000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee018080" - ); - - await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot(), 200000); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickBoth(); - - await tx; - } finally { - await sim.close(); - } -}); diff --git a/tests/src/swap_on_uniswap_fork.test.js b/tests/src/swap_on_uniswap_fork.test.js deleted file mode 100644 index ff65a40..0000000 --- a/tests/src/swap_on_uniswap_fork.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import "core-js/stable"; -import "regenerator-runtime/runtime"; -import Eth from "@ledgerhq/hw-app-eth"; -import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20"; -import Zemu from "@zondax/zemu"; -import { TransportStatusError } from "@ledgerhq/errors"; - -const {NANOS_ETH_ELF_PATH, NANOX_ETH_ELF_PATH, NANOS_PARASWAP_LIB, NANOX_PARASWAP_LIB, sim_options_nanos, sim_options_nanox, TIMEOUT} = require("generic.js"); - -test("Test SimpleSwap", async () => { - jest.setTimeout(100000); - const sim = new Zemu(NANOS_ETH_ELF_PATH, NANOS_PARASWAP_LIB); - try { - await sim.start(sim_options_nanos); - - let transport = await sim.getTransport(); - const eth = new Eth(transport); - - // Original TX: https://etherscan.io/tx/0x30f033eae4ef9f426b934b7b494de6ca839cd45f6fc3390690ff894fa6519ec4 - // Send ALCX 0.795106864969129095 - // Receive USDC 1212.688661 (user got 1523.52118) - // Max Fees: 0.011521299 - let tx = eth.signTransaction( - "44'/60'/0'/0/0", - "f9016d8202ce850c570bd20083035127941bd435f3c054b6e901b7b108a0ab7617c808677b80b901440863b7ac000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ace18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c63030000000000000000000000000000000000000000000000000b08c97b24f59c87000000000000000000000000000000000000000000000000000000004848291500000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000dbdb4d16eda451d0503b854cf79d55697f90c8df000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48018080" - ); - - await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickRight(); - await sim.clickBoth(); - await tx; - } finally { - await sim.close(); - } -}); diff --git a/tests/src/test.fixture.js b/tests/src/test.fixture.js new file mode 100644 index 0000000..d82ebdd --- /dev/null +++ b/tests/src/test.fixture.js @@ -0,0 +1,168 @@ +import Zemu from "@zondax/zemu"; +import Eth from "@ledgerhq/hw-app-eth"; +import { generate_plugin_config } from "./generate_plugin_config"; +import { parseEther, parseUnits, RLP } from "ethers/lib/utils"; + +const transactionUploadDelay = 200000; + +const sim_options_generic = { + logging: true, + X11: true, + startDelay: 5000, + custom: "", +}; + +const Resolve = require("path").resolve; + +const NANOS_ETH_PATH = Resolve("elfs/ethereum_nanos.elf"); +const NANOX_ETH_PATH = Resolve("elfs/ethereum_nanox.elf"); + +const NANOS_PLUGIN_PATH = Resolve("elfs/paraswap_nanos.elf"); +const NANOX_PLUGIN_PATH = Resolve("elfs/paraswap_nanox.elf"); + +const NANOS_PLUGIN = { Paraswap: NANOS_PLUGIN_PATH }; +const NANOX_PLUGIN = { Paraswap: NANOX_PLUGIN_PATH }; + +const paraswapJSON = generate_plugin_config(); + +const SPECULOS_ADDRESS = "0xFE984369CE3919AA7BB4F431082D027B4F8ED70C"; +const RANDOM_ADDRESS = "0xaaaabbbbccccddddeeeeffffgggghhhhiiiijjjj"; + +let genericTx = { + nonce: Number(0), + gasLimit: Number(21000), + gasPrice: parseUnits("1", "gwei"), + value: parseEther("1"), + chainId: 1, + to: RANDOM_ADDRESS, + data: null, +}; + +const TIMEOUT = 1000000; + +/** + * Generates a serializedTransaction from a rawHexTransaction copy pasted from etherscan. + * @param {string} rawTx Raw transaction + * @returns {string} serializedTx + */ +function txFromEtherscan(rawTx) { + // Remove 0x prefix + rawTx = rawTx.slice(2); + + let txType = rawTx.slice(0, 2); + if (txType == "02" || txType == "01") { + // Remove "02" prefix + rawTx = rawTx.slice(2); + } else { + txType = ""; + } + + let decoded = RLP.decode("0x" + rawTx); + if (txType != "") { + decoded = decoded.slice(0, decoded.length - 3); // remove v, r, s + } else { + decoded[decoded.length - 1] = "0x"; // empty + decoded[decoded.length - 2] = "0x"; // empty + decoded[decoded.length - 3] = "0x01"; // chainID 1 + } + + // Encode back the data, drop the '0x' prefix + let encoded = RLP.encode(decoded).slice(2); + + // Don't forget to prepend the txtype + return txType + encoded; +} + +/** + * Emulation of the device using zemu + * @param {string} device name of the device to emulate (nanos, nanox) + * @param {function} func + * @param {boolean} signed the plugin is already signed + * @returns {Promise} + */ +function zemu(device, func, signed = false) { + return async () => { + jest.setTimeout(TIMEOUT); + let eth_path; + let plugin; + let sim_options = sim_options_generic; + + if (device === "nanos") { + eth_path = NANOS_ETH_PATH; + plugin = NANOS_PLUGIN; + sim_options.model = "nanos"; + } else { + eth_path = NANOX_ETH_PATH; + plugin = NANOX_PLUGIN; + sim_options.model = "nanox"; + } + + const sim = new Zemu(eth_path, plugin); + + try { + await sim.start(sim_options); + const transport = await sim.getTransport(); + const eth = new Eth(transport); + + if(!signed){ + eth.setPluginsLoadConfig({ + baseURL: null, + extraPlugins: paraswapJSON, + }); + } + await func(sim, eth); + } finally { + await sim.close(); + } + }; +} + +/** + * Process the trasaction through the full test process in interaction with the simulator + * @param {string} eth Device to test (nanos, nanox) + * @param {function} sim Zemu simulator + * @param {int} steps Number of steps to push right button + * @param {string} label directory against which the test snapshots must be checked. + * @param {string} rawTxHex RawTransaction Hex to process + */ +async function processTransaction(eth, sim, steps, label, rawTxHex) { + const serializedTx = txFromEtherscan(rawTxHex); + let tx = eth.signTransaction("44'/60'/0'/0/0", serializedTx); + + await sim.waitUntilScreenIsNot( + sim.getMainMenuSnapshot(), + transactionUploadDelay + ); + await sim.navigateAndCompareSnapshots(".", label, [steps, 0]); + + await tx; +} + +/** + * Function to execute test with the simulator + * @param {Object} device Device including its name, its label, and the number of steps to process the use case + * @param {string} contractName Name of the contract + * @param {string} testLabel Name of the test case + * @param {string} testDirSuffix Name of the folder suffix for snapshot comparison + * @param {string} rawTxHex RawTx Hex to test + * @param {boolean} signed The plugin is already signed and existing in Ledger database + */ +function processTest(device, contractName, testLabel, testDirSuffix, rawTxHex, signed ) { + test( + "[" + contractName + "] - " + device.label + " - " + testLabel, + zemu(device.name, async (sim, eth) => { + await processTransaction( + eth, + sim, + device.steps, + device.name + "_" + testDirSuffix, + rawTxHex, + signed + ); + },signed) + ); +} + +module.exports = { + processTest, +}; diff --git a/tests/src/v4/buy.v4.test.js b/tests/src/v4/buy.v4.test.js new file mode 100644 index 0000000..3802330 --- /dev/null +++ b/tests/src/v4/buy.v4.test.js @@ -0,0 +1,27 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V4"; +// From : https://etherscan.io/tx/0xa545791016756d3126cd99d0e0b941ec4263c343288282bedcf1870bbe6c734f +const rawTxHex = + "0xf903cd8203f385037e11d60083042bf1941bd435f3c054b6e901b7b108a0ab7617c808677b80b90364f95a49eb0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000001ded80a200000000000000000000000000000000000000000000000002815173c0004228000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000056d6f6f6e690000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000017312cbd32df845a3941f1bc80f33ad8f59c84260000000000000000000000006317c5e82a06e1d8bf200d21f4510ac2c038ac81000000000000000000000000000000000000000000000000000000001ded809d00000000000000000000000000000000000000000000000002815173c000422800000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000d88b55317516b84e78fbba7cde3f910d5686901000000000000000000000000000000000000000000000000000000001da1a55d00000000000000000000000000000000000000000000000002815173c0004228ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff26a07628ab495161321758d75ba2b72195a606ea283b56c62b9d834d6a37e106c6f9a0093a57391d796996b5db11a71846f836d373ee258e9ebb0592a3e87249f7690b"; +const testLabel = "Buy"; // <= Name of the test +const testDirSuffix = "buy_v4"; // <= directory to compare device snapshots to +const signedPlugin = true; // <== set to true if the plugin is already signed and available +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 6, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + + + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex, signedPlugin) +); diff --git a/tests/src/v4/buy_on_uniswap.v4.test.js b/tests/src/v4/buy_on_uniswap.v4.test.js new file mode 100644 index 0000000..ba53cc4 --- /dev/null +++ b/tests/src/v4/buy_on_uniswap.v4.test.js @@ -0,0 +1,27 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V4"; +// From : https://etherscan.io/tx/0x74cf3c6bcdcdd2db5998e7b2836456d40c238fcb6d4d0db0776e2f3a16c49b88 +const rawTxHex = + "0xf9014c8205b885028fa6ae008303375e941bd435f3c054b6e901b7b108a0ab7617c808677b80b8e4f9355f72000000000000000000000000000000000000000000000003dacc12f3fe33b468000000000000000000000000000000000000000000000000063c63848f37478e000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000de30da39c46104798bb5aa3fe8b9e0e1f348163f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee26a0e340f76fa1762f684a11b578b17e19be63ad3fd70f4e30cb0e4878c5da0abff9a0158cb6914abc788bc545908679d21e2ddf50f43887259ba74537c87b62d599d0"; +const testLabel = "Buy On Uniswap"; // <= Name of the test +const testDirSuffix = "buy_on_uniswap_v4"; // <= directory to compare device snapshots to +const signedPlugin = true; // <== set to true if the plugin is already signed and available +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 7, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + + + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex, signedPlugin) +); diff --git a/tests/src/v4/buy_on_uniswap_fork.v4.test.js b/tests/src/v4/buy_on_uniswap_fork.v4.test.js new file mode 100644 index 0000000..5f8e4f1 --- /dev/null +++ b/tests/src/v4/buy_on_uniswap_fork.v4.test.js @@ -0,0 +1,27 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V4"; +// From : https://etherscan.io/tx/0xb543fb02efb0890bdff0228c1a41de068d18c4709e254c7d1c3825c28778a996 +const rawTxHex = + "0xf9018d82010f8509c76524008302e7a9941bd435f3c054b6e901b7b108a0ab7617c808677b80b90124336352260000000000000000000000009deb29c9a4c7a88a3c0257393b7f3335338d9a9d69d637e77615df9f235f642acebbdad8963ef35c5523142078c9b8f9d0ceba7e00000000000000000000000000000000000000000000000000000000223efc940000000000000000000000000000000000000000000000000283436748eb996b00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee26a006d701b9ed2db5d1dc508a021005adb414ae0d4e1bd8150b7e83a2fa5b1d420da023bedbfb8bd274e21337a6af6d177f24b7ef2a22e2af9955fcabcd7623c5d1f9"; +const testLabel = "Buy On Uniswap Fork"; // <= Name of the test +const testDirSuffix = "buy_on_uniswap_fork_v4"; // <= directory to compare device snapshots to +const signedPlugin = true; // <== set to true if the plugin is already signed and available +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 6, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + + + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex, signedPlugin) +); diff --git a/tests/src/v4/mega_swap.v4.test.js b/tests/src/v4/mega_swap.v4.test.js new file mode 100644 index 0000000..faf4495 --- /dev/null +++ b/tests/src/v4/mega_swap.v4.test.js @@ -0,0 +1,27 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V4"; +// From : https://etherscan.io/tx/0xf87e29ee49230352f56f099ef2ae9c7144b3ecb2d0085212e2478b267479b4df +const rawTxHex = + "0xf90b95820a13850c92a69c008309fb5e941bd435f3c054b6e901b7b108a0ab7617c808677b888ac7230489e80000b90b24ec1d21dd0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000000000059012bb00000000000000000000000000000000000000000000000000000000059e752f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000b70617261737761702e696f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000020d0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000467bccd9d29f223bce8043b84e8c8b282827790f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000695725627e04898ef4a126ae71fc30aa935c5fb600000000000000000000000086d3579b043585a97532514016dcf0c2d6c4b6a100000000000000000000000000000000000000000000000000000000000011ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000467bccd9d29f223bce8043b84e8c8b282827790f00000000000000000000000017312cbd32df845a3941f1bc80f33ad8f59c84260000000000000000000000006317c5e82a06e1d8bf200d21f4510ac2c038ac81000000000000000000000000000000000000000000000000000000000000156400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006cb5c5cb789fae62ce5ce280e1fbc5dd3bbdad810000000000000000000000000000000000000000000000003fd67ba0cecc00000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000280000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000017312cbd32df845a3941f1bc80f33ad8f59c84260000000000000000000000006317c5e82a06e1d8bf200d21f4510ac2c038ac81000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000059a19d8c652fa0284f44113d0ff9aba70bd46fb400000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000467bccd9d29f223bce8043b84e8c8b282827790f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000017312cbd32df845a3941f1bc80f33ad8f59c84260000000000000000000000006317c5e82a06e1d8bf200d21f4510ac2c038ac81000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000003b63a353c996a2c0a7beadd8a9052a04ca8d7a5c000000000000000000000000000000000000000000000004972411230cd2fd700000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff25a0ffb4409987569488be7e9e6b94b4b3eab41477c6abec965d73f547f0eb1fe421a00c180ecb60187f13d49b37f290b533671062d8aa1f01a34c34b6ebedfbc89558"; +const testLabel = "Mega Swap"; // <= Name of the test +const testDirSuffix = "mega_swap_v4"; // <= directory to compare device snapshots to +const signedPlugin = true; // <== set to true if the plugin is already signed and available +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 5, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + + + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex, signedPlugin) +); diff --git a/tests/src/v4/multi_swap.v4.test.js b/tests/src/v4/multi_swap.v4.test.js new file mode 100644 index 0000000..995fb49 --- /dev/null +++ b/tests/src/v4/multi_swap.v4.test.js @@ -0,0 +1,27 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V4"; +// From : https://etherscan.io/tx/0xc615fa3630a17b8e5b088b25f3514489fdd94c4f140801e055b6806bb5c3f8f3 +const rawTxHex = + "0xf9086b1c850cce4166008307b932941bd435f3c054b6e901b7b108a0ab7617c808677b80b908048f00eccb00000000000000000000000000000000000000000000000000000000000000200000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000001f65c6000000000000000000000000000000000000000000000000000000004bf5837e000000000000000000000000000000000000000000000000000000004c08fa86e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000076c65646765723200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000360000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000064c3fb89f934592a2d7a5d1aa87c504b4bffe428000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59900000000000000000000000000000000000000000000000000000004cd4fb0d70000000000000000000000000000000000000000000000000000000001fb626b00000000000000000000000056178a0d5f301baf6cf3e1cd53d9863437345bf90000000000000000000000001bd435f3c054b6e901b7b108a0ab7617c808677b000000000000000000000000df36df36201044f544e55c6f026d209ad9a55f48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000616cf89301ffffffffffffffffffffffffffffffffffffff10e7f1a1616cf8390000002b0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000001c22738251b375d2fe29b366ccdfcb295c5829f0d01cf039bbe53bf174a3fa12794a1c6d067f2d971f66f0b14b7e4a1c6c56dc84e9d4dd49becefd404ec440dee1000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000064c3fb89f934592a2d7a5d1aa87c504b4bffe428000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000004ccbb262500000000000000000000000000000000000000000000000000000004cd3cb9da000000000000000000000000a5d07e978398eb1715056d3ca5cb31035c02fdad0000000000000000000000001bd435f3c054b6e901b7b108a0ab7617c808677b000000000000000000000000df36df36201044f544e55c6f026d209ad9a55f48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000616cf8ed0000000000000000000000000000000000000000000000000000017c91a9a1920000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000001ce8045b1f9a4f692c12d09f2c027689be50a46b9768a718ca17b98a6fa6c2e8dc58d21631665f910addb16671b9886e5102c15c4383450883c8b515184f75cb9d25a0d0ede5249700adbfe9ad359b0f6bbee8ed66afecc70ab96928287684a9b8a423a061cf71c28497fa3c5857aec280523b58da217f4fb1dc2e3cfc00bbbc0d66b370"; +const testLabel = "Multi Swap"; // <= Name of the test +const testDirSuffix = "multi_swap_v4"; // <= directory to compare device snapshots to +const signedPlugin = true; // <== set to true if the plugin is already signed and available +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 5, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + + + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex, signedPlugin) +); diff --git a/tests/src/v4/simple_swap.v4.test.js b/tests/src/v4/simple_swap.v4.test.js new file mode 100644 index 0000000..cffc3f3 --- /dev/null +++ b/tests/src/v4/simple_swap.v4.test.js @@ -0,0 +1,27 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V4"; +// From : https://etherscan.io/tx/0x4a99078854129f69d6c4dce690b311c26b88869efa84eb57edc2c2976a186970 +const rawTxHex = + "0xf9040b10850e6f7cec0083044a31941bd435f3c054b6e901b7b108a0ab7617c808677b80b903a4cfc0afeb000000000000000000000000f629cbd94d3791c9250152bd8dfbdf380e2a3b9c000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000191556e0a46e44312400000000000000000000000000000000000000000000000002b036a93598378400000000000000000000000000000000000000000000000002c57f9bf7e975f0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f806f9972f9a34fc05394ca6cf2cc606297ca6d500000000000000000000000000000000000000000000000000000000000000c499585aac0000000000000000000000000000000000000000000000191556e0a46e443124000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f629cbd94d3791c9250152bd8dfbdf380e2a3b9c000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c40000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076c6564676572320000000000000000000000000000000000000000000000000026a04c51e49d0468db9a8a204529e6a5963b3474cd6f11ad58f09b4a4a5675ae9ffba02838a36d64417748f3b99421114eb6ac9811af6486807c960abeb8c10a144209"; +const testLabel = "Simple Swap"; // <= Name of the test +const testDirSuffix = "simple_swap_v4"; // <= directory to compare device snapshots to +const signedPlugin = true; +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 8, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + + + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex, signedPlugin) +); diff --git a/tests/src/v4/swap_on_uniswap.v4.test.js b/tests/src/v4/swap_on_uniswap.v4.test.js new file mode 100644 index 0000000..c5224d5 --- /dev/null +++ b/tests/src/v4/swap_on_uniswap.v4.test.js @@ -0,0 +1,27 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V4"; +// From : https://etherscan.io/tx/0x6b6aeef79fc7e295109fd6dd6f614753e30996a8ac1d5c15269c440c4c768df5 +const rawTxHex = + "0xf9014a30850bdfd63e0083029fb2941bd435f3c054b6e901b7b108a0ab7617c808677b80b8e458b9d179000000000000000000000000000000000000000000000007dc477bc1cfa4000000000000000000000000000000000000000000000000000003ee127868deef220000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000b38210ea11411557c13457d4da7dc6ea731b88a000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee26a022380972064ddd3aef0178dec7f1a2542df6ad8c5d95ccd6e29d6f0e0a3f938ca04343dcc66bf041170803672fd96d6d7b2030c0bb3ecd3069e247475f30edc9ec"; +const testLabel = "Swap On Uniswap"; // <= Name of the test +const testDirSuffix = "swap_on_uniswap_v4"; // <= directory to compare device snapshots to +const signedPlugin = true; +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 6, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + + + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex, signedPlugin) +); diff --git a/tests/src/v4/swap_on_uniswap_fork.v4.test.js b/tests/src/v4/swap_on_uniswap_fork.v4.test.js new file mode 100644 index 0000000..a450bef --- /dev/null +++ b/tests/src/v4/swap_on_uniswap_fork.v4.test.js @@ -0,0 +1,27 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V4"; +// From : https://etherscan.io/tx/0x30f033eae4ef9f426b934b7b494de6ca839cd45f6fc3390690ff894fa6519ec4 +const rawTxHex = + "0xf901ad8202ce850c570bd20083035127941bd435f3c054b6e901b7b108a0ab7617c808677b80b901440863b7ac000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ace18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c63030000000000000000000000000000000000000000000000000b08c97b24f59c87000000000000000000000000000000000000000000000000000000004848291500000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000dbdb4d16eda451d0503b854cf79d55697f90c8df000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4826a0649856a7c253e327433f667c4816f3eb616f57c74bd95fe2f7c70b5b51d4e1e1a023227729bf28bfaa85706e738447f3c953ea6f07a6869f616d0a898ff4ca99db"; +const testLabel = "Swap On Uniswap Fork"; // <= Name of the test +const testDirSuffix = "swap_on_uniswap_fork_v4"; // <= directory to compare device snapshots to +const signedPlugin = true; +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 7, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + + + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex, signedPlugin) +); diff --git a/tests/src/v5/buy_on_uniswap.test.js b/tests/src/v5/buy_on_uniswap.test.js new file mode 100644 index 0000000..aec71d7 --- /dev/null +++ b/tests/src/v5/buy_on_uniswap.test.js @@ -0,0 +1,25 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V5"; +// From : https://etherscan.io/tx/0x6d92259fc715278a3f44aa88a0147d147e313c5e202fc71580362142bb134aca +const rawTxHex = + "0x02f9013b0182305e84773594008528b730555d830257bb94def171fe48cf0115b1d80b88dc8eab59176fee578809c55848d4657c8fb8c4935fb84b00000000000000000000000000000000000000000000000009c55848d4657c8f000000000000000000000000000000000000000000000000000000daa12dbdc000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000002b591e99afe9f32eaa6214f7b7629768c40eeb39c001a0adc705de9be63a2d4a70ecefe9b65e93b7d22526715df723c2f3bc7fc72d7702a06f91aba422975a0947bc0434578d220c9e13743bfe1fb716784be5e3613c7907"; +const testLabel = "Buy On Uniswap"; // <= Name of the test +const testDirSuffix = "buy_on_uniswap"; // <= directory to compare device snapshots to + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 8, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex) +); diff --git a/tests/src/v5/buy_on_uniswap_fork.test.js b/tests/src/v5/buy_on_uniswap_fork.test.js new file mode 100644 index 0000000..cf14341 --- /dev/null +++ b/tests/src/v5/buy_on_uniswap_fork.test.js @@ -0,0 +1,25 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V5"; +// From : https://etherscan.io/tx/0x5a0912bcaa6252b5a1349dc1f53279983c1b1e290d3c1457cd6d8689fd6e6cfe +const rawTxHex = + "0x02f9017c01823044849502f900851d31d51fd683028b2494def171fe48cf0115b1d80b88dc8eab59176fee578814ebb29b0ccbda64b90104c03786b0000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ace18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c630300000000000000000000000000000000000000000000000014ebb29b0ccbda640000000000000000000000000000000000000000000000424574f1f86b49000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000004104b135dbc9609fc1a9490e61369036497660c8c001a0b57599150493405ea7216b9f63648788dc86eff43d3b77cce71d5f76bf41ae02a06dfed183b80740e42dc768dc6eb57ed0d3a8bfc8690703f0135c8afa711e342d"; +const testLabel = "Buy On Uniswap Fork"; // <= Name of the test +const testDirSuffix = "buy_on_uniswap_fork"; // <= directory to compare device snapshots to + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 8, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex) +); diff --git a/tests/src/v5/mega_swap.test.js b/tests/src/v5/mega_swap.test.js new file mode 100644 index 0000000..74732e9 --- /dev/null +++ b/tests/src/v5/mega_swap.test.js @@ -0,0 +1,25 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V5"; +// From : https://etherscan.io/tx/0x214eb3b22fd02c4101d0866bbf40f2598c1d0e6313fd66cd1025e930336f35e7 +const rawTxHex = + "0x02f91052011484b2d05e008527592f5a00830f080294def171fe48cf0115b1d80b88dc8eab59176fee5780b90fe446c67b6d00000000000000000000000000000000000000000000000000000000000000200000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59900000000000000000000000000000000000000000000000000000000337664cb000000000000000000000000000000000000000000000000000000792c8787d300000000000000000000000000000000000000000000000000000079c869565600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa000000000000000000000000000000000000000000000000000000000616b053e64c1e0d02ea211ec941a2142925dfdc1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000005e00000000000000000000000000000000000000000000000000000000000000fa0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000003a0430bf7cd2633af111ce3204db4b0990857a6f0000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff00000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000c4d3ffb670000000000000000000000000000000000000000000000000000000005329d1f0000000000000000000000000000006daea1723962647b7e189d311d757fb793000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee5700000000000000000000000098e21fc2f3cc6564bf60d2572b614f99e8bd93fb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000616b053e767d1e7b722290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000001ccd7eb55a4c107235746869d5fac02518c2bd495328b1f39f5b3744d25d1456e46baf466229b52215e1d5e15c9bafb88d236eaaa644d09a45ed5979f86aaf05dd0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000000000000000000000000000000000000000001d4c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000000000000000000000000000000000000616b12f3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017700000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000560000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002200000000000000000000000003a0430bf7cd2633af111ce3204db4b0990857a6f000000000000000000000000000000000000000000000000000000000000232800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000616b12f300000000000000000000000000000000000000000000000000000000000000000000000000000000000000005165e2bafffc0863c3a6cdb31b0c263c5c2a944100000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000060000000000000000000000001c87257f5e8609940bc751a07bb085bb7f8cdbe6000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001cf68bbc2b6d3c6cfe1bd3590cf0e10b06a05f1700000000000000000000000000000000000000000000000000000000000000020000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000003a0430bf7cd2633af111ce3204db4b0990857a6f000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000616b12f300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c001a0744d03f57f3494813a325e64b44bb38cd7007156cde93b0cb3bae7ef5ec3f598a0271630c83d7eb5283a116a959e457bbe29ef0af26b38a83723059ab3dab33add"; +const testLabel = "Mega Swap"; // <= Name of the test +const testDirSuffix = "mega_swap"; // <= directory to compare device snapshots to + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 5, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex) +); diff --git a/tests/src/v5/multi_swap.test.js b/tests/src/v5/multi_swap.test.js new file mode 100644 index 0000000..e37cccf --- /dev/null +++ b/tests/src/v5/multi_swap.test.js @@ -0,0 +1,25 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V5"; +// From : https://etherscan.io/tx/0xe086cc63ffdd8a275e6fbb1dcdc96c5912c7f7b7a40da5675a162c6b589520a2 +const rawTxHex = + "0x02f907740182036e847735940085141dd01068830acb0e94def171fe48cf0115b1d80b88dc8eab59176fee5780b90704a94e78ef00000000000000000000000000000000000000000000000000000000000000200000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000008fa736b000000000000000000000000000000000000000000000000000000156cc03bf6000000000000000000000000000000000000000000000000000000157d4132a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006c000000000000000000000000000000000000000000000000000000000616b1e312f67d1602e7f11ec928acb4ede16602d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000003a0430bf7cd2633af111ce3204db4b0990857a6f00000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000d51a44d3fae010294c616388b506acda1bfaae46000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000003a0430bf7cd2633af111ce3204db4b0990857a6f000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000616ad7e100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c001a027ac85c9b42990501bde0631aa23360eafb98ae6bf4d8435acb934cfad38ef1ba034c77b650698dfae5a132ec2730c594c5bead0adf078bfa4c106286ef132eab0"; +const testLabel = "Multi Swap"; // <= Name of the test +const testDirSuffix = "multi_swap"; // <= directory to compare device snapshots to + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 7, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex) +); diff --git a/tests/src/v5/simple_buy.test.js b/tests/src/v5/simple_buy.test.js new file mode 100644 index 0000000..db616d1 --- /dev/null +++ b/tests/src/v5/simple_buy.test.js @@ -0,0 +1,25 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V5"; +// From : https://etherscan.io/tx/0xe592df06975a1161a4582ab1663382457b0ea6619d5640f410096afd92643bf2 +const rawTxHex = + "0x02f9065d018230868503b9aca0008521bd3cdabe83054b7494def171fe48cf0115b1d80b88dc8eab59176fee57884b6eb9c3a9b52b63b905e42298207a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000467bccd9d29f223bce8043b84e8c8b282827790f0000000000000000000000000000000000000000000000004b6eb9c3a9b52b630000000000000000000000000000000000000000000000000000000005c718d90000000000000000000000000000000000000000000000004aaf87c442a42af600000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000616b8659447c5ba02ebd11ec9c2e59c773c2c810000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000f9234cb08edb93c0d4a4d4c70cc3ffd070e78e07000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156400000000000000000000000000000000000000000000000000000000000001ecd0e30db03f1c8c53000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000015135a9399c818d300000000000000000000000000000000000000000000000000000000019e25ad000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000004de5291c69fdaebd3cbe953843da243f8605a766a268db3e2198000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000467bccd9d29f223bce8043b84e8c8b282827790f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee5700000000000000000000000000000000000000000000000000000000616b4009000000000000000000000000000000000000000000000000000000000428f32c000000000000000000000000000000000000000000000000365b5f300fed128d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000e800000000000000000000000000000000000000000000000000000000000001ec000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000035d1988ad578aa7300000000000000000000000000000000000000000000000015135a9399c818d300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c080a0f34b1bc1a7131bdf5c562e784e906e0f705a049811dbaf9418352e737b3da421a0063c085bb909fb95f795fbf5f81723e80b0e846740157a793e14ab80e03500dd"; +const testLabel = "Simple Buy"; // <= Name of the test +const testDirSuffix = "simple_buy"; // <= directory to compare device snapshots to + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 7, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex) +); diff --git a/tests/src/v5/simple_swap.test.js b/tests/src/v5/simple_swap.test.js new file mode 100644 index 0000000..cf03666 --- /dev/null +++ b/tests/src/v5/simple_swap.test.js @@ -0,0 +1,25 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V5"; +// From : https://etherscan.io/tx/0xdbb51396354475e12b94a85a5832ce1549fb6f4bac9574eee088a853c5ae28d5 +const rawTxHex = + "0x02f90533018182847f8dcf008536951deb808303bd0d94def171fe48cf0115b1d80b88dc8eab59176fee5780b904c454e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000eb953eda0dc65e3246f43dc8fa13f35623bdd5ed000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000069f4d48d5271c9170628000000000000000000000000000000000000000000000000886b2710ca3717c50000000000000000000000000000000000000000000000008ca34006c0a25d2000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000004200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000006169763276dbd6c02d8211ec90ab8be685117a17000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000000000000000000000000000000000000000000128414bf389000000000000000000000000eb953eda0dc65e3246f43dc8fa13f35623bdd5ed000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000002710000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000000000000000000000000000000000000061692fe20000000000000000000000000000000000000000000069f4d48d5271c917062800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000e1829cfe000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010400000000000000000000000000000000000000000000000000000000000001280000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c001a03b0936dc8bbad15649c8c3e7ea48bb82e14df6795250f4bd6e9645a54aed9940a021c6843471efc1a0da9af6c5af2e70750d6d957c3e9ad58c313e93db83db2152"; +const testLabel = "Simple Swap"; // <= Name of the test +const testDirSuffix = "simple_swap"; // <= directory to compare device snapshots to + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 8, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex) +); diff --git a/tests/src/v5/swap_on_uniswap.test.js b/tests/src/v5/swap_on_uniswap.test.js new file mode 100644 index 0000000..ee58f19 --- /dev/null +++ b/tests/src/v5/swap_on_uniswap.test.js @@ -0,0 +1,25 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V5"; +// From : https://etherscan.io/tx/0x4ae6d1fe1d298a6f84eb710cf5fb3107f5646ed3dbbe04a89d869de4e2a6888a +const rawTxHex = + "0x02f90131010c84625900808532cc8a99008302a53494def171fe48cf0115b1d80b88dc8eab59176fee5780b8c454840d1a00000000000000000000000000000000000000000000027a14a0ff5e40a67d0b0000000000000000000000000000000000000000000000000c16dfffe3c8c66400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d9016a907dc0ecfa3ca425ab20b6b785b42f2373000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeec001a09b996bf896d123a326b3851742e45d9bb60215bd304d1fb38e062a9b8a930c1ea02541f8a2ecd909d6000518b72f27b22aeb94594e0602e933f45859cbc4da8b67"; +const testLabel = "Swap On Uniswap"; // <= Name of the test +const testDirSuffix = "swap_on_uniswap"; // <= directory to compare device snapshots to + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 8, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex) +); diff --git a/tests/src/v5/swap_on_uniswap_fork.test.js b/tests/src/v5/swap_on_uniswap_fork.test.js new file mode 100644 index 0000000..6eaad32 --- /dev/null +++ b/tests/src/v5/swap_on_uniswap_fork.test.js @@ -0,0 +1,25 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V5"; +// From : https://etherscan.io/tx/0xe7b7b2683b300ba8a096e5ebab88eae13d0e1860ea6e44a439f1a6c454a1c970 +const rawTxHex = + "0x02f901720105845cfbb60085208d534c808302d8f794def171fe48cf0115b1d80b88dc8eab59176fee5780b90104f56610340000000000000000000000009deb29c9a4c7a88a3c0257393b7f3335338d9a9d69d637e77615df9f235f642acebbdad8963ef35c5523142078c9b8f9d0ceba7e0000000000000000000000000000000000000000000000000000000014d2f28e00000000000000000000000000000000000000000000000001581dcf2479497a00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeec001a0d6680c8da8c738b49ae62b6fbf562c78bd095284996d509dd765fc07562c7fe6a01d3bd78d9af02c86d126a2a03e78a2c99cfc6f4fc7e631abc099f2bf7b5b1024"; +const testLabel = "Swap On Uniswap Fork"; // <= Name of the test +const testDirSuffix = "swap_on_uniswap_fork"; // <= directory to compare device snapshots to + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 6, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex) +); diff --git a/tests/src/v5/swap_on_zero_v2.test.js b/tests/src/v5/swap_on_zero_v2.test.js new file mode 100644 index 0000000..45f6957 --- /dev/null +++ b/tests/src/v5/swap_on_zero_v2.test.js @@ -0,0 +1,25 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V5"; +// From : https://etherscan.io/tx/0xe37f4739b8069ff94b052b500a50f137bfa26d6f50b05a6f7c145f477e6beb0a +const rawTxHex = + "0xf904eb3385280bffb800830a3e4e94def171fe48cf0115b1d80b88dc8eab59176fee5780b9048481033120000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000007fc66500c84a76ad7e9c93437bfc5ac33e2ddae900000000000000000000000000000000000000000000000000000022ecb25c0000000000000000000000000000000000000000000000001518e94bb7e14d6ae2000000000000000000000000080bf510fcbf18b91105470639e956102293771200000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000003a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000006daea1723962647b7e189d311d757fb793000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee5700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015f2bb07f66311000000000000000000000000000000000000000000000000000000000023461a8b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000612d2d3a00000000000000000000000000000000000000000000000000000000196cd614000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b00000000000000000000000007fc66500c84a76ad7e9c93437bfc5ac33e2ddae9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000421c7b44cfc210222497f3ece7e875e9f9ff9dbf01924c0204e7839722f722cf79572e015d46b0a648f88521c327ed0ff19bf17ce6d762eaa8080fcd144b64e26d120400000000000000000000000000000000000000000000000000000000000025a052f01f886b44fc2f0102841e87d8a0b6366403b56885b5395eaaca45b9630a5aa02f451a1b3a805b8c3ffccef192ea90736140903929735c60f844d27d031b1e18"; +const testLabel = "Swap On Zero V2"; // <= Name of the test +const testDirSuffix = "swap_on_zero_v2"; // <= directory to compare device snapshots to + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 7, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex) +); diff --git a/tests/src/v5/swap_on_zero_v4.test.js b/tests/src/v5/swap_on_zero_v4.test.js new file mode 100644 index 0000000..1779934 --- /dev/null +++ b/tests/src/v5/swap_on_zero_v4.test.js @@ -0,0 +1,25 @@ +import { processTest } from "../test.fixture"; + +const contractName = "Paraswap V5"; +// From : https://etherscan.io/tx/0x66444ad6c169e9ae2923626ae329e5e20f69a3d2e89a32ce62c5ade8afed7ee6 +const rawTxHex = + "0x02f90312011f845cfbb60085263cdeed80830443d994def171fe48cf0115b1d80b88dc8eab59176fee5780b902a464466805000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000000000000000000000000000000000057096761f000000000000000000000000000000000000000000000000000000054657621c000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000057e07cf0f000000000000000000000000000000000000000000000000000000057e837c6c000000000000000000000000a5d07e978398eb1715056d3ca5cb31035c02fdad000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000fe2f21f0ee075cdbd2f6dfc91fbb4f889ce95af1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000616b1ed70000000000000000000000000000000000000000000000000000017c8a6dbb360000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000001b0ea3dcff2eceddd23b122287c2513398ff96e551034053c48a52bbbcb76da2422edc65e62af0c482999233a51397a66a452654e313bc1a7a59b306e6a128af05c080a0305ac70e2a3b55e41799e34ac06d91883086e98830879010b19ac2f20007300ea063c05dfaab87f069288b10852e1e2fa66c3465194aac9842f49b8443e5d8f5ed"; +const testLabel = "Swap On Zero V4"; // <= Name of the test +const testDirSuffix = "swap_on_zero_v4"; // <= directory to compare device snapshots to + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 5, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 5, // <= Define the number of steps for this test case and this device + }, +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, rawTxHex) +);