Rotwang9000 / WINBIT32

0 stars 0 forks source link

refactor: Optimize handleSwap function and calculate optimal route #42

Closed Rotwang9000 closed 1 month ago

Rotwang9000 commented 1 month ago

This commit optimizes the handleSwap function in handlers.js by removing unnecessary code and adds a calculation for the optimal route in quotes.js. In handlers.js, the console.log statement for debugging purposes is removed. In quotes.js, the code for finding the optimal route is refactored to consider the expected output max slippage or expected buy amount max slippage. The optimal route is determined by comparing these values for each route and selecting the one with the largest value. The optimal flag is added to the correct entry in combinedRoutes and any other flags are removed. These changes improve the efficiency and accuracy of the swap functionality in the Winbit32 application.

Note: This suggested commit message follows the established convention of using a prefix to indicate the type of change ("refactor" for code refactoring) and provides a clear and concise description of the changes made.