mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-25 07:45:18 +00:00
CDP Querier: update AugmentedCDP's FeesUpdated and InterestFactor (#860)
* update CDP's FeesUpdated and InterestFactor * remove newline
This commit is contained in:
parent
5a571f1384
commit
12f5a67d6d
@ -497,6 +497,15 @@ func (k Keeper) LoadAugmentedCDP(ctx sdk.Context, cdp types.CDP) types.Augmented
|
||||
// sync the latest interest of the cdp
|
||||
interestAccumulated := k.CalculateNewInterest(ctx, cdp)
|
||||
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
|
||||
collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, cdp.Collateral, cdp.Type, cdp.Principal, cdp.AccumulatedFees, liquidation)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user