diff --git a/README.md b/README.md index 3c3c106..7412bfa 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ - I've analysed the main components of the wallet router, see here: - [wallet/Router file analysis](./analysis/wallet_router.md) - [wallet/Router struct usage](./analysis/wallet_router_usage.md) + - [wallet/Router `newSuggestedRoutes()`](./analysis/wallet_router_newSuggestedRoutes.md) ## Schedule - I raised an axe to the crew meetings, swung hard and true. Toppled and prostrate they settled motionless. Tonight we revel in the light of their embers! diff --git a/analysis/wallet_router.md b/analysis/wallet_router.md index 5374507..574a97d 100644 --- a/analysis/wallet_router.md +++ b/analysis/wallet_router.md @@ -25,6 +25,12 @@ - Fetch balance of ERC20 or ERC1155 tokens respectively. - `suggestedRoutes()` - Suggests possible transaction routes based on constraints like disabled or preferred chain IDs, and calculates fees and estimated transaction times. + - **Exclusive Utility Functions:** + - `containsNetworkChainID()` + - Determines if a specified blockchain network's Chain ID is present within a given list of Chain IDs + - `newSuggestedRoutes()` + - newSuggestedRoutes function is a crucial part of the route selection and optimization process routing transactions across potentially complex network paths. + - [Detailed Analysis of `newSuggestedRoutes()`](./wallet_router_newSuggestedRoutes.md) # Transaction Handling - The code handles transactions through various bridges which abstract the different transaction types. diff --git a/analysis/wallet_router_newSuggestedRoutes.md b/analysis/wallet_router_newSuggestedRoutes.md new file mode 100644 index 0000000..fd10ab3 --- /dev/null +++ b/analysis/wallet_router_newSuggestedRoutes.md @@ -0,0 +1,30 @@ +# `newSuggestedRoutes()` + +A constructor function used to create and initialize a struct that represents a collection of suggested routes for a cross-chain transaction. This function aggregates relevant data for each route to determine the best possible paths for a transaction. + +## Purpose and Role +The primary purpose of `newSuggestedRoutes` is to assemble a structured view of all potential transaction paths based on the criteria cost, speed, network preferences, and other operational parameters. + +### Aggregates Routes: +Collects and organises routes that meet given criteria. + +### Filters and Selects Routes: +Applies business logic or algorithms to select the most efficient or cost-effective routes. + +### Provides Contextual Data: +Enriches routes with additional data such as cost estimates, gas fees, and estimated transaction times. + +## Component Analysis +### `amountIn *big.Int` +The amount of tokens or currency to be transferred, influencing which paths are viable based on the maximum transferable amounts and balance restrictions. + +### `candidates []*Path` +A list of potential paths that have been pre-determined as possible routes for the transaction. + +### `fromLockedAmount map[uint64]*hexutil.Big` +A map indicating amounts locked or reserved on specific networks, possibly affecting the viability of certain paths. + +### `filterRoutes` and `findBest` +Helper functions that might be used within `newSuggestedRoutes` to filter out infeasible paths and then select the optimal path based on the criteria. These functions represent core logic for determining the best routes from a set of candidates. + +TODO Additional analysis is required for both of these.