Commit 4145d53e authored by vipwzw's avatar vipwzw

auto ci

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