Created initial wallet router analysis

This commit is contained in:
Samuel Hawksby-Robinson 2024-05-14 13:18:57 +01:00
parent ea9f161392
commit 8f333916c5
2 changed files with 61 additions and 1 deletions

View File

@ -1,4 +1,17 @@
# 2022-05-13 # 2024-05-14
## Scoping
- Wallet Router
- I've analysed the main components of the wallet router, see here:
- [wallet/router analysis](./analysis/wallet_router.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!
---
# 2024-05-13
## Scoping ## Scoping

47
analysis/wallet_router.md Normal file
View File

@ -0,0 +1,47 @@
# Constants and Types
- `EstimateUsername` and `EstimatePubKey` are used as placeholder data in estimation calculations.
- `SendType` is an enum that categorises the types of transaction that the router supports
- e.g. transfers, ENS (Ethereum Name Service) operations, purchasing stickers, etc.
# Utility Functions
- `IsCollectiblesTransfer()`: Checks if the transaction involves ERC721 or ERC1155 collectibles.
- `FetchPrices()`: Fetches current token prices from a market manager service.
- `FindToken()`: Finds a token within a given blockchain network, handling both ERC20 tokens and collectibles.
- `isAvailableBetween()`: Checks if a certain transaction type is permissible between two networks.
- `EstimateGas()`: Estimates the gas required for transactions such as ENS registrations or transfers.
# Structs
- `Node` and `Graph`
- Are used for constructing a graph of potential transaction paths, representing routes for transferring tokens across networks.
- `Path`
- Represents a transaction path including details like from/to networks, fees, and estimated costs.
- `Router`
- Manages routing of transactions using different bridges defined for various transaction types.
- **Functions:**
- `requireApproval()`
- Determines if token approval is required before executing a transaction over a bridge.
- `getBalance()` and `getERC1155Balance()`
- 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.
# Transaction Handling
- The code handles transactions through various bridges which abstract the different transaction types.
- e.g. simple transfers, ERC721, ERC1155, and cross-chain transfers.
- TODO need to explore down this route
- A method for calculating optimal transaction routes (`suggestedRoutes`) evaluates multiple paths, considering various factors like fees, token prices, and network constraints.
- TODO need to explore down this route
# Error Handling and Data Integrity
- There is significant error handling to ensure that only valid transactions are processed.
- For example, when finding tokens or fetching prices, errors lead to early termination with descriptive messages.
- Use of concurrency (`sync.Mutex`, `async.NewAtomicGroup`) suggests an approach of handling multiple transactions or operations concurrently.
- TODO need to explore more on this.
# Observations and Potential Improvements
- Error Reporting:
- Detailed errors and/or logging could help with debugging.
- Optimisation:
- The graph-building and route optimisation process could potentially be optimised for performance, especially when dealing with a large number of possible paths.
- Knapsack, mD Knapsack, Travelling Salesman
- TODO need to explore more on this.