mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
fix: use sdk.Int when loading augmented cdp (#539)
This commit is contained in:
parent
4a8b5696cb
commit
aebb3093ff
@ -439,17 +439,10 @@ func (k Keeper) LoadAugmentedCDP(ctx sdk.Context, cdp types.CDP) types.Augmented
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return types.AugmentedCDP{CDP: cdp}
|
return types.AugmentedCDP{CDP: cdp}
|
||||||
}
|
}
|
||||||
|
|
||||||
// total debt is the sum of all outstanding principal and fees
|
|
||||||
var totalDebt int64
|
|
||||||
totalDebt += cdp.Principal.Amount.Int64()
|
|
||||||
totalDebt += cdp.AccumulatedFees.Amount.Int64()
|
|
||||||
|
|
||||||
// convert collateral value to debt coin
|
// convert collateral value to debt coin
|
||||||
debtBaseAdjusted := sdk.NewDec(totalDebt).QuoInt64(BaseDigitFactor)
|
totalDebt := cdp.Principal.Amount.Add(cdp.AccumulatedFees.Amount)
|
||||||
collateralValueInDebtDenom := collateralizationRatio.Mul(debtBaseAdjusted)
|
collateralValueInDebtDenom := sdk.NewDecFromInt(totalDebt).Mul(collateralizationRatio)
|
||||||
collateralValueInDebt := sdk.NewInt64Coin(cdp.Principal.Denom, collateralValueInDebtDenom.Int64())
|
collateralValueInDebt := sdk.NewCoin(cdp.Principal.Denom, collateralValueInDebtDenom.RoundInt())
|
||||||
|
|
||||||
// create new augmuented cdp
|
// create new augmuented cdp
|
||||||
augmentedCDP := types.NewAugmentedCDP(cdp, collateralValueInDebt, collateralizationRatio)
|
augmentedCDP := types.NewAugmentedCDP(cdp, collateralValueInDebt, collateralizationRatio)
|
||||||
return augmentedCDP
|
return augmentedCDP
|
||||||
|
Loading…
Reference in New Issue
Block a user