Commit ebffcd28 authored by pengjun's avatar pengjun

#627 update issuance

parent adb27358
......@@ -258,7 +258,7 @@ func CollateralizeManage(cmd *cobra.Command, args []string) {
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.CollateralizeX),
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\":%s}",
debtCeiling, liquidationRatio, stabilityFeeRatio, period)),
}
......
......@@ -5,6 +5,7 @@
package executor
import (
"fmt"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
dbm "github.com/33cn/chain33/common/db"
......@@ -62,13 +63,13 @@ func Key(id string) (key []byte) {
// Key for CollateralizeConfig
func ConfigKey() (key []byte) {
key = append(key, []byte("mavl-"+pty.CollateralizeX+"config")...)
key = append(key, []byte("mavl-"+pty.CollateralizeX+"-config")...)
return key
}
// Key for CollateralizeAddrConfig
func AddrKey() (key []byte) {
key = append(key, []byte("mavl-"+issuanceE.IssuanceX+"addr")...)
key = append(key, []byte("mavl-"+issuanceE.IssuanceX+"-addr")...)
return key
}
......@@ -274,30 +275,22 @@ func (action *Action) getCollateralizeConfig() (*pty.CollateralizeManage, error)
}
func (action *Action) getSuperAddr() []string {
data, err := action.db.Get(AddrKey())
func isSuperAddr(addr string, db dbm.KV) bool {
data, err := db.Get(AddrKey())
if err != nil {
clog.Error("getSuperAddr", "error", err)
return nil
return false
}
var addrStore pty.CollateralizeAddr
err = types.Decode(data, &addrStore)
var item types.ConfigItem
err = types.Decode(data, &item)
if err != nil {
clog.Debug("getSuperAddr", "decode", err)
return nil
}
return addrStore.SuperAddrs
}
func isSuperAddr(super []string, addr string) bool {
if super == nil || len(super) == 0 {
clog.Error("isSuperAddr", "Decode", data)
return false
}
for _, superAddr := range super {
if superAddr == addr {
for _, op := range item.GetArr().Value {
if op == addr {
return true
}
}
......@@ -311,8 +304,7 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ
var kv []*types.KeyValue
var receipt *types.Receipt
superAddr := action.getSuperAddr()
if !isSuperAddr(superAddr, action.fromaddr) {
if !isSuperAddr(action.fromaddr, action.db) {
clog.Error("CollateralizeCreate", "error", "CollateralizeCreate need super address")
return nil, pty.ErrPermissionDeny
}
......@@ -332,7 +324,7 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ
}
// 冻结ccny
receipt, err = action.tokenAccount.ExecFrozen(action.fromaddr, action.execaddr, create.TotalBalance)
receipt, err = action.tokenAccount.ExecFrozen(action.fromaddr, action.execaddr, create.TotalBalance * Coin)
if err != nil {
clog.Error("CollateralizeCreate.Frozen", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", create.TotalBalance)
return nil, err
......@@ -402,14 +394,14 @@ func calcLiquidationPrice(value int64, colValue int64) float32 {
func (action *Action)getLatestPrice(db dbm.KV, assetType int32) (float32, error) {
data, err := db.Get(calcCollateralizeLatestPriceKey())
if err != nil {
clog.Debug("getLatestPrice", "get", err)
clog.Error("getLatestPrice", "get", err)
return -1, err
}
var price pty.AssetPriceRecord
//decode
err = types.Decode(data, &price)
if err != nil {
clog.Debug("getLatestPrice", "decode", err)
clog.Error("getLatestPrice", "decode", err)
return -1, err
}
......@@ -517,7 +509,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
kv = append(kv, receipt.KV...)
// 抵押物冻结
receipt, err = action.coinsAccount.ExecFrozen(coll.CreateAddr, action.execaddr, btyFrozen)
receipt, err = action.coinsAccount.ExecFrozen(coll.CreateAddr, action.execaddr, btyFrozen*Coin)
if err != nil {
clog.Error("CollateralizeBorrow.Frozen", "addr", coll.CreateAddr, "execaddr", action.execaddr, "amount", btyFrozen)
return nil, err
......@@ -526,7 +518,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
kv = append(kv, receipt.KV...)
// 借出ccny
receipt, err = action.tokenAccount.ExecTransfer(coll.CreateAddr, action.fromaddr, action.execaddr, borrow.Value)
receipt, err = action.tokenAccount.ExecTransfer(coll.CreateAddr, action.fromaddr, action.execaddr, borrow.Value*Coin)
if err != nil {
clog.Error("CollateralizeBorrow.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", borrow.Value)
return nil, err
......@@ -604,23 +596,17 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
return nil, pty.ErrRecordNotExist
}
// 检查清算金额(默认全部清算,部分清算在其他接口)
if repay.Value != borrowRecord.DebtValue {
clog.Error("CollateralizeRepay", "CollID", repay.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "collateralize value", borrowRecord.DebtValue, "err", pty.ErrRepayValueInsufficient)
return nil, pty.ErrRepayValueInsufficient
}
// 借贷金额+利息
realRepay := repay.Value + int64(float32(repay.Value) * coll.StabilityFeeRatio) + 1
realRepay := borrowRecord.DebtValue + int64(float32(borrowRecord.DebtValue) * coll.StabilityFeeRatio) + 1
// 检查
if !action.CheckExecTokenAccount(action.fromaddr, realRepay, false) {
if !action.CheckExecTokenAccount(action.fromaddr, realRepay*Coin, false) {
clog.Error("CollateralizeRepay", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrInsufficientBalance)
return nil, types.ErrNoBalance
}
// ccny转移
receipt, err = action.tokenAccount.ExecTransfer(action.fromaddr, coll.CreateAddr, action.execaddr, realRepay)
receipt, err = action.tokenAccount.ExecTransfer(action.fromaddr, coll.CreateAddr, action.execaddr, realRepay*Coin)
if err != nil {
clog.Error("CollateralizeRepay.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", realRepay)
return nil, err
......@@ -629,7 +615,7 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
kv = append(kv, receipt.KV...)
// 抵押物归还
receipt, err = action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, action.execaddr, action.execaddr, borrowRecord.CollateralValue)
receipt, err = action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, action.fromaddr, action.execaddr, borrowRecord.CollateralValue*Coin)
if err != nil {
clog.Error("CollateralizeRepay.ExecTransferFrozen", "addr", coll.CreateAddr, "execaddr", action.execaddr, "amount", borrowRecord.CollateralValue)
return nil, err
......@@ -642,7 +628,7 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
borrowRecord.Status = pty.CollateralizeUserStatusClose
// 保存
coll.Balance += repay.Value
coll.Balance += borrowRecord.DebtValue
coll.BorrowRecords = append(coll.BorrowRecords[:index], coll.BorrowRecords[index+1:]...)
coll.InvalidRecords = append(coll.InvalidRecords, borrowRecord)
coll.LatestLiquidationPrice = getLatestLiquidationPrice(&coll.Collateralize)
......@@ -702,7 +688,7 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty
}
// 检查抵押物账户余额
if !action.CheckExecAccountBalance(action.fromaddr, cAppend.CollateralValue, 0) {
if !action.CheckExecAccountBalance(action.fromaddr, cAppend.CollateralValue*Coin, 0) {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrNoBalance)
return nil, types.ErrNoBalance
}
......@@ -717,7 +703,7 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty
kv = append(kv, receipt.KV...)
// 抵押物冻结
receipt, err = action.coinsAccount.ExecFrozen(coll.CreateAddr, action.execaddr, cAppend.CollateralValue)
receipt, err = action.coinsAccount.ExecFrozen(coll.CreateAddr, action.execaddr, cAppend.CollateralValue*Coin)
if err != nil {
clog.Error("CollateralizeBorrow.Frozen", "addr", coll.CreateAddr, "execaddr", action.execaddr, "amount", cAppend.CollateralValue, "err", err)
return nil, err
......@@ -812,7 +798,7 @@ func getGuarantorAddr(db dbm.KV) (string, error) {
return "", err
}
return item.GetAddr(), nil
return item.GetArr().Value[0], nil
}
// 系统清算
......@@ -840,7 +826,7 @@ func (action *Action) systemLiquidation(coll *pty.Collateralize, price float32)
}
// 抵押物转移
receipt, err := action.coinsAccount.ExecTransferFrozen(action.fromaddr, getGuarantorAddr, action.execaddr, borrowRecord.CollateralValue)
receipt, err := action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, getGuarantorAddr, action.execaddr, borrowRecord.CollateralValue*Coin)
if err != nil {
clog.Error("systemLiquidation", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", borrowRecord.CollateralValue, "err", err)
continue
......@@ -852,8 +838,8 @@ func (action *Action) systemLiquidation(coll *pty.Collateralize, price float32)
borrowRecord.LiquidateTime = action.blocktime
borrowRecord.PreStatus = borrowRecord.Status
borrowRecord.Status = pty.CollateralizeUserStatusSystemLiquidate
coll.BorrowRecords = append(coll.BorrowRecords[:index], coll.BorrowRecords[index+1:]...)
coll.InvalidRecords = append(coll.InvalidRecords, borrowRecord)
coll.BorrowRecords = append(coll.BorrowRecords[:index], coll.BorrowRecords[index+1:]...)
} else {
borrowRecord.PreStatus = borrowRecord.Status
borrowRecord.Status = pty.CollateralizeUserStatusWarning
......@@ -896,7 +882,7 @@ func (action *Action) expireLiquidation(coll *pty.Collateralize) (*types.Receipt
}
// 抵押物转移
receipt, err := action.coinsAccount.ExecTransferFrozen(action.fromaddr, getGuarantorAddr, action.execaddr, borrowRecord.CollateralValue)
receipt, err := action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, getGuarantorAddr, action.execaddr, borrowRecord.CollateralValue*Coin)
if err != nil {
clog.Error("systemLiquidation", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", borrowRecord.CollateralValue, "err", err)
continue
......@@ -908,8 +894,8 @@ func (action *Action) expireLiquidation(coll *pty.Collateralize) (*types.Receipt
borrowRecord.LiquidateTime = action.blocktime
borrowRecord.PreStatus = borrowRecord.Status
borrowRecord.Status = pty.CollateralizeUserStatusExpireLiquidate
coll.BorrowRecords = append(coll.BorrowRecords[:index], coll.BorrowRecords[index+1:]...)
coll.InvalidRecords = append(coll.InvalidRecords, borrowRecord)
coll.BorrowRecords = append(coll.BorrowRecords[:index], coll.BorrowRecords[index+1:]...)
} else {
borrowRecord.PreStatus = borrowRecord.Status
borrowRecord.Status = pty.CollateralizeUserStatusExpire
......@@ -968,14 +954,14 @@ func (action *Action) CollateralizeFeed(feed *pty.CollateralizeFeed) (*types.Rec
return nil, pty.ErrPriceInvalid
}
collIDRecords, err := queryCollateralizeByStatus(action.localDB, pty.CollateralizeStatusCreated)
ids, err := queryCollateralizeByStatus(action.localDB, pty.CollateralizeStatusCreated)
if err != nil {
clog.Error("CollateralizePriceFeed", "get collateralize record error", err)
return nil, err
}
for _, collID := range collIDRecords {
coll, err := queryCollateralizeByID(action.db, collID.CollateralizeId)
for _, collID := range ids {
coll, err := queryCollateralizeByID(action.db, collID)
if err != nil {
clog.Error("CollateralizePriceFeed", "Collateralize ID", coll.CollateralizeId, "get collateralize record by id error", err)
continue
......@@ -1032,6 +1018,7 @@ func (action *Action) CollateralizeFeed(feed *pty.CollateralizeFeed) (*types.Rec
func (action *Action) CollateralizeClose(close *pty.CollateralizeClose) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
var receipt *types.Receipt
collateralize, err := queryCollateralizeByID(action.db, close.CollateralizeId)
if err != nil {
......@@ -1039,6 +1026,11 @@ func (action *Action) CollateralizeClose(close *pty.CollateralizeClose) (*types.
return nil, err
}
if action.fromaddr != collateralize.CreateAddr {
clog.Error("CollateralizeClose", "CollateralizeId", close.CollateralizeId, "err", "account error", "create", collateralize.CreateAddr, "from", action.fromaddr)
return nil, pty.ErrPermissionDeny
}
for _, borrowRecord := range collateralize.BorrowRecords {
if borrowRecord.Status != pty.CollateralizeUserStatusClose {
clog.Error("CollateralizeClose", "CollateralizeId", close.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", pty.ErrCollateralizeRecordNotEmpty)
......@@ -1046,6 +1038,15 @@ func (action *Action) CollateralizeClose(close *pty.CollateralizeClose) (*types.
}
}
// 解冻ccny
receipt, err = action.tokenAccount.ExecActive(action.fromaddr, action.execaddr, collateralize.TotalBalance*Coin)
if err != nil {
clog.Error("IssuanceClose.ExecActive", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", collateralize.TotalBalance)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
clog.Debug("CollateralizeClose", "ID", close.CollateralizeId)
coll := &CollateralizeDB{*collateralize}
......@@ -1078,14 +1079,14 @@ func queryCollateralizeByID(db dbm.KV, collateralizeID string) (*pty.Collaterali
return &coll, nil
}
func queryCollateralizeByStatus(localdb dbm.Lister, status int32) ([]*pty.CollateralizeRecord, error) {
func queryCollateralizeByStatus(localdb dbm.Lister, status int32) ([]string, error) {
data, err := localdb.List(calcCollateralizeStatusPrefix(status), nil, DefultCount, ListDESC)
if err != nil {
clog.Debug("queryCollateralizesByStatus", "error", err)
return nil, err
}
var colls []*pty.CollateralizeRecord
var ids []string
var coll pty.CollateralizeRecord
for _, collBytes := range data {
err = types.Decode(collBytes, &coll)
......@@ -1093,20 +1094,20 @@ func queryCollateralizeByStatus(localdb dbm.Lister, status int32) ([]*pty.Collat
clog.Debug("queryCollateralizesByStatus", "decode", err)
return nil, err
}
colls = append(colls, &coll)
ids = append(ids, coll.CollateralizeId)
}
return colls, nil
return ids, nil
}
func queryCollateralizeByAddr(localdb dbm.Lister, addr string) ([]*pty.CollateralizeRecord, error) {
func queryCollateralizeByAddr(localdb dbm.Lister, addr string) ([]string, error) {
data, err := localdb.List(calcCollateralizeAddrPrefix(addr), nil, DefultCount, ListDESC)
if err != nil {
clog.Debug("queryCollateralizesByAddr", "error", err)
return nil, err
}
var colls []*pty.CollateralizeRecord
var ids []string
var coll pty.CollateralizeRecord
for _, collBytes := range data {
err = types.Decode(collBytes, &coll)
......@@ -1114,10 +1115,10 @@ func queryCollateralizeByAddr(localdb dbm.Lister, addr string) ([]*pty.Collatera
clog.Debug("queryCollateralizesByAddr", "decode", err)
return nil, err
}
colls = append(colls, &coll)
ids = append(ids, coll.CollateralizeId)
}
return colls, nil
return ids, nil
}
// 精确查找发行记录
......@@ -1171,7 +1172,14 @@ func queryCollateralizeRecordByAddr(db dbm.KV, localdb dbm.Lister, addr string)
}
func queryCollateralizeRecordByStatus(db dbm.KV, localdb dbm.Lister, status int32) ([]*pty.BorrowRecord, error) {
data, err := localdb.List(calcCollateralizeRecordStatusPrefix(status), nil, DefultCount, ListDESC)
var statusKey string
if status == 0 {
statusKey = ""
} else {
statusKey = fmt.Sprintf("%d", status)
}
data, err := localdb.List(calcCollateralizeRecordStatusPrefix(statusKey), nil, DefultCount, ListDESC)
if err != nil {
clog.Debug("queryCollateralizeRecordByStatus", "error", err)
return nil, err
......@@ -1183,13 +1191,13 @@ func queryCollateralizeRecordByStatus(db dbm.KV, localdb dbm.Lister, status int3
err = types.Decode(collBytes, &coll)
if err != nil {
clog.Debug("queryCollateralizesByStatus", "decode", err)
return nil, err
continue
}
record, err := queryCollateralizeRecordByID(db, coll.CollateralizeId, coll.RecordId)
if err != nil {
clog.Error("queryIssuanceRecordsByStatus", "decode", err)
return nil, err
continue
}
records = append(records, record)
}
......
......@@ -12,47 +12,51 @@ import (
func (c *Collateralize) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
for _, item := range receiptData.Logs {
var collateralizeLog pty.ReceiptCollateralize
err := types.Decode(item.Log, &collateralizeLog)
if err != nil {
return nil, err
}
if item.Ty == pty.TyLogCollateralizeCreate || item.Ty == pty.TyLogCollateralizeBorrow || item.Ty == pty.TyLogCollateralizeAppend ||
item.Ty == pty.TyLogCollateralizeRepay || item.Ty == pty.TyLogCollateralizeFeed || item.Ty == pty.TyLogCollateralizeClose {
var collateralizeLog pty.ReceiptCollateralize
err := types.Decode(item.Log, &collateralizeLog)
if err != nil {
return nil, err
}
switch item.Ty {
case pty.TyLogCollateralizeCreate:
set.KV = append(set.KV, c.deleteCollateralizeStatus(collateralizeLog.Status, collateralizeLog.Index)...)
set.KV = append(set.KV, c.deleteCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.Index)...)
break
case pty.TyLogCollateralizeBorrow:
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.Index)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.Index)...)
break
case pty.TyLogCollateralizeAppend: // append没有状态变化
break
case pty.TyLogCollateralizeRepay:
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordPreStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
break
case pty.TyLogCollateralizeFeed:
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
// 如果没有被清算,需要把地址索引更新
if collateralizeLog.RecordStatus == pty.CollateralizeUserStatusWarning || collateralizeLog.RecordStatus == pty.CollateralizeUserStatusExpire {
switch item.Ty {
case pty.TyLogCollateralizeCreate:
set.KV = append(set.KV, c.deleteCollateralizeStatus(collateralizeLog.Status, collateralizeLog.Index)...)
set.KV = append(set.KV, c.deleteCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.Index)...)
break
case pty.TyLogCollateralizeBorrow:
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.Index)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.Index)...)
break
case pty.TyLogCollateralizeAppend: // append没有状态变化
break
case pty.TyLogCollateralizeRepay:
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordPreStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
break
case pty.TyLogCollateralizeFeed:
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.PreIndex)...)
// 如果没有被清算,需要把地址索引更新
if collateralizeLog.RecordStatus == pty.CollateralizeUserStatusWarning || collateralizeLog.RecordStatus == pty.CollateralizeUserStatusExpire {
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.Index)...)
}
break
case pty.TyLogCollateralizeClose:
set.KV = append(set.KV, c.deleteCollateralizeStatus(collateralizeLog.Status, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeStatus(pty.CollateralizeStatusCreated, collateralizeLog.CollateralizeId,
collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.addCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.CollateralizeId,
collateralizeLog.PreIndex)...)
break
}
break
case pty.TyLogCollateralizeClose:
set.KV = append(set.KV, c.addCollateralizeStatus(pty.CollateralizeStatusCreated, collateralizeLog.CollateralizeId,
collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.addCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.CollateralizeId,
collateralizeLog.PreIndex)...)
break
}
}
return set, nil
......
......@@ -13,46 +13,50 @@ import (
func (c *Collateralize) execLocal(tx *types.Transaction, receipt *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
for _, item := range receipt.Logs {
var collateralizeLog pty.ReceiptCollateralize
err := types.Decode(item.Log, &collateralizeLog)
if err != nil {
return nil, err
}
if item.Ty == pty.TyLogCollateralizeCreate || item.Ty == pty.TyLogCollateralizeBorrow || item.Ty == pty.TyLogCollateralizeAppend ||
item.Ty == pty.TyLogCollateralizeRepay || item.Ty == pty.TyLogCollateralizeFeed || item.Ty == pty.TyLogCollateralizeClose {
var collateralizeLog pty.ReceiptCollateralize
err := types.Decode(item.Log, &collateralizeLog)
if err != nil {
return nil, err
}
switch item.Ty {
case pty.TyLogCollateralizeCreate:
set.KV = append(set.KV, c.addCollateralizeStatus(collateralizeLog.Status, collateralizeLog.CollateralizeId, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.CollateralizeId, collateralizeLog.Index)...)
break
case pty.TyLogCollateralizeBorrow:
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...)
break
case pty.TyLogCollateralizeAppend: //append没有状态变化
break
case pty.TyLogCollateralizeRepay:
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordPreStatus, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.PreIndex)...)
break
case pty.TyLogCollateralizeFeed:
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordPreStatus, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.PreIndex)...)
// 如果没有被清算,需要把地址索引更新
if collateralizeLog.RecordStatus == pty.CollateralizeUserStatusWarning || collateralizeLog.RecordStatus == pty.CollateralizeUserStatusExpire {
switch item.Ty {
case pty.TyLogCollateralizeCreate:
set.KV = append(set.KV, c.addCollateralizeStatus(collateralizeLog.Status, collateralizeLog.CollateralizeId, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.CollateralizeId, collateralizeLog.Index)...)
break
case pty.TyLogCollateralizeBorrow:
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...)
set.KV = append(set.KV, c.addCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...)
break
case pty.TyLogCollateralizeAppend: //append没有状态变化
break
case pty.TyLogCollateralizeRepay:
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordPreStatus, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.PreIndex)...)
break
case pty.TyLogCollateralizeFeed:
set.KV = append(set.KV, c.deleteCollateralizeRecordStatus(collateralizeLog.RecordPreStatus, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.addCollateralizeRecordStatus(collateralizeLog.RecordStatus, collateralizeLog.CollateralizeId,
collateralizeLog.RecordId, collateralizeLog.Index)...)
set.KV = append(set.KV, c.deleteCollateralizeRecordAddr(collateralizeLog.AccountAddr, collateralizeLog.PreIndex)...)
// 如果没有被清算,需要把地址索引更新
if collateralizeLog.RecordStatus == pty.CollateralizeUserStatusWarning || collateralizeLog.RecordStatus == 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(pty.CollateralizeStatusCreated, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.deleteCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.PreIndex)...)
break
}
break
case pty.TyLogCollateralizeClose:
set.KV = append(set.KV, c.deleteCollateralizeStatus(pty.CollateralizeStatusCreated, collateralizeLog.PreIndex)...)
set.KV = append(set.KV, c.deleteCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.PreIndex)...)
break
}
}
return set, nil
......
......@@ -7,56 +7,56 @@ package executor
import "fmt"
func calcCollateralizeKey(collateralizeID string, index int64) []byte {
key := fmt.Sprintf("LODB-Collateralize-ID:%s:%018d", collateralizeID, index)
key := fmt.Sprintf("LODB-collateralize-ID:%s:%018d", collateralizeID, index)
return []byte(key)
}
func calcCollateralizeStatusPrefix(status int32) []byte {
key := fmt.Sprintf("LODB-Collateralize-status-index:%d", status)
key := fmt.Sprintf("LODB-collateralize-status:%d", status)
return []byte(key)
}
func calcCollateralizeStatusKey(status int32, index int64) []byte {
key := fmt.Sprintf("LODB-Collateralize-status:%d:%018d", status, index)
key := fmt.Sprintf("LODB-collateralize-status:%d:%018d", status, index)
return []byte(key)
}
func calcCollateralizeAddrPrefix(addr string) []byte {
key := fmt.Sprintf("LODB-Collateralize-addr:%s", addr)
key := fmt.Sprintf("LODB-collateralize-addr:%s", addr)
return []byte(key)
}
func calcCollateralizeAddrKey(addr string, index int64) []byte {
key := fmt.Sprintf("LODB-Collateralize-addr:%s:%018d", addr, index)
key := fmt.Sprintf("LODB-collateralize-addr:%s:%018d", addr, index)
return []byte(key)
}
func calcCollateralizePriceKey(time string) []byte {
key := fmt.Sprintf("LODB-Collateralize-price:%s", time)
key := fmt.Sprintf("LODB-collateralize-price:%s", time)
return []byte(key)
}
func calcCollateralizeLatestPriceKey() []byte {
key := fmt.Sprintf("LODB-Collateralize-latest-price")
key := fmt.Sprintf("LODB-collateralize-latest-price")
return []byte(key)
}
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)
}
func calcCollateralizeRecordAddrKey(addr string, index int64) []byte {
key := fmt.Sprintf("LODB-Collateralize-record-addr:%d:%018d", addr, index)
key := fmt.Sprintf("LODB-collateralize-record-addr:%d:%018d", addr, index)
return []byte(key)
}
func calcCollateralizeRecordStatusPrefix(status int32) []byte {
key := fmt.Sprintf("LODB-Collateralize-record-status:%d", status)
func calcCollateralizeRecordStatusPrefix(status string) []byte {
key := fmt.Sprintf("LODB-collateralize-record-status:%s", status)
return []byte(key)
}
func calcCollateralizeRecordStatusKey(status int32, index int64) []byte {
key := fmt.Sprintf("LODB-Collateralize-record-status:%d:%018d", status, index)
key := fmt.Sprintf("LODB-collateralize-record-status:%d:%018d", status, index)
return []byte(key)
}
\ No newline at end of file
......@@ -58,10 +58,7 @@ func (c *Collateralize) Query_CollateralizeByStatus(req *pty.ReqCollateralizeByS
return nil, err
}
for _, record := range collIDRecords {
ids.IDs = append(ids.IDs, record.CollateralizeId)
}
ids.IDs = append(ids.IDs, collIDRecords...)
return ids, nil
}
......@@ -73,47 +70,42 @@ func (c *Collateralize) Query_CollateralizeByAddr(req *pty.ReqCollateralizeByAdd
return nil, err
}
for _, record := range collIDRecords {
ids.IDs = append(ids.IDs, record.CollateralizeId)
}
ids.IDs = append(ids.IDs, collIDRecords...)
return ids, nil
}
func (c *Collateralize) Query_CollateralizeRecordByID(req *pty.ReqCollateralizeRecord) (types.Message, error) {
ret := &pty.RepCollateralizeRecord{}
issuRecord, err := queryCollateralizeRecordByID(c.GetStateDB(), req.CollateralizeId, req.RecordId)
if err != nil {
clog.Error("Query_IssuanceRecordByID", "get issuance record error", err)
clog.Error("Query_IssuanceRecordByID", "get collateralize record error", err)
return nil, err
}
ret := &pty.RepCollateralizeRecord{}
ret.Record = issuRecord
return issuRecord, nil
return ret, nil
}
func (c *Collateralize) Query_CollateralizeRecordByAddr(req *pty.ReqCollateralizeRecordByAddr) (types.Message, error) {
ret := &pty.RepCollateralizeRecords{}
records, err := queryCollateralizeRecordByAddr(c.GetStateDB(), c.GetLocalDB(), req.Addr)
if err != nil {
clog.Error("Query_CollateralizeRecordByAddr", "get collateralize record error", err)
return nil, err
}
ret := &pty.RepCollateralizeRecords{}
ret.Records = records
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)
if err != nil {
clog.Error("Query_CollateralizeRecordByAddr", "get collateralize record error", err)
clog.Error("Query_CollateralizeRecordByStatus", "get collateralize record error", err)
return nil, err
}
ret := &pty.RepCollateralizeRecords{}
ret.Records = records
return ret, nil
}
\ No newline at end of file
......@@ -85,7 +85,6 @@ message CollateralizeBorrow {
message CollateralizeRepay {
string collateralizeId = 1; //借贷期数ID
string recordId = 2; //借贷ID
int64 value = 3; //借贷价值(ccny)
}
// 追加抵押物
......
......@@ -201,7 +201,7 @@ func CreateRawCollateralizeRepayTx(parm *CollateralizeRepayTx) (*types.Transacti
v := &CollateralizeRepay{
CollateralizeId: parm.CollateralizeID,
Value: parm.Value,
RecordId:parm.RecordID,
}
repay := &CollateralizeAction{
Ty: CollateralizeActionRepay,
......@@ -230,6 +230,7 @@ func CreateRawCollateralizeAppendTx(parm *CollateralizeAppendTx) (*types.Transac
v := &CollateralizeAppend{
CollateralizeId: parm.CollateralizeID,
RecordId:parm.RecordID,
CollateralValue: parm.Value,
}
append := &CollateralizeAction{
......
......@@ -730,7 +730,6 @@ func (m *CollateralizeBorrow) GetValue() int64 {
type CollateralizeRepay struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
RecordId string `protobuf:"bytes,2,opt,name=recordId,proto3" json:"recordId,omitempty"`
Value int64 `protobuf:"varint,3,opt,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -775,13 +774,6 @@ func (m *CollateralizeRepay) GetRecordId() string {
return ""
}
func (m *CollateralizeRepay) GetValue() int64 {
if m != nil {
return m.Value
}
return 0
}
// 追加抵押物
type CollateralizeAppend struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
......@@ -1727,78 +1719,77 @@ func init() {
func init() { proto.RegisterFile("collateralize.proto", fileDescriptor_a988fb4a61381972) }
var fileDescriptor_a988fb4a61381972 = []byte{
// 1155 bytes of a gzipped FileDescript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0xc8, 0xbe, 0x90,
0x4b, 0x3f, 0xaf, 0xaa, 0x9b, 0xf8, 0x43, 0x3b, 0xc5, 0x77, 0xee, 0x30, 0x37, 0x4c, 0x30, 0xfe,
0x0c, 0xf7, 0x5f, 0x16, 0x29, 0xfb, 0x10, 0x7a, 0x0a, 0xa5, 0x5f, 0xa9, 0x4b, 0xe3, 0xd4, 0x90,
0x49, 0x8f, 0x3e, 0xcd, 0x1f, 0xfd, 0x15, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xc2, 0xca, 0x4a, 0xb1,
0x0f, 0x00, 0x00,
// 1148 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x57, 0xe1, 0x6e, 0xdc, 0x44,
0x10, 0xae, 0xed, 0xbb, 0x4b, 0x6e, 0x2e, 0x69, 0x93, 0x4d, 0x08, 0x26, 0x54, 0xd1, 0x69, 0x85,
0xc4, 0x09, 0x4a, 0x24, 0xd2, 0x0a, 0x51, 0x21, 0x21, 0x92, 0xb4, 0x55, 0x4e, 0x2a, 0x52, 0x65,
0x0a, 0x42, 0x08, 0x90, 0x7c, 0xf6, 0xa6, 0x58, 0x72, 0xce, 0x8e, 0xbd, 0x17, 0x7a, 0xfc, 0x06,
0xfe, 0xf6, 0x05, 0x78, 0x01, 0x5e, 0x80, 0xe7, 0x43, 0x33, 0xbb, 0x67, 0x7b, 0xd7, 0x77, 0x51,
0x02, 0xfc, 0xe2, 0xcf, 0xe9, 0x66, 0xe6, 0x9b, 0xdd, 0xd9, 0x99, 0x6f, 0x67, 0xd6, 0xb0, 0x13,
0x65, 0x69, 0x1a, 0x4a, 0x51, 0x84, 0x69, 0xf2, 0x8b, 0x38, 0xcc, 0x8b, 0x4c, 0x66, 0xac, 0x2b,
0xe7, 0xb9, 0x28, 0xf9, 0x9b, 0x2e, 0x6c, 0x9e, 0x36, 0xcd, 0x6c, 0x04, 0xf7, 0x0c, 0x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, 0x29, 0xd9, 0x16, 0x78, 0xe3, 0x27, 0x8b,
0x13, 0xe3, 0x5f, 0xfe, 0x3d, 0x1e, 0xf2, 0x72, 0x09, 0x41, 0xf5, 0xe2, 0xff, 0xea, 0x6e, 0xf1,
0x09, 0x1c, 0xac, 0x5a, 0xbd, 0xee, 0x1a, 0x37, 0x5c, 0xbf, 0x4e, 0x8c, 0x6b, 0x24, 0xe6, 0x0c,
0xde, 0xb6, 0x8f, 0xba, 0xb8, 0x90, 0x1f, 0xd9, 0x17, 0x72, 0xe9, 0x87, 0x54, 0x75, 0x13, 0x7f,
0x6c, 0xa7, 0xf8, 0xd6, 0x1d, 0xe6, 0xba, 0xf9, 0xf8, 0x14, 0xd7, 0x5f, 0x16, 0x29, 0xfb, 0x10,
0x7a, 0x0a, 0xa5, 0xdf, 0xa3, 0x4b, 0xe3, 0xd4, 0x90, 0x49, 0x8f, 0x3e, 0xc2, 0x1f, 0xfe, 0x1d,
0x00, 0x00, 0xff, 0xff, 0xd0, 0x3f, 0xd2, 0x26, 0x9b, 0x0f, 0x00, 0x00,
}
......@@ -20,13 +20,14 @@ type CollateralizeBorrowTx struct {
// CollateralizeRepayTx for construction
type CollateralizeRepayTx struct {
CollateralizeID string `json:"collateralizeId"`
Value int64 `json:"value"`
RecordID string `json:"recordID"`
Fee int64 `json:"fee"`
}
// CollateralizeAppednTx for construction
type CollateralizeAppendTx struct {
CollateralizeID string `json:"collateralizeId"`
RecordID string `json:"recordID"`
Value int64 `json:"value"`
Fee int64 `json:"fee"`
}
......
......@@ -2,11 +2,11 @@ package commands
import (
"fmt"
"github.com/spf13/cobra"
jsonrpc "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
pkt "github.com/33cn/plugin/plugin/dapp/issuance/types"
"github.com/spf13/cobra"
"strconv"
)
......@@ -44,6 +44,7 @@ func IssuanceCreateRawTxCmd() *cobra.Command {
func addIssuanceCreateFlags(cmd *cobra.Command) {
cmd.Flags().Uint64P("balance", "b", 0, "balance")
cmd.MarkFlagRequired("balance")
cmd.Flags().Uint64P("debtCeiling", "d", 0, "debtCeiling")
cmd.Flags().Float32P("liquidationRatio", "l", 0, "liquidationRatio")
cmd.Flags().Uint64P("period", "p", 0, "period")
......@@ -56,11 +57,10 @@ func IssuanceCreate(cmd *cobra.Command, args []string) {
liquidationRatio, _ := cmd.Flags().GetFloat32("liquidationRatio")
period, _ := cmd.Flags().GetUint64("period")
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.IssuanceX),
ActionName: "IssuanceCreate",
Payload: []byte(fmt.Sprintf("{\"balance\":%d, \"debtCeiling\":%d, \"liquidationRatio\":%f, \"period\":%d,}",
Payload: []byte(fmt.Sprintf("{\"totalBalance\":%d, \"debtCeiling\":%d, \"liquidationRatio\":%f, \"period\":%d}",
balance, debtCeiling, liquidationRatio, period)),
}
......@@ -95,7 +95,7 @@ func IssuanceDebt(cmd *cobra.Command, args []string) {
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.IssuanceX),
ActionName: "IssuanceDebt",
Payload: []byte(fmt.Sprintf("{\"issuanceID\":%s,\"value\":%d}", issuanceID, value)),
Payload: []byte(fmt.Sprintf("{\"issuanceID\":\"%s\",\"value\":%d}", issuanceID, value)),
}
var res string
......@@ -117,16 +117,19 @@ func IssuanceRepayRawTxCmd() *cobra.Command {
func addIssuanceRepayFlags(cmd *cobra.Command) {
cmd.Flags().StringP("issuanceID", "g", "", "issuance ID")
cmd.MarkFlagRequired("issuanceID")
cmd.Flags().StringP("debtID", "d", "", "debt ID")
cmd.MarkFlagRequired("debtID")
}
func IssuanceRepay(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
issuanceID, _ := cmd.Flags().GetString("issuanceID")
debtID, _ := cmd.Flags().GetString("debtID")
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.IssuanceX),
ActionName: "IssuanceRepay",
Payload: []byte(fmt.Sprintf("{\"issuanceID\":%s}", issuanceID)),
Payload: []byte(fmt.Sprintf("{\"issuanceID\":\"%s\", \"debtID\":\"%s\"}", issuanceID, debtID)),
}
var res string
......@@ -160,7 +163,7 @@ func IssuancePriceFeed(cmd *cobra.Command, args []string) {
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.IssuanceX),
ActionName: "IssuancePriceFeed",
Payload: []byte(fmt.Sprintf("{[\"price\":%s],[\"volume\":%d]}", price, volume)),
Payload: []byte(fmt.Sprintf("{\"price\":[ %f ], \"volume\":[ %d ]}", price, volume)),
}
var res string
......@@ -191,7 +194,7 @@ func IssuanceClose(cmd *cobra.Command, args []string) {
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.IssuanceX),
ActionName: "IssuanceClose",
Payload: []byte(fmt.Sprintf("{\"issuanceID\":%s}", issuanceID)),
Payload: []byte(fmt.Sprintf("{\"issuanceId\":\"%s\"}", issuanceID)),
}
var res string
......@@ -212,6 +215,7 @@ func IssuanceManageRawTxCmd() *cobra.Command {
func addIssuanceManageFlags(cmd *cobra.Command) {
cmd.Flags().StringP("addr", "a", "", "addr")
cmd.MarkFlagRequired("addr")
}
func IssuanceManage(cmd *cobra.Command, args []string) {
......@@ -221,7 +225,7 @@ func IssuanceManage(cmd *cobra.Command, args []string) {
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pkt.IssuanceX),
ActionName: "IssuanceManage",
Payload: []byte(fmt.Sprintf("{[\"addr\":%s]}", addr)),
Payload: []byte(fmt.Sprintf("{\"addr\":[\"%s\"]}", addr)),
}
var res string
......@@ -270,11 +274,15 @@ func IssuanceQuery(cmd *cobra.Command, args []string) {
// req.Index = index
//}
status, err := strconv.ParseInt(statusStr, 10, 32)
if err != nil {
fmt.Println(err)
cmd.Help()
return
var status int64
var err error
if statusStr != "" {
status, err = strconv.ParseInt(statusStr, 10, 32)
if err != nil {
fmt.Println(err)
cmd.Help()
return
}
}
if issuanceID != "" {
......@@ -297,7 +305,7 @@ func IssuanceQuery(cmd *cobra.Command, args []string) {
Addr: address,
}
params.Payload = types.MustPBToJSON(req)
var res pkt.RepIssuanceDebtInfo
var res pkt.RepIssuanceRecords
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
} else if debtID != ""{
......@@ -308,7 +316,7 @@ func IssuanceQuery(cmd *cobra.Command, args []string) {
DebtId: debtID,
}
params.Payload = types.MustPBToJSON(req)
var res pkt.RepIssuanceCurrentInfo
var res pkt.RepIssuanceDebtInfo
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
} else {
......@@ -342,7 +350,6 @@ func IssuanceQuery(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")
cmd.Help()
}
}
......@@ -16,7 +16,7 @@ func (c *Issuance) Exec_Create(payload *pty.IssuanceCreate, tx *types.Transactio
}
// Exec_Borrow Action
func (c *Issuance) Exec_Borrow(payload *pty.IssuanceDebt, tx *types.Transaction, index int) (*types.Receipt, error) {
func (c *Issuance) Exec_Debt(payload *pty.IssuanceDebt, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewIssuanceAction(c, tx, index)
return actiondb.IssuanceDebt(payload)
}
......@@ -38,3 +38,9 @@ func (c *Issuance) Exec_Close(payload *pty.IssuanceClose, tx *types.Transaction,
actiondb := NewIssuanceAction(c, tx, index)
return actiondb.IssuanceClose(payload)
}
// Exec_Manage Action
func (c *Issuance) Exec_Manage(payload *pty.IssuanceManage, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewIssuanceAction(c, tx, index)
return actiondb.IssuanceManage(payload)
}
......@@ -12,41 +12,46 @@ import (
func (c *Issuance) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
for _, item := range receiptData.Logs {
var issuanceLog pty.ReceiptIssuance
err := types.Decode(item.Log, &issuanceLog)
if err != nil {
return nil, err
}
if item.Ty == pty.TyLogIssuanceCreate || item.Ty == pty.TyLogIssuanceDebt || item.Ty == pty.TyLogIssuanceRepay ||
item.Ty == pty.TyLogIssuanceFeed || item.Ty == pty.TyLogIssuanceClose {
var issuanceLog pty.ReceiptIssuance
err := types.Decode(item.Log, &issuanceLog)
if err != nil {
return nil, err
}
switch item.Ty {
case pty.TyLogIssuanceCreate:
set.KV = append(set.KV, c.deleteIssuanceStatus(issuanceLog.Status, issuanceLog.Index)...)
break
case pty.TyLogIssuanceDebt:
set.KV = append(set.KV, c.deleteIssuanceRecordStatus(issuanceLog.RecordStatus, issuanceLog.Index)...)
set.KV = append(set.KV, c.deleteIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.Index)...)
break
case pty.TyLogIssuanceRepay:
set.KV = append(set.KV, c.addIssuanceRecordStatus(issuanceLog.RecordPreStatus, issuanceLog.AccountAddr, issuanceLog.PreIndex,
issuanceLog.DebtId, issuanceLog.IssuanceId)...)
set.KV = append(set.KV, c.deleteIssuanceRecordStatus(issuanceLog.RecordStatus, issuanceLog.Index)...)
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.RecordStatus, issuanceLog.AccountAddr, issuanceLog.PreIndex,
issuanceLog.DebtId, issuanceLog.IssuanceId)...)
set.KV = append(set.KV, c.deleteIssuanceRecordStatus(issuanceLog.RecordStatus, issuanceLog.Index)...)
set.KV = append(set.KV, c.addIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.PreIndex, issuanceLog.DebtId,
issuanceLog.IssuanceId)...)
// 如果没有被清算,需要把地址索引更新
if issuanceLog.RecordStatus == pty.IssuanceUserStatusWarning || issuanceLog.RecordStatus == pty.IssuanceUserStatusExpire {
switch item.Ty {
case pty.TyLogIssuanceCreate:
set.KV = append(set.KV, c.deleteIssuanceStatus(issuanceLog.Status, issuanceLog.Index)...)
break
case pty.TyLogIssuanceDebt:
set.KV = append(set.KV, c.deleteIssuanceRecordStatus(issuanceLog.Status, issuanceLog.Index)...)
set.KV = append(set.KV, c.deleteIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.Index)...)
break
case pty.TyLogIssuanceRepay:
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)...)
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.deleteIssuancePriceRecord(issuanceLog.RecordTime)...)
break
case pty.TyLogIssuanceClose:
set.KV = append(set.KV, c.deleteIssuanceStatus(issuanceLog.Status, issuanceLog.Index)...)
set.KV = append(set.KV, c.addIssuanceStatus(issuanceLog.PreStatus, issuanceLog.PreIndex, issuanceLog.IssuanceId)...)
break
}
break
case pty.TyLogIssuanceClose:
set.KV = append(set.KV, c.addIssuanceStatus(pty.IssuanceStatusCreated, issuanceLog.PreIndex, issuanceLog.IssuanceId)...)
break
}
}
return set, nil
......
......@@ -13,42 +13,47 @@ import (
func (c *Issuance) execLocal(tx *types.Transaction, receipt *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
for _, item := range receipt.Logs {
var issuanceLog pty.ReceiptIssuance
err := types.Decode(item.Log, &issuanceLog)
if err != nil {
return nil, err
}
if item.Ty == pty.TyLogIssuanceCreate || item.Ty == pty.TyLogIssuanceDebt || item.Ty == pty.TyLogIssuanceRepay ||
item.Ty == pty.TyLogIssuanceFeed || item.Ty == pty.TyLogIssuanceClose {
var issuanceLog pty.ReceiptIssuance
err := types.Decode(item.Log, &issuanceLog)
if err != nil {
return nil, err
}
switch item.Ty {
case pty.TyLogIssuanceCreate:
set.KV = append(set.KV, c.addIssuanceStatus(issuanceLog.Status, issuanceLog.Index, issuanceLog.IssuanceId)...)
break
case pty.TyLogIssuanceDebt:
set.KV = append(set.KV, c.addIssuanceRecordStatus(issuanceLog.RecordStatus, issuanceLog.AccountAddr, issuanceLog.Index,
issuanceLog.DebtId, issuanceLog.IssuanceId)...)
set.KV = append(set.KV, c.addIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.Index, issuanceLog.DebtId,
issuanceLog.IssuanceId)...)
break
case pty.TyLogIssuanceRepay:
set.KV = append(set.KV, c.deleteIssuanceRecordStatus(issuanceLog.RecordPreStatus, issuanceLog.PreIndex)...)
set.KV = append(set.KV, c.addIssuanceRecordStatus(issuanceLog.RecordStatus, issuanceLog.AccountAddr, issuanceLog.Index,
issuanceLog.DebtId, issuanceLog.IssuanceId)...)
set.KV = append(set.KV, c.deleteIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.PreIndex)...)
break
case pty.TyLogIssuanceFeed:
set.KV = append(set.KV, c.deleteIssuanceRecordStatus(issuanceLog.RecordPreStatus, issuanceLog.PreIndex)...)
set.KV = append(set.KV, c.addIssuanceRecordStatus(issuanceLog.RecordStatus, issuanceLog.AccountAddr, issuanceLog.Index,
issuanceLog.DebtId, issuanceLog.IssuanceId)...)
set.KV = append(set.KV, c.deleteIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.PreIndex)...)
// 如果没有被清算,需要把地址索引更新
if issuanceLog.RecordStatus == pty.IssuanceUserStatusWarning || issuanceLog.RecordStatus == pty.IssuanceUserStatusExpire {
switch item.Ty {
case pty.TyLogIssuanceCreate:
set.KV = append(set.KV, c.addIssuanceStatus(issuanceLog.Status, issuanceLog.Index, issuanceLog.IssuanceId)...)
break
case pty.TyLogIssuanceDebt:
set.KV = append(set.KV, c.addIssuanceRecordStatus(issuanceLog.Status, issuanceLog.AccountAddr, issuanceLog.Index,
issuanceLog.DebtId, issuanceLog.IssuanceId)...)
set.KV = append(set.KV, c.addIssuanceRecordAddr(issuanceLog.AccountAddr, issuanceLog.Index, issuanceLog.DebtId,
issuanceLog.IssuanceId)...)
break
case pty.TyLogIssuanceRepay:
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)...)
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.addIssuancePriceRecord(issuanceLog.RecordTime, issuanceLog.BtyPrice)...)
break
case pty.TyLogIssuanceClose:
set.KV = append(set.KV, c.addIssuanceStatus(issuanceLog.Status, issuanceLog.Index, issuanceLog.IssuanceId)...)
set.KV = append(set.KV, c.deleteIssuanceStatus(issuanceLog.PreStatus, issuanceLog.PreIndex)...)
break
}
break
case pty.TyLogIssuanceClose:
set.KV = append(set.KV, c.deleteIssuanceStatus(issuanceLog.Status, issuanceLog.PreIndex)...)
break
}
}
return set, nil
......
......@@ -143,6 +143,26 @@ func (c *Issuance) deleteIssuanceRecordStatus(status int32, index int64) (kvs []
return kvs
}
func (c *Issuance) addIssuancePriceRecord(recordTime int64, price float32) (kvs []*types.KeyValue) {
key := calcIssuancePriceKey(string(recordTime))
record := &pty.IssuanceAssetPriceRecord{
RecordTime:recordTime,
BtyPrice:price,
}
kv := &types.KeyValue{Key: key, Value: types.Encode(record)}
kvs = append(kvs, kv)
return kvs
}
func (c *Issuance) deleteIssuancePriceRecord(recordTime int64) (kvs []*types.KeyValue) {
key := calcIssuancePriceKey(string(recordTime))
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 *Issuance) CheckReceiptExecOk() bool {
return true
......
......@@ -5,6 +5,7 @@
package executor
import (
"fmt"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
dbm "github.com/33cn/chain33/common/db"
......@@ -24,6 +25,9 @@ const (
const (
Coin = types.Coin // 1e8
DefaultDebtCeiling = 100000 // 默认借贷限额
DefaultLiquidationRatio = 0.25 // 默认质押比
DefaultPeriod = 3600 * 24 * 365 // 默认合约限期
PriceWarningRate = 1.3 // 价格提前预警率
ExpireWarningTime = 3600 * 24 * 10 // 提前10天超时预警
)
......@@ -61,7 +65,7 @@ func getGuarantorAddr(db dbm.KV) (string, error) {
return "", err
}
return item.GetAddr(), nil
return item.GetArr().Value[0], nil
}
func isRightAddr(key string, addr string, db dbm.KV) bool {
......@@ -91,6 +95,29 @@ func isRightAddr(key string, addr string, db dbm.KV) bool {
}
func isSuperAddr(addr string, db dbm.KV) bool {
data, err := db.Get(AddrKey())
if err != nil {
clog.Error("getSuperAddr", "error", err)
return false
}
var item types.ConfigItem
err = types.Decode(data, &item)
if err != nil {
clog.Error("isSuperAddr", "Decode", data)
return false
}
for _, op := range item.GetArr().Value {
if op == addr {
return true
}
}
return false
}
// IssuanceDB def
type IssuanceDB struct {
pty.Issuance
......@@ -120,7 +147,13 @@ func Key(id string) (key []byte) {
// Key for IssuanceAddrConfig
func AddrKey() (key []byte) {
key = append(key, []byte("mavl-"+pty.IssuanceX+"addr")...)
key = append(key, []byte("mavl-"+pty.IssuanceX+"-addr")...)
return key
}
// Key for IssuancePriceFeed
func PriceKey() (key []byte) {
key = append(key, []byte("mavl-"+pty.IssuanceX+"-price")...)
return key
}
......@@ -156,22 +189,15 @@ func NewIssuanceAction(c *Issuance, tx *types.Transaction, index int) *Action {
execaddr: dapp.ExecAddress(string(tx.Execer)), difficulty: c.GetDifficulty(), index: index, Issuance: c}
}
// GetCollCommonRecipt generate logs for Issuance common action
func (action *Action) GetCollCommonRecipt(issuance *pty.Issuance) *pty.ReceiptIssuance {
c := &pty.ReceiptIssuance{}
c.IssuanceId = issuance.IssuanceId
c.Status = issuance.Status
c.Index = issuance.Index
c.PreIndex = issuance.PreIndex
return c
}
// GetCreateReceiptLog generate logs for Issuance create action
func (action *Action) GetCreateReceiptLog(issuance *pty.Issuance) *types.ReceiptLog {
log := &types.ReceiptLog{}
log.Ty = pty.TyLogIssuanceCreate
c := action.GetCollCommonRecipt(issuance)
c := &pty.ReceiptIssuance{}
c.IssuanceId = issuance.IssuanceId
c.Status = issuance.Status
c.Index = issuance.Index
log.Log = types.Encode(c)
......@@ -183,10 +209,12 @@ func (action *Action) GetDebtReceiptLog(issuance *pty.Issuance, debtRecord *pty.
log := &types.ReceiptLog{}
log.Ty = pty.TyLogIssuanceDebt
c := action.GetCollCommonRecipt(issuance)
c := &pty.ReceiptIssuance{}
c.IssuanceId = issuance.IssuanceId
c.AccountAddr = action.fromaddr
c.DebtId = debtRecord.DebtId
c.RecordStatus = debtRecord.Status
c.Status = debtRecord.Status
c.Index = debtRecord.Index
log.Log = types.Encode(c)
......@@ -198,11 +226,14 @@ func (action *Action) GetRepayReceiptLog(issuance *pty.Issuance, debtRecord *pty
log := &types.ReceiptLog{}
log.Ty = pty.TyLogIssuanceRepay
c := action.GetCollCommonRecipt(issuance)
c := &pty.ReceiptIssuance{}
c.IssuanceId = issuance.IssuanceId
c.AccountAddr = action.fromaddr
c.DebtId = debtRecord.DebtId
c.RecordStatus = debtRecord.Status
c.RecordPreStatus = debtRecord.PreStatus
c.Status = debtRecord.Status
c.PreStatus = debtRecord.PreStatus
c.Index = debtRecord.Index
c.PreIndex = debtRecord.PreIndex
log.Log = types.Encode(c)
......@@ -214,11 +245,27 @@ func (action *Action) GetFeedReceiptLog(issuance *pty.Issuance, debtRecord *pty.
log := &types.ReceiptLog{}
log.Ty = pty.TyLogIssuanceFeed
c := action.GetCollCommonRecipt(issuance)
c := &pty.ReceiptIssuance{}
c.IssuanceId = issuance.IssuanceId
c.AccountAddr = debtRecord.AccountAddr
c.DebtId = debtRecord.DebtId
c.RecordStatus = debtRecord.Status
c.RecordPreStatus = debtRecord.PreStatus
c.Status = debtRecord.Status
c.PreStatus = debtRecord.PreStatus
c.Index = debtRecord.Index
c.PreIndex = debtRecord.PreIndex
log.Log = types.Encode(c)
return log
}
// GetFeedReceiptLog generate logs for Issuance price feed action
func (action *Action) GetPriceReceiptLog(price *pty.IssuanceAssetPriceRecord) *types.ReceiptLog {
log := &types.ReceiptLog{}
log.Ty = pty.TyLogIssuanceFeed
c := &pty.ReceiptIssuance{}
c.RecordTime = price.RecordTime
c.BtyPrice = price.BtyPrice
log.Log = types.Encode(c)
......@@ -226,11 +273,16 @@ func (action *Action) GetFeedReceiptLog(issuance *pty.Issuance, debtRecord *pty.
}
// GetCloseReceiptLog generate logs for Issuance close action
func (action *Action) GetCloseReceiptLog(Issuance *pty.Issuance) *types.ReceiptLog {
func (action *Action) GetCloseReceiptLog(issuance *pty.Issuance) *types.ReceiptLog {
log := &types.ReceiptLog{}
log.Ty = pty.TyLogIssuanceClose
c := action.GetCollCommonRecipt(Issuance)
c := &pty.ReceiptIssuance{}
c.IssuanceId = issuance.IssuanceId
c.Status = issuance.Status
c.PreStatus = pty.IssuanceStatusCreated
c.Index = issuance.Index
c.PreIndex = issuance.PreIndex
log.Log = types.Encode(c)
......@@ -277,24 +329,29 @@ func (action *Action) IssuanceManage(manage *pty.IssuanceManage) (*types.Receipt
}
// 添加大户地址
var item types.ConfigItem
data, err := action.db.Get(AddrKey())
if err != nil {
if err != types.ErrNotFound {
clog.Error("IssuanceManage", "error", err)
return nil, err
}
value := types.Encode(manage)
emptyValue := &types.ArrayConfig{Value: make([]string, 0)}
arr := types.ConfigItem_Arr{Arr: emptyValue}
item.Value = &arr
item.GetArr().Value = append(item.GetArr().Value, manage.SuperAddrs...)
value := types.Encode(&item)
action.db.Set(AddrKey(), value)
kv = append(kv, &types.KeyValue{Key:AddrKey(), Value: value})
} else {
var addrStore pty.IssuanceManage
err = types.Decode(data, &addrStore)
err = types.Decode(data, &item)
if err != nil {
clog.Debug("IssuanceManage", "decode", err)
return nil, err
}
addrStore.SuperAddrs = append(addrStore.SuperAddrs, manage.SuperAddrs...)
value := types.Encode(&addrStore)
item.GetArr().Value = append(item.GetArr().Value, manage.SuperAddrs...)
value := types.Encode(&item)
action.db.Set(AddrKey(), value)
kv = append(kv, &types.KeyValue{Key:AddrKey(), Value: value})
}
......@@ -320,20 +377,6 @@ func (action *Action) getSuperAddr() []string {
return addrStore.SuperAddrs
}
func isSuperAddr(super []string, addr string) bool {
if super == nil || len(super) == 0 {
return false
}
for _, superAddr := range super {
if superAddr == addr {
return true
}
}
return false
}
// IssuanceCreate 创建借贷,持有一定数量ccny的用户可创建借贷,提供给其他用户借贷
func (action *Action) IssuanceCreate(create *pty.IssuanceCreate) (*types.Receipt, error) {
var logs []*types.ReceiptLog
......@@ -347,7 +390,7 @@ func (action *Action) IssuanceCreate(create *pty.IssuanceCreate) (*types.Receipt
}
// 检查ccny余额
if !action.CheckExecTokenAccount(action.fromaddr, create.TotalBalance, false) {
if !action.CheckExecTokenAccount(action.fromaddr, create.TotalBalance*Coin, false) {
return nil, types.ErrInsufficientBalance
}
......@@ -360,7 +403,7 @@ func (action *Action) IssuanceCreate(create *pty.IssuanceCreate) (*types.Receipt
}
// 冻结ccny
receipt, err = action.tokenAccount.ExecFrozen(action.fromaddr, action.execaddr, create.TotalBalance)
receipt, err = action.tokenAccount.ExecFrozen(action.fromaddr, action.execaddr, create.TotalBalance*Coin)
if err != nil {
clog.Error("IssuanceCreate.Frozen", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", create.TotalBalance)
return nil, err
......@@ -371,16 +414,27 @@ func (action *Action) IssuanceCreate(create *pty.IssuanceCreate) (*types.Receipt
// 构造coll结构
issu := &IssuanceDB{}
issu.IssuanceId = issuanceID
issu.LiquidationRatio = create.LiquidationRatio
issu.TotalBalance = create.TotalBalance
if create.LiquidationRatio != 0 {
issu.LiquidationRatio = create.LiquidationRatio
} else {
issu.LiquidationRatio = DefaultLiquidationRatio
}
if create.DebtCeiling != 0 {
issu.DebtCeiling = create.DebtCeiling
} else {
issu.DebtCeiling = DefaultDebtCeiling
}
if create.Period != 0 {
issu.Period = create.Period
} else {
issu.Period = DefaultPeriod
}
issu.Balance = create.TotalBalance
issu.DebtCeiling = create.DebtCeiling
issu.Period = create.Period
issu.CreateTime = action.blocktime
issu.IssuerAddr = action.fromaddr
issu.Status = pty.IssuanceActionCreate
issu.Index = action.GetIndex()
issu.CreateIndex = issu.Index
clog.Debug("IssuanceCreate created", "IssuanceID", issuanceID, "TotalBalance", issu.TotalBalance)
......@@ -410,16 +464,16 @@ func getBtyNumToFrozen(value int64, price float32, ratio float32) (int64,error)
// 获取最近抵押物价格
func (action *Action)getLatestPrice(db dbm.KV) (float32, error) {
data, err := db.Get(calcIssuanceLatestPriceKey())
data, err := db.Get(PriceKey())
if err != nil {
clog.Debug("getLatestPrice", "get", err)
clog.Error("getLatestPrice", "get", err)
return -1, err
}
var price pty.IssuanceAssetPriceRecord
//decode
err = types.Decode(data, &price)
if err != nil {
clog.Debug("getLatestPrice", "decode", err)
clog.Error("getLatestPrice", "decode", err)
return -1, err
}
......@@ -455,6 +509,11 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
var logs []*types.ReceiptLog
var kv []*types.KeyValue
if !isSuperAddr(action.fromaddr, action.db) {
clog.Error("IssuanceDebt", "error", "IssuanceDebt need super address")
return nil, pty.ErrPermissionDeny
}
// 查找对应的借贷ID
issuance, err := queryIssuanceByID(action.db, debt.IssuanceId)
if err != nil {
......@@ -468,13 +527,6 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
return nil, pty.ErrIssuanceStatus
}
//// 一个地址在一期借贷中只允许借出一次
//for _, record := range issuance.DebtRecords {
// if record.AccountAddr == action.fromaddr {
// clog.Error("IssuanceDebt","IssuanceId", debt.IssuanceId, action.fromaddr, "execaddr", action.execaddr, "err", pty.ErrIssuanceAccountExist)
// return nil, err
// }
//}
issu := &IssuanceDB{*issuance}
// 借贷金额检查
......@@ -511,7 +563,7 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
}
// 检查抵押物账户余额
if !action.CheckExecAccountBalance(action.fromaddr, btyFrozen, 0) {
if !action.CheckExecAccountBalance(action.fromaddr, btyFrozen*Coin, 0) {
clog.Error("IssuanceDebt", "CollID", issu.IssuanceId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrNoBalance)
return nil, types.ErrNoBalance
}
......@@ -526,7 +578,7 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
kv = append(kv, receipt.KV...)
// 抵押物冻结
receipt, err = action.coinsAccount.ExecFrozen(issu.IssuerAddr, action.execaddr, btyFrozen)
receipt, err = action.coinsAccount.ExecFrozen(issu.IssuerAddr, action.execaddr, btyFrozen*Coin)
if err != nil {
clog.Error("IssuanceDebt.Frozen", "addr", issu.IssuerAddr, "execaddr", action.execaddr, "amount", btyFrozen)
return nil, err
......@@ -535,7 +587,7 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
kv = append(kv, receipt.KV...)
// 借出ccny
receipt, err = action.tokenAccount.ExecTransfer(issu.IssuerAddr, action.fromaddr, action.execaddr, debt.Value)
receipt, err = action.tokenAccount.ExecTransfer(issu.IssuerAddr, action.fromaddr, action.execaddr, debt.Value*Coin)
if err != nil {
clog.Error("IssuanceDebt.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", debt.Value)
return nil, err
......@@ -554,6 +606,7 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
debtRecord.LiquidationPrice = issu.LiquidationRatio * lastPrice * pty.IssuancePreLiquidationRatio
debtRecord.Status = pty.IssuanceUserStatusCreate
debtRecord.ExpireTime = action.blocktime + issu.Period
debtRecord.Index = action.GetIndex()
// 记录当前借贷的最高自动清算价格
if issu.LatestLiquidationPrice < debtRecord.LiquidationPrice {
......@@ -565,8 +618,6 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
issu.CollateralValue += btyFrozen
issu.DebtValue += debt.Value
issu.Balance -= debt.Value
issu.PreIndex = issu.Index
issu.Index = action.GetIndex()
issu.Save(action.db)
kv = append(kv, issu.GetKVSet()...)
......@@ -615,13 +666,13 @@ func (action *Action) IssuanceRepay(repay *pty.IssuanceRepay) (*types.Receipt, e
}
// 检查
if !action.CheckExecTokenAccount(action.fromaddr, debtRecord.DebtValue, false) {
if !action.CheckExecTokenAccount(action.fromaddr, debtRecord.DebtValue*Coin, false) {
clog.Error("IssuanceRepay", "CollID", issu.IssuanceId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrInsufficientBalance)
return nil, types.ErrNoBalance
}
// ccny转移
receipt, err = action.tokenAccount.ExecTransfer(action.fromaddr, issu.IssuerAddr, action.execaddr, debtRecord.DebtValue)
receipt, err = action.tokenAccount.ExecTransfer(action.fromaddr, issu.IssuerAddr, action.execaddr, debtRecord.DebtValue*Coin)
if err != nil {
clog.Error("IssuanceRepay.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", debtRecord.DebtValue)
return nil, err
......@@ -630,7 +681,7 @@ func (action *Action) IssuanceRepay(repay *pty.IssuanceRepay) (*types.Receipt, e
kv = append(kv, receipt.KV...)
// 抵押物归还
receipt, err = action.coinsAccount.ExecTransferFrozen(issu.IssuerAddr, action.execaddr, action.execaddr, debtRecord.CollateralValue)
receipt, err = action.coinsAccount.ExecTransferFrozen(issu.IssuerAddr, action.fromaddr, action.execaddr, debtRecord.CollateralValue*Coin)
if err != nil {
clog.Error("IssuanceRepay.ExecTransferFrozen", "addr", issu.IssuerAddr, "execaddr", action.execaddr, "amount", debtRecord.CollateralValue)
return nil, err
......@@ -641,6 +692,8 @@ func (action *Action) IssuanceRepay(repay *pty.IssuanceRepay) (*types.Receipt, e
// 借贷记录关闭
debtRecord.PreStatus = debtRecord.Status
debtRecord.Status = pty.IssuanceUserStatusClose
debtRecord.PreIndex = debtRecord.Index
debtRecord.Index = action.GetIndex()
// 保存
issu.Balance += debtRecord.DebtValue
......@@ -650,8 +703,6 @@ func (action *Action) IssuanceRepay(repay *pty.IssuanceRepay) (*types.Receipt, e
issu.InvalidRecords = append(issu.InvalidRecords, debtRecord)
issu.LatestLiquidationPrice = getLatestLiquidationPrice(&issu.Issuance)
issu.LatestExpireTime = getLatestExpireTime(&issu.Issuance)
issu.PreIndex = issu.Index
issu.Index = action.GetIndex()
issu.Save(action.db)
kv = append(kv, issu.GetKVSet()...)
......@@ -687,7 +738,7 @@ func (action *Action) systemLiquidation(issu *pty.Issuance, price float32) (*typ
}
// 抵押物转移
receipt, err := action.coinsAccount.ExecTransferFrozen(action.fromaddr, getGuarantorAddr, action.execaddr, debtRecord.CollateralValue)
receipt, err := action.coinsAccount.ExecTransferFrozen(issu.IssuerAddr, getGuarantorAddr, action.execaddr, debtRecord.CollateralValue*Coin)
if err != nil {
clog.Error("systemLiquidation", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", debtRecord.CollateralValue, "err", err)
continue
......@@ -699,14 +750,16 @@ func (action *Action) systemLiquidation(issu *pty.Issuance, price float32) (*typ
debtRecord.LiquidateTime = action.blocktime
debtRecord.PreStatus = debtRecord.Status
debtRecord.Status = pty.IssuanceUserStatusSystemLiquidate
issu.DebtRecords = append(issu.DebtRecords[:index], issu.DebtRecords[index+1:]...)
debtRecord.PreIndex = debtRecord.Index
debtRecord.Index = action.GetIndex()
issu.InvalidRecords = append(issu.InvalidRecords, debtRecord)
issu.DebtRecords = append(issu.DebtRecords[:index], issu.DebtRecords[index+1:]...)
} else {
debtRecord.PreIndex = debtRecord.Index
debtRecord.Index = action.GetIndex()
debtRecord.PreStatus = debtRecord.Status
debtRecord.Status = pty.IssuanceUserStatusWarning
}
issu.PreIndex = issu.Index
issu.Index = action.GetIndex()
log := action.GetFeedReceiptLog(issu, debtRecord)
logs = append(logs, log)
......@@ -743,7 +796,7 @@ func (action *Action) expireLiquidation(issu *pty.Issuance) (*types.Receipt, err
}
// 抵押物转移
receipt, err := action.coinsAccount.ExecTransferFrozen(action.fromaddr, getGuarantorAddr, action.execaddr, debtRecord.CollateralValue)
receipt, err := action.coinsAccount.ExecTransferFrozen(issu.IssuerAddr, getGuarantorAddr, action.execaddr, debtRecord.CollateralValue*Coin)
if err != nil {
clog.Error("systemLiquidation", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", debtRecord.CollateralValue, "err", err)
continue
......@@ -755,14 +808,16 @@ func (action *Action) expireLiquidation(issu *pty.Issuance) (*types.Receipt, err
debtRecord.LiquidateTime = action.blocktime
debtRecord.PreStatus = debtRecord.Status
debtRecord.Status = pty.IssuanceUserStatusExpireLiquidate
issu.DebtRecords = append(issu.DebtRecords[:index], issu.DebtRecords[index+1:]...)
debtRecord.PreIndex = debtRecord.Index
debtRecord.Index = action.GetIndex()
issu.InvalidRecords = append(issu.InvalidRecords, debtRecord)
issu.DebtRecords = append(issu.DebtRecords[:index], issu.DebtRecords[index+1:]...)
} else {
debtRecord.PreIndex = debtRecord.Index
debtRecord.Index = action.GetIndex()
debtRecord.PreStatus = debtRecord.Status
debtRecord.Status = pty.IssuanceUserStatusExpire
}
issu.PreIndex = issu.Index
issu.Index = action.GetIndex()
log := action.GetFeedReceiptLog(issu, debtRecord)
logs = append(logs, log)
......@@ -815,14 +870,14 @@ func (action *Action) IssuanceFeed(feed *pty.IssuanceFeed) (*types.Receipt, erro
return nil, pty.ErrPriceInvalid
}
collIDRecords, err := queryIssuanceByStatus(action.localDB, pty.IssuanceStatusCreated)
ids, err := queryIssuanceByStatus(action.localDB, pty.IssuanceStatusCreated)
if err != nil {
clog.Error("IssuancePriceFeed", "get issuance record error", err)
return nil, err
}
for _, collID := range collIDRecords {
issu, err := queryIssuanceByID(action.db, collID.IssuanceId)
for _, collID := range ids {
issu, err := queryIssuanceByID(action.db, collID)
if err != nil {
clog.Error("IssuancePriceFeed", "Issuance ID", issu.IssuanceId, "get issuance record by id error", err)
continue
......@@ -854,12 +909,11 @@ func (action *Action) IssuanceFeed(feed *pty.IssuanceFeed) (*types.Receipt, erro
priceRecord.RecordTime = action.blocktime
// 喂价记录
pricekv := &types.KeyValue{Key: calcIssuancePriceKey(string(action.blocktime)), Value: types.Encode(&priceRecord)}
action.db.Set(pricekv.Key, pricekv.Value)
kv = append(kv, pricekv)
log := action.GetPriceReceiptLog(&priceRecord)
logs = append(logs, log)
// 最近喂价记录
pricekv = &types.KeyValue{Key: calcIssuanceLatestPriceKey(), Value: types.Encode(&priceRecord)}
pricekv := &types.KeyValue{Key: PriceKey(), Value: types.Encode(&priceRecord)}
action.db.Set(pricekv.Key, pricekv.Value)
kv = append(kv, pricekv)
......@@ -871,6 +925,7 @@ func (action *Action) IssuanceFeed(feed *pty.IssuanceFeed) (*types.Receipt, erro
func (action *Action) IssuanceClose(close *pty.IssuanceClose) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
var receipt *types.Receipt
issuance, err := queryIssuanceByID(action.db, close.IssuanceId)
if err != nil {
......@@ -878,6 +933,11 @@ func (action *Action) IssuanceClose(close *pty.IssuanceClose) (*types.Receipt, e
return nil, err
}
if !isRightAddr(manageKey, action.fromaddr, action.db) {
clog.Error("IssuanceClose", "addr", action.fromaddr, "error", "Address has no permission to close")
return nil, pty.ErrPermissionDeny
}
for _, debtRecord := range issuance.DebtRecords {
if debtRecord.Status != pty.IssuanceUserStatusClose {
clog.Error("IssuanceClose", "IssuanceId", close.IssuanceId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", pty.ErrIssuanceRecordNotEmpty)
......@@ -885,11 +945,20 @@ func (action *Action) IssuanceClose(close *pty.IssuanceClose) (*types.Receipt, e
}
}
// 解冻ccny
receipt, err = action.tokenAccount.ExecActive(action.fromaddr, action.execaddr, issuance.TotalBalance*Coin)
if err != nil {
clog.Error("IssuanceClose.ExecActive", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", issuance.TotalBalance)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
clog.Debug("IssuanceClose", "ID", close.IssuanceId)
issu := &IssuanceDB{*issuance}
issu.Status = pty.IssuanceStatusClose
issu.PreIndex = issu.CreateIndex
issu.PreIndex = issu.Index
issu.Index = action.GetIndex()
issu.Save(action.db)
......@@ -905,7 +974,6 @@ func (action *Action) IssuanceClose(close *pty.IssuanceClose) (*types.Receipt, e
func queryIssuanceByID(db dbm.KV, issuanceID string) (*pty.Issuance, error) {
data, err := db.Get(Key(issuanceID))
if err != nil {
clog.Error("queryIssuanceByID", "error", err)
return nil, err
}
......@@ -919,14 +987,14 @@ func queryIssuanceByID(db dbm.KV, issuanceID string) (*pty.Issuance, error) {
}
// 根据发行状态查找发行ID
func queryIssuanceByStatus(localdb dbm.Lister, status int32) ([]*pty.IssuanceRecord, error) {
func queryIssuanceByStatus(localdb dbm.Lister, status int32) ([]string, error) {
data, err := localdb.List(calcIssuanceStatusPrefix(status), nil, DefultCount, ListDESC)
if err != nil {
clog.Debug("queryIssuancesByStatus", "error", err)
return nil, err
}
var colls []*pty.IssuanceRecord
var ids []string
var issu pty.IssuanceRecord
for _, collBytes := range data {
err = types.Decode(collBytes, &issu)
......@@ -934,10 +1002,10 @@ func queryIssuanceByStatus(localdb dbm.Lister, status int32) ([]*pty.IssuanceRec
clog.Debug("queryIssuancesByStatus", "decode", err)
return nil, err
}
colls = append(colls, &issu)
ids = append(ids, issu.IssuanceId)
}
return colls, nil
return ids, nil
}
// 精确查找发行记录
......@@ -969,7 +1037,7 @@ func queryIssuanceRecordsByStatus(db dbm.KV, localdb dbm.Lister, status int32) (
if status == 0 {
statusKey = ""
} else {
statusKey = string(status)
statusKey = fmt.Sprintf("%d", status)
}
data, err := localdb.List(calcIssuanceRecordStatusPrefix(statusKey), nil, DefultCount, ListDESC)
......@@ -984,13 +1052,13 @@ func queryIssuanceRecordsByStatus(db dbm.KV, localdb dbm.Lister, status int32) (
err = types.Decode(collBytes, &issu)
if err != nil {
clog.Error("queryIssuanceRecordsByStatus", "decode", err)
return nil, err
continue
}
record, err := queryIssuanceRecordByID(db, issu.IssuanceId, issu.DebtId)
if err != nil {
clog.Error("queryIssuanceRecordsByStatus", "decode", err)
return nil, err
continue
}
records = append(records, record)
}
......
......@@ -7,46 +7,41 @@ package executor
import "fmt"
func calcIssuanceKey(issuanceID string, index int64) []byte {
key := fmt.Sprintf("LODB-Issuance-ID:%s:%018d", issuanceID, index)
key := fmt.Sprintf("LODB-issuance-ID:%s:%018d", issuanceID, index)
return []byte(key)
}
func calcIssuanceStatusPrefix(status int32) []byte {
key := fmt.Sprintf("LODB-Issuance-status-index:%d", status)
key := fmt.Sprintf("LODB-issuance-status:%d", status)
return []byte(key)
}
func calcIssuanceStatusKey(status int32, index int64) []byte {
key := fmt.Sprintf("LODB-Issuance-status:%d:%018d", status, index)
key := fmt.Sprintf("LODB-issuance-status:%d:%018d", status, index)
return []byte(key)
}
func calcIssuanceRecordAddrPrefix(addr string) []byte {
key := fmt.Sprintf("LODB-Issuance-record-addr:%s", addr)
key := fmt.Sprintf("LODB-issuance-record-addr:%s", addr)
return []byte(key)
}
func calcIssuanceRecordAddrKey(addr string, index int64) []byte {
key := fmt.Sprintf("LODB-Issuance-record-addr:%s:%018d", addr, index)
key := fmt.Sprintf("LODB-issuance-record-addr:%s:%018d", addr, index)
return []byte(key)
}
func calcIssuancePriceKey(time string) []byte {
key := fmt.Sprintf("LODB-Issuance-price:%s", time)
return []byte(key)
}
func calcIssuanceLatestPriceKey() []byte {
key := fmt.Sprintf("LODB-Issuance-latest-price")
key := fmt.Sprintf("LODB-issuance-price:%s", time)
return []byte(key)
}
func calcIssuanceRecordStatusPrefix(status string) []byte {
key := fmt.Sprintf("LODB-Issuance-record-status:%s", status)
key := fmt.Sprintf("LODB-issuance-record-status:%s", status)
return []byte(key)
}
func calcIssuanceRecordStatusKey(status int32, index int64) []byte {
key := fmt.Sprintf("LODB-Issuance-record-status:%d:%018d", status, index)
key := fmt.Sprintf("LODB-issuance-record-status:%d:%018d", status, index)
return []byte(key)
}
\ No newline at end of file
......@@ -22,6 +22,8 @@ func (c *Issuance) Query_IssuanceInfoByID(req *pty.ReqIssuanceInfo) (types.Messa
DebtCeiling: issu.DebtCeiling,
LiquidationRatio: issu.LiquidationRatio,
Balance: issu.Balance,
CollateralValue: issu.CollateralValue,
DebtValue: issu.DebtValue,
}, nil
}
......@@ -40,6 +42,8 @@ func (c *Issuance) Query_IssuanceInfoByIDs(req *pty.ReqIssuanceInfos) (types.Mes
DebtCeiling: issu.DebtCeiling,
LiquidationRatio: issu.LiquidationRatio,
Balance: issu.Balance,
CollateralValue: issu.CollateralValue,
DebtValue: issu.DebtValue,
})
}
......@@ -50,49 +54,46 @@ func (c *Issuance) Query_IssuanceByStatus(req *pty.ReqIssuanceByStatus) (types.M
ids := &pty.RepIssuanceIDs{}
issuIDRecords, err := queryIssuanceByStatus(c.GetLocalDB(), req.Status)
if err != nil {
clog.Error("Query_IssuanceByStatus", "get issuance record error", err)
clog.Error("Query_IssuanceByStatus", "get issuance error", err)
return nil, err
}
for _, record := range issuIDRecords {
ids.IDs = append(ids.IDs, record.IssuanceId)
}
ids.IDs = append(ids.IDs, issuIDRecords...)
return ids, nil
}
func (c *Issuance) Query_IssuanceRecordByID(req *pty.ReqIssuanceDebtInfo) (types.Message, error) {
ret := &pty.RepIssuanceDebtInfo{}
issuRecord, err := queryIssuanceRecordByID(c.GetStateDB(), req.IssuanceId, req.DebtId)
if err != nil {
clog.Error("Query_IssuanceRecordByID", "get issuance record error", err)
return nil, err
}
ret := &pty.RepIssuanceDebtInfo{}
ret.Record = issuRecord
return issuRecord, nil
return ret, nil
}
func (c *Issuance) Query_IssuanceRecordsByAddr(req *pty.ReqIssuanceRecordsByAddr) (types.Message, error) {
ret := &pty.RepIssuanceRecords{}
records, err := queryIssuanceRecordByAddr(c.GetStateDB(), c.GetLocalDB(), req.Addr)
if err != nil {
clog.Error("Query_IssuanceDebtInfoByAddr", "get issuance record error", err)
return nil, err
}
ret := &pty.RepIssuanceRecords{}
ret.Records = records
return ret, nil
}
func (c *Issuance) Query_IssuanceRecordsByStatus(req *pty.ReqIssuanceRecordsByStatus) (types.Message, error) {
ret := &pty.RepIssuanceRecords{}
records, err := queryIssuanceRecordsByStatus(c.GetStateDB(), c.GetLocalDB(), req.Status)
if err != nil {
clog.Error("Query_IssuanceDebtInfoByAddr", "get issuance record error", err)
clog.Error("Query_IssuanceDebtInfoByStatus", "get issuance record error", err)
return nil, err
}
ret := &pty.RepIssuanceRecords{}
ret.Records = records
ret.Records = append(ret.Records, records...)
return ret, nil
}
\ No newline at end of file
......@@ -21,7 +21,6 @@ message Issuance {
string issuerAddr = 15;//发行地址
int64 index = 16;//当前索引
int64 preIndex = 17;//上级索引
int64 createIndex = 18;//创建索引,用于close删除状态
}
// 抵押记录
......@@ -37,6 +36,8 @@ message DebtRecord {
int64 expireTime = 9; //超时清算时间
int32 preStatus = 10;//上一次抵押状态,用于告警恢复
string debtId = 11;//借贷id
int64 index = 12;//当前索引
int64 preIndex = 13;//上级索引
}
// 资产价格记录
......@@ -98,12 +99,13 @@ message IssuanceClose {
message ReceiptIssuance {
string issuanceId = 1;
string accountAddr = 2;
int32 status = 3;
string debtId = 4;
int32 recordStatus = 5;
int32 recordPreStatus = 6;
int64 index = 7;
int64 preIndex = 8;
string debtId = 3;
int32 status = 4;
int32 preStatus = 5;
int64 index = 6;
int64 preIndex = 7;
int64 recordTime = 8; //价格记录时间
float btyPrice = 9; //bty价格
}
// exec_local 借贷记录信息
......
......@@ -84,7 +84,7 @@ func (Issuance IssuanceType) CreateTx(action string, message json.RawMessage) (*
return nil, types.ErrInvalidParam
}
return CreateRawIssuanceRepayTx(&param)
} else if action == "IssuanceFeed" {
} else if action == "IssuancePriceFeed" {
var param IssuanceFeedTx
err := json.Unmarshal(message, &param)
if err != nil {
......@@ -117,7 +117,7 @@ func (Issuance IssuanceType) CreateTx(action string, message json.RawMessage) (*
func (Issuance IssuanceType) GetTypeMap() map[string]int32 {
return map[string]int32{
"Create": IssuanceActionCreate,
"Borrow": IssuanceActionDebt,
"Debt": IssuanceActionDebt,
"Repay": IssuanceActionRepay,
"Feed": IssuanceActionFeed,
"Close": IssuanceActionClose,
......@@ -191,6 +191,7 @@ func CreateRawIssuanceRepayTx(parm *IssuanceRepayTx) (*types.Transaction, error)
v := &IssuanceRepay{
IssuanceId: parm.IssuanceID,
DebtId: parm.DebtID,
}
repay := &IssuanceAction{
Ty: IssuanceActionRepay,
......
......@@ -39,7 +39,6 @@ type Issuance struct {
IssuerAddr string `protobuf:"bytes,15,opt,name=issuerAddr,proto3" json:"issuerAddr,omitempty"`
Index int64 `protobuf:"varint,16,opt,name=index,proto3" json:"index,omitempty"`
PreIndex int64 `protobuf:"varint,17,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
CreateIndex int64 `protobuf:"varint,18,opt,name=createIndex,proto3" json:"createIndex,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -189,13 +188,6 @@ func (m *Issuance) GetPreIndex() int64 {
return 0
}
func (m *Issuance) GetCreateIndex() int64 {
if m != nil {
return m.CreateIndex
}
return 0
}
// 抵押记录
type DebtRecord struct {
AccountAddr string `protobuf:"bytes,1,opt,name=accountAddr,proto3" json:"accountAddr,omitempty"`
......@@ -209,6 +201,8 @@ type DebtRecord struct {
ExpireTime int64 `protobuf:"varint,9,opt,name=expireTime,proto3" json:"expireTime,omitempty"`
PreStatus int32 `protobuf:"varint,10,opt,name=preStatus,proto3" json:"preStatus,omitempty"`
DebtId string `protobuf:"bytes,11,opt,name=debtId,proto3" json:"debtId,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_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -316,6 +310,20 @@ func (m *DebtRecord) GetDebtId() string {
return ""
}
func (m *DebtRecord) GetIndex() int64 {
if m != nil {
return m.Index
}
return 0
}
func (m *DebtRecord) GetPreIndex() int64 {
if m != nil {
return m.PreIndex
}
return 0
}
// 资产价格记录
type IssuanceAssetPriceRecord struct {
RecordTime int64 `protobuf:"varint,1,opt,name=recordTime,proto3" json:"recordTime,omitempty"`
......@@ -812,12 +820,13 @@ func (m *IssuanceClose) GetIssuanceId() string {
type ReceiptIssuance struct {
IssuanceId string `protobuf:"bytes,1,opt,name=issuanceId,proto3" json:"issuanceId,omitempty"`
AccountAddr string `protobuf:"bytes,2,opt,name=accountAddr,proto3" json:"accountAddr,omitempty"`
Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"`
DebtId string `protobuf:"bytes,4,opt,name=debtId,proto3" json:"debtId,omitempty"`
RecordStatus int32 `protobuf:"varint,5,opt,name=recordStatus,proto3" json:"recordStatus,omitempty"`
RecordPreStatus int32 `protobuf:"varint,6,opt,name=recordPreStatus,proto3" json:"recordPreStatus,omitempty"`
Index int64 `protobuf:"varint,7,opt,name=index,proto3" json:"index,omitempty"`
PreIndex int64 `protobuf:"varint,8,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
DebtId string `protobuf:"bytes,3,opt,name=debtId,proto3" json:"debtId,omitempty"`
Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"`
PreStatus int32 `protobuf:"varint,5,opt,name=preStatus,proto3" json:"preStatus,omitempty"`
Index int64 `protobuf:"varint,6,opt,name=index,proto3" json:"index,omitempty"`
PreIndex int64 `protobuf:"varint,7,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
RecordTime int64 `protobuf:"varint,8,opt,name=recordTime,proto3" json:"recordTime,omitempty"`
BtyPrice float32 `protobuf:"fixed32,9,opt,name=btyPrice,proto3" json:"btyPrice,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -862,13 +871,6 @@ func (m *ReceiptIssuance) GetAccountAddr() string {
return ""
}
func (m *ReceiptIssuance) GetStatus() int32 {
if m != nil {
return m.Status
}
return 0
}
func (m *ReceiptIssuance) GetDebtId() string {
if m != nil {
return m.DebtId
......@@ -876,16 +878,16 @@ func (m *ReceiptIssuance) GetDebtId() string {
return ""
}
func (m *ReceiptIssuance) GetRecordStatus() int32 {
func (m *ReceiptIssuance) GetStatus() int32 {
if m != nil {
return m.RecordStatus
return m.Status
}
return 0
}
func (m *ReceiptIssuance) GetRecordPreStatus() int32 {
func (m *ReceiptIssuance) GetPreStatus() int32 {
if m != nil {
return m.RecordPreStatus
return m.PreStatus
}
return 0
}
......@@ -904,6 +906,20 @@ func (m *ReceiptIssuance) GetPreIndex() int64 {
return 0
}
func (m *ReceiptIssuance) GetRecordTime() int64 {
if m != nil {
return m.RecordTime
}
return 0
}
func (m *ReceiptIssuance) GetBtyPrice() float32 {
if m != nil {
return m.BtyPrice
}
return 0
}
// exec_local 借贷记录信息
type IssuanceRecord struct {
IssuanceId string `protobuf:"bytes,1,opt,name=issuanceId,proto3" json:"issuanceId,omitempty"`
......@@ -1550,72 +1566,72 @@ func init() {
func init() { proto.RegisterFile("issuance.proto", fileDescriptor_7110f4228953d675) }
var fileDescriptor_7110f4228953d675 = []byte{
// 1067 bytes of a gzipped FileDescriptorProto
// 1060 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcd, 0x6e, 0xdb, 0x46,
0x10, 0x36, 0x49, 0x51, 0xb2, 0x47, 0xb6, 0xec, 0x6c, 0x1c, 0x97, 0x08, 0xda, 0x40, 0x58, 0xf4,
0xa0, 0xf4, 0xc7, 0x6e, 0xed, 0xa2, 0x40, 0x6f, 0xb5, 0xec, 0xb6, 0x16, 0xd0, 0x04, 0x01, 0x6b,
0x04, 0xbd, 0xd2, 0xe4, 0x3a, 0x20, 0x40, 0x8b, 0x0c, 0xb9, 0x32, 0xa2, 0x73, 0xfb, 0x0c, 0x3d,
0xf4, 0x5d, 0xfa, 0x6a, 0x45, 0x31, 0xb3, 0x4b, 0x2e, 0x7f, 0xa4, 0x4a, 0xe8, 0xa1, 0x17, 0x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01, 0x00, 0x00, 0xff, 0xff, 0xba, 0x69, 0x9e, 0x9a,
0x21, 0x0d, 0x00, 0x00,
}
......@@ -23,6 +23,7 @@ type IssuanceDebtTx struct {
// IssuanceRepayTx for construction
type IssuanceRepayTx struct {
IssuanceID string `json:"issuanceId"`
DebtID string `json:"debtId"`
Fee int64 `json:"fee"`
}
......
......@@ -24,7 +24,7 @@ const (
// Issuance name
const (
IssuanceX = "issuance"
CCNYTokenName = "ccny"
CCNYTokenName = "CCNY"
IssuancePreLiquidationRatio = 1.1 //TODO 预清算比例,抵押物价值跌到借出ccny价值110%的时候开始清算
)
......
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