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
4145d53e
Commit
4145d53e
authored
Dec 03, 2021
by
vipwzw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto ci
parent
350814d5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
12 deletions
+14
-12
collateralizedb.go
plugin/dapp/collateralize/executor/collateralizedb.go
+8
-7
types.go
plugin/dapp/collateralize/types/types.go
+1
-1
issuancedb.go
plugin/dapp/issuance/executor/issuancedb.go
+4
-3
types.go
plugin/dapp/issuance/types/types.go
+1
-1
No files found.
plugin/dapp/collateralize/executor/collateralizedb.go
View file @
4145d53e
...
@@ -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
()
...
...
plugin/dapp/collateralize/types/types.go
View file @
4145d53e
...
@@ -56,5 +56,5 @@ const (
...
@@ -56,5 +56,5 @@ const (
//fork ...
//fork ...
var
(
var
(
ForkCollateralizeTableUpdate
=
"ForkCollateralizeTableUpdate"
ForkCollateralizeTableUpdate
=
"ForkCollateralizeTableUpdate"
ForkCollateralizePrecision
=
"ForkCollateralizePrecision"
ForkCollateralizePrecision
=
"ForkCollateralizePrecision"
)
)
plugin/dapp/issuance/executor/issuancedb.go
View file @
4145d53e
...
@@ -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
()
}
}
...
...
plugin/dapp/issuance/types/types.go
View file @
4145d53e
...
@@ -55,5 +55,5 @@ const (
...
@@ -55,5 +55,5 @@ const (
//fork ...
//fork ...
var
(
var
(
ForkIssuanceTableUpdate
=
"ForkIssuanceTableUpdate"
ForkIssuanceTableUpdate
=
"ForkIssuanceTableUpdate"
ForkIssuancePrecision
=
"ForkIssuancePrecision"
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