A quick refactoring together with a change in the transfers logic.
It seems this fixes multiple issues, including coherence between the total balance and the graph (which is the sum of the individual balance series).
Todo:
[x] Fix spread issue.
[x] Check for bugs on key DAO addresses.
[x] The ERC20.balance_usd value is defined from Covalent portfolio_v2, whereas our Balances objects calculate the USD balance themselves based on the token balance and the token USD quote for each day. This introduces some discrepancy between Treasury.usd_total and the UI graph which is based on the Balances objects. We should maybe remove the ERC20.balance_usd altogether (to be added to an issue).
[x] List improvements from this PR:
Prevents negative values in plotted graphs.
[x] Next step: paginate through Covalent transfers_v2 results.
I believe an important next step is to move the balance series (today in the Balances object) inside of the Treasury object, so that Treasury is the only maintainer of the dict mapping between token symbols and values. This way, no place for any incoherence between balance series and treasury structure.
Then later, I believe we should remove the BalancesAtTransfers struct and replace it with a Transfers struct which holds a sparse series containing only transfers with amounts (deltas in token value). We should start properly bookkeeping the transfers themselves, as transfers a more fundamental data points than balances, and will allow refining our backtesting features.
A quick refactoring together with a change in the transfers logic.
It seems this fixes multiple issues, including coherence between the total balance and the graph (which is the sum of the individual balance series).
Todo:
ERC20.balance_usd
value is defined from Covalentportfolio_v2
, whereas ourBalances
objects calculate the USD balance themselves based on the token balance and the token USD quote for each day. This introduces some discrepancy betweenTreasury.usd_total
and the UI graph which is based on theBalances
objects. We should maybe remove theERC20.balance_usd
altogether (to be added to an issue).I believe an important next step is to move the balance series (today in the
Balances
object) inside of theTreasury
object, so thatTreasury
is the only maintainer of the dict mapping between token symbols and values. This way, no place for any incoherence between balance series and treasury structure.Then later, I believe we should remove the
BalancesAtTransfers
struct and replace it with aTransfers
struct which holds a sparse series containing only transfers with amounts (deltas in token value). We should start properly bookkeeping the transfers themselves, as transfers a more fundamental data points than balances, and will allow refining our backtesting features.