Questions on new blockchain Wallet Integration

Hi, I’m currently building a new wallet support for Binance Chain for Binance DEX integration.

I have few question regarding current code for Ethereum wallet on Hummingbot:

  1. What’s the difference between mock_wallet and web3_wallet?
  2. Why does it need the wallet backend and watcher, instead of just wrap over web3 functionalities in one file implementing the wallet_base?
  1. The mock_wallet is only there for backtesting, and it doesn’t connect to any actual blockchain network. The web3_wallet is an interface to Ethereum blockchains.

  2. The separation between web3 and web3 backend is for redundancy and reliability. Because public web3 wallets tend to be unreliable (at least when we were writing the wallet) - and high frequency trading requires reliable transactions - we want to give users a way to use multiple web3 nodes behind a wallet.

    The separation between web3 backend and watchers is just there to keep the web3 backend from becoming one huge mess of code. Our wallets are not just simple wrappers to web3 API but also processes / matches events from the blockchain. We’re separating the processing for each type of event into its own watcher class to keep things sane and organized.

When you’re writing a Binance DEX wallet… you can ask yourself these questions w.r.t. whether you should follow the same architectural design of the web3 wallet.

  1. Are Binance DEX nodes reliable enough for high frequency trading? If I can just connect to one Binance DEX node and it can work and keep working 24x7… then you don’t need to separate a Binance DEX wallet from a Binance DEX wallet backend. However, if that’s not the case and you need the redundancy… then you should follow the same design as the Web3 wallet / Web3 wallet backend.

  2. Do I expect a need to interact with many different types of events or smart contracts on Binance DEX? If it’s a yes and it causes your wallet / wallet backend’s code size to become enormous and hard to maintain… then you should separate them into watchers. If it’s a no - then you can probably just integrate them into your wallet / wallet backend class.

Hi @martin_kou, thanks for the explanation!

Especially for this one, it is really helpful ! :grinning: