Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
350814d5
Commit
350814d5
authored
Dec 03, 2021
by
pengjun
Committed by
vipwzw
Dec 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1024 collateralize和issuance合约支持coins可配精度
parent
c34694de
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
75 additions
and
12 deletions
+75
-12
chain33.para.toml
chain33.para.toml
+2
-0
chain33.para.toml.readme
chain33.para.toml.readme
+2
-0
go.mod
go.mod
+1
-0
collateralizedb.go
plugin/dapp/collateralize/executor/collateralizedb.go
+42
-3
collateralize.go
plugin/dapp/collateralize/types/collateralize.go
+6
-5
types.go
plugin/dapp/collateralize/types/types.go
+1
-0
issuancedb.go
plugin/dapp/issuance/executor/issuancedb.go
+16
-1
issuance.go
plugin/dapp/issuance/types/issuance.go
+4
-3
types.go
plugin/dapp/issuance/types/types.go
+1
-0
No files found.
chain33.para.toml
View file @
350814d5
...
@@ -393,10 +393,12 @@ Enable=0
...
@@ -393,10 +393,12 @@ Enable=0
[fork.sub.issuance]
[fork.sub.issuance]
Enable
=
0
Enable
=
0
ForkIssuanceTableUpdate
=
0
ForkIssuanceTableUpdate
=
0
ForkIssuancePrecision
=
0
[fork.sub.collateralize]
[fork.sub.collateralize]
Enable
=
0
Enable
=
0
ForkCollateralizeTableUpdate
=
0
ForkCollateralizeTableUpdate
=
0
ForkCollateralizePrecision
=
0
#对已有的平行链如果不是从0开始同步数据,需要设置这个kvmvccmavl的对应平行链高度的fork,如果从0开始同步,statehash会跟以前mavl的不同
#对已有的平行链如果不是从0开始同步数据,需要设置这个kvmvccmavl的对应平行链高度的fork,如果从0开始同步,statehash会跟以前mavl的不同
[fork.sub.store-kvmvccmavl]
[fork.sub.store-kvmvccmavl]
...
...
chain33.para.toml.readme
View file @
350814d5
...
@@ -394,10 +394,12 @@ Enable=0
...
@@ -394,10 +394,12 @@ Enable=0
[fork.sub.issuance]
[fork.sub.issuance]
Enable=0
Enable=0
ForkIssuanceTableUpdate=0
ForkIssuanceTableUpdate=0
ForkIssuancePrecision=0
[fork.sub.collateralize]
[fork.sub.collateralize]
Enable=0
Enable=0
ForkCollateralizeTableUpdate=0
ForkCollateralizeTableUpdate=0
ForkCollateralizePrecision=0
#对已有的平行链如果不是从0开始同步数据,需要设置这个kvmvccmavl的对应平行链高度的fork,如果从0开始同步,statehash会跟以前mavl的不同
#对已有的平行链如果不是从0开始同步数据,需要设置这个kvmvccmavl的对应平行链高度的fork,如果从0开始同步,statehash会跟以前mavl的不同
[fork.sub.store-kvmvccmavl]
[fork.sub.store-kvmvccmavl]
...
...
go.mod
View file @
350814d5
...
@@ -33,6 +33,7 @@ require (
...
@@ -33,6 +33,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/pkg/errors v0.9.1
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
github.com/rs/cors v1.7.0
github.com/rs/cors v1.7.0
github.com/shopspring/decimal v1.2.0
github.com/spf13/cobra v1.1.1
github.com/spf13/cobra v1.1.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.0
github.com/tjfoc/gmsm v1.3.2
github.com/tjfoc/gmsm v1.3.2
...
...
plugin/dapp/collateralize/executor/collateralizedb.go
View file @
350814d5
...
@@ -6,6 +6,8 @@ package executor
...
@@ -6,6 +6,8 @@ package executor
import
(
import
(
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/common/db/table"
"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"
...
@@ -569,12 +571,25 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
...
@@ -569,12 +571,25 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
return
nil
,
err
return
nil
,
err
}
}
// 精度转换 #1024
// token精度转成精度8
valueReal
:=
borrow
.
GetValue
()
cfg
:=
action
.
Collateralize
.
GetAPI
()
.
GetConfig
()
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
()
}
// 根据价格和需要借贷的金额,计算需要质押的抵押物数量
// 根据价格和需要借贷的金额,计算需要质押的抵押物数量
btyFrozen
,
err
:=
getBtyNumToFrozen
(
borrow
.
GetValue
()
,
lastPrice
,
coll
.
LiquidationRatio
)
btyFrozen
,
err
:=
getBtyNumToFrozen
(
valueReal
,
lastPrice
,
coll
.
LiquidationRatio
)
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"CollateralizeBorrow.getBtyNumToFrozen"
,
"CollID"
,
coll
.
CollateralizeId
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"error"
,
err
)
clog
.
Error
(
"CollateralizeBorrow.getBtyNumToFrozen"
,
"CollID"
,
coll
.
CollateralizeId
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"error"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
// bty精度8转成coins精度
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
()
}
// 检查抵押物账户余额
// 检查抵押物账户余额
if
!
action
.
CheckExecAccountBalance
(
action
.
fromaddr
,
btyFrozen
,
0
)
{
if
!
action
.
CheckExecAccountBalance
(
action
.
fromaddr
,
btyFrozen
,
0
)
{
...
@@ -680,8 +695,22 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
...
@@ -680,8 +695,22 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
return
nil
,
pty
.
ErrRecordNotExist
return
nil
,
pty
.
ErrRecordNotExist
}
}
// 精度转换 #1024
// token精度转成精度8
cfg
:=
action
.
Collateralize
.
GetAPI
()
.
GetConfig
()
valueReal
:=
borrowRecord
.
DebtValue
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
:=
((
borrowRecord
.
DebtValue
*
coll
.
StabilityFeeRatio
)
/
1e8
)
*
1e4
fee
:=
((
valueReal
*
coll
.
StabilityFeeRatio
)
/
1e8
)
*
1e4
// 精度8转成token精度
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
()
}
realRepay
:=
borrowRecord
.
DebtValue
+
fee
realRepay
:=
borrowRecord
.
DebtValue
+
fee
// 检查
// 检查
...
@@ -813,7 +842,17 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty
...
@@ -813,7 +842,17 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty
// 构造借出记录
// 构造借出记录
borrowRecord
.
CollateralValue
+=
cAppend
.
CollateralValue
borrowRecord
.
CollateralValue
+=
cAppend
.
CollateralValue
borrowRecord
.
CollateralPrice
=
lastPrice
borrowRecord
.
CollateralPrice
=
lastPrice
borrowRecord
.
LiquidationPrice
=
calcLiquidationPrice
(
borrowRecord
.
DebtValue
,
borrowRecord
.
CollateralValue
)
// 精度转换 #1024
cfg
:=
action
.
Collateralize
.
GetAPI
()
.
GetConfig
()
debtValueReal
:=
borrowRecord
.
DebtValue
collateralValueReal
:=
borrowRecord
.
CollateralValue
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
()
}
borrowRecord
.
LiquidationPrice
=
calcLiquidationPrice
(
debtValueReal
,
collateralValueReal
)
if
borrowRecord
.
LiquidationPrice
*
PriceWarningRate
<
lastPrice
{
if
borrowRecord
.
LiquidationPrice
*
PriceWarningRate
<
lastPrice
{
// 告警解除
// 告警解除
if
borrowRecord
.
Status
==
pty
.
CollateralizeUserStatusWarning
{
if
borrowRecord
.
Status
==
pty
.
CollateralizeUserStatusWarning
{
...
...
plugin/dapp/collateralize/types/collateralize.go
View file @
350814d5
...
@@ -30,6 +30,7 @@ func init() {
...
@@ -30,6 +30,7 @@ func init() {
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
cfg
.
RegisterDappFork
(
CollateralizeX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
CollateralizeX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
CollateralizeX
,
ForkCollateralizeTableUpdate
,
0
)
cfg
.
RegisterDappFork
(
CollateralizeX
,
ForkCollateralizeTableUpdate
,
0
)
cfg
.
RegisterDappFork
(
CollateralizeX
,
ForkCollateralizePrecision
,
0
)
}
}
//InitExecutor ...
//InitExecutor ...
...
@@ -157,7 +158,7 @@ func CreateRawCollateralizeCreateTx(cfg *types.Chain33Config, parm *Collateraliz
...
@@ -157,7 +158,7 @@ func CreateRawCollateralizeCreateTx(cfg *types.Chain33Config, parm *Collateraliz
llog
.
Error
(
"CreateRawCollateralizeCreateTx"
,
"parm"
,
parm
)
llog
.
Error
(
"CreateRawCollateralizeCreateTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
totalBalanceInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
TotalBalance
,
cfg
.
Get
Coi
nPrecision
())
totalBalanceInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
TotalBalance
,
cfg
.
Get
Toke
nPrecision
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.TotalBalance"
)
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.TotalBalance"
)
}
}
...
@@ -188,7 +189,7 @@ func CreateRawCollateralizeBorrowTx(cfg *types.Chain33Config, parm *Collateraliz
...
@@ -188,7 +189,7 @@ func CreateRawCollateralizeBorrowTx(cfg *types.Chain33Config, parm *Collateraliz
llog
.
Error
(
"CreateRawCollateralizeBorrowTx"
,
"parm"
,
parm
)
llog
.
Error
(
"CreateRawCollateralizeBorrowTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
valueInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
Value
,
cfg
.
Get
Coi
nPrecision
())
valueInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
Value
,
cfg
.
Get
Toke
nPrecision
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.Value"
)
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.Value"
)
}
}
...
@@ -315,7 +316,7 @@ func CreateRawCollateralizeRetrieveTx(cfg *types.Chain33Config, parm *Collateral
...
@@ -315,7 +316,7 @@ func CreateRawCollateralizeRetrieveTx(cfg *types.Chain33Config, parm *Collateral
llog
.
Error
(
"CreateRawCollateralizeCloseTx"
,
"parm"
,
parm
)
llog
.
Error
(
"CreateRawCollateralizeCloseTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
balanceInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
Balance
,
cfg
.
Get
Coi
nPrecision
())
balanceInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
Balance
,
cfg
.
Get
Toke
nPrecision
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.Balance"
)
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.Balance"
)
}
}
...
@@ -348,11 +349,11 @@ func CreateRawCollateralizeManageTx(cfg *types.Chain33Config, parm *Collateraliz
...
@@ -348,11 +349,11 @@ func CreateRawCollateralizeManageTx(cfg *types.Chain33Config, parm *Collateraliz
llog
.
Error
(
"CreateRawCollateralizeManageTx"
,
"parm"
,
parm
)
llog
.
Error
(
"CreateRawCollateralizeManageTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
totalBalanceInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
TotalBalance
,
cfg
.
Get
Coi
nPrecision
())
totalBalanceInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
TotalBalance
,
cfg
.
Get
Toke
nPrecision
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.totalBalance"
)
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.totalBalance"
)
}
}
debtCeilingInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
DebtCeiling
,
cfg
.
Get
Coi
nPrecision
())
debtCeilingInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
DebtCeiling
,
cfg
.
Get
Toke
nPrecision
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.DebtCeiling"
)
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.DebtCeiling"
)
}
}
...
...
plugin/dapp/collateralize/types/types.go
View file @
350814d5
...
@@ -56,4 +56,5 @@ const (
...
@@ -56,4 +56,5 @@ const (
//fork ...
//fork ...
var
(
var
(
ForkCollateralizeTableUpdate
=
"ForkCollateralizeTableUpdate"
ForkCollateralizeTableUpdate
=
"ForkCollateralizeTableUpdate"
ForkCollateralizePrecision
=
"ForkCollateralizePrecision"
)
)
plugin/dapp/issuance/executor/issuancedb.go
View file @
350814d5
...
@@ -13,6 +13,8 @@ import (
...
@@ -13,6 +13,8 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
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"
"math"
)
)
// List control
// List control
...
@@ -536,12 +538,25 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
...
@@ -536,12 +538,25 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
return
nil
,
err
return
nil
,
err
}
}
// 精度转换 #1024
// 先将token由token精度转成精度8
valueReal
:=
debt
.
GetValue
()
cfg
:=
action
.
Issuance
.
GetAPI
()
.
GetConfig
()
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
()
}
// 根据价格和需要借贷的金额,计算需要质押的抵押物数量
// 根据价格和需要借贷的金额,计算需要质押的抵押物数量
btyFrozen
,
err
:=
getBtyNumToFrozen
(
debt
.
Value
,
lastPrice
,
issu
.
LiquidationRatio
)
btyFrozen
,
err
:=
getBtyNumToFrozen
(
valueReal
,
lastPrice
,
issu
.
LiquidationRatio
)
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"IssuanceDebt.getBtyNumToFrozen"
,
"CollID"
,
issu
.
IssuanceId
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"error"
,
err
)
clog
.
Error
(
"IssuanceDebt.getBtyNumToFrozen"
,
"CollID"
,
issu
.
IssuanceId
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"error"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
// 再将bty由精度8转成coins精度
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
()
}
// 检查抵押物账户余额
// 检查抵押物账户余额
if
!
action
.
CheckExecAccountBalance
(
action
.
fromaddr
,
btyFrozen
,
0
)
{
if
!
action
.
CheckExecAccountBalance
(
action
.
fromaddr
,
btyFrozen
,
0
)
{
...
...
plugin/dapp/issuance/types/issuance.go
View file @
350814d5
...
@@ -30,6 +30,7 @@ func init() {
...
@@ -30,6 +30,7 @@ func init() {
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
cfg
.
RegisterDappFork
(
IssuanceX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
IssuanceX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
IssuanceX
,
ForkIssuanceTableUpdate
,
0
)
cfg
.
RegisterDappFork
(
IssuanceX
,
ForkIssuanceTableUpdate
,
0
)
cfg
.
RegisterDappFork
(
IssuanceX
,
ForkIssuancePrecision
,
0
)
}
}
//InitExecutor ...
//InitExecutor ...
...
@@ -148,11 +149,11 @@ func CreateRawIssuanceCreateTx(cfg *types.Chain33Config, parm *IssuanceCreateTx)
...
@@ -148,11 +149,11 @@ func CreateRawIssuanceCreateTx(cfg *types.Chain33Config, parm *IssuanceCreateTx)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
totalBalanceInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
TotalBalance
,
cfg
.
Get
Coi
nPrecision
())
totalBalanceInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
TotalBalance
,
cfg
.
Get
Toke
nPrecision
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.totalBalance"
)
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.totalBalance"
)
}
}
debtCeilingInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
DebtCeiling
,
cfg
.
Get
Coi
nPrecision
())
debtCeilingInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
DebtCeiling
,
cfg
.
Get
Toke
nPrecision
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.DebtCeiling"
)
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.DebtCeiling"
)
}
}
...
@@ -187,7 +188,7 @@ func CreateRawIssuanceDebtTx(cfg *types.Chain33Config, parm *IssuanceDebtTx) (*t
...
@@ -187,7 +188,7 @@ func CreateRawIssuanceDebtTx(cfg *types.Chain33Config, parm *IssuanceDebtTx) (*t
llog
.
Error
(
"CreateRawIssuanceBorrowTx"
,
"parm"
,
parm
)
llog
.
Error
(
"CreateRawIssuanceBorrowTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
valueInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
Value
,
cfg
.
Get
Coi
nPrecision
())
valueInt64
,
err
:=
types
.
FormatFloatDisplay2Value
(
parm
.
Value
,
cfg
.
Get
Toke
nPrecision
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.Value"
)
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"FormatFloatDisplay2Value.Value"
)
}
}
...
...
plugin/dapp/issuance/types/types.go
View file @
350814d5
...
@@ -55,4 +55,5 @@ const (
...
@@ -55,4 +55,5 @@ const (
//fork ...
//fork ...
var
(
var
(
ForkIssuanceTableUpdate
=
"ForkIssuanceTableUpdate"
ForkIssuanceTableUpdate
=
"ForkIssuanceTableUpdate"
ForkIssuancePrecision
=
"ForkIssuancePrecision"
)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment