Commit c0128c37 authored by pengjun's avatar pengjun

Merge branch 'master' of https://github.com/jpeng-go/plugin

parents 2a594640 5f334a26
......@@ -29,7 +29,7 @@ const (
Coin = types.Coin // 1e8
DefaultDebtCeiling = 10000 * Coin // 默认借贷限额
DefaultLiquidationRatio = 0.4 * 1e4 // 默认质押比
DefaultStabilityFeeRation = 0.08 * 1e4 // 默认稳定费
DefaultStabilityFeeRation = 0.08 * 1e4 // 默认稳定费
DefaultPeriod = 3600 * 24 * 365 // 默认合约限期
DefaultTotalBalance = 0 // 默认放贷总额
PriceWarningRate = 1.3 * 1e4 // 价格提前预警率
......@@ -475,7 +475,7 @@ func getBtyNumToFrozen(value int64, price int64, ratio int64) (int64, error) {
// 计算清算价格
// value:借出ccny数量, colValue:抵押物数量, price:抵押物价格
func calcLiquidationPrice(value int64, colValue int64) int64 {
return (value *pty.CollateralizePreLiquidationRatio) / colValue
return (value * pty.CollateralizePreLiquidationRatio) / colValue
}
// 获取最近抵押物价格
......@@ -615,7 +615,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
borrowRecord.StartTime = action.blocktime
borrowRecord.CollateralPrice = lastPrice
borrowRecord.DebtValue = borrow.GetValue()
borrowRecord.LiquidationPrice = (coll.LiquidationRatio*lastPrice*pty.CollateralizePreLiquidationRatio)/1e8
borrowRecord.LiquidationPrice = (coll.LiquidationRatio * lastPrice * pty.CollateralizePreLiquidationRatio) / 1e8
borrowRecord.Status = pty.CollateralizeUserStatusCreate
borrowRecord.ExpireTime = action.blocktime + coll.Period
......@@ -678,7 +678,7 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
}
// 借贷金额+利息
fee := (borrowRecord.DebtValue * coll.StabilityFeeRatio)/1e4
fee := (borrowRecord.DebtValue * coll.StabilityFeeRatio) / 1e4
realRepay := borrowRecord.DebtValue + fee
// 检查
......
......@@ -334,8 +334,8 @@ func CreateRawCollateralizeManageTx(cfg *types.Chain33Config, parm *Collateraliz
v := &CollateralizeManage{
DebtCeiling: int64(math.Trunc((parm.DebtCeiling+0.0000001)*1e4)) * 1e4,
LiquidationRatio: int64(math.Trunc((parm.LiquidationRatio+0.0000001)*1e4)),
StabilityFeeRatio: int64(math.Trunc((parm.StabilityFeeRatio+0.0000001)*1e4)),
LiquidationRatio: int64(math.Trunc((parm.LiquidationRatio + 0.0000001) * 1e4)),
StabilityFeeRatio: int64(math.Trunc((parm.StabilityFeeRatio + 0.0000001) * 1e4)),
Period: parm.Period,
TotalBalance: int64(math.Trunc((parm.TotalBalance+0.0000001)*1e4)) * 1e4,
}
......
......@@ -582,7 +582,7 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
debtRecord.StartTime = action.blocktime
debtRecord.CollateralPrice = lastPrice
debtRecord.DebtValue = debt.Value
debtRecord.LiquidationPrice = (issu.LiquidationRatio*lastPrice*pty.IssuancePreLiquidationRatio) / 1e8
debtRecord.LiquidationPrice = (issu.LiquidationRatio * lastPrice * pty.IssuancePreLiquidationRatio) / 1e8
debtRecord.Status = pty.IssuanceUserStatusCreate
debtRecord.ExpireTime = action.blocktime + issu.Period
......
......@@ -146,7 +146,7 @@ func CreateRawIssuanceCreateTx(cfg *types.Chain33Config, parm *IssuanceCreateTx)
v := &IssuanceCreate{
TotalBalance: int64(math.Trunc((parm.TotalBalance+0.0000001)*1e4)) * 1e4,
DebtCeiling: int64(math.Trunc((parm.DebtCeiling+0.0000001)*1e4)) * 1e4,
LiquidationRatio: int64(math.Trunc((parm.LiquidationRatio+0.0000001)*1e4)),
LiquidationRatio: int64(math.Trunc((parm.LiquidationRatio + 0.0000001) * 1e4)),
Period: parm.Period,
}
create := &IssuanceAction{
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment