Commit 4145d53e authored by vipwzw's avatar vipwzw

auto ci

parent 350814d5
......@@ -5,9 +5,10 @@
package executor
import (
"math"
"github.com/33cn/chain33/common/db/table"
"github.com/shopspring/decimal"
"math"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
......@@ -575,7 +576,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
// token精度转成精度8
valueReal := borrow.GetValue()
cfg := action.Collateralize.GetAPI().GetConfig()
if(cfg.IsDappFork(action.Collateralize.GetHeight(), pty.CollateralizeX, pty.ForkCollateralizePrecision)) {
if cfg.IsDappFork(action.Collateralize.GetHeight(), pty.CollateralizeX, pty.ForkCollateralizePrecision) {
precisionNum := int(math.Log10(float64(cfg.GetTokenPrecision())))
valueReal = decimal.NewFromInt(valueReal).Shift(int32(-precisionNum)).Shift(8).IntPart()
}
......@@ -586,7 +587,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
return nil, err
}
// bty精度8转成coins精度
if(cfg.IsDappFork(action.Collateralize.GetHeight(), pty.CollateralizeX, pty.ForkCollateralizePrecision)) {
if cfg.IsDappFork(action.Collateralize.GetHeight(), pty.CollateralizeX, pty.ForkCollateralizePrecision) {
precisionNum := int(math.Log10(float64(cfg.GetCoinPrecision())))
btyFrozen = decimal.NewFromInt(btyFrozen).Shift(-8).Shift(int32(precisionNum)).IntPart()
}
......@@ -699,14 +700,14 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
// token精度转成精度8
cfg := action.Collateralize.GetAPI().GetConfig()
valueReal := borrowRecord.DebtValue
if(cfg.IsDappFork(action.Collateralize.GetHeight(), pty.CollateralizeX, pty.ForkCollateralizePrecision)) {
if cfg.IsDappFork(action.Collateralize.GetHeight(), pty.CollateralizeX, pty.ForkCollateralizePrecision) {
precisionNum := int(math.Log10(float64(cfg.GetTokenPrecision())))
valueReal = decimal.NewFromInt(valueReal).Shift(int32(-precisionNum)).Shift(8).IntPart()
}
// 借贷金额+利息
fee := ((valueReal * coll.StabilityFeeRatio) / 1e8) * 1e4
// 精度8转成token精度
if(cfg.IsDappFork(action.Collateralize.GetHeight(), pty.CollateralizeX, pty.ForkCollateralizePrecision)) {
if cfg.IsDappFork(action.Collateralize.GetHeight(), pty.CollateralizeX, pty.ForkCollateralizePrecision) {
precisionNum := int(math.Log10(float64(cfg.GetTokenPrecision())))
fee = decimal.NewFromInt(fee).Shift(-8).Shift(int32(precisionNum)).IntPart()
}
......@@ -847,7 +848,7 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty
cfg := action.Collateralize.GetAPI().GetConfig()
debtValueReal := borrowRecord.DebtValue
collateralValueReal := borrowRecord.CollateralValue
if(cfg.IsDappFork(action.Collateralize.GetHeight(), pty.CollateralizeX, pty.ForkCollateralizePrecision)) {
if cfg.IsDappFork(action.Collateralize.GetHeight(), pty.CollateralizeX, pty.ForkCollateralizePrecision) {
precisionNum := int(math.Log10(float64(cfg.GetTokenPrecision())))
debtValueReal = decimal.NewFromInt(debtValueReal).Shift(int32(-precisionNum)).Shift(8).IntPart()
collateralValueReal = decimal.NewFromInt(collateralValueReal).Shift(int32(-precisionNum)).Shift(8).IntPart()
......
......@@ -5,6 +5,8 @@
package executor
import (
"math"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
dbm "github.com/33cn/chain33/common/db"
......@@ -14,7 +16,6 @@ import (
pty "github.com/33cn/plugin/plugin/dapp/issuance/types"
tokenE "github.com/33cn/plugin/plugin/dapp/token/executor"
"github.com/shopspring/decimal"
"math"
)
// List control
......@@ -542,7 +543,7 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
// 先将token由token精度转成精度8
valueReal := debt.GetValue()
cfg := action.Issuance.GetAPI().GetConfig()
if(cfg.IsDappFork(action.Issuance.GetHeight(), pty.IssuanceX, pty.ForkIssuancePrecision)) {
if cfg.IsDappFork(action.Issuance.GetHeight(), pty.IssuanceX, pty.ForkIssuancePrecision) {
precisionNum := int(math.Log10(float64(cfg.GetTokenPrecision())))
valueReal = decimal.NewFromInt(valueReal).Shift(int32(-precisionNum)).Shift(8).IntPart()
}
......@@ -553,7 +554,7 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
return nil, err
}
// 再将bty由精度8转成coins精度
if(cfg.IsDappFork(action.Issuance.GetHeight(), pty.IssuanceX, pty.ForkIssuancePrecision)) {
if cfg.IsDappFork(action.Issuance.GetHeight(), pty.IssuanceX, pty.ForkIssuancePrecision) {
precisionNum := int(math.Log10(float64(cfg.GetCoinPrecision())))
btyFrozen = decimal.NewFromInt(btyFrozen).Shift(-8).Shift(int32(precisionNum)).IntPart()
}
......
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