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
fd703948
Commit
fd703948
authored
Oct 16, 2019
by
pengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#627 删除清算罚金;增加借贷超时时间和超时清算
parent
c9fbaf73
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
174 additions
and
63 deletions
+174
-63
collateralize.go
plugin/dapp/collateralize/executor/collateralize.go
+14
-0
collateralizedb.go
plugin/dapp/collateralize/executor/collateralizedb.go
+127
-36
query.go
plugin/dapp/collateralize/executor/query.go
+14
-5
collateralize.proto
plugin/dapp/collateralize/proto/collateralize.proto
+16
-19
collateralize.go
plugin/dapp/collateralize/types/collateralize.go
+0
-1
collateralize.pb.go
plugin/dapp/collateralize/types/collateralize.pb.go
+0
-0
tx.go
plugin/dapp/collateralize/types/tx.go
+1
-2
types.go
plugin/dapp/collateralize/types/types.go
+2
-0
No files found.
plugin/dapp/collateralize/executor/collateralize.go
View file @
fd703948
...
...
@@ -139,4 +139,17 @@ func (c *Collateralize) deleteCollateralizeRecordStatus(collateralizelog *pty.Re
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
}
kvs
=
append
(
kvs
,
kv
)
return
kvs
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func
(
c
*
Collateralize
)
CheckReceiptExecOk
()
bool
{
return
true
}
// ExecutorOrder 设置localdb的EnableRead
func
(
c
*
Collateralize
)
ExecutorOrder
()
int64
{
if
types
.
IsFork
(
c
.
GetHeight
(),
"ForkLocalDBAccess"
)
{
return
drivers
.
ExecLocalSameTime
}
return
c
.
DriverBase
.
ExecutorOrder
()
}
\ No newline at end of file
plugin/dapp/collateralize/executor/collateralizedb.go
View file @
fd703948
This diff is collapsed.
Click to expand it.
plugin/dapp/collateralize/executor/query.go
View file @
fd703948
...
...
@@ -21,7 +21,6 @@ func (c *Collateralize) Query_CollateralizeInfoByID(req *pty.ReqCollateralizeInf
TotalBalance
:
coll
.
TotalBalance
,
DebtCeiling
:
coll
.
DebtCeiling
,
LiquidationRatio
:
coll
.
LiquidationRatio
,
LiquidationPenalty
:
coll
.
LiquidationPenalty
,
StabilityFee
:
coll
.
StabilityFee
,
CreateAddr
:
coll
.
CreateAddr
,
Balance
:
coll
.
Balance
,
...
...
@@ -42,7 +41,6 @@ func (c *Collateralize) Query_CollateralizeInfoByIDs(req *pty.ReqCollateralizeIn
TotalBalance
:
coll
.
TotalBalance
,
DebtCeiling
:
coll
.
DebtCeiling
,
LiquidationRatio
:
coll
.
LiquidationRatio
,
LiquidationPenalty
:
coll
.
LiquidationPenalty
,
StabilityFee
:
coll
.
StabilityFee
,
CreateAddr
:
coll
.
CreateAddr
,
Balance
:
coll
.
Balance
,
...
...
@@ -89,6 +87,7 @@ func (c *Collateralize) Query_CollateralizeBorrowInfoByAddr(req *pty.ReqCollater
return
nil
,
err
}
ret
:=
&
pty
.
RepCollateralizeBorrowInfos
{}
for
_
,
record
:=
range
records
{
if
record
.
CollateralizeId
==
req
.
CollateralizeId
{
coll
,
err
:=
queryCollateralizeByID
(
c
.
GetStateDB
(),
record
.
CollateralizeId
)
...
...
@@ -99,9 +98,13 @@ func (c *Collateralize) Query_CollateralizeBorrowInfoByAddr(req *pty.ReqCollater
for
_
,
borrowRecord
:=
range
coll
.
BorrowRecords
{
if
borrowRecord
.
AccountAddr
==
req
.
Addr
{
ret
:=
&
pty
.
RepCollateralizeBorrowInfo
{}
ret
.
Record
=
borrowRecord
return
ret
,
nil
ret
.
Record
=
append
(
ret
.
Record
,
borrowRecord
)
}
}
for
_
,
borrowRecord
:=
range
coll
.
InvalidRecords
{
if
borrowRecord
.
AccountAddr
==
req
.
Addr
{
ret
.
Record
=
append
(
ret
.
Record
,
borrowRecord
)
}
}
}
...
...
@@ -130,6 +133,12 @@ func (c *Collateralize) Query_CollateralizeBorrowInfoByStatus(req *pty.ReqCollat
ret
.
Record
=
append
(
ret
.
Record
,
borrowRecord
)
}
}
for
_
,
borrowRecord
:=
range
coll
.
InvalidRecords
{
if
borrowRecord
.
Status
==
req
.
Status
{
ret
.
Record
=
append
(
ret
.
Record
,
borrowRecord
)
}
}
}
return
ret
,
nil
...
...
plugin/dapp/collateralize/proto/collateralize.proto
View file @
fd703948
...
...
@@ -4,18 +4,20 @@ package types;
// 借贷信息
message
Collateralize
{
string
collateralizeId
=
1
;
//借贷ID,一期借贷对应一个ID
int64
totalBalance
=
2
;
//当期可借贷的总金额(ccny)
int64
debtCeiling
=
3
;
//单用户可借出的限额(ccny)
float
liquidationRatio
=
4
;
//清算比例
int64
stabilityFee
=
5
;
//稳定费
int64
liquidationPenalty
=
6
;
//清算罚金
string
createAddr
=
7
;
//创建人地址
int64
balance
=
8
;
//剩余可借贷金额(ccny)
repeated
BorrowRecord
borrowRecords
=
9
;
//借贷记录
int32
status
=
10
;
//当期借贷的状态,是否关闭
int32
collType
=
11
;
//质押资产类型(1,bty,2,btc,3,eth...)
float
latestLiquidationPrice
=
12
;
//最大清算价格
string
collateralizeId
=
1
;
//借贷ID,一期借贷对应一个ID
int64
totalBalance
=
2
;
//当期可借贷的总金额(ccny)
int64
debtCeiling
=
3
;
//单用户可借出的限额(ccny)
float
liquidationRatio
=
4
;
//清算比例
int64
stabilityFee
=
5
;
//稳定费
string
createAddr
=
6
;
//创建人地址
int64
balance
=
7
;
//剩余可借贷金额(ccny)
repeated
BorrowRecord
borrowRecords
=
8
;
//借贷记录
repeated
BorrowRecord
InvalidRecords
=
9
;
//失效的借贷记录
int32
status
=
10
;
//当期借贷的状态,是否关闭
int32
collType
=
11
;
//质押资产类型(1,bty,2,btc,3,eth...)
float
latestLiquidationPrice
=
12
;
//最高清算价格
int64
period
=
13
;
//借贷最大期限
int64
latestExpireTime
=
14
;
//最近超期时间
}
// 借出记录
...
...
@@ -28,6 +30,7 @@ message BorrowRecord {
float
liquidationPrice
=
6
;
//抵押物清算价格
int32
status
=
7
;
//抵押状态,是否被清算
int64
liquidateTime
=
8
;
//清算时间
int64
expireTime
=
9
;
//超时清算时间
}
// 资产价格记录
...
...
@@ -57,8 +60,7 @@ message CollateralizeCreate {
int64
debtCeiling
=
1
;
//单用户可借出的限额(ccny)
float
liquidationRatio
=
2
;
//清算比例
int64
stabilityFee
=
3
;
//稳定费
int64
liquidationPenalty
=
4
;
//清算罚金
int64
totalBalance
=
5
;
//可借贷总金额
int64
totalBalance
=
4
;
//可借贷总金额
}
// 质押借出
...
...
@@ -162,11 +164,6 @@ message ReqCollateralizeBorrowInfoByAddr {
string
addr
=
2
;
}
// 返回借贷记录
message
RepCollateralizeBorrowInfo
{
BorrowRecord
record
=
1
;
}
// 根据状态和借贷ID混合查询具体借贷记录
message
ReqCollateralizeBorrowInfoByStatus
{
string
collateralizeId
=
1
;
...
...
plugin/dapp/collateralize/types/collateralize.go
View file @
fd703948
...
...
@@ -137,7 +137,6 @@ func CreateRawCollateralizeCreateTx(parm *CollateralizeCreateTx) (*types.Transac
DebtCeiling
:
parm
.
DebtCeiling
,
LiquidationRatio
:
parm
.
LiquidationRatio
,
StabilityFee
:
parm
.
StabilityFee
,
LiquidationPenalty
:
parm
.
LiquidationPenalty
,
TotalBalance
:
parm
.
TotalBalance
,
}
create
:=
&
CollateralizeAction
{
...
...
plugin/dapp/collateralize/types/collateralize.pb.go
View file @
fd703948
This diff is collapsed.
Click to expand it.
plugin/dapp/collateralize/types/tx.go
View file @
fd703948
...
...
@@ -9,7 +9,6 @@ type CollateralizeCreateTx struct {
DebtCeiling
int64
`json:"debtCeiling"`
LiquidationRatio
float32
`json:"liquidationRatio"`
StabilityFee
int64
`json:"stabilityFee"`
LiquidationPenalty
int64
`json:"liquidationPenalty"`
TotalBalance
int64
`json:"totalBalance"`
Fee
int64
`json:"fee"`
}
...
...
@@ -37,7 +36,7 @@ type CollateralizeAppendTx struct {
// CollateralizeFeedTx for construction
type
CollateralizeFeedTx
struct
{
Price
[]
int64
`json:"price"`
Price
[]
float32
`json:"price"`
Volume
[]
int64
`json:"volume"`
Fee
int64
`json:"fee"`
}
...
...
plugin/dapp/collateralize/types/types.go
View file @
fd703948
...
...
@@ -45,5 +45,6 @@ const (
CollateralizeUserStatusCreate
=
1
+
iota
CollateralizeUserStatusWarning
CollateralizeUserStatusSystemLiquidate
CollateralizeUserStatusExpire
CollateralizeUserStatusClose
)
\ No newline at end of file
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