💰Distributor
The distributor module is the initial piece of logic that executes upon running pandoras-box
. It is in charge of distributing funds (either network currency, or specific ERC20 tokens) to subaccounts involved in the stress test.
The fund distribution is always performed from the index 0 address (first address) derived from the specified mnemonic phrase. The fund address does not participate in the actual stress test, it is rather only used for distribution. Therefore, users should take care that this initial address has enough funds for distribution before performing the stress test.
The distributor goes through a pipeline to perform a fund distribution:
Calculate the base transaction cost - The base transaction cost is the cost of the actual raw transaction in native network currency for a single account to send out (taking into account the value of the transaction for specific modes, like EOA). The base transaction cost is calculated using the formula
cost = gasPrice * gasEstimate + value
Find accounts that require funds - From the chosen subaccount set, there can be accounts that are underfunded to perform the stress test. These accounts are marked for funding in the next step
Fund underfunded accounts - Accounts from step 2, if any, are topped off to the least required balance for performing the stress test
If the distributor cannot fund all the subaccounts for the stress test, it attempts to reduce the number of accounts involved in the stress test. Additionally, if the distributor cannot distribute enough funds to a single account, it reports an error to the user.
Value distributor
The value token distributor is in charge of distributing network currency to subaccounts, and relies on standard Ethereum JSON-RPC endpoints to query the balance and send funds.
The base logic for the value distributor is located in distributor.ts.
Token Distributor
The ERC20 token distributor is in charge of distributing ERC20 tokens to subaccounts, and requires a deployed ERC20 token for querying and transferring funds.
The base logic for the ERC20 distributor is located in tokenDistributor.ts.
The ERC20 token required for distribution is automatically deployed and available before the distribution takes place, upon running pandoras-box
.
Last updated