Commit 491ce6b8 authored by pengjun's avatar pengjun

#627 update collateralize

parent ebffcd28
...@@ -55,7 +55,7 @@ func CollateralizeCreate(cmd *cobra.Command, args []string) { ...@@ -55,7 +55,7 @@ func CollateralizeCreate(cmd *cobra.Command, args []string) {
params := &rpctypes.CreateTxIn{ params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.CollateralizeX), Execer: types.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeCreate", ActionName: "CollateralizeCreate",
Payload: []byte(fmt.Sprintf("{\"balance\":%d}", balance)), Payload: []byte(fmt.Sprintf("{\"totalBalance\":%d}", balance)),
} }
var res string var res string
...@@ -89,7 +89,7 @@ func CollateralizeBorrow(cmd *cobra.Command, args []string) { ...@@ -89,7 +89,7 @@ func CollateralizeBorrow(cmd *cobra.Command, args []string) {
params := &rpctypes.CreateTxIn{ params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.CollateralizeX), Execer: types.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeBorrow", ActionName: "CollateralizeBorrow",
Payload: []byte(fmt.Sprintf("{\"collateralizeID\":%s,\"value\":%d}", collateralizeID, value)), Payload: []byte(fmt.Sprintf("{\"collateralizeID\":\"%s\",\"value\":%d}", collateralizeID, value)),
} }
var res string var res string
...@@ -111,6 +111,8 @@ func CollateralizeAppendRawTxCmd() *cobra.Command { ...@@ -111,6 +111,8 @@ func CollateralizeAppendRawTxCmd() *cobra.Command {
func addCollateralizeAppendFlags(cmd *cobra.Command) { func addCollateralizeAppendFlags(cmd *cobra.Command) {
cmd.Flags().StringP("collateralizeID", "g", "", "collateralize ID") cmd.Flags().StringP("collateralizeID", "g", "", "collateralize ID")
cmd.MarkFlagRequired("collateralizeID") cmd.MarkFlagRequired("collateralizeID")
cmd.Flags().StringP("recordID", "r", "", "recordID")
cmd.MarkFlagRequired("recordID")
cmd.Flags().Uint64P("value", "v", 0, "value") cmd.Flags().Uint64P("value", "v", 0, "value")
cmd.MarkFlagRequired("value") cmd.MarkFlagRequired("value")
} }
...@@ -118,12 +120,13 @@ func addCollateralizeAppendFlags(cmd *cobra.Command) { ...@@ -118,12 +120,13 @@ func addCollateralizeAppendFlags(cmd *cobra.Command) {
func CollateralizeAppend(cmd *cobra.Command, args []string) { func CollateralizeAppend(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
collateralizeID, _ := cmd.Flags().GetString("collateralizeID") collateralizeID, _ := cmd.Flags().GetString("collateralizeID")
recordID, _ := cmd.Flags().GetString("recordID")
value, _ := cmd.Flags().GetUint64("value") value, _ := cmd.Flags().GetUint64("value")
params := &rpctypes.CreateTxIn{ params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.CollateralizeX), Execer: types.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeAppend", ActionName: "CollateralizeAppend",
Payload: []byte(fmt.Sprintf("{\"collateralizeID\":%s,\"value\":%d}", collateralizeID, value)), Payload: []byte(fmt.Sprintf("{\"collateralizeID\":\"%s\", \"recordID\":\"%s\", \"value\":%d}", collateralizeID, recordID, value)),
} }
var res string var res string
...@@ -145,19 +148,19 @@ func CollateralizeRepayRawTxCmd() *cobra.Command { ...@@ -145,19 +148,19 @@ func CollateralizeRepayRawTxCmd() *cobra.Command {
func addCollateralizeRepayFlags(cmd *cobra.Command) { func addCollateralizeRepayFlags(cmd *cobra.Command) {
cmd.Flags().StringP("collateralizeID", "g", "", "collateralize ID") cmd.Flags().StringP("collateralizeID", "g", "", "collateralize ID")
cmd.MarkFlagRequired("collateralizeID") cmd.MarkFlagRequired("collateralizeID")
cmd.Flags().Uint64P("value", "v", 0, "value") cmd.Flags().StringP("recordID", "r", "", "recordID")
cmd.MarkFlagRequired("value") cmd.MarkFlagRequired("recordID")
} }
func CollateralizeRepay(cmd *cobra.Command, args []string) { func CollateralizeRepay(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
collateralizeID, _ := cmd.Flags().GetString("collateralizeID") collateralizeID, _ := cmd.Flags().GetString("collateralizeID")
value, _ := cmd.Flags().GetUint64("value") recordID, _ := cmd.Flags().GetString("recordID")
params := &rpctypes.CreateTxIn{ params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.CollateralizeX), Execer: types.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeRepay", ActionName: "CollateralizeRepay",
Payload: []byte(fmt.Sprintf("{\"collateralizeID\":%s,\"value\":%d}", collateralizeID, value)), Payload: []byte(fmt.Sprintf("{\"collateralizeID\":\"%s\",\"recordID\":\"%s\"}", collateralizeID, recordID)),
} }
var res string var res string
...@@ -191,7 +194,7 @@ func CollateralizePriceFeed(cmd *cobra.Command, args []string) { ...@@ -191,7 +194,7 @@ func CollateralizePriceFeed(cmd *cobra.Command, args []string) {
params := &rpctypes.CreateTxIn{ params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.CollateralizeX), Execer: types.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizePriceFeed", ActionName: "CollateralizePriceFeed",
Payload: []byte(fmt.Sprintf("{[\"price\":%s],[\"volume\":%d]}", price, volume)), Payload: []byte(fmt.Sprintf("{\"price\":[ %f ], \"volume\":[ %d ]}", price, volume)),
} }
var res string var res string
...@@ -222,7 +225,7 @@ func CollateralizeClose(cmd *cobra.Command, args []string) { ...@@ -222,7 +225,7 @@ func CollateralizeClose(cmd *cobra.Command, args []string) {
params := &rpctypes.CreateTxIn{ params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.CollateralizeX), Execer: types.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeClose", ActionName: "CollateralizeClose",
Payload: []byte(fmt.Sprintf("{\"collateralizeID\":%s}", collateralizeID)), Payload: []byte(fmt.Sprintf("{\"collateralizeID\":\"%s\"}", collateralizeID)),
} }
var res string var res string
...@@ -258,7 +261,7 @@ func CollateralizeManage(cmd *cobra.Command, args []string) { ...@@ -258,7 +261,7 @@ func CollateralizeManage(cmd *cobra.Command, args []string) {
params := &rpctypes.CreateTxIn{ params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.CollateralizeX), Execer: types.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeManage", ActionName: "CollateralizeManage",
Payload: []byte(fmt.Sprintf("{\"debtCeiling\":%d, \"liquidationRatio\":%f, \"stabilityFeeRatio\":%f, \"period\":%s}", Payload: []byte(fmt.Sprintf("{\"debtCeiling\":%d, \"liquidationRatio\":%f, \"stabilityFeeRatio\":%f, \"period\":%d}",
debtCeiling, liquidationRatio, stabilityFeeRatio, period)), debtCeiling, liquidationRatio, stabilityFeeRatio, period)),
} }
...@@ -308,12 +311,16 @@ func CollateralizeQuery(cmd *cobra.Command, args []string) { ...@@ -308,12 +311,16 @@ func CollateralizeQuery(cmd *cobra.Command, args []string) {
// req.Index = index // req.Index = index
//} //}
status, err := strconv.ParseInt(statusStr, 10, 32) var status int64
var err error
if statusStr != "" {
status, err = strconv.ParseInt(statusStr, 10, 32)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
cmd.Help() cmd.Help()
return return
} }
}
if collateralizeID != "" { if collateralizeID != "" {
if statusStr != "" { if statusStr != "" {
......
...@@ -73,6 +73,12 @@ func AddrKey() (key []byte) { ...@@ -73,6 +73,12 @@ func AddrKey() (key []byte) {
return key return key
} }
// Key for IssuancePriceFeed
func PriceKey() (key []byte) {
key = append(key, []byte("mavl-"+pty.CollateralizeX+"-price")...)
return key
}
// Action struct // Action struct
type Action struct { type Action struct {
coinsAccount *account.DB // bty账户 coinsAccount *account.DB // bty账户
...@@ -105,23 +111,16 @@ func NewCollateralizeAction(c *Collateralize, tx *types.Transaction, index int) ...@@ -105,23 +111,16 @@ func NewCollateralizeAction(c *Collateralize, tx *types.Transaction, index int)
execaddr: dapp.ExecAddress(string(tx.Execer)), difficulty: c.GetDifficulty(), index: index, Collateralize: c} execaddr: dapp.ExecAddress(string(tx.Execer)), difficulty: c.GetDifficulty(), index: index, Collateralize: c}
} }
// GetCollCommonRecipt generate logs for Collateralize common action
func (action *Action) GetCollCommonRecipt(collateralize *pty.Collateralize) *pty.ReceiptCollateralize {
c := &pty.ReceiptCollateralize{}
c.CollateralizeId = collateralize.CollateralizeId
c.Status = collateralize.Status
c.PreIndex = collateralize.PreIndex
c.Index = collateralize.Index
return c
}
// GetCreateReceiptLog generate logs for Collateralize create action // GetCreateReceiptLog generate logs for Collateralize create action
func (action *Action) GetCreateReceiptLog(collateralize *pty.Collateralize) *types.ReceiptLog { func (action *Action) GetCreateReceiptLog(collateralize *pty.Collateralize) *types.ReceiptLog {
log := &types.ReceiptLog{} log := &types.ReceiptLog{}
log.Ty = pty.TyLogCollateralizeCreate log.Ty = pty.TyLogCollateralizeCreate
c := action.GetCollCommonRecipt(collateralize) c := &pty.ReceiptCollateralize{}
c.CollateralizeId = collateralize.CollateralizeId
c.Status = collateralize.Status
c.CreateAddr = action.fromaddr c.CreateAddr = action.fromaddr
c.Index = collateralize.Index
log.Log = types.Encode(c) log.Log = types.Encode(c)
...@@ -133,10 +132,12 @@ func (action *Action) GetBorrowReceiptLog(collateralize *pty.Collateralize, reco ...@@ -133,10 +132,12 @@ func (action *Action) GetBorrowReceiptLog(collateralize *pty.Collateralize, reco
log := &types.ReceiptLog{} log := &types.ReceiptLog{}
log.Ty = pty.TyLogCollateralizeBorrow log.Ty = pty.TyLogCollateralizeBorrow
c := action.GetCollCommonRecipt(collateralize) c := &pty.ReceiptCollateralize{}
c.CollateralizeId = collateralize.CollateralizeId
c.AccountAddr = action.fromaddr c.AccountAddr = action.fromaddr
c.RecordId = record.RecordId c.RecordId = record.RecordId
c.RecordStatus = record.Status c.Status = record.Status
c.Index = record.Index
log.Log = types.Encode(c) log.Log = types.Encode(c)
...@@ -148,11 +149,14 @@ func (action *Action) GetRepayReceiptLog(collateralize *pty.Collateralize, recor ...@@ -148,11 +149,14 @@ func (action *Action) GetRepayReceiptLog(collateralize *pty.Collateralize, recor
log := &types.ReceiptLog{} log := &types.ReceiptLog{}
log.Ty = pty.TyLogCollateralizeRepay log.Ty = pty.TyLogCollateralizeRepay
c := action.GetCollCommonRecipt(collateralize) c := &pty.ReceiptCollateralize{}
c.CollateralizeId = collateralize.CollateralizeId
c.AccountAddr = action.fromaddr c.AccountAddr = action.fromaddr
c.RecordId = record.RecordId c.RecordId = record.RecordId
c.RecordStatus = record.Status c.Status = record.Status
c.RecordPreStatus = record.PreStatus c.PreStatus = record.PreStatus
c.PreIndex = record.PreIndex
c.Index = record.Index
log.Log = types.Encode(c) log.Log = types.Encode(c)
...@@ -160,11 +164,18 @@ func (action *Action) GetRepayReceiptLog(collateralize *pty.Collateralize, recor ...@@ -160,11 +164,18 @@ func (action *Action) GetRepayReceiptLog(collateralize *pty.Collateralize, recor
} }
// GetAppendReceiptLog generate logs for Collateralize append action // GetAppendReceiptLog generate logs for Collateralize append action
func (action *Action) GetAppendReceiptLog(collateralize *pty.Collateralize) *types.ReceiptLog { func (action *Action) GetAppendReceiptLog(collateralize *pty.Collateralize, record *pty.BorrowRecord) *types.ReceiptLog {
log := &types.ReceiptLog{} log := &types.ReceiptLog{}
log.Ty = pty.TyLogCollateralizeAppend log.Ty = pty.TyLogCollateralizeAppend
c := action.GetCollCommonRecipt(collateralize) c := &pty.ReceiptCollateralize{}
c.CollateralizeId = collateralize.CollateralizeId
c.AccountAddr = action.fromaddr
c.RecordId = record.RecordId
c.Status = record.Status
c.PreStatus = record.PreStatus
c.PreIndex = record.PreIndex
c.Index = record.Index
log.Log = types.Encode(c) log.Log = types.Encode(c)
...@@ -176,11 +187,14 @@ func (action *Action) GetFeedReceiptLog(collateralize *pty.Collateralize, record ...@@ -176,11 +187,14 @@ func (action *Action) GetFeedReceiptLog(collateralize *pty.Collateralize, record
log := &types.ReceiptLog{} log := &types.ReceiptLog{}
log.Ty = pty.TyLogCollateralizeFeed log.Ty = pty.TyLogCollateralizeFeed
c := action.GetCollCommonRecipt(collateralize) c := &pty.ReceiptCollateralize{}
c.CollateralizeId = collateralize.CollateralizeId
c.AccountAddr = record.AccountAddr c.AccountAddr = record.AccountAddr
c.RecordId = record.RecordId c.RecordId = record.RecordId
c.RecordStatus = record.Status c.Status = record.Status
c.RecordPreStatus = record.PreStatus c.PreStatus = record.PreStatus
c.PreIndex = record.PreIndex
c.Index = record.Index
log.Log = types.Encode(c) log.Log = types.Encode(c)
...@@ -188,11 +202,17 @@ func (action *Action) GetFeedReceiptLog(collateralize *pty.Collateralize, record ...@@ -188,11 +202,17 @@ func (action *Action) GetFeedReceiptLog(collateralize *pty.Collateralize, record
} }
// GetCloseReceiptLog generate logs for Collateralize close action // GetCloseReceiptLog generate logs for Collateralize close action
func (action *Action) GetCloseReceiptLog(Collateralize *pty.Collateralize) *types.ReceiptLog { func (action *Action) GetCloseReceiptLog(collateralize *pty.Collateralize) *types.ReceiptLog {
log := &types.ReceiptLog{} log := &types.ReceiptLog{}
log.Ty = pty.TyLogCollateralizeClose log.Ty = pty.TyLogCollateralizeClose
c := action.GetCollCommonRecipt(Collateralize) c := &pty.ReceiptCollateralize{}
c.CollateralizeId = collateralize.CollateralizeId
c.Status = collateralize.Status
c.PreStatus = pty.CollateralizeStatusCreated
c.CreateAddr = action.fromaddr
c.PreIndex = collateralize.PreIndex
c.Index = collateralize.Index
log.Log = types.Encode(c) log.Log = types.Encode(c)
...@@ -233,7 +253,7 @@ func (action *Action) CollateralizeManage(manage *pty.CollateralizeManage) (*typ ...@@ -233,7 +253,7 @@ func (action *Action) CollateralizeManage(manage *pty.CollateralizeManage) (*typ
var receipt *types.Receipt var receipt *types.Receipt
// 是否配置管理用户 // 是否配置管理用户
if !isRightAddr(configKey, action.fromaddr, action.db) { if !isRightAddr(issuanceE.ManageKey, action.fromaddr, action.db) {
clog.Error("CollateralizeManage", "addr", action.fromaddr, "error", "Address has no permission to config") clog.Error("CollateralizeManage", "addr", action.fromaddr, "error", "Address has no permission to config")
return nil, pty.ErrPermissionDeny return nil, pty.ErrPermissionDeny
} }
...@@ -245,10 +265,29 @@ func (action *Action) CollateralizeManage(manage *pty.CollateralizeManage) (*typ ...@@ -245,10 +265,29 @@ func (action *Action) CollateralizeManage(manage *pty.CollateralizeManage) (*typ
} }
collConfig := &pty.CollateralizeManage{} collConfig := &pty.CollateralizeManage{}
if manage.StabilityFeeRatio != 0 {
collConfig.StabilityFeeRatio = manage.StabilityFeeRatio collConfig.StabilityFeeRatio = manage.StabilityFeeRatio
} else {
collConfig.StabilityFeeRatio = DefaultStabilityFeeRation
}
if manage.Period != 0 {
collConfig.Period = manage.Period collConfig.Period = manage.Period
} else {
collConfig.Period = DefaultPeriod
}
if manage.LiquidationRatio != 0 {
collConfig.LiquidationRatio = manage.LiquidationRatio collConfig.LiquidationRatio = manage.LiquidationRatio
} else {
collConfig.LiquidationRatio = DefaultLiquidationRatio
}
if manage.DebtCeiling != 0 {
collConfig.DebtCeiling = manage.DebtCeiling collConfig.DebtCeiling = manage.DebtCeiling
} else {
collConfig.DebtCeiling = DefaultDebtCeiling
}
value := types.Encode(collConfig) value := types.Encode(collConfig)
action.db.Set(ConfigKey(), value) action.db.Set(ConfigKey(), value)
...@@ -313,6 +352,7 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ ...@@ -313,6 +352,7 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ
// 检查ccny余额 // 检查ccny余额
if !action.CheckExecTokenAccount(action.fromaddr, create.TotalBalance, false) { if !action.CheckExecTokenAccount(action.fromaddr, create.TotalBalance, false) {
clog.Error("CollateralizeCreate", "fromaddr", action.fromaddr, "balance", create.TotalBalance, "error", types.ErrInsufficientBalance)
return nil, types.ErrInsufficientBalance return nil, types.ErrInsufficientBalance
} }
...@@ -353,7 +393,6 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ ...@@ -353,7 +393,6 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ
coll.CreateAddr = action.fromaddr coll.CreateAddr = action.fromaddr
coll.Status = pty.CollateralizeActionCreate coll.Status = pty.CollateralizeActionCreate
coll.Index = action.GetIndex() coll.Index = action.GetIndex()
coll.CreateIndex = coll.Index
clog.Debug("CollateralizeCreate created", "CollateralizeID", collateralizeID, "TotalBalance", coll.TotalBalance) clog.Debug("CollateralizeCreate created", "CollateralizeID", collateralizeID, "TotalBalance", coll.TotalBalance)
...@@ -391,8 +430,8 @@ func calcLiquidationPrice(value int64, colValue int64) float32 { ...@@ -391,8 +430,8 @@ func calcLiquidationPrice(value int64, colValue int64) float32 {
} }
// 获取最近抵押物价格 // 获取最近抵押物价格
func (action *Action)getLatestPrice(db dbm.KV, assetType int32) (float32, error) { func (action *Action)getLatestPrice(db dbm.KV) (float32, error) {
data, err := db.Get(calcCollateralizeLatestPriceKey()) data, err := db.Get(PriceKey())
if err != nil { if err != nil {
clog.Error("getLatestPrice", "get", err) clog.Error("getLatestPrice", "get", err)
return -1, err return -1, err
...@@ -405,16 +444,7 @@ func (action *Action)getLatestPrice(db dbm.KV, assetType int32) (float32, error) ...@@ -405,16 +444,7 @@ func (action *Action)getLatestPrice(db dbm.KV, assetType int32) (float32, error)
return -1, err return -1, err
} }
switch assetType { return price.BtyPrice, nil
case pty.CollateralizeAssetTypeBty:
return price.BtcPrice, nil
case pty.CollateralizeAssetTypeBtc:
return price.BtcPrice, nil
case pty.CollateralizeAssetTypeEth:
return price.EthPrice, nil
default:
return -1, pty.ErrAssetType
}
} }
// CheckExecAccountBalance 检查账户抵押物余额 // CheckExecAccountBalance 检查账户抵押物余额
...@@ -480,7 +510,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ ...@@ -480,7 +510,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
clog.Debug("CollateralizeBorrow", "value", borrow.GetValue()) clog.Debug("CollateralizeBorrow", "value", borrow.GetValue())
// 获取抵押物价格 // 获取抵押物价格
lastPrice, err := action.getLatestPrice(action.db, coll.CollType) lastPrice, err := action.getLatestPrice(action.db)
if err != nil { if err != nil {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", err) clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", err)
return nil, err return nil, err
...@@ -537,6 +567,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ ...@@ -537,6 +567,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
borrowRecord.LiquidationPrice = coll.LiquidationRatio * lastPrice * pty.CollateralizePreLiquidationRatio borrowRecord.LiquidationPrice = coll.LiquidationRatio * lastPrice * pty.CollateralizePreLiquidationRatio
borrowRecord.Status = pty.CollateralizeUserStatusCreate borrowRecord.Status = pty.CollateralizeUserStatusCreate
borrowRecord.ExpireTime = action.blocktime + coll.Period borrowRecord.ExpireTime = action.blocktime + coll.Period
borrowRecord.Index = action.GetIndex()
// 记录当前借贷的最高自动清算价格 // 记录当前借贷的最高自动清算价格
if coll.LatestLiquidationPrice < borrowRecord.LiquidationPrice { if coll.LatestLiquidationPrice < borrowRecord.LiquidationPrice {
...@@ -547,8 +578,6 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ ...@@ -547,8 +578,6 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
coll.BorrowRecords = append(coll.BorrowRecords, borrowRecord) coll.BorrowRecords = append(coll.BorrowRecords, borrowRecord)
coll.Status = pty.CollateralizeStatusCreated coll.Status = pty.CollateralizeStatusCreated
coll.Balance -= borrow.Value coll.Balance -= borrow.Value
coll.PreIndex = coll.Index
coll.Index = action.GetIndex()
coll.Save(action.db) coll.Save(action.db)
kv = append(kv, coll.GetKVSet()...) kv = append(kv, coll.GetKVSet()...)
...@@ -597,7 +626,7 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types. ...@@ -597,7 +626,7 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
} }
// 借贷金额+利息 // 借贷金额+利息
realRepay := borrowRecord.DebtValue + int64(float32(borrowRecord.DebtValue) * coll.StabilityFeeRatio) + 1 realRepay := borrowRecord.DebtValue + int64(float32(borrowRecord.DebtValue) * coll.StabilityFeeRatio)
// 检查 // 检查
if !action.CheckExecTokenAccount(action.fromaddr, realRepay*Coin, false) { if !action.CheckExecTokenAccount(action.fromaddr, realRepay*Coin, false) {
...@@ -626,6 +655,8 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types. ...@@ -626,6 +655,8 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
// 借贷记录关闭 // 借贷记录关闭
borrowRecord.PreStatus = borrowRecord.Status borrowRecord.PreStatus = borrowRecord.Status
borrowRecord.Status = pty.CollateralizeUserStatusClose borrowRecord.Status = pty.CollateralizeUserStatusClose
borrowRecord.PreIndex = borrowRecord.Index
borrowRecord.Index = action.GetIndex()
// 保存 // 保存
coll.Balance += borrowRecord.DebtValue coll.Balance += borrowRecord.DebtValue
...@@ -633,8 +664,6 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types. ...@@ -633,8 +664,6 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
coll.InvalidRecords = append(coll.InvalidRecords, borrowRecord) coll.InvalidRecords = append(coll.InvalidRecords, borrowRecord)
coll.LatestLiquidationPrice = getLatestLiquidationPrice(&coll.Collateralize) coll.LatestLiquidationPrice = getLatestLiquidationPrice(&coll.Collateralize)
coll.LatestExpireTime = getLatestExpireTime(&coll.Collateralize) coll.LatestExpireTime = getLatestExpireTime(&coll.Collateralize)
coll.PreIndex = coll.Index
coll.Index = action.GetIndex()
coll.Save(action.db) coll.Save(action.db)
kv = append(kv, coll.GetKVSet()...) kv = append(kv, coll.GetKVSet()...)
...@@ -681,7 +710,7 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty ...@@ -681,7 +710,7 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty
clog.Debug("CollateralizeAppend", "value", cAppend.CollateralValue) clog.Debug("CollateralizeAppend", "value", cAppend.CollateralValue)
// 获取抵押物价格 // 获取抵押物价格
lastPrice, err := action.getLatestPrice(action.db, coll.CollType) lastPrice, err := action.getLatestPrice(action.db)
if err != nil { if err != nil {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", err) clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", err)
return nil, err return nil, err
...@@ -720,6 +749,8 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty ...@@ -720,6 +749,8 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty
if borrowRecord.Status == pty.CollateralizeUserStatusWarning { if borrowRecord.Status == pty.CollateralizeUserStatusWarning {
borrowRecord.PreStatus = borrowRecord.Status borrowRecord.PreStatus = borrowRecord.Status
borrowRecord.Status = pty.CollateralizeStatusCreated borrowRecord.Status = pty.CollateralizeStatusCreated
borrowRecord.PreIndex = borrowRecord.Index
borrowRecord.Index = action.GetIndex()
} }
} }
...@@ -731,7 +762,7 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty ...@@ -731,7 +762,7 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty
kv = append(kv, coll.GetKVSet()...) kv = append(kv, coll.GetKVSet()...)
receiptLog := action.GetAppendReceiptLog(&coll.Collateralize) receiptLog := action.GetAppendReceiptLog(&coll.Collateralize, borrowRecord)
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
receipt = &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs} receipt = &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}
...@@ -747,12 +778,6 @@ func getManageKey(key string, db dbm.KV) ([]byte, error) { ...@@ -747,12 +778,6 @@ func getManageKey(key string, db dbm.KV) ([]byte, error) {
return value, nil return value, nil
} }
const (
priceFeedKey = "collateralize-price-feed"
guarantorKey = "collateralize-guarantor"
configKey = "collateralize-config"
)
func isRightAddr(key string, addr string, db dbm.KV) bool { func isRightAddr(key string, addr string, db dbm.KV) bool {
value, err := getManageKey(key, db) value, err := getManageKey(key, db)
if err != nil { if err != nil {
...@@ -781,7 +806,7 @@ func isRightAddr(key string, addr string, db dbm.KV) bool { ...@@ -781,7 +806,7 @@ func isRightAddr(key string, addr string, db dbm.KV) bool {
} }
func getGuarantorAddr(db dbm.KV) (string, error) { func getGuarantorAddr(db dbm.KV) (string, error) {
value, err := getManageKey(guarantorKey, db) value, err := getManageKey(issuanceE.GuarantorKey, db)
if err != nil { if err != nil {
clog.Error("CollateralizePriceFeed", "getGuarantorAddr", err) clog.Error("CollateralizePriceFeed", "getGuarantorAddr", err)
return "", err return "", err
...@@ -838,15 +863,17 @@ func (action *Action) systemLiquidation(coll *pty.Collateralize, price float32) ...@@ -838,15 +863,17 @@ func (action *Action) systemLiquidation(coll *pty.Collateralize, price float32)
borrowRecord.LiquidateTime = action.blocktime borrowRecord.LiquidateTime = action.blocktime
borrowRecord.PreStatus = borrowRecord.Status borrowRecord.PreStatus = borrowRecord.Status
borrowRecord.Status = pty.CollateralizeUserStatusSystemLiquidate borrowRecord.Status = pty.CollateralizeUserStatusSystemLiquidate
borrowRecord.PreIndex = borrowRecord.Index
borrowRecord.Index = action.GetIndex()
coll.InvalidRecords = append(coll.InvalidRecords, borrowRecord) coll.InvalidRecords = append(coll.InvalidRecords, borrowRecord)
coll.BorrowRecords = append(coll.BorrowRecords[:index], coll.BorrowRecords[index+1:]...) coll.BorrowRecords = append(coll.BorrowRecords[:index], coll.BorrowRecords[index+1:]...)
} else { } else {
borrowRecord.PreStatus = borrowRecord.Status borrowRecord.PreStatus = borrowRecord.Status
borrowRecord.Status = pty.CollateralizeUserStatusWarning borrowRecord.Status = pty.CollateralizeUserStatusWarning
borrowRecord.PreIndex = borrowRecord.Index
borrowRecord.Index = action.GetIndex()
} }
coll.PreIndex = coll.Index
coll.Index = action.GetIndex()
log := action.GetFeedReceiptLog(coll, borrowRecord) log := action.GetFeedReceiptLog(coll, borrowRecord)
logs = append(logs, log) logs = append(logs, log)
} }
...@@ -894,15 +921,17 @@ func (action *Action) expireLiquidation(coll *pty.Collateralize) (*types.Receipt ...@@ -894,15 +921,17 @@ func (action *Action) expireLiquidation(coll *pty.Collateralize) (*types.Receipt
borrowRecord.LiquidateTime = action.blocktime borrowRecord.LiquidateTime = action.blocktime
borrowRecord.PreStatus = borrowRecord.Status borrowRecord.PreStatus = borrowRecord.Status
borrowRecord.Status = pty.CollateralizeUserStatusExpireLiquidate borrowRecord.Status = pty.CollateralizeUserStatusExpireLiquidate
borrowRecord.PreIndex = borrowRecord.Index
borrowRecord.Index = action.GetIndex()
coll.InvalidRecords = append(coll.InvalidRecords, borrowRecord) coll.InvalidRecords = append(coll.InvalidRecords, borrowRecord)
coll.BorrowRecords = append(coll.BorrowRecords[:index], coll.BorrowRecords[index+1:]...) coll.BorrowRecords = append(coll.BorrowRecords[:index], coll.BorrowRecords[index+1:]...)
} else { } else {
borrowRecord.PreIndex = borrowRecord.Index
borrowRecord.Index = action.GetIndex()
borrowRecord.PreStatus = borrowRecord.Status borrowRecord.PreStatus = borrowRecord.Status
borrowRecord.Status = pty.CollateralizeUserStatusExpire borrowRecord.Status = pty.CollateralizeUserStatusExpire
} }
coll.PreIndex = coll.Index
coll.Index = action.GetIndex()
log := action.GetFeedReceiptLog(coll, borrowRecord) log := action.GetFeedReceiptLog(coll, borrowRecord)
logs = append(logs, log) logs = append(logs, log)
} }
...@@ -943,7 +972,7 @@ func (action *Action) CollateralizeFeed(feed *pty.CollateralizeFeed) (*types.Rec ...@@ -943,7 +972,7 @@ func (action *Action) CollateralizeFeed(feed *pty.CollateralizeFeed) (*types.Rec
} }
// 是否后台管理用户 // 是否后台管理用户
if !isRightAddr(priceFeedKey, action.fromaddr, action.db) { if !isRightAddr(issuanceE.PriceFeedKey, action.fromaddr, action.db) {
clog.Error("CollateralizePriceFeed", "addr", action.fromaddr, "error", "Address has no permission to feed price") clog.Error("CollateralizePriceFeed", "addr", action.fromaddr, "error", "Address has no permission to feed price")
return nil, pty.ErrPermissionDeny return nil, pty.ErrPermissionDeny
} }
...@@ -989,24 +1018,11 @@ func (action *Action) CollateralizeFeed(feed *pty.CollateralizeFeed) (*types.Rec ...@@ -989,24 +1018,11 @@ func (action *Action) CollateralizeFeed(feed *pty.CollateralizeFeed) (*types.Rec
} }
var priceRecord pty.AssetPriceRecord var priceRecord pty.AssetPriceRecord
if feed.CollType == pty.CollateralizeAssetTypeBty {
priceRecord.BtyPrice = price priceRecord.BtyPrice = price
} else if feed.CollType == pty.CollateralizeAssetTypeBtc {
priceRecord.BtcPrice = price
} else if feed.CollType == pty.CollateralizeAssetTypeEth {
priceRecord.EthPrice = price
} else {
priceRecord.BtyPrice = price
}
priceRecord.RecordTime = action.blocktime priceRecord.RecordTime = action.blocktime
// 喂价记录
pricekv := &types.KeyValue{Key: calcCollateralizePriceKey(string(action.blocktime)), Value: types.Encode(&priceRecord)}
action.db.Set(pricekv.Key, pricekv.Value)
kv = append(kv, pricekv)
// 最近喂价记录 // 最近喂价记录
pricekv = &types.KeyValue{Key: calcCollateralizeLatestPriceKey(), Value: types.Encode(&priceRecord)} pricekv := &types.KeyValue{Key: PriceKey(), Value: types.Encode(&priceRecord)}
action.db.Set(pricekv.Key, pricekv.Value) action.db.Set(pricekv.Key, pricekv.Value)
kv = append(kv, pricekv) kv = append(kv, pricekv)
...@@ -1051,7 +1067,7 @@ func (action *Action) CollateralizeClose(close *pty.CollateralizeClose) (*types. ...@@ -1051,7 +1067,7 @@ func (action *Action) CollateralizeClose(close *pty.CollateralizeClose) (*types.
coll := &CollateralizeDB{*collateralize} coll := &CollateralizeDB{*collateralize}
coll.Status = pty.CollateralizeStatusClose coll.Status = pty.CollateralizeStatusClose
coll.PreIndex = coll.CreateIndex coll.PreIndex = coll.Index
coll.Index = action.GetIndex() coll.Index = action.GetIndex()
coll.Save(action.db) coll.Save(action.db)
kv = append(kv, coll.GetKVSet()...) kv = append(kv, coll.GetKVSet()...)
......
...@@ -26,26 +26,34 @@ func (c *Collateralize) execDelLocal(tx *types.Transaction, receiptData *types.R ...@@ -26,26 +26,34 @@ func (c *Collateralize) execDelLocal(tx *types.Transaction, receiptData *types.R
set.KV = append(set.KV, c.deleteCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.Index)...) set.KV = append(set.KV, c.deleteCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.Index)...)
break break
case pty.TyLogCollateralizeBorrow: case pty.TyLogCollateralizeBorrow:
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.Index)...) set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.Status, collateralizeLog.Index)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.Index)...) set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.Index)...)
break break
case pty.TyLogCollateralizeAppend: // append没有状态变化 case pty.TyLogCollateralizeAppend:
if collateralizeLog.Status == pty.CollateralizeUserStatusWarning {
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.PreStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.Status, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.Index)...)
}
break break
case pty.TyLogCollateralizeRepay: case pty.TyLogCollateralizeRepay:
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordPreStatus, collateralizeLog.CollateralizeId, set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.PreStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...) collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.Index)...) set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.Status, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId, set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...) collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
break break
case pty.TyLogCollateralizeFeed: case pty.TyLogCollateralizeFeed:
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId, set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.Status, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...) collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.Index)...) set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.Status, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId, set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...) collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
// 如果没有被清算,需要把地址索引更新 // 如果没有被清算,需要把地址索引更新
if collateralizeLog.RecordStatus == pty.CollateralizeUserStatusWarning || collateralizeLog.RecordStatus == pty.CollateralizeUserStatusExpire { if collateralizeLog.Status == pty.CollateralizeUserStatusWarning || collateralizeLog.Status == pty.CollateralizeUserStatusExpire {
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.Index)...) set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.Index)...)
} }
break break
......
...@@ -27,33 +27,41 @@ func (c *Collateralize) execLocal(tx *types.Transaction, receipt *types.ReceiptD ...@@ -27,33 +27,41 @@ func (c *Collateralize) execLocal(tx *types.Transaction, receipt *types.ReceiptD
set.KV = append(set.KV, c.addCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.CollateralizeId, collateralizeLog.Index)...) set.KV = append(set.KV, c.addCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.CollateralizeId, collateralizeLog.Index)...)
break break
case pty.TyLogCollateralizeBorrow: case pty.TyLogCollateralizeBorrow:
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId, set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.Status, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...) collateralizeLog.RecordId, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId, set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...) collateralizeLog.RecordId, collateralizeLog.Index)...)
break break
case pty.TyLogCollateralizeAppend: //append没有状态变化 case pty.TyLogCollateralizeAppend:
if collateralizeLog.Status == pty.CollateralizeUserStatusWarning {
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)...)
}
break break
case pty.TyLogCollateralizeRepay: case pty.TyLogCollateralizeRepay:
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordPreStatus, collateralizeLog.PreIndex)...) set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.PreStatus, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId, set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.Status, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...) 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 break
case pty.TyLogCollateralizeFeed: case pty.TyLogCollateralizeFeed:
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordPreStatus, collateralizeLog.PreIndex)...) set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.PreStatus, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId, set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.Status, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...) 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)...)
// 如果没有被清算,需要把地址索引更新 // 如果没有被清算,需要把地址索引更新
if collateralizeLog.RecordStatus == pty.CollateralizeUserStatusWarning || collateralizeLog.RecordStatus == pty.CollateralizeUserStatusExpire { if collateralizeLog.Status == pty.CollateralizeUserStatusWarning || collateralizeLog.Status == pty.CollateralizeUserStatusExpire {
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId, set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...) collateralizeLog.RecordId, collateralizeLog.Index)...)
} }
break break
case pty.TyLogCollateralizeClose: case pty.TyLogCollateralizeClose:
set.KV = append(set.KV, c.addCollateralizeStatus(collateralizeLog.Status, collateralizeLog.CollateralizeId, collateralizeLog.Index)...) set.KV = append(set.KV, c.addCollateralizeStatus(collateralizeLog.Status, collateralizeLog.CollateralizeId, collateralizeLog.Index)...)
set.KV = append(set.KV, c.deleteCollateralizeStatus(pty.CollateralizeStatusCreated, collateralizeLog.PreIndex)...) 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 break
} }
......
...@@ -36,11 +36,6 @@ func calcCollateralizePriceKey(time string) []byte { ...@@ -36,11 +36,6 @@ func calcCollateralizePriceKey(time string) []byte {
return []byte(key) return []byte(key)
} }
func calcCollateralizeLatestPriceKey() []byte {
key := fmt.Sprintf("LODB-collateralize-latest-price")
return []byte(key)
}
func calcCollateralizeRecordAddrPrefix(addr string) []byte { func calcCollateralizeRecordAddrPrefix(addr string) []byte {
key := fmt.Sprintf("LODB-collateralize-record-addr:%d", addr) key := fmt.Sprintf("LODB-collateralize-record-addr:%d", addr)
return []byte(key) return []byte(key)
......
...@@ -14,13 +14,11 @@ message Collateralize { ...@@ -14,13 +14,11 @@ message Collateralize {
repeated BorrowRecord borrowRecords = 8; //借贷记录 repeated BorrowRecord borrowRecords = 8; //借贷记录
repeated BorrowRecord InvalidRecords = 9; //失效的借贷记录 repeated BorrowRecord InvalidRecords = 9; //失效的借贷记录
int32 status = 10;//当期借贷的状态,是否关闭 int32 status = 10;//当期借贷的状态,是否关闭
int32 collType = 11;//质押资产类型(1,bty,2,btc,3,eth...) float latestLiquidationPrice = 11;//最高清算价格
float latestLiquidationPrice = 12;//最高清算价格 int64 period = 12;//借贷最大期限
int64 period = 13;//借贷最大期限 int64 latestExpireTime = 13;//最近超期时间
int64 latestExpireTime = 14;//最近超期时间 int64 index = 14;//当前索引
int64 index = 15;//当前索引 int64 preIndex = 15;//上一个索引
int64 preIndex = 16;//上一个索引
int64 createIndex = 17;//创建时的索引,用于close删除记录
} }
// 借出记录 // 借出记录
...@@ -36,6 +34,8 @@ message BorrowRecord { ...@@ -36,6 +34,8 @@ message BorrowRecord {
int64 expireTime = 9; //超时清算时间 int64 expireTime = 9; //超时清算时间
int32 preStatus = 10;//上一次抵押状态,用于告警恢复 int32 preStatus = 10;//上一次抵押状态,用于告警恢复
string recordId = 11;//借出id,标识一次借出记录 string recordId = 11;//借出id,标识一次借出记录
int64 index = 12;//当前索引
int64 preIndex = 13;//上级索引
} }
// 资产价格记录 // 资产价格记录
...@@ -111,13 +111,12 @@ message ReceiptCollateralize { ...@@ -111,13 +111,12 @@ message ReceiptCollateralize {
string collateralizeId = 1; string collateralizeId = 1;
string createAddr = 2; string createAddr = 2;
string accountAddr = 3; string accountAddr = 3;
int32 status = 4; string recordId = 4;
int64 index = 5; int32 status = 5;
int32 recordStatus = 6; int32 PreStatus = 6;
int32 recordPreStatus = 7; int64 index = 7;
string recordId = 8; int64 preIndex = 8;
int64 preIndex = 9; }
}
// exec_local 借贷记录信息 // exec_local 借贷记录信息
message CollateralizeRecord { message CollateralizeRecord {
......
...@@ -93,7 +93,7 @@ func (Collateralize CollateralizeType) CreateTx(action string, message json.RawM ...@@ -93,7 +93,7 @@ func (Collateralize CollateralizeType) CreateTx(action string, message json.RawM
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
return CreateRawCollateralizeAppendTx(&param) return CreateRawCollateralizeAppendTx(&param)
} else if action == "CollateralizeFeed" { } else if action == "CollateralizePriceFeed" {
var param CollateralizeFeedTx var param CollateralizeFeedTx
err := json.Unmarshal(message, &param) err := json.Unmarshal(message, &param)
if err != nil { if err != nil {
......
...@@ -32,13 +32,11 @@ type Collateralize struct { ...@@ -32,13 +32,11 @@ type Collateralize struct {
BorrowRecords []*BorrowRecord `protobuf:"bytes,8,rep,name=borrowRecords,proto3" json:"borrowRecords,omitempty"` BorrowRecords []*BorrowRecord `protobuf:"bytes,8,rep,name=borrowRecords,proto3" json:"borrowRecords,omitempty"`
InvalidRecords []*BorrowRecord `protobuf:"bytes,9,rep,name=InvalidRecords,proto3" json:"InvalidRecords,omitempty"` InvalidRecords []*BorrowRecord `protobuf:"bytes,9,rep,name=InvalidRecords,proto3" json:"InvalidRecords,omitempty"`
Status int32 `protobuf:"varint,10,opt,name=status,proto3" json:"status,omitempty"` Status int32 `protobuf:"varint,10,opt,name=status,proto3" json:"status,omitempty"`
CollType int32 `protobuf:"varint,11,opt,name=collType,proto3" json:"collType,omitempty"` LatestLiquidationPrice float32 `protobuf:"fixed32,11,opt,name=latestLiquidationPrice,proto3" json:"latestLiquidationPrice,omitempty"`
LatestLiquidationPrice float32 `protobuf:"fixed32,12,opt,name=latestLiquidationPrice,proto3" json:"latestLiquidationPrice,omitempty"` Period int64 `protobuf:"varint,12,opt,name=period,proto3" json:"period,omitempty"`
Period int64 `protobuf:"varint,13,opt,name=period,proto3" json:"period,omitempty"` LatestExpireTime int64 `protobuf:"varint,13,opt,name=latestExpireTime,proto3" json:"latestExpireTime,omitempty"`
LatestExpireTime int64 `protobuf:"varint,14,opt,name=latestExpireTime,proto3" json:"latestExpireTime,omitempty"` Index int64 `protobuf:"varint,14,opt,name=index,proto3" json:"index,omitempty"`
Index int64 `protobuf:"varint,15,opt,name=index,proto3" json:"index,omitempty"` PreIndex int64 `protobuf:"varint,15,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
PreIndex int64 `protobuf:"varint,16,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
CreateIndex int64 `protobuf:"varint,17,opt,name=createIndex,proto3" json:"createIndex,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -139,13 +137,6 @@ func (m *Collateralize) GetStatus() int32 { ...@@ -139,13 +137,6 @@ func (m *Collateralize) GetStatus() int32 {
return 0 return 0
} }
func (m *Collateralize) GetCollType() int32 {
if m != nil {
return m.CollType
}
return 0
}
func (m *Collateralize) GetLatestLiquidationPrice() float32 { func (m *Collateralize) GetLatestLiquidationPrice() float32 {
if m != nil { if m != nil {
return m.LatestLiquidationPrice return m.LatestLiquidationPrice
...@@ -181,13 +172,6 @@ func (m *Collateralize) GetPreIndex() int64 { ...@@ -181,13 +172,6 @@ func (m *Collateralize) GetPreIndex() int64 {
return 0 return 0
} }
func (m *Collateralize) GetCreateIndex() int64 {
if m != nil {
return m.CreateIndex
}
return 0
}
// 借出记录 // 借出记录
type BorrowRecord struct { type BorrowRecord struct {
AccountAddr string `protobuf:"bytes,1,opt,name=accountAddr,proto3" json:"accountAddr,omitempty"` AccountAddr string `protobuf:"bytes,1,opt,name=accountAddr,proto3" json:"accountAddr,omitempty"`
...@@ -201,6 +185,8 @@ type BorrowRecord struct { ...@@ -201,6 +185,8 @@ type BorrowRecord struct {
ExpireTime int64 `protobuf:"varint,9,opt,name=expireTime,proto3" json:"expireTime,omitempty"` ExpireTime int64 `protobuf:"varint,9,opt,name=expireTime,proto3" json:"expireTime,omitempty"`
PreStatus int32 `protobuf:"varint,10,opt,name=preStatus,proto3" json:"preStatus,omitempty"` PreStatus int32 `protobuf:"varint,10,opt,name=preStatus,proto3" json:"preStatus,omitempty"`
RecordId string `protobuf:"bytes,11,opt,name=recordId,proto3" json:"recordId,omitempty"` RecordId string `protobuf:"bytes,11,opt,name=recordId,proto3" json:"recordId,omitempty"`
Index int64 `protobuf:"varint,12,opt,name=index,proto3" json:"index,omitempty"`
PreIndex int64 `protobuf:"varint,13,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -308,6 +294,20 @@ func (m *BorrowRecord) GetRecordId() string { ...@@ -308,6 +294,20 @@ func (m *BorrowRecord) GetRecordId() string {
return "" return ""
} }
func (m *BorrowRecord) GetIndex() int64 {
if m != nil {
return m.Index
}
return 0
}
func (m *BorrowRecord) GetPreIndex() int64 {
if m != nil {
return m.PreIndex
}
return 0
}
// 资产价格记录 // 资产价格记录
type AssetPriceRecord struct { type AssetPriceRecord struct {
RecordTime int64 `protobuf:"varint,1,opt,name=recordTime,proto3" json:"recordTime,omitempty"` RecordTime int64 `protobuf:"varint,1,opt,name=recordTime,proto3" json:"recordTime,omitempty"`
...@@ -931,12 +931,11 @@ type ReceiptCollateralize struct { ...@@ -931,12 +931,11 @@ type ReceiptCollateralize struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"` CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
CreateAddr string `protobuf:"bytes,2,opt,name=createAddr,proto3" json:"createAddr,omitempty"` CreateAddr string `protobuf:"bytes,2,opt,name=createAddr,proto3" json:"createAddr,omitempty"`
AccountAddr string `protobuf:"bytes,3,opt,name=accountAddr,proto3" json:"accountAddr,omitempty"` AccountAddr string `protobuf:"bytes,3,opt,name=accountAddr,proto3" json:"accountAddr,omitempty"`
Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"` RecordId string `protobuf:"bytes,4,opt,name=recordId,proto3" json:"recordId,omitempty"`
Index int64 `protobuf:"varint,5,opt,name=index,proto3" json:"index,omitempty"` Status int32 `protobuf:"varint,5,opt,name=status,proto3" json:"status,omitempty"`
RecordStatus int32 `protobuf:"varint,6,opt,name=recordStatus,proto3" json:"recordStatus,omitempty"` PreStatus int32 `protobuf:"varint,6,opt,name=PreStatus,proto3" json:"PreStatus,omitempty"`
RecordPreStatus int32 `protobuf:"varint,7,opt,name=recordPreStatus,proto3" json:"recordPreStatus,omitempty"` Index int64 `protobuf:"varint,7,opt,name=index,proto3" json:"index,omitempty"`
RecordId string `protobuf:"bytes,8,opt,name=recordId,proto3" json:"recordId,omitempty"` PreIndex int64 `protobuf:"varint,8,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
PreIndex int64 `protobuf:"varint,9,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -988,41 +987,34 @@ func (m *ReceiptCollateralize) GetAccountAddr() string { ...@@ -988,41 +987,34 @@ func (m *ReceiptCollateralize) GetAccountAddr() string {
return "" return ""
} }
func (m *ReceiptCollateralize) GetStatus() int32 { func (m *ReceiptCollateralize) GetRecordId() string {
if m != nil { if m != nil {
return m.Status return m.RecordId
} }
return 0 return ""
} }
func (m *ReceiptCollateralize) GetIndex() int64 { func (m *ReceiptCollateralize) GetStatus() int32 {
if m != nil { if m != nil {
return m.Index return m.Status
} }
return 0 return 0
} }
func (m *ReceiptCollateralize) GetRecordStatus() int32 { func (m *ReceiptCollateralize) GetPreStatus() int32 {
if m != nil { if m != nil {
return m.RecordStatus return m.PreStatus
} }
return 0 return 0
} }
func (m *ReceiptCollateralize) GetRecordPreStatus() int32 { func (m *ReceiptCollateralize) GetIndex() int64 {
if m != nil { if m != nil {
return m.RecordPreStatus return m.Index
} }
return 0 return 0
} }
func (m *ReceiptCollateralize) GetRecordId() string {
if m != nil {
return m.RecordId
}
return ""
}
func (m *ReceiptCollateralize) GetPreIndex() int64 { func (m *ReceiptCollateralize) GetPreIndex() int64 {
if m != nil { if m != nil {
return m.PreIndex return m.PreIndex
...@@ -1719,77 +1711,76 @@ func init() { ...@@ -1719,77 +1711,76 @@ func init() {
func init() { proto.RegisterFile("collateralize.proto", fileDescriptor_a988fb4a61381972) } func init() { proto.RegisterFile("collateralize.proto", fileDescriptor_a988fb4a61381972) }
var fileDescriptor_a988fb4a61381972 = []byte{ var fileDescriptor_a988fb4a61381972 = []byte{
// 1148 bytes of a gzipped FileDescriptorProto // 1127 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x57, 0xe1, 0x6e, 0xdc, 0x44, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x57, 0xef, 0x6e, 0xdc, 0x44,
0x10, 0xae, 0xed, 0xbb, 0x4b, 0x6e, 0x2e, 0x69, 0x93, 0x4d, 0x08, 0x26, 0x54, 0xd1, 0x69, 0x85, 0x10, 0x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0x0f, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xd0, 0x3f, 0xd2, 0x26, 0x9b, 0x0f, 0x00, 0x00,
} }
...@@ -26,7 +26,7 @@ const ( ...@@ -26,7 +26,7 @@ const (
// Collateralize name // Collateralize name
const ( const (
CollateralizeX = "collateralize" CollateralizeX = "collateralize"
CCNYTokenName = "ccny" CCNYTokenName = "CCNY"
CollateralizePreLiquidationRatio = 1.1 //TODO 预清算比例,抵押物价值跌到借出ccny价值110%的时候开始清算 CollateralizePreLiquidationRatio = 1.1 //TODO 预清算比例,抵押物价值跌到借出ccny价值110%的时候开始清算
) )
...@@ -36,11 +36,12 @@ const ( ...@@ -36,11 +36,12 @@ const (
CollateralizeStatusClose CollateralizeStatusClose
) )
const ( //暂时只支持bty
CollateralizeAssetTypeBty = 1 + iota //const (
CollateralizeAssetTypeBtc // CollateralizeAssetTypeBty = 1 + iota
CollateralizeAssetTypeEth // CollateralizeAssetTypeBtc
) // CollateralizeAssetTypeEth
//)
const ( const (
CollateralizeUserStatusCreate = 1 + iota CollateralizeUserStatusCreate = 1 + iota
......
...@@ -32,12 +32,6 @@ const ( ...@@ -32,12 +32,6 @@ const (
ExpireWarningTime = 3600 * 24 * 10 // 提前10天超时预警 ExpireWarningTime = 3600 * 24 * 10 // 提前10天超时预警
) )
const (
priceFeedKey = "issuance-price-feed"
guarantorKey = "issuance-guarantor"
manageKey = "issuance-manage"
)
func getManageKey(key string, db dbm.KV) ([]byte, error) { func getManageKey(key string, db dbm.KV) ([]byte, error) {
manageKey := types.ManageKey(key) manageKey := types.ManageKey(key)
value, err := db.Get([]byte(manageKey)) value, err := db.Get([]byte(manageKey))
...@@ -48,7 +42,7 @@ func getManageKey(key string, db dbm.KV) ([]byte, error) { ...@@ -48,7 +42,7 @@ func getManageKey(key string, db dbm.KV) ([]byte, error) {
} }
func getGuarantorAddr(db dbm.KV) (string, error) { func getGuarantorAddr(db dbm.KV) (string, error) {
value, err := getManageKey(guarantorKey, db) value, err := getManageKey(pty.GuarantorKey, db)
if err != nil { if err != nil {
clog.Error("IssuancePriceFeed", "getGuarantorAddr", err) clog.Error("IssuancePriceFeed", "getGuarantorAddr", err)
return "", err return "", err
...@@ -323,7 +317,7 @@ func (action *Action) IssuanceManage(manage *pty.IssuanceManage) (*types.Receipt ...@@ -323,7 +317,7 @@ func (action *Action) IssuanceManage(manage *pty.IssuanceManage) (*types.Receipt
var receipt *types.Receipt var receipt *types.Receipt
// 是否配置管理用户 // 是否配置管理用户
if !isRightAddr(manageKey, action.fromaddr, action.db) { if !isRightAddr(pty.ManageKey, action.fromaddr, action.db) {
clog.Error("IssuanceManage", "addr", action.fromaddr, "error", "Address has no permission to config") clog.Error("IssuanceManage", "addr", action.fromaddr, "error", "Address has no permission to config")
return nil, pty.ErrPermissionDeny return nil, pty.ErrPermissionDeny
} }
...@@ -384,7 +378,7 @@ func (action *Action) IssuanceCreate(create *pty.IssuanceCreate) (*types.Receipt ...@@ -384,7 +378,7 @@ func (action *Action) IssuanceCreate(create *pty.IssuanceCreate) (*types.Receipt
var receipt *types.Receipt var receipt *types.Receipt
// 是否配置管理用户 // 是否配置管理用户
if !isRightAddr(manageKey, action.fromaddr, action.db) { if !isRightAddr(pty.ManageKey, action.fromaddr, action.db) {
clog.Error("IssuanceCreate", "addr", action.fromaddr, "error", "Address has no permission to create") clog.Error("IssuanceCreate", "addr", action.fromaddr, "error", "Address has no permission to create")
return nil, pty.ErrPermissionDeny return nil, pty.ErrPermissionDeny
} }
...@@ -859,7 +853,7 @@ func (action *Action) IssuanceFeed(feed *pty.IssuanceFeed) (*types.Receipt, erro ...@@ -859,7 +853,7 @@ func (action *Action) IssuanceFeed(feed *pty.IssuanceFeed) (*types.Receipt, erro
} }
// 是否后台管理用户 // 是否后台管理用户
if !isRightAddr(priceFeedKey, action.fromaddr, action.db) { if !isRightAddr(pty.PriceFeedKey, action.fromaddr, action.db) {
clog.Error("IssuancePriceFeed", "addr", action.fromaddr, "error", "Address has no permission to feed price") clog.Error("IssuancePriceFeed", "addr", action.fromaddr, "error", "Address has no permission to feed price")
return nil, pty.ErrPermissionDeny return nil, pty.ErrPermissionDeny
} }
...@@ -933,7 +927,7 @@ func (action *Action) IssuanceClose(close *pty.IssuanceClose) (*types.Receipt, e ...@@ -933,7 +927,7 @@ func (action *Action) IssuanceClose(close *pty.IssuanceClose) (*types.Receipt, e
return nil, err return nil, err
} }
if !isRightAddr(manageKey, action.fromaddr, action.db) { if !isRightAddr(pty.ManageKey, action.fromaddr, action.db) {
clog.Error("IssuanceClose", "addr", action.fromaddr, "error", "Address has no permission to close") clog.Error("IssuanceClose", "addr", action.fromaddr, "error", "Address has no permission to close")
return nil, pty.ErrPermissionDeny return nil, pty.ErrPermissionDeny
} }
......
...@@ -42,3 +42,9 @@ const ( ...@@ -42,3 +42,9 @@ const (
IssuanceUserStatusExpireLiquidate IssuanceUserStatusExpireLiquidate
IssuanceUserStatusClose IssuanceUserStatusClose
) )
const (
PriceFeedKey = "issuance-price-feed"
GuarantorKey = "issuance-guarantor"
ManageKey = "issuance-manage"
)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment