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
c0128c37
Commit
c0128c37
authored
Dec 26, 2019
by
pengjun
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/jpeng-go/plugin
parents
2a594640
5f334a26
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
8 additions
and
8 deletions
+8
-8
collateralizedb.go
plugin/dapp/collateralize/executor/collateralizedb.go
+4
-4
collateralize.go
plugin/dapp/collateralize/types/collateralize.go
+2
-2
collateralize.pb.go
plugin/dapp/collateralize/types/collateralize.pb.go
+0
-0
issuancedb.go
plugin/dapp/issuance/executor/issuancedb.go
+1
-1
issuance.go
plugin/dapp/issuance/types/issuance.go
+1
-1
issuance.pb.go
plugin/dapp/issuance/types/issuance.pb.go
+0
-0
No files found.
plugin/dapp/collateralize/executor/collateralizedb.go
View file @
c0128c37
...
...
@@ -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
// 检查
...
...
plugin/dapp/collateralize/types/collateralize.go
View file @
c0128c37
...
...
@@ -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
,
}
...
...
plugin/dapp/collateralize/types/collateralize.pb.go
View file @
c0128c37
This diff is collapsed.
Click to expand it.
plugin/dapp/issuance/executor/issuancedb.go
View file @
c0128c37
...
...
@@ -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
...
...
plugin/dapp/issuance/types/issuance.go
View file @
c0128c37
...
...
@@ -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
{
...
...
plugin/dapp/issuance/types/issuance.pb.go
View file @
c0128c37
This diff is collapsed.
Click to expand it.
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