novasamatech/subquery-history

Fee calculation

Closed this issue · 0 comments

Previous approach for fee calculation took sum of the amount values from the events balances.Deposit and treasury.Deposit. This approach is indirect and makes assumption that fee for transaction processing is distributed between block author and treasury. However there are corner cases: it can be multiple balances.Deposit events and also it can be imbalance which also contributes to treasury.Deposit.

New approach should you recently introduced balances.Withdraw event but also should have fallback for previous approach to support old blocks. So the algorithm is the following:

  1. If extrinsic contains balances.Withdraw event with who parameters matching extrinsic sender then extract amount parameter as a fee, otherwise go to step 2.
  2. Take last balances.Deposit and treasury.Deposit events and use their amounts sum as fee

To test check these extrinsics:

  1. Extrinsic with balances.Withdrawn and multiple balances.Deposit

  2. Block with only balances.Deposit

  3. Extrinsic with balances.Deposit and treasury.Deposit