@@ -600,7 +600,7 @@ def get_block_balances(
600600 if existing_block < block :
601601 prev_block = existing_block
602602 start = existing_block + 1
603- account_bals = deepcopy (cast (Mapping [ChecksumAddress , Union [Decimal , float ]], cache_copy_of_account_bals [prev_block ]))
603+ account_bals = deepcopy (cast (Dict [ChecksumAddress , Union [Decimal , float ]], cache_copy_of_account_bals [prev_block ]))
604604 break
605605
606606 # Fetch pair config from self.start_block if not already done
@@ -708,6 +708,7 @@ def get_block_balances(
708708 # remaining reserves after end of epoch/term.
709709 amm_contract_function = self .amm_contract .functions .getReserves
710710 amm_pools = self .amm_balances_by_lp_token .values ()
711+ amm_pools_with_tc = [p for p in amm_pools if p .term_config is not None ]
711712 amm_calls = [
712713 (
713714 self .amm_contract ,
@@ -717,7 +718,7 @@ def get_block_balances(
717718 amm_pool .term_config .share_token_addr ,
718719 ],
719720 )
720- for amm_pool in amm_pools
721+ for amm_pool in amm_pools_with_tc
721722 ]
722723 multicall_results = multicall_by_address (
723724 wb3 = self .w3 ,
@@ -730,7 +731,7 @@ def get_block_balances(
730731 # - The `result[0]` is the total balance of the asset token in the AMM pool
731732 # - The `result[1]` is the total balance of the share token in the AMM pool
732733 for amm_pool , result in zip (
733- amm_pools , multicall_results
734+ amm_pools_with_tc , multicall_results
734735 ):
735736 # Update the total Ethena-asset and PSM-shares balance of each AMM pool
736737 amm_pool .total_assets = (result [0 ], result [1 ])
@@ -909,9 +910,9 @@ def get_block_balances(
909910 # attribute the Ethena asset balances to the respective LP token holders
910911 elif psm_pool .term_config is not None and account_addr == psm_pool .term_config .amm_pool_addr and amount :
911912 tc = psm_pool .term_config
912- lp_token_addr = tc .amm_lp_token_addr
913- if lp_token_addr is not None :
914- amm_pool = self .amm_balances_by_lp_token [lp_token_addr ]
913+ lp_addr = tc .amm_lp_token_addr
914+ if lp_addr is not None :
915+ amm_pool = self .amm_balances_by_lp_token [lp_addr ]
915916 amm_ta = cast (Tuple [int , int ], amm_pool .total_assets )
916917 # If there are other Uniswap V4 pools which manage PSM-shares,
917918 # the total amount of PSM-shares at the UniV4 PoolManager address
@@ -952,7 +953,7 @@ def get_block_balances(
952953 account_bals [account_addr ] = Decimal (bal ) + qty
953954 print (
954955 "LPT-LVT-holder:" ,
955- lp_token_addr , vault_share_token_addr , account_addr ,
956+ lp_addr , vault_share_token_addr , account_addr ,
956957 "start:" , bal ,
957958 "in:" , qty ,
958959 "end:" , account_bals [account_addr ]
@@ -966,7 +967,7 @@ def get_block_balances(
966967 )
967968 account_bals [account_addr ] = Decimal (bal ) + qty
968969 print (
969- "LPT-holder:" , lp_token_addr , account_addr ,
970+ "LPT-holder:" , lp_addr , account_addr ,
970971 "start:" , bal ,
971972 "in:" , qty ,
972973 "end:" , account_bals [account_addr ]
0 commit comments