diff --git a/apps/shared/loan_entity.py b/apps/shared/loan_entity.py index 7fdd3c06..0ca62e4f 100644 --- a/apps/shared/loan_entity.py +++ b/apps/shared/loan_entity.py @@ -45,14 +45,12 @@ def compute_collateral_usd( return sum( float(token_amount) / (10 ** collateral_token_parameters[token].decimals) - * ( - collateral_token_parameters[token].collateral_factor - if risk_adjusted - else 1.0 - ) - * float(collateral_interest_rate_model[token]) - * prices[collateral_token_parameters[token].underlying_address] - for token, token_amount in self.collateral.items() + * (collateral_token_parameters[token].collateral_factor if risk_adjusted else 1.0) + * float(collateral_interest_rate_model.get(token, 1.0)) + * prices[underlying_address] + for token, token_amount in self.collateral.values.items() + if (underlying_address := collateral_token_parameters[token].underlying_address) + in prices ) def compute_debt_usd( @@ -74,9 +72,10 @@ def compute_debt_usd( float(token_amount) / (10 ** debt_token_parameters[token].decimals) / (debt_token_parameters[token].debt_factor if risk_adjusted else 1.0) - * float(debt_interest_rate_model[token]) - * prices[debt_token_parameters[token].underlying_address] - for token, token_amount in self.debt.items() + * float(debt_interest_rate_model.get(token, 1.0)) + * prices[underlying_address] + for token, token_amount in self.debt.values.items() + if (underlying_address := debt_token_parameters[token].underlying_address) in prices ) @abstractmethod