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
b48db05f
Commit
b48db05f
authored
Nov 06, 2019
by
pengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#627 fix test error
parent
1330dd41
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
145 additions
and
50 deletions
+145
-50
cmd.go
plugin/dapp/collateralize/commands/cmd.go
+29
-3
collateralizedb.go
plugin/dapp/collateralize/executor/collateralizedb.go
+37
-13
exec_local.go
plugin/dapp/collateralize/executor/exec_local.go
+11
-11
query.go
plugin/dapp/collateralize/executor/query.go
+31
-5
collateralize.proto
plugin/dapp/collateralize/proto/collateralize.proto
+13
-0
collateralize.go
plugin/dapp/collateralize/types/collateralize.go
+1
-0
collateralize.pb.go
plugin/dapp/collateralize/types/collateralize.pb.go
+0
-0
tx.go
plugin/dapp/collateralize/types/tx.go
+1
-0
cmd.go
plugin/dapp/issuance/commands/cmd.go
+1
-0
exec_del_local.go
plugin/dapp/issuance/executor/exec_del_local.go
+8
-8
exec_local.go
plugin/dapp/issuance/executor/exec_local.go
+7
-7
issuancedb.go
plugin/dapp/issuance/executor/issuancedb.go
+3
-3
query.go
plugin/dapp/issuance/executor/query.go
+2
-0
issuance.proto
plugin/dapp/issuance/proto/issuance.proto
+1
-0
issuance.pb.go
plugin/dapp/issuance/types/issuance.pb.go
+0
-0
No files found.
plugin/dapp/collateralize/commands/cmd.go
View file @
b48db05f
...
...
@@ -285,6 +285,7 @@ func addCollateralizeManageFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
Float32P
(
"liquidationRatio"
,
"l"
,
0
,
"liquidationRatio"
)
cmd
.
Flags
()
.
Float32P
(
"stabilityFeeRatio"
,
"s"
,
0
,
"stabilityFeeRatio"
)
cmd
.
Flags
()
.
Uint64P
(
"period"
,
"p"
,
0
,
"period"
)
cmd
.
Flags
()
.
Uint64P
(
"totalBalance"
,
"t"
,
0
,
"totalBalance"
)
}
func
CollateralizeManage
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
@@ -299,12 +300,13 @@ func CollateralizeManage(cmd *cobra.Command, args []string) {
liquidationRatio
,
_
:=
cmd
.
Flags
()
.
GetFloat32
(
"liquidationRatio"
)
stabilityFeeRatio
,
_
:=
cmd
.
Flags
()
.
GetFloat32
(
"stabilityFeeRatio"
)
period
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"period"
)
totalBalance
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"totalBalance"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
cfg
.
ExecName
(
pkt
.
CollateralizeX
),
ActionName
:
"CollateralizeManage"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
debtCeiling
\"
:%d,
\"
liquidationRatio
\"
:%f,
\"
stabilityFeeRatio
\"
:%f,
\"
period
\"
:%d}"
,
debtCeiling
,
liquidationRatio
,
stabilityFeeRatio
,
period
)),
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
debtCeiling
\"
:%d,
\"
liquidationRatio
\"
:%f,
\"
stabilityFeeRatio
\"
:%f,
\"
period
\"
:%d
,
\"
totalBalance
\"
:%d,
}"
,
debtCeiling
,
liquidationRatio
,
stabilityFeeRatio
,
period
,
totalBalance
)),
}
var
res
string
...
...
@@ -312,6 +314,27 @@ func CollateralizeManage(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
}
func
CollateralizeQueryCfgCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"config"
,
Short
:
"Query config result"
,
Run
:
CollateralizeQueryConfig
,
}
return
cmd
}
func
CollateralizeQueryConfig
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
params
rpctypes
.
Query4Jrpc
params
.
Execer
=
pkt
.
CollateralizeX
params
.
FuncName
=
"CollateralizeConfig"
var
res
pkt
.
RepCollateralizeConfig
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
}
// CollateralizeQueryCmd 查询命令行
func
CollateralizeQueryCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
...
@@ -320,6 +343,9 @@ func CollateralizeQueryCmd() *cobra.Command {
Run
:
CollateralizeQuery
,
}
addCollateralizeQueryFlags
(
cmd
)
cmd
.
AddCommand
(
CollateralizeQueryCfgCmd
(),
)
return
cmd
}
...
...
@@ -437,7 +463,7 @@ func CollateralizeQuery(cmd *cobra.Command, args []string) {
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
}
else
{
fmt
.
Println
(
"Error: requeres at least one of
gameID
, address or status"
)
fmt
.
Println
(
"Error: requeres at least one of
collId
, address or status"
)
cmd
.
Help
()
}
}
plugin/dapp/collateralize/executor/collateralizedb.go
View file @
b48db05f
...
...
@@ -30,6 +30,7 @@ const (
DefaultLiquidationRatio
=
0.4
// 默认质押比
DefaultStabilityFeeRation
=
0.08
// 默认稳定费
DefaultPeriod
=
3600
*
24
*
365
// 默认合约限期
DefaultCollTotalBalance
=
0
// 默认放贷总额
PriceWarningRate
=
1.3
// 价格提前预警率
ExpireWarningTime
=
3600
*
24
*
10
// 提前10天超时预警
)
...
...
@@ -265,29 +266,46 @@ func (action *Action) CollateralizeManage(manage *pty.CollateralizeManage) (*typ
return
nil
,
pty
.
ErrRiskParam
}
collConfig
:=
&
pty
.
CollateralizeManage
{}
var
collConfig
*
pty
.
CollateralizeManage
manConfig
,
_
:=
getCollateralizeConfig
(
action
.
db
)
if
manConfig
==
nil
{
manConfig
=
&
pty
.
CollateralizeManage
{
DebtCeiling
:
DefaultDebtCeiling
,
LiquidationRatio
:
DefaultLiquidationRatio
,
StabilityFeeRatio
:
DefaultStabilityFeeRation
,
Period
:
DefaultPeriod
,
CollTotalBalance
:
DefaultCollTotalBalance
,
}
}
if
manage
.
StabilityFeeRatio
!=
0
{
collConfig
.
StabilityFeeRatio
=
manage
.
StabilityFeeRatio
}
else
{
collConfig
.
StabilityFeeRatio
=
DefaultStabilityFeeRation
collConfig
.
StabilityFeeRatio
=
manConfig
.
StabilityFeeRatio
}
if
manage
.
Period
!=
0
{
collConfig
.
Period
=
manage
.
Period
}
else
{
collConfig
.
Period
=
Default
Period
collConfig
.
Period
=
manConfig
.
Period
}
if
manage
.
LiquidationRatio
!=
0
{
collConfig
.
LiquidationRatio
=
manage
.
LiquidationRatio
}
else
{
collConfig
.
LiquidationRatio
=
Default
LiquidationRatio
collConfig
.
LiquidationRatio
=
manConfig
.
LiquidationRatio
}
if
manage
.
DebtCeiling
!=
0
{
collConfig
.
DebtCeiling
=
manage
.
DebtCeiling
}
else
{
collConfig
.
DebtCeiling
=
DefaultDebtCeiling
collConfig
.
DebtCeiling
=
manConfig
.
DebtCeiling
}
if
manage
.
CollTotalBalance
!=
0
{
collConfig
.
CollTotalBalance
=
manage
.
CollTotalBalance
}
else
{
collConfig
.
CollTotalBalance
=
manConfig
.
CollTotalBalance
}
value
:=
types
.
Encode
(
collConfig
)
...
...
@@ -298,8 +316,8 @@ func (action *Action) CollateralizeManage(manage *pty.CollateralizeManage) (*typ
return
receipt
,
nil
}
func
(
action
*
Action
)
getCollateralizeConfig
(
)
(
*
pty
.
CollateralizeManage
,
error
)
{
data
,
err
:=
action
.
db
.
Get
(
ConfigKey
())
func
getCollateralizeConfig
(
db
dbm
.
KV
)
(
*
pty
.
CollateralizeManage
,
error
)
{
data
,
err
:=
db
.
Get
(
ConfigKey
())
if
err
!=
nil
{
clog
.
Debug
(
"getCollateralizeConfig"
,
"error"
,
err
)
return
nil
,
err
...
...
@@ -375,9 +393,15 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ
// 获取借贷配置
var
collcfg
*
pty
.
CollateralizeManage
cfg
,
err
:=
action
.
getCollateralizeConfig
()
if
err
!=
nil
{
collcfg
=
&
pty
.
CollateralizeManage
{
DebtCeiling
:
DefaultDebtCeiling
,
LiquidationRatio
:
DefaultLiquidationRatio
,
StabilityFeeRatio
:
DefaultStabilityFeeRation
,
Period
:
DefaultPeriod
}
cfg
,
err
:=
getCollateralizeConfig
(
action
.
db
)
if
cfg
==
nil
{
collcfg
=
&
pty
.
CollateralizeManage
{
DebtCeiling
:
DefaultDebtCeiling
,
LiquidationRatio
:
DefaultLiquidationRatio
,
StabilityFeeRatio
:
DefaultStabilityFeeRation
,
Period
:
DefaultPeriod
,
CollTotalBalance
:
DefaultCollTotalBalance
,
}
}
else
{
collcfg
=
cfg
}
...
...
@@ -835,9 +859,9 @@ func (action *Action) systemLiquidation(coll *pty.Collateralize, price float32)
collDB
:=
&
CollateralizeDB
{
*
coll
}
for
index
,
borrowRecord
:=
range
coll
.
BorrowRecords
{
if
borrowRecord
.
LiquidationPrice
*
PriceWarningRate
<
price
{
if
borrowRecord
.
Status
==
pty
.
CollateralizeUserStatus
SystemLiquidate
{
borrowRecord
.
Status
=
borrowRecord
.
Pre
Status
borrowRecord
.
PreStatus
=
pty
.
CollateralizeUserStatusSystemLiquid
ate
if
borrowRecord
.
Status
==
pty
.
CollateralizeUserStatus
Warning
{
borrowRecord
.
PreStatus
=
borrowRecord
.
Status
borrowRecord
.
Status
=
pty
.
CollateralizeUserStatusCre
ate
}
continue
}
...
...
plugin/dapp/collateralize/executor/exec_local.go
View file @
b48db05f
...
...
@@ -37,32 +37,32 @@ func (c *Collateralize) execLocal(tx *types.Transaction, receipt *types.ReceiptD
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeRecordStatus
(
collateralizeLog
.
PreStatus
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeRecordStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
RecordId
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeRecordAddr
(
collateralizeLog
.
AccountAddr
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeRecordAddr
(
collateralizeLog
.
AccountAddr
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
RecordId
,
collateralizeLog
.
Index
)
...
)
//
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.PreIndex)...)
//
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
//
collateralizeLog.RecordId, collateralizeLog.Index)...)
}
break
case
pty
.
TyLogCollateralizeRepay
:
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeRecordStatus
(
collateralizeLog
.
PreStatus
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeRecordStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
RecordId
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeRecordAddr
(
collateralizeLog
.
AccountAddr
,
collateralizeLog
.
PreIndex
)
...
)
//
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.PreIndex)...)
break
case
pty
.
TyLogCollateralizeFeed
:
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeRecordStatus
(
collateralizeLog
.
PreStatus
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeRecordStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
RecordId
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeRecordAddr
(
collateralizeLog
.
AccountAddr
,
collateralizeLog
.
PreIndex
)
...
)
// 如果没有被清算,需要把地址索引更新
if
collateralizeLog
.
Status
==
pty
.
CollateralizeUserStatusWarning
||
collateralizeLog
.
Status
==
pty
.
CollateralizeUserStatusExpire
{
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeRecordAddr
(
collateralizeLog
.
AccountAddr
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
RecordId
,
collateralizeLog
.
Index
)
...
)
}
//
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.PreIndex)...)
//
//
如果没有被清算,需要把地址索引更新
//
if collateralizeLog.Status == pty.CollateralizeUserStatusWarning || collateralizeLog.Status == pty.CollateralizeUserStatusExpire {
//
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
//
collateralizeLog.RecordId, collateralizeLog.Index)...)
//
}
break
case
pty
.
TyLogCollateralizeClose
:
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeStatus
(
collateralizeLog
.
PreStatus
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeAddr
(
collateralizeLog
.
CreateAddr
,
collateralizeLog
.
PreIndex
)
...
)
//
set.KV = append(set.KV, c.deleteCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.PreIndex)...)
break
}
}
...
...
plugin/dapp/collateralize/executor/query.go
View file @
b48db05f
...
...
@@ -24,6 +24,7 @@ func (c *Collateralize) Query_CollateralizeInfoByID(req *pty.ReqCollateralizeInf
StabilityFeeRatio
:
coll
.
StabilityFeeRatio
,
CreateAddr
:
coll
.
CreateAddr
,
Balance
:
coll
.
Balance
,
Period
:
coll
.
Period
,
},
nil
}
...
...
@@ -44,6 +45,7 @@ func (c *Collateralize) Query_CollateralizeInfoByIDs(req *pty.ReqCollateralizeIn
StabilityFeeRatio
:
coll
.
StabilityFeeRatio
,
CreateAddr
:
coll
.
CreateAddr
,
Balance
:
coll
.
Balance
,
Period
:
coll
.
Period
,
})
}
...
...
@@ -98,14 +100,37 @@ func (c *Collateralize) Query_CollateralizeRecordByAddr(req *pty.ReqCollateraliz
return
ret
,
nil
}
func
(
c
*
Collateralize
)
Query_CollateralizeRecordByStatus
(
req
*
pty
.
ReqCollateralizeRecordByStatus
)
(
types
.
Message
,
error
)
{
ret
:=
&
pty
.
RepCollateralizeRecords
{}
records
,
err
:=
queryCollateralizeRecordByStatus
(
c
.
GetStateDB
(),
c
.
GetLocalDB
(),
req
.
Status
,
req
.
Index
)
func
(
c
*
Collateralize
)
Query_CollateralizeConfig
(
req
*
pty
.
ReqCollateralizeRecordByAddr
)
(
types
.
Message
,
error
)
{
config
,
err
:=
getCollateralizeConfig
(
c
.
GetStateDB
())
if
err
!=
nil
{
clog
.
Error
(
"Query_Collateralize
RecordByStatus"
,
"get collateralize record
error"
,
err
)
clog
.
Error
(
"Query_Collateralize
Config"
,
"get collateralize config
error"
,
err
)
return
nil
,
err
}
ret
.
Records
=
records
collIDRecords
,
err
:=
queryCollateralizeByStatus
(
c
.
GetLocalDB
(),
pty
.
CollateralizeStatusCreated
,
0
)
if
err
!=
nil
{
clog
.
Error
(
"Query_CollateralizeByStatus"
,
"get collateralize record error"
,
err
)
return
nil
,
err
}
collBalance
:=
config
.
CollTotalBalance
for
_
,
id
:=
range
collIDRecords
{
coll
,
err
:=
queryCollateralizeByID
(
c
.
GetStateDB
(),
id
)
if
err
!=
nil
{
clog
.
Error
(
"Query_CollateralizeInfoByID"
,
"id"
,
id
,
"error"
,
err
)
return
nil
,
err
}
collBalance
-=
coll
.
TotalBalance
}
ret
:=
&
pty
.
RepCollateralizeConfig
{
CollTotalBalance
:
config
.
CollTotalBalance
,
DebtCeiling
:
config
.
DebtCeiling
,
LiquidationRatio
:
config
.
LiquidationRatio
,
StabilityFeeRatio
:
config
.
StabilityFeeRatio
,
Period
:
config
.
Period
,
CollBalance
:
collBalance
,
}
return
ret
,
nil
}
\ No newline at end of file
plugin/dapp/collateralize/proto/collateralize.proto
View file @
b48db05f
...
...
@@ -65,6 +65,7 @@ message CollateralizeManage {
float
liquidationRatio
=
2
;
//清算比例
float
stabilityFeeRatio
=
3
;
//稳定费
int64
period
=
4
;
//合约期限
int64
collTotalBalance
=
5
;
//放贷总量
}
message
CollateralizeAddr
{
...
...
@@ -145,6 +146,7 @@ message RepCollateralizeCurrentInfo {
float
stabilityFeeRatio
=
5
;
//稳定费
string
createAddr
=
6
;
//创建人地址
int64
balance
=
7
;
//剩余可借贷金额(ccny)
int64
period
=
8
;
//合约期限
}
// 根据ID列表查询多期借贷信息
...
...
@@ -203,3 +205,13 @@ message ReqCollateralizeRecord {
message
RepCollateralizeRecord
{
BorrowRecord
record
=
1
;
}
// 返回放贷配置
message
RepCollateralizeConfig
{
int64
debtCeiling
=
1
;
//单用户可借出的限额(ccny)
float
liquidationRatio
=
2
;
//清算比例
float
stabilityFeeRatio
=
3
;
//稳定费
int64
period
=
4
;
//合约期限
int64
collTotalBalance
=
5
;
//放贷总量
int64
collBalance
=
6
;
//剩余放贷额度
}
\ No newline at end of file
plugin/dapp/collateralize/types/collateralize.go
View file @
b48db05f
...
...
@@ -331,6 +331,7 @@ func CreateRawCollateralizeManageTx(cfg *types.Chain33Config, parm *Collateraliz
LiquidationRatio
:
parm
.
LiquidationRatio
,
StabilityFeeRatio
:
parm
.
StabilityFeeRatio
,
Period
:
parm
.
Period
,
CollTotalBalance
:
parm
.
TotalBalance
,
}
manage
:=
&
CollateralizeAction
{
...
...
plugin/dapp/collateralize/types/collateralize.pb.go
View file @
b48db05f
This diff is collapsed.
Click to expand it.
plugin/dapp/collateralize/types/tx.go
View file @
b48db05f
...
...
@@ -51,5 +51,6 @@ type CollateralizeManageTx struct {
LiquidationRatio
float32
`json:"liquidationRatio"`
StabilityFeeRatio
float32
`json:"stabilityFeeRatio"`
Period
int64
`json:"period"`
TotalBalance
int64
`json:"totalBalance"`
Fee
int64
`json:"fee"`
}
plugin/dapp/issuance/commands/cmd.go
View file @
b48db05f
...
...
@@ -382,6 +382,7 @@ func IssuanceQuery(cmd *cobra.Command, args []string) {
issuanceIDsS
=
append
(
issuanceIDsS
,
issuanceIDs
)
req
:=
&
pkt
.
ReqIssuanceInfos
{
IssuanceIds
:
issuanceIDsS
}
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
fmt
.
Println
(
params
.
Payload
)
var
res
pkt
.
RepIssuanceCurrentInfos
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
...
...
plugin/dapp/issuance/executor/exec_del_local.go
View file @
b48db05f
...
...
@@ -32,19 +32,19 @@ func (c *Issuance) execDelLocal(tx *types.Transaction, receiptData *types.Receip
set
.
KV
=
append
(
set
.
KV
,
c
.
addIssuanceRecordStatus
(
issuanceLog
.
PreStatus
,
issuanceLog
.
AccountAddr
,
issuanceLog
.
PreIndex
,
issuanceLog
.
DebtId
,
issuanceLog
.
IssuanceId
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteIssuanceRecordStatus
(
issuanceLog
.
Status
,
issuanceLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addIssuanceRecordAddr
(
issuanceLog
.
AccountAddr
,
issuanceLog
.
PreIndex
,
issuanceLog
.
DebtId
,
issuanceLog
.
IssuanceId
)
...
)
//
set.KV = append(set.KV, c.addIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.PreIndex, issuanceLog.DebtId,
//
issuanceLog.IssuanceId)...)
break
case
pty
.
TyLogIssuanceFeed
:
set
.
KV
=
append
(
set
.
KV
,
c
.
addIssuanceRecordStatus
(
issuanceLog
.
Status
,
issuanceLog
.
AccountAddr
,
issuanceLog
.
PreIndex
,
issuanceLog
.
DebtId
,
issuanceLog
.
IssuanceId
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteIssuanceRecordStatus
(
issuanceLog
.
Status
,
issuanceLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addIssuanceRecordAddr
(
issuanceLog
.
AccountAddr
,
issuanceLog
.
PreIndex
,
issuanceLog
.
DebtId
,
issuanceLog
.
IssuanceId
)
...
)
// 如果没有被清算,需要把地址索引更新
if
issuanceLog
.
Status
==
pty
.
IssuanceUserStatusWarning
||
issuanceLog
.
Status
==
pty
.
IssuanceUserStatusExpire
{
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteIssuanceRecordAddr
(
issuanceLog
.
AccountAddr
,
issuanceLog
.
Index
)
...
)
}
//
set.KV = append(set.KV, c.addIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.PreIndex, issuanceLog.DebtId,
//
issuanceLog.IssuanceId)...)
//
//
如果没有被清算,需要把地址索引更新
//
if issuanceLog.Status == pty.IssuanceUserStatusWarning || issuanceLog.Status == pty.IssuanceUserStatusExpire {
//
set.KV = append(set.KV, c.deleteIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.Index)...)
//
}
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteIssuancePriceRecord
(
issuanceLog
.
RecordTime
)
...
)
break
case
pty
.
TyLogIssuanceClose
:
...
...
plugin/dapp/issuance/executor/exec_local.go
View file @
b48db05f
...
...
@@ -35,18 +35,18 @@ func (c *Issuance) execLocal(tx *types.Transaction, receipt *types.ReceiptData)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteIssuanceRecordStatus
(
issuanceLog
.
PreStatus
,
issuanceLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addIssuanceRecordStatus
(
issuanceLog
.
Status
,
issuanceLog
.
AccountAddr
,
issuanceLog
.
Index
,
issuanceLog
.
DebtId
,
issuanceLog
.
IssuanceId
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteIssuanceRecordAddr
(
issuanceLog
.
AccountAddr
,
issuanceLog
.
PreIndex
)
...
)
//
set.KV = append(set.KV, c.deleteIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.PreIndex)...)
break
case
pty
.
TyLogIssuanceFeed
:
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteIssuanceRecordStatus
(
issuanceLog
.
PreStatus
,
issuanceLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addIssuanceRecordStatus
(
issuanceLog
.
Status
,
issuanceLog
.
AccountAddr
,
issuanceLog
.
Index
,
issuanceLog
.
DebtId
,
issuanceLog
.
IssuanceId
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteIssuanceRecordAddr
(
issuanceLog
.
AccountAddr
,
issuanceLog
.
PreIndex
)
...
)
// 如果没有被清算,需要把地址索引更新
if
issuanceLog
.
Status
==
pty
.
IssuanceUserStatusWarning
||
issuanceLog
.
Status
==
pty
.
IssuanceUserStatusExpire
{
set
.
KV
=
append
(
set
.
KV
,
c
.
addIssuanceRecordAddr
(
issuanceLog
.
AccountAddr
,
issuanceLog
.
Index
,
issuanceLog
.
DebtId
,
issuanceLog
.
IssuanceId
)
...
)
}
//
set.KV = append(set.KV, c.deleteIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.PreIndex)...)
//
//
如果没有被清算,需要把地址索引更新
//
if issuanceLog.Status == pty.IssuanceUserStatusWarning || issuanceLog.Status == pty.IssuanceUserStatusExpire {
//
set.KV = append(set.KV, c.addIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.Index, issuanceLog.DebtId,
//
issuanceLog.IssuanceId)...)
//
}
set
.
KV
=
append
(
set
.
KV
,
c
.
addIssuancePriceRecord
(
issuanceLog
.
RecordTime
,
issuanceLog
.
BtyPrice
)
...
)
break
case
pty
.
TyLogIssuanceClose
:
...
...
plugin/dapp/issuance/executor/issuancedb.go
View file @
b48db05f
...
...
@@ -716,9 +716,9 @@ func (action *Action) systemLiquidation(issu *pty.Issuance, price float32) (*typ
collDB
:=
&
IssuanceDB
{
*
issu
}
for
index
,
debtRecord
:=
range
issu
.
DebtRecords
{
if
debtRecord
.
LiquidationPrice
*
PriceWarningRate
<
price
{
if
debtRecord
.
Status
==
pty
.
IssuanceUserStatus
SystemLiquidate
{
debtRecord
.
Status
=
debtRecord
.
Pre
Status
debtRecord
.
PreStatus
=
pty
.
IssuanceUserStatusSystemLiquid
ate
if
debtRecord
.
Status
==
pty
.
IssuanceUserStatus
Warning
{
debtRecord
.
PreStatus
=
debtRecord
.
Status
debtRecord
.
Status
=
pty
.
IssuanceUserStatusCre
ate
}
continue
}
...
...
plugin/dapp/issuance/executor/query.go
View file @
b48db05f
...
...
@@ -24,6 +24,7 @@ func (c *Issuance) Query_IssuanceInfoByID(req *pty.ReqIssuanceInfo) (types.Messa
Balance
:
issu
.
Balance
,
CollateralValue
:
issu
.
CollateralValue
,
DebtValue
:
issu
.
DebtValue
,
Period
:
issu
.
Period
,
},
nil
}
...
...
@@ -44,6 +45,7 @@ func (c *Issuance) Query_IssuanceInfoByIDs(req *pty.ReqIssuanceInfos) (types.Mes
Balance
:
issu
.
Balance
,
CollateralValue
:
issu
.
CollateralValue
,
DebtValue
:
issu
.
DebtValue
,
Period
:
issu
.
Period
,
})
}
...
...
plugin/dapp/issuance/proto/issuance.proto
View file @
b48db05f
...
...
@@ -135,6 +135,7 @@ message RepIssuanceCurrentInfo {
int64
balance
=
5
;
//剩余可借贷金额(ccny)
int64
collateralValue
=
6
;
//抵押物总数量(bty)
int64
debtValue
=
7
;
//产生的ccny数量
int64
period
=
8
;
//借贷最大期限
}
// 根据ID列表查询多期借贷信息
...
...
plugin/dapp/issuance/types/issuance.pb.go
View file @
b48db05f
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