Fix: improve handling of missing data and simplify loan calculations #365
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes changes to improve the handling of missing data and simplify the codebase across multiple files. The most important changes include updating the calculation of collateral and debt statistics to handle missing interest rate models and simplifying the processing of loan entities.
Improvements to handling missing data:
apps/dashboard_app/helpers/protocol_stats.py
: Updated theget_collateral_stats
andget_debt_stats
functions to handle missing interest rate models by using default values. [1] [2]apps/legacy_app/src/helpers.py
: Added error logging in theget_prices
function to handle cases where token information is not found.Codebase simplification:
apps/legacy_app/src/state.py
: Simplified theset_loan_entities
method by removing unnecessary JSON decoding and directly using the loan entity data.apps/legacy_app/src/types.py
: Simplified thecompute_collateral_usd
andcompute_debt_usd
methods by using the walrus operator to handle underlying addresses and checking their presence in prices. [1] [2]apps/shared/loan_entity.py
: Updated thecompute_collateral_usd
andcompute_debt_usd
methods to handle missing interest rate models by using default values and simplified the processing of collateral and debt items. [1] [2]