CDP Querier: update AugmentedCDP's FeesUpdated and InterestFactor (#860)

* update CDP's FeesUpdated and InterestFactor

* remove newline
This commit is contained in:
Denali Marsh 2021-03-11 05:40:43 +01:00 committed by GitHub
parent 5a571f1384
commit 12f5a67d6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -497,6 +497,15 @@ func (k Keeper) LoadAugmentedCDP(ctx sdk.Context, cdp types.CDP) types.Augmented
// sync the latest interest of the cdp // sync the latest interest of the cdp
interestAccumulated := k.CalculateNewInterest(ctx, cdp) interestAccumulated := k.CalculateNewInterest(ctx, cdp)
cdp.AccumulatedFees = cdp.AccumulatedFees.Add(interestAccumulated) cdp.AccumulatedFees = cdp.AccumulatedFees.Add(interestAccumulated)
// update cdp fields to match synced accumulated fees
prevAccrualTime, found := k.GetPreviousAccrualTime(ctx, cdp.Type)
if found {
cdp.FeesUpdated = prevAccrualTime
}
globalInterestFactor, found := k.GetInterestFactor(ctx, cdp.Type)
if found {
cdp.InterestFactor = globalInterestFactor
}
// calculate collateralization ratio // calculate collateralization ratio
collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, cdp.Collateral, cdp.Type, cdp.Principal, cdp.AccumulatedFees, liquidation) collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, cdp.Collateral, cdp.Type, cdp.Principal, cdp.AccumulatedFees, liquidation)
if err != nil { if err != nil {